Vulnhub-Pwned: 1
文章目录
基本介绍
靶机地址
https://www.vulnhub.com/entry/pwned-1,507/
目标
获取 3 个 flag。
环境
名称 | 介绍 |
---|---|
主机 | Manjaro 20.1 |
虚拟化软件 | Virtualbox 6.1.14 |
靶机网络 | Host-only (vboxnet0) |
kali in docker | 2020.3 |
工具
名称 | 版本 |
---|---|
arp-scan | 1.9.7 |
Nmap | 7.80 |
rustbuster | 1.0.4 |
信息收集
获取 IP 地址
使用 arp-scan 对 vboxnet0 接口进行二层扫描,得到靶机的地址为 192.168.56.124。
{% blockquote %}
|
|
Interface: vboxnet0, type: EN10MB, MAC: 0a:00:27:00:00:00, IPv4: 192.168.56.1 Starting arp-scan 1.9.7 with 256 hosts (https://github.com/royhills/arp-scan) 192.168.56.100 08:00:27:fd:e7:14 PCS Systemtechnik GmbH 192.168.56.124 08:00:27:4d:01:c6 PCS Systemtechnik GmbH
2 packets received by filter, 0 packets dropped by kernel Ending arp-scan 1.9.7: 256 hosts scanned in 2.027 seconds (126.30 hosts/sec). 2 responded {% endblockquote %}
端口扫描
使用 Nmap 的半连接方式对靶机进行全 TCP 端口扫描,该靶机开放了 3 个端口:
{% blockquote %}
|
|
Nmap scan report for 192.168.56.124 Host is up (0.00013s latency). Not shown: 65532 closed ports PORT STATE SERVICE 21/tcp open ftp 22/tcp open ssh 80/tcp open http MAC Address: 08:00:27:4D:01:C6 (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 2.07 seconds {% endblockquote %}
服务枚举
使用 Nmap 进行服务枚举,只发现了 ftp,ssh 和 apache httpd 三种服务:
{% blockquote %}
|
|
Nmap scan report for 192.168.56.124 Host is up (0.00050s latency).
PORT STATE SERVICE VERSION 21/tcp open ftp vsftpd 3.0.3 22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0) | ssh-hostkey: | 2048 fe💿90:19:74:91:ae:f5:64:a8:a5:e8:6f:6e:ef:7e (RSA) | 256 81:32:93:bd:ed:9b:e7:98:af:25:06:79:5f🇩🇪91:5d (ECDSA) |_ 256 dd:72:74:5d:4d:2d:a3:62:3e:81:af:09:51:e0:14:4a (ED25519) 80/tcp open http Apache httpd 2.4.38 ((Debian)) |_http-server-header: Apache/2.4.38 (Debian) |_http-title: Pwned….!! MAC Address: 08:00:27:4D:01:C6 (Oracle VirtualBox virtual NIC) Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Aggressive OS guesses: Linux 2.6.32 (96%), Linux 3.2 - 4.9 (96%), Linux 2.6.32 - 3.10 (96%), Linux 3.4 - 3.10 (95%), Linux 3.1 (95%), Linux 3.2 (95%), AXIS 210A or 211 Network Camera (Linux 2.6.17) (94%), Synology DiskStation Manager 5.2-5644 (94%), Netgear RAIDiator 4.2.28 (94%), Linux 2.6.32 - 2.6.35 (94%) No exact OS matches for host (test conditions non-ideal). Network Distance: 1 hop Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 12.15 seconds {% endblockquote %}
服务版本都很新,vsftp 和 openssh 不存在可利用的漏洞,apache 2.4.38貌似存在一个 LPE 的漏洞,暂时派不上用场。
ftp anonymous 探测
ftp 可能会存在允许匿名登陆的情况,而且调查 ftp 是比较省时间的(相比 Web 而言),但是,该靶机不允许 ftp 匿名登陆。
尝试暴力破解,也没有破解出什么。
Web 枚举
首先使用浏览器查看:
倒是很直接了当,接着查看源码发现一行注释:
|
|
并没有什么用,直接爆破路径。
Web 路径爆破
使用 rustbuster 进行爆破:
{% blockquote %}
|
|
http://192.168.56.124/# 200 OK http://192.168.56.124/server-status 403 Forbidden http://192.168.56.124/hidden_text 301 Moved Permanently http://192.168.56.124/nothing 301 Moved Permanently {% endblockquote %}
访问 /hidden_text 可以得到一个文件 secret.dic。下载下来查看似乎是包含路径的字典:
再次进行路径爆破,可以发现一个新的路径:
{% blockquote %}
|
|
http://192.168.56.124//pwned.vuln 301 Moved Permanently {% endblockquote %}
访问该 URL,可见简易的登陆框,查看源码可见一段注释
|
|
得到了疑似的 ftp 账户。
ftp
经过验证确实是 ftp 的账号和密码,可以发现有两个文件:
使用 mget 将文件下载到本地,查看 note.txt,发现提到了 ariana,还有一个 id_rsa 明显是 ssh 的私钥。
SSH 登陆
之前有遇到过使用私钥登陆的情况,要先将私钥的权限更改为 600,猜测用户名为 ariana,使用 ssh 远程登陆
|
|
成功登陆,获取到第一个 flag:
权限提升 Part I
搜索 SUID 权限程序并没有什么异常的项目,接着查看 sudo:
{% blockquote %}
|
|
Matching Defaults entries for ariana on pwned: env_reset, mail_badpass, secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
User ariana may run the following commands on pwned: (selena) NOPASSWD: /home/messenger.sh {% endblockquote %}
查看 /home/messenger.sh 的内容:
|
|
可见 $msg 直接执行了读入的 msg,从而可以利用该脚本进行水平越权:
|
|
权限提升 Part II
刚才查看 selena 发现所属组竟然有 docker,果不其然该靶机安装了 docker:
由于靶机并没有连接到互联网,查看已经存在的镜像:
直接利用 docker 提权为 root:
|
|
成功获取到 root 权限,完成垂直越权。
总结
事实证明,扫目录也有学问,字典很重要。刚开始我使用 rockyou 和 wfuzz 自带的字典扫了半天什么也没扫出来,差点怀疑人生。借鉴了巨佬的 walkthorugh,没想到换用 dirbuster 的字典就能扫到路径。
再者就是之前对于 sudo 的理解不足,成功卡死;这次算是重新 “认识” 了。
参考链接
文章作者 Josephine
上次更新 2020-09-21