🏠
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
  • Installation
  • Configuration
  1. Common Services Pentest
  2. Web Services - 80/443/8080
  3. Tomcat

Lab Setup & Configuration

PreviousTomcatNextEnumeration

Last updated 4 months ago

Topics

Installation

Apache Tomcat depends on Java, so the Java JDK must be installed on your server. Use the following command to install it:

sudo apt install openjdk-21-jdk

Create a new user named tomcat with the following command:

sudo useradd -m -U -d /opt/tomcat -s /bin/false tomcat

Download the Tomcat tar.gz file from the .

Download the latest version to the Ubuntu machine and extract the files:

wget https://dlcdn.apache.org/tomcat/tomcat-11/v11.0.0/bin/apache-tomcat-11.0.0.tar.gz
tar -xvf apache-tomcat-11.0.0.tar.gz

Move the extracted folder to the /opt/tomcat directory, assign ownership to the tomcat user, and set execution permissions for the binary files:

mv apache-tomcat-11.0.0/* /opt/tomcat
chown -R tomcat: /opt/tomcat
sh -c 'chmod +x /opt/tomcat/bin/*.sh'

Create a tomcat.service file in the /etc/systemd/system/ directory with the following content:

[Unit]
Description=Apache Tomcat
After=network.target

[Service]
Type=forking
User=tomcat
Group=tomcat
Environment=JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
Environment=CATALINA_PID=/opt/tomcat/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
ExecReload=/bin/kill $MAINPID
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Reload the systemd daemon to apply the changes:

systemctl daemon-reload

Enable the Tomcat service to start automatically on reboot:

systemctl enable --now tomcat

Check the Tomcat server status:

systemctl status tomcat

Configuration

Once installation is complete, configure the Tomcat server.

To set an admin user password, modify the tomcat-users.xml file:

nvim /opt/tomcat/conf/tomcat-users.xml

If neovim is not installed, install it using:

sudo apt install neovim

Add the following lines before the closing </tomcat-users> tag:

xmlCopia codice<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="admin" password="password" roles="admin-gui,manager-gui"/>

To enable remote access for the Tomcat Manager, edit the context.xml file in both the manager and host-manager directories:

nvim /opt/tomcat/webapps/manager/META-INF/context.xml
nvim /opt/tomcat/webapps/host-manager/META-INF/context.xml

Remove the following line from both files:

<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

Restart the Tomcat service:

systemctl restart tomcat

Verify that the Tomcat server is running on port 8080.

Lab Setup & Configuration
Enumeration
Exploitation
Mitigation & Hardening
official website