┌──(root㉿kali)-[/miaosec] └─# nmap -sn 192.168.2.0/24 Starting Nmap 7.94SVN ( https://nmap.org ) at 2026-01-05 10:38 CST Nmap scan report for 192.168.2.1 Host is up (0.00049s latency). MAC Address: 0A:00:27:00:00:07 (Unknown) Nmap scan report for 192.168.2.2 Host is up (0.00040s latency). MAC Address: 08:00:27:02:7F:AE (Oracle VirtualBox virtual NIC) Nmap scan report for 192.168.2.243 Host is up (0.00087s latency). MAC Address: 08:00:27:01:78:BE (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 2.19 seconds
靶机IP:192.168.2.243
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.243 Starting Nmap 7.94SVN ( https://nmap.org ) at 2026-01-05 10:38 CST Nmap scan report for 192.168.2.243 Host is up (0.00019s latency). Not shown: 65533 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http MAC Address: 08:00:27:01:78:BE (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 32.56 seconds
┌──(root㉿kali)-[/miaosec] └─# nmap --min-rate 10000 -sT -sV -sC -O -p22,80 192.168.2.243 Starting Nmap 7.94SVN ( https://nmap.org ) at 2026-01-05 10:40 CST Nmap scan report for 192.168.2.243 Host is up (0.00066s 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-server-header: Apache/2.4.62 (Debian) | http-cookie-flags: | /: | PHPSESSID: |_ httponly flag not set |_http-title: \xE7\x82\x89\xE5\xBF\x83\xE8\x9E\x8D\xE8\xA7\xA3 MAC Address: 08:00:27:01:78:BE (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
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 8.81 seconds
3.udp扫描
1 2 3 4 5 6 7 8 9 10
┌──(root㉿kali)-[/miaosec] └─# nmap -sU --top-ports 100 192.168.2.243 Starting Nmap 7.94SVN ( https://nmap.org ) at 2026-01-05 10:41 CST Nmap scan report for 192.168.2.243 Host is up (0.00085s latency). All 100 scanned ports on 192.168.2.243 are in ignored states. Not shown: 51 closed udp ports (port-unreach), 49 open|filtered udp ports (no-response) MAC Address: 08:00:27:01:78:BE (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 47.60 seconds
www-data@meltdown:/home$ su rin Password: rin@meltdown:/home$ id uid=1000(rin) gid=1000(rin) groups=1000(rin)
2、获取root权限
查看sudo -l
1 2 3 4 5 6 7
rin@meltdown:~$ sudo -l Matching Defaults entries for rin on meltdown: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User rin may run the following commands on meltdown: (root) NOPASSWD: /opt/repeater.sh
ifecho"$user_input" | grep -qE '[;&|`$\\]'; then echo"错误:输入包含非法字符" return 1 fi
ifecho"$user_input" | grep -qiE '(cat|ls|echo|rm|mv|cp|chmod)'; then echo"错误:输入包含危险关键字" return 1 fi
ifecho"$user_input" | grep -qE '[[:space:]]'; then if ! echo"$user_input" | grep -qE '^[a-zA-Z0-9]*[[:space:]]+[a-zA-Z0-9]*$'; then echo"错误:空格使用受限" return 1 fi fi
echo"处理结果: $user_input"
local sanitized_input=$(echo"$user_input" | tr -d '\n\r') eval"output=\"$sanitized_input\"" echo"最终输出: $output" }
if [ $# -ne 1 ]; then echo"用法: $0 <输入内容>" exit 1 fi
main "$1"
1、过滤黑名单字符 过滤了 ; & | $ \ 等字符,避免命令拼接、执行多条命令或命令替换玩法
1 2 3 4
ifecho"$user_input" | grep -qE '[;&|`$\\]'; then echo"错误:输入包含非法字符" return 1 fi
2、过滤关键字 这里只是过滤了一些简单命令
1 2 3 4
ifecho"$user_input" | grep -qiE '(cat|ls|echo|rm|mv|cp|chmod)'; then echo"错误:输入包含危险关键字" return 1 fi
3、空格限制 过滤了空格,但是允许特定形式的空格
1 2 3 4 5 6
ifecho"$user_input" | grep -qE '[[:space:]]'; then if ! echo"$user_input" | grep -qE '^[a-zA-Z0-9]*[[:space:]]+[a-zA-Z0-9]*$'; then echo"错误:空格使用受限" return 1 fi fi