Array (hash) conflicts

Source: Internet
Author: User
Recently (looks like the 28th) from abroad (address: http://nikic.github.com/2011/12/28/Supercolliding-a-PHP-array.html) broke out a new PHP conflict on the Array, you can call the hash table conflict to launch a denial of service attack on the server. Principle: at present... "> <LINKhref =" ht

Recently (looks like the 28th) from abroad (address: http://nikic.github.com/2011/12/28/Supercolliding-a-PHP-array.html) broke out a new PHP conflict on the Array, you can call the hash table conflict to launch a denial of service attack on the server.

Principle: hash is used in many languages to store key-value data, including frequently used POST data from users. attackers can construct request headers, with a large number of special "key" values in POST (customized based on the Hash algorithm of each language), the Hash table storing POST data at the underlying layer of the language is "conflicted" (collision) it degrades to a linked list.

 

In this way, if the data size is large enough, the language can be used for computing, searching, and inserting, resulting in a large amount of CPU usage, thus implementing DoS attacks.

 

  

$ Size = pow (2, 16 );

$ StartTime = microtime (true );

$ Array = array ();

For ($ key = 0, $ maxKey = ($ size-1) * $ size; $ key <= $ maxKey; $ key + = $ size ){

$ Array [$ key] = 0;

}

$ EndTime = microtime (true );

Echo 'insert'. $ size. 'malicious elements require'. $ endTime-$ startTime. 'second'. "\ n ";

$ StartTime = microtime (true );

$ Array = array ();

For ($ key = 0, $ maxKey = $ size-1; $ key <= $ maxKey; ++ $ key ){

$ Array [$ key] = 0;

}

$ EndTime = microtime (true );

Echo 'insert'. $ size. 'common elements require'. $ endTime-$ startTime. 'second'. "\ n ";

/**

* Result

*

* It takes 65536 seconds to insert 36.357950925827 malicious elements.

* It takes 65536 seconds to insert 0.029613018035889 common elements.

*/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.