8009 - Pentesting Apache JServ Protocol (AJP) | HackTricks | HackTricks (2024)

Learn AWS hacking from zero to hero with htARTE (HackTricks AWS Red Team Expert)!

Other ways to support HackTricks:

Join HackenProof Discord server to communicate with experienced hackers and bug bounty hunters!

Hacking InsightsEngage with content that delves into the thrill and challenges of hacking

Real-Time Hack NewsKeep up-to-date with fast-paced hacking world through real-time news and insights

Latest AnnouncementsStay informed with the newest bug bounties launching and crucial platform updates

Join us on Discord and start collaborating with top hackers today!

Basic Information

From: https://diablohorn.com/2011/10/19/8009-the-forgotten-tomcat-port/

AJP is a wire protocol. It an optimized version of the HTTP protocol to allow a standalone web server such as Apache to talk to Tomcat. Historically, Apache has been much faster than Tomcat at serving static content. The idea is to let Apache serve the static content when possible, but proxy the request to Tomcat for Tomcat related content.

Also interesting:

The ajp13 protocol is packet-oriented. A binary format was presumably chosen over the more readable plain text for reasons of performance. The web server communicates with the servlet container over TCP connections. To cut down on the expensive process of socket creation, the web server will attempt to maintain persistent TCP connections to the servlet container, and to reuse a connection for multiple request/response cycles

Default port: 8009

PORT STATE SERVICE8009/tcp open ajp13

CVE-2020-1938 'Ghostcat'

If the AJP port is exposed, Tomcat might be susceptible to the Ghostcat vulnerability. Here is an exploit that works with this issue.

Ghostcat is a LFI vulnerability, but somewhat restricted: only files from a certain path can be pulled. Still, this can include files like WEB-INF/web.xml which can leak important information like credentials for the Tomcat interface, depending on the server setup.

Patched versions at or above 9.0.31, 8.5.51, and 7.0.100 have fixed this issue.

Enumeration

Automatic

nmap -sV --script ajp-auth,ajp-headers,ajp-methods,ajp-request -n -p 8009 <IP>

Brute force

AJP Proxy

Nginx Reverse Proxy & AJP

Checkout the Dockerized version

When we come across an open AJP proxy port (8009 TCP), we can use Nginx with the ajp_module to access the "hidden" Tomcat Manager. This can be done by compiling the Nginx source code and adding the required module, as follows:

# Download Nginx codewget https://nginx.org/download/nginx-1.21.3.tar.gztar -xzvf nginx-1.21.3.tar.gz# Compile Nginx source code with the ajp modulegit clone https://github.com/dvershinin/nginx_ajp_module.gitcd nginx-1.21.3sudo apt install libpcre3-dev./configure --add-module=`pwd`/../nginx_ajp_module --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modulesmakesudo make installnginx -V

Comment out the entire server block and append the following lines inside the http block in /etc/nginx/conf/nginx.conf.

upstream tomcats {server <TARGET_SERVER>:8009;keepalive 10;}server {listen 80;location / {ajp_keep_conn on;ajp_pass tomcats;}}

Start Nginx and check if everything is working correctly by issuing a cURL request to your local host.

sudo nginxcurl http://127.0.0.1:80<!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8" /> <title>Apache Tomcat/X.X.XX</title> <link href="favicon.ico" rel="icon" type="image/x-icon" /> <link href="favicon.ico" rel="shortcut icon" type="image/x-icon" /> <link href="tomcat.css" rel="stylesheet" type="text/css" /> </headas <body> <div id="wrapper"> <div id="navigation" class="curved container"> <span id="nav-home"><a href="https://tomcat.apache.org/">Home</a></span> <span id="nav-hosts"><a href="/docs/">Documentation</a></span> <span id="nav-config"><a href="/docs/config/">Configuration</a></span> <span id="nav-examples"><a href="/examples/">Examples</a></span> <span id="nav-wiki"><a href="https://wiki.apache.org/tomcat/FrontPage">Wiki</a></span> <span id="nav-lists"><a href="https://tomcat.apache.org/lists.html">Mailing Lists</a></span> <span id="nav-help"><a href="https://tomcat.apache.org/findhelp.html">Find Help</a></span> <br class="separator" /> </div> <div id="asf-box"> <h1>Apache Tomcat/X.X.XX</h1> </div> <div id="upper" class="curved container"> <div id="congrats" class="curved container"> <h2>If you're seeing this, you've successfully installed Tomcat. Congratulations!</h2><SNIP>

Nginx Dockerized-version

git clone https://github.com/ScribblerCoder/nginx-ajp-dockercd nginx-ajp-docker

Replace TARGET-IP in nginx.conf witg AJP IP then build and run

docker build . -t nginx-ajp-proxydocker run -it --rm -p 80:80 nginx-ajp-proxy

