Brief introduction
Taint can be used to detect hidden XSS code, SQL injection, Shell injection and other vulnerabilities, and these vulnerabilities to use static analysis tools to troubleshoot, such as the following example:
<?php echo $_GET["name"];?>
For requests:
http://localhost/?name=222
Static analysis tools, often powerless, but taint can accurately burst out of this type of problem.
Warning: Main::test() [function.echo]: Attempt to echo a string that might be tainted in
Taint Installation
wget http://pecl.php.net/get/taint-1.2.2.tgztar zxvf taint-1.2.2.tgzcd taint-1.2.2/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmake && make install
Configure PHP.ini
[taint]extension=taint.sotaint.enable=1taint.error_level=E_WARNING
Run results
php -i | grep tainttainttaint support => enabledtaint.enable => On => Ontaint.error_level => 2 => 2
# # #附录
A. Validated string
All from G E T , G E T, _post, $_cookie variables, are considered to be tainted String
B. A list of functions/statements detected by taint, taint will give a warning when these functions use tainted string arguments:
1. 输出函数/语句系列 echo print printf file_put_contents2. 文件系统函数 fopen opendir basename dirname file pathinfo3. 数据库系列函数/方法 mysql_query mysqli_query sqlite_query sqlite_single_query oci_parse Mysqli::query SqliteDataBase::query SqliteDataBase::SingleQuery PDO::query PDO::prepare4. 命令行系列 system exec proc_open passthru shell_exec5. 语法结构 eval include(_once) require(_once)
C. Functions that eliminate tainted information, and when these functions are called, the tainted string becomes a valid string:
escapeshellcmdhtmlspecialcharsescapeshellcmdaddcslashesaddslashesmysqli_escape_stringmysql_real_escape_stringmysql_escape_stringsqlite_escape_stringPDO::quoteMysqli::escape_stringMysql::real_escape_string
D. Functions/statements that hold tainted information in the call, when these functions/statements are called, the output is also tainted string if the input is tainted string:
=."{$var}.=strvalexplodeimplodesprintfvsprintftrimrtrimltrim
From for notes (Wiz)
PHP extension--taint detect hidden vulnerabilities