# 8009 - Pentesting Apache JServ Protocol (AJP)
{% hint style="success" %}
Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** π¬ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** π¦ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}
Join [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server to communicate with experienced hackers and bug bounty hunters!
**Hacking Insights**\
Engage with content that delves into the thrill and challenges of hacking
**Real-Time Hack News**\
Keep up-to-date with fast-paced hacking world through real-time news and insights
**Latest Announcements**\
Stay informed with the newest bug bounties launching and crucial platform updates
**Join us on** [**Discord**](https://discord.com/invite/N3FrSbmwdy) and start collaborating with top hackers today!
## κΈ°λ³Έ μ 보
From: [https://diablohorn.com/2011/10/19/8009-the-forgotten-tomcat-port/](https://diablohorn.com/2011/10/19/8009-the-forgotten-tomcat-port/)
> AJPλ μ μ‘ νλ‘ν μ½μ
λλ€. λ
립ν μΉ μλ²μΈ [Apache](http://httpd.apache.org/)κ° Tomcatκ³Ό ν΅μ ν μ μλλ‘ HTTP νλ‘ν μ½μ μ΅μ νλ λ²μ μ
λλ€. μμ¬μ μΌλ‘ Apacheλ μ μ μ½ν
μΈ λ₯Ό μ 곡νλ λ° Tomcatλ³΄λ€ ν¨μ¬ λΉ λ¦
λλ€. μμ΄λμ΄λ κ°λ₯ν κ²½μ° Apacheκ° μ μ μ½ν
μΈ λ₯Ό μ 곡νκ³ , Tomcat κ΄λ ¨ μ½ν
μΈ μ λν΄μλ μμ²μ TomcatμΌλ‘ νλ‘μνλ κ²μ
λλ€.
λν ν₯λ―Έλ‘μ΄ μ :
> ajp13 νλ‘ν μ½μ ν¨ν· μ§ν₯μ
λλ€. μ±λ₯μμ μ΄μ λ‘ λ μ½κΈ° μ¬μ΄ μΌλ° ν
μ€νΈλ³΄λ€ μ΄μ§ νμμ΄ μ νλ κ²μΌλ‘ 보μ
λλ€. μΉ μλ²λ TCP μ°κ²°μ ν΅ν΄ μλΈλ¦Ώ 컨ν
μ΄λμ ν΅μ ν©λλ€. μμΌ μμ±μ λΉμΌ νλ‘μΈμ€λ₯Ό μ€μ΄κΈ° μν΄ μΉ μλ²λ μλΈλ¦Ώ 컨ν
μ΄λμ λν μ§μμ μΈ TCP μ°κ²°μ μ μ§νκ³ μ¬λ¬ μμ²/μλ΅ μ£ΌκΈ°λ₯Ό μν΄ μ°κ²°μ μ¬μ¬μ©νλ €κ³ μλν©λλ€.
**κΈ°λ³Έ ν¬νΈ:** 8009
```
PORT STATE SERVICE
8009/tcp open ajp13
```
## CVE-2020-1938 ['Ghostcat'](https://www.chaitin.cn/en/ghostcat)
AJP ν¬νΈκ° λ
ΈμΆλλ©΄ Tomcatμ Ghostcat μ·¨μ½μ μ λ
ΈμΆλ μ μμ΅λλ€. μ΄ λ¬Έμ μ κ΄λ ¨λ [μ΅μ€νλ‘μ](https://www.exploit-db.com/exploits/48143)μ΄ μμ΅λλ€.
Ghostcatμ LFI μ·¨μ½μ μ΄μ§λ§ λ€μ μ νμ μ
λλ€: νΉμ κ²½λ‘μ νμΌλ§ κ°μ Έμ¬ μ μμ΅λλ€. κ·ΈλΌμλ λΆκ΅¬νκ³ , μ΄λ μλ² μ€μ μ λ°λΌ Tomcat μΈν°νμ΄μ€μ μ격 μ¦λͺ
κ³Ό κ°μ μ€μν μ 보λ₯Ό μ μΆν μ μλ `WEB-INF/web.xml`κ³Ό κ°μ νμΌμ ν¬ν¨ν μ μμ΅λλ€.
9.0.31, 8.5.51 λ° 7.0.100 μ΄μμ ν¨μΉλ λ²μ μμ μ΄ λ¬Έμ κ° μμ λμμ΅λλ€.
## Enumeration
### Automatic
```bash
nmap -sV --script ajp-auth,ajp-headers,ajp-methods,ajp-request -n -p 8009
```
### [**λΈλ£¨νΈ ν¬μ€**](../generic-methodologies-and-resources/brute-force.md#ajp)
## AJP νλ‘μ
### Nginx 리λ²μ€ νλ‘μ & AJP
[λ컀νλ λ²μ νμΈνκΈ°](8009-pentesting-apache-jserv-protocol-ajp.md#Dockerized-version)
μ΄λ¦° AJP νλ‘μ ν¬νΈ(8009 TCP)λ₯Ό λ°κ²¬νλ©΄, `ajp_module`μ μ¬μ©νμ¬ Nginxλ‘ "μ¨κ²¨μ§" Tomcat Managerμ μ κ·Όν μ μμ΅λλ€. μ΄λ Nginx μμ€ μ½λλ₯Ό μ»΄νμΌνκ³ νμν λͺ¨λμ μΆκ°νμ¬ μνν μ μμ΅λλ€:
* Nginx μμ€ μ½λ λ€μ΄λ‘λ
* νμν λͺ¨λ λ€μ΄λ‘λ
* `ajp_module`κ³Ό ν¨κ» Nginx μμ€ μ½λ μ»΄νμΌ
* AJP ν¬νΈλ₯Ό κ°λ¦¬ν€λ κ΅¬μ± νμΌ μμ±
```bash
# Download Nginx code
wget https://nginx.org/download/nginx-1.21.3.tar.gz
tar -xzvf nginx-1.21.3.tar.gz
# Compile Nginx source code with the ajp module
git clone https://github.com/dvershinin/nginx_ajp_module.git
cd nginx-1.21.3
sudo apt install libpcre3-dev
./configure --add-module=`pwd`/../nginx_ajp_module --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules
make
sudo make install
nginx -V
```
`server` λΈλ‘ μ 체λ₯Ό μ£Όμ μ²λ¦¬νκ³ `/etc/nginx/conf/nginx.conf`μ `http` λΈλ‘ μμ λ€μ μ€μ μΆκ°ν©λλ€.
```shell-session
upstream tomcats {
server :8009;
keepalive 10;
}
server {
listen 80;
location / {
ajp_keep_conn on;
ajp_pass tomcats;
}
}
```
Nginxλ₯Ό μμνκ³ λ‘컬 νΈμ€νΈμ cURL μμ²μ λ°ννμ¬ λͺ¨λ κ²μ΄ μ¬λ°λ₯΄κ² μλνλμ§ νμΈνμμμ€.
```html
sudo nginx
curl http://127.0.0.1:80
Apache Tomcat/X.X.XX