Module 16: Assembling the Pieces: Web Application Assessment Breakdown

Introduction to WEB-200 Challenge Machines

Welcome to the Challenge Machines

These fall between the sandbox and the cast study machines, running custom-designed applications intended to mimic real-world applications. You may need to combine multiple attacks or apply techniques in different ways to exploit them.

Starting and Accessing Challenge Machines

Start, revert, or stop the challenge machines from the Labs page. Add them to your hosts file for ease of access.

Completing Challenge Machines

Each challenge machine contains two flags. Each machine may be different, but generally, there is a local.txt obtained within the application after performing an authenticated bypass attack. The proof.txt requires gaining a shell on the machine.

Web Application Enumeration

Accessing the Challenge Machine

Start the VPN, the VM, and add its ip/hostname to your hosts file.

Basic Host Enumeration and OS Detection

Run nmap to identify open ports and other information.

Basic nmap scan of the challenge machine

Nmap scan with OS discovery enabled

Content Discovery

Strigi's Pizzeria Home Page
HTTP History includes external requests
Adding a Request to scope
Proxy history logging dialog window
HTTP History Filter Settings
HTTP POST Request from clicking Subscribe

Running gobuster against the challenge machine

Login page
Whitelabel Error Page
Burp Suite Site Map

Authentication Bypass

Finding a Directory Traversal

Baseline Request and Response in Repeater
Response for web200.html

Nmap scan excerpt

Exploiting Directory Traversal to access WIN.INI

Exploiting a Directory Traversal

Contents of paths.txt

Contents of files.txt

Wfuzz results

Using curl to access application.properties

Logged in to the Admin page

Remote Code Execution

Finding SQL Injection

HTTP Request to Delete a Message

Baseline Request and Response to /admin/message/delete

If the application redirects us to http://asio/login, our session has expired. In which case, we would need to log in with the API key again and update the JSESSIONID value in Repeater.

The Server responded to our basic SQL injection Payload with an error

Excerpt from application.properties

Sending a stacked query in Burp Suite Repeater

Wordlist of potential table names

Base INSERT statement payload

Using Wfuzz to send SQL injection attacks

Inspecting the newsletter subscription entries on the admin page

Exploit SQL Injection for RCE

Excerpt from application.properties

Base SQL payload to enable advanced options

Sending the first payload in Burp Suite Repeater

Base SQL payload to enable xp_cmdshell

Sending the second payload in Burp Suite Repeater

Starting a netcat listener on port 8000

Base SQL payload to invoke curl using xp_cmdshell

Sending the curl command payload in Burp Suite Repeater

Netcat listener received an HTTP request

Obtaining a Shell

In real-world application assessments, we may need to customize a reverse shell or some other piece of code to complete an attack. However, we recognize that WEB-200 is not a programming course. While we will walk through the code and explain it, we will also provide a copy of the final shell at the end of this section.

Java Reverse Shell example

An example Hello World application

Creating a file for our reverse shell

Basic Java class code

Import statements

Java Reverse Shell

We compile Java code with the javac command. In this scenario, we can rely on the victim machine to compile the code for us. However, if you wish to run javac locally but the command is not found, you can install the necessary files with sudo apt-get install default-jdk.

Java compiler error

Updated main() method declaration

Starting a python http server to host our shell

Base SQL injection payload to download the reverse shell

Sending the SQL injection payload to run curl and download our shell

Python HTTP Server log

Starting a netcat listener on port 4444

On older versions of Java, we'd need to compile the source file using javac. The compiler creates a class file with the same name, but no file extension. In theory, we could compile it locally and upload the class file. However, we would have to know the version of Java running on the server to ensure we compiled our code at the right target version. Java is backwards-compatible, so newer versions of Java will run code compiled for older versions. However, there are exceptions where updates removed some APIs from newer versions due to security concerns.

Base SQL injection payload to run our Java reverse shell

Sending the request to run our reverse shell

Netcat received our reverse shell

Conclusion

Good job, you did it.

Last updated