Apache AJP Proxy

Encountering an open port 8009 without any other accessible web ports is rare. However, it is still possible to exploit it using Metasploit. By leveraging Apache as a proxy, requests can be redirected to Tomcat on port 8009.

sudo apt-get install libapache2-mod-jksudo vim /etc/apache2/apache2.conf # append the following line to the config Include ajp.confsudo vim /etc/apache2/ajp.conf # create the following file, change HOST to the target address  ProxyRequests Off <Proxy *> Order deny,allow Deny from all Allow from localhost </Proxy> ProxyPass / ajp://HOST:8009/ ProxyPassReverse / ajp://HOST:8009/sudo a2enmod proxy_httpsudo a2enmod proxy_ajpsudo systemctl restart apache2

This setup offers the potential to bypass intrusion detection and prevention systems (IDS/IPS) due to the AJP protocol's binary nature, although this capability has not been verified. By directing a regular Metasploit Tomcat exploit to 127.0.0.1:80, you can effectively seize control of the targeted system.

msf exploit(tomcat_mgr_deploy) > show options

References

Join HackenProof Discord server to communicate with experienced hackers and bug bounty hunters!

Hacking InsightsEngage with content that delves into the thrill and challenges of hacking

Real-Time Hack NewsKeep up-to-date with fast-paced hacking world through real-time news and insights

Latest AnnouncementsStay informed with the newest bug bounties launching and crucial platform updates

Join us on Discord and start collaborating with top hackers today!

Learn AWS hacking from zero to hero with htARTE (HackTricks AWS Red Team Expert)!

Other ways to support HackTricks:

8009 - Pentesting Apache JServ Protocol (AJP) | HackTricks | HackTricks (2024)

FAQs

Is port 8009 vulnerable? ›

out by default, or the service name if running on Windows) or the configuration file is the best way to determine if the server is vulnerable. 8009 is the default port for the AJP protocol endpoint. If there is an entry in your log file that includes “ajp” and “initializing”, the server is vulnerable.

Is AJP better than HTTP? ›

Ajp carries the same information as http but in a binary format. The request method – GET or POST – is reduced to a single byte, and each of the additional headers are reduced to 2 bytes – which is about a fifth of the size of the http packet.so ajp is lighter and faster than http.

How do I temporarily disable the AJP protocol port? ›

To disable the AJP connector:
  1. Navigate to: <EMHOME>/etc/emweb/tomcat/conf.
  2. make a backup copy of the file: server.xml.
  3. Edit server.xml, change the following line: <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/> to: <!-- < ...
  4. Restart the Control-M/EM web server.

What is port 8009 used for? ›

Apache AJP Proxy

By leveraging Apache as a proxy, requests can be redirected to Tomcat on port 8009. This setup offers the potential to bypass intrusion detection and prevention systems (IDS/IPS) due to the AJP protocol's binary nature, although this capability has not been verified.

What is ajp port used for? ›

The Apache JServ Protocol (AJP) is a binary protocol that can proxy inbound requests from a web server through to an application server that sits behind the web server.

What is the most insecure port? ›

These are the ports most targeted by attackers:
  • Port 22 (SSH)
  • Port 53 (DNS)
  • Port 25 (SMTP)
  • Port 3389 (remote desktop)
  • Ports 80, 443, 8080 and 8443 (HTTP and HTTPS)
  • Ports 20 and 21 (FTP)
  • Port 23 (Telnet)
  • Ports 1433, 1434 and 3306 (used by databases)

Is AJP deprecated? ›

IMPORTANT NOTE: The AJP/1.3 Connector is now deprecated. Use the Coyote JK Connector instead. The AJP/1.3 Connector element represents a Connector component that communicates with a web connector via the JK protocol (also known as the AJP protocol).

Is the AJP protocol secure? ›

AJP is a highly trusted protocol and should never be exposed to untrusted clients. It is insecure (clear text transmission) and assumes that your network is safe.

What is the maximum AJP packet size? ›

#'max_packet_size': This attribute sets the maximum AJP packet size in Bytes. The maximum value is 65536.

What is the Tomcat AJP connector? ›

The AJP Connector element represents a Connector component that communicates with a web connector via the AJP protocol.

What is the packet size of AJP? ›

packetSize: This attribute sets the maximum AJP packet size in bytes. The maximum value is 65536. It should be the same as the max_packet_size directive configured for mod_jk. Normally it is not necessary to change the maximum packet size.

What is ajp13 8009? ›

Apache JServ Protocol (AJP) is used for communication between Tomcat and Apache web server. This protocol is binary and is enabled by default. Anytime the web server is started, AJP protocol is started on port 8009. It is primarily used as a reverse proxy to communicate with application servers.

How to enable port 8009? ›

To enable the AJP connector and run it on port 8009 (default), perform the following steps: Open the /Apache Software Foundation/Tomcat 9.0_Tomcat9_30/conf/server. xml file with a text editor. Remove the comments for the connector.

What is ghostcat vulnerability? ›

What can Ghostcat do ? By exploiting the Ghostcat vulnerability, an attacker can read the contents of configuration files and source code files of all webapps deployed on Tomcat.

What port is Tomcat running on? ›

Overview. By default, Apache Tomcat runs on port 8080.

Is port 8000 vulnerable? ›

TCP port 8000 is commonly used for web servers and HTTP-based applications. If unrestricted inbound access is allowed on this port, it can pose a security risk to the system as it can be exploited by attackers to gain unauthorized access, execute arbitrary code, or steal sensitive information.

Which type of port is most vulnerable to attacks? ›

Here are some common vulnerable ports you need to know.
  1. FTP (20, 21) FTP stands for File Transfer Protocol. ...
  2. SSH (22) SSH stands for Secure Shell. ...
  3. SMB (139, 137, 445) SMB stands for Server Message Block. ...
  4. DNS (53) DNS stands for Domain Name System. ...
  5. HTTP / HTTPS (443, 80, 8080, 8443) ...
  6. Telnet (23) ...
  7. SMTP (25) ...
  8. TFTP (69)
Mar 29, 2022

Is SSH port vulnerable? ›

Port 22 is associated with the SSH (Secure Shell) protocol, which is used to securely connect to a remote device and issue commands just like you would on your own device. This default port does have its vulnerabilities, though: port 22 a popular target for brute force attacks and unauthorized access attempts.

Are TCP ports vulnerable? ›

DNS (Port 53): This UDP and TCP port is used for DNS queries and transfers. It is particularly susceptible to DDoS attacks. SSH (Port 22): This TCP port provides secure access to servers, but hackers can still exploit it through brute-force attacks, or by using leaked SSH keys.

Top Articles
Incoterms | Access2Markets
Frequently Asked Questions | Michigan Mortgage
Food King El Paso Ads
Algebra Calculator Mathway
Wmu Course Offerings
Ati Capstone Orientation Video Quiz
How to Type German letters ä, ö, ü and the ß on your Keyboard
Stolen Touches Neva Altaj Read Online Free
13 The Musical Common Sense Media
Urban Dictionary Fov
Cincinnati Bearcats roll to 66-13 win over Eastern Kentucky in season-opener
Ukraine-Russia war: Latest updates
Slushy Beer Strain
Elizabethtown Mesothelioma Legal Question
Overton Funeral Home Waterloo Iowa
Eka Vore Portal
Cvb Location Code Lookup
Bnsf.com/Workforce Hub
Dtab Customs
Site : Storagealamogordo.com Easy Call
Rural King Credit Card Minimum Credit Score
/Www.usps.com/International/Passports.htm
BMW K1600GT (2017-on) Review | Speed, Specs & Prices
Aes Salt Lake City Showdown
Mineral Wells Skyward
Meridian Owners Forum
Milwaukee Nickname Crossword Clue
Wood Chipper Rental Menards
Coindraw App
Lindy Kendra Scott Obituary
The Procurement Acronyms And Abbreviations That You Need To Know Short Forms Used In Procurement
Armor Crushing Weapon Crossword Clue
Gyeon Jahee
Texters Wish You Were Here
2016 Honda Accord Belt Diagram
To Give A Guarantee Promise Figgerits
Ishow Speed Dick Leak
USB C 3HDMI Dock UCN3278 (12 in 1)
Deshuesadero El Pulpo
Gary Lezak Annual Salary
Thothd Download
Brown launches digital hub to expand community, career exploration for students, alumni
Best Haircut Shop Near Me
John Wick: Kapitel 4 (2023)
Noga Funeral Home Obituaries
Craigslist Chautauqua Ny
Read Love in Orbit - Chapter 2 - Page 974 | MangaBuddy
Provincial Freeman (Toronto and Chatham, ON: Mary Ann Shadd Cary (October 9, 1823 – June 5, 1893)), November 3, 1855, p. 1
Haunted Mansion Showtimes Near The Grand 14 - Ambassador
Latest Posts
Article information

Author: Foster Heidenreich CPA

Last Updated:

Views: 5427

Rating: 4.6 / 5 (56 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Foster Heidenreich CPA

Birthday: 1995-01-14

Address: 55021 Usha Garden, North Larisa, DE 19209

Phone: +6812240846623

Job: Corporate Healthcare Strategist

Hobby: Singing, Listening to music, Rafting, LARPing, Gardening, Quilting, Rappelling

Introduction: My name is Foster Heidenreich CPA, I am a delightful, quaint, glorious, quaint, faithful, enchanting, fine person who loves writing and wants to share my knowledge and understanding with you.