When I was a beginner in PHP, I read a bad book from the school library, and I didn't write any PHP code in it. when processing the form, it will automatically urldecode, therefore, I used the urldecode function to decode the Discuz X1.5 Forum of Ihipop school. I had a quarrel there for an afternoon. Google "Discuz! X1-1.5 notify_credit.php Blind SQL injection exploit ", you'll know.
Discuz is a popular forum system in China. There should be many hacked websites. However, I am not interested in intruding other people's websites. I also despise the so-called "hackers" whose code will not write attacks that only use tools released by others ".
After a rough look at the code, this SQL injection vulnerability is caused by the urldecode function. In the PHP manual, the urldecode function has a warning:
The superglobals $ _ GET and $ _ REQUEST are already decoded. Using urldecode () on an element in $ _ GET or $ _ REQUEST cocould have unexpected and dangerous results.
The Discuz developer (probably a newbie) adds a urldecode:
The code is as follows:
Foreach ($ _ POST as $ k => $ v ){
$ Value = urldecode ($ v );
$ This-> setParameter ($ k, $ value );
}
The single quotation mark is urlencode twice and then % 2527. then, POST. When PHP generates the global variable $ _ POST, urldecode first and get % 27, PHP then checks the settings of Magic Quotes, but % 27 will not be set by addslashes whether or not Magic Quotes is enabled, because there is no single quotation mark at all. However, if you add urldecode to the PHP code, % 27 will become a single quotation mark, and then ...... You know.
When I was a beginner in PHP, I read a bad book from the school library, and I didn't write any PHP code in it. when processing the form, it will automatically urldecode, so I used the urldecode function to decode it myself (I vaguely remember it was written in the book as well. it was a mistake ).
To sum up, it is: 1. it is very important to choose a good book; 2. use the urldecode function with caution. 3. pay attention to the warning in the PHP Manual.
From http://demon.tw/programming/php-urldecode-sql-injection.html