| <?php //被测试的保护函数 function safe( $string ) { return "'" . mysql_real_escape_string( $string ) . "'" } //连接到数据库 /////////////////////// //试图进行注入 /////////////////////// $exploit = "lemming' AND 1=1;"; //进行清理 $safe = safe( $exploit ); $query = "SELECT * FROM animals WHERE name = $safe"; $result = mysql_query( $query ); //测试是否保护是足够的 if ( $result && mysql_num_rows( $result ) == 1 ) { exitt "Protection succeeded:\n exploit $exploit was neutralized."; } else { exit( "Protection failed:\n exploit $exploit was able to retrieve all rows." ); } ?> |
| ·Java初学者专区 | ·Java高级技术 | ||
| ·Java图像与多媒体 | ·Java网络编程 | ||
| ·Eclipse | ·Hibernate | ||
| ·Spring | ·Struts | ||
| ·Java设计模式 | ·EJB开发 |
关注此文的读者还看过: