OverPass

Date: 20, May, 2021

Author: Dhilip Sanjay S


Click Herearrow-up-right to go to the TryHackMe room.

Enumeration

Nmap

$ nmap -sC -sV -p- 10.10.123.199 -oN nmap-full
Starting Nmap 7.91 ( https://nmap.org ) at 2021-05-19 23:53 IST
Stats: 0:06:24 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 60.23% done; ETC: 00:04 (0:04:13 remaining)
Nmap scan report for 10.10.123.199
Host is up (0.15s latency).
Not shown: 65533 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 37:96:85:98:d1:00:9c:14:63:d9:b0:34:75:b1:f9:57 (RSA)
|   256 53:75:fa:c0:65:da:dd:b1:e8:dd:40:b8:f6:82:39:24 (ECDSA)
|_  256 1c:4a:da:1f:36:54:6d:a6:c6:17:00:27:2e:67:75:9c (ED25519)
80/tcp open  http    Golang net/http server (Go-IPFS json-rpc or InfluxDB API)
|_http-title: Overpass
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 652.91 seconds

Gobuster

Overpass

Admin login

  • By analysing the javascript files login.js and cookie.js, we find that a cookie named SessionToken being set on a successful login.

  • If the cookie value is not being verified in the backend, then we'll be able to access the admin panel.

  • So we can manually set the SessionToken cookie in the browser or just use curl:

  • We find the Private Key of the user James.

Initial Shell

  • We'll use ssh to get intial shell:

  • But the ssh key is passphrase protected.

  • We'll use ssh2john, so that we can bruteforce the passpharse.

  • The passpharse is james13.

  • Now, we'll use ssh to login into the machine:

user.txt

  • Answer: thm{65c1aaf000506e56996822c6281e6bf7}

Overpass - user.txt

Privilege Escalation Attempts

Cracking James' password and checking for sudo permission

  • By understanding the overpass.go file, we find that the password will be stored in ~/.overpass file in ROT47 encoding.

  • So, we'll check this file in james directory:

  • By ROT47 decoding:

  • We run the command sudo -l and using the password we obtained recently.

  • Unfortunately, james doesn't have any of the sudo permission!

Checking for SUID

  • Even though sudo and su were having SUID bit set, we couldn't abuse it.

Checking for other Users

  • May be we can check the password file of tryhackme user.

  • But still, permission denied!!

Running Linpeas.sh

  • Host a python server to get linpeas on target machine:

  • Download and run linpeas.sh in the target vulnerable machine.

  • I have included only a small part of linpeas output.

  • Cron jobs!!

Privilege Escalation

Viewing /etc/crontab

  • We must inject code into buildscript.sh inorder to escalate our privilege.

  • But, the file is being downloaded from overpass.thm

  • It turns out that overpass.thm is 127.0.0.1. And the server is being hosted by tryhackme user, so we can't change the script file.

Modifying /etc/hosts

  • If we look at the linpeas output closely, we can find that /etc/hosts file is writable.

  • So, we can change the IP address and host a different buildscript.sh with our malicious code. (Maybe we can add James to the sudoers group, we know his password!)

  • Before modifying the IP address, we must replicate the directory structure: /downloads/src/buildscript.sh and host a server:

  • Modify the /etc/hosts file on the target:

Escalating to root (before adding james to /etc/sudoers)

  • We see that our script file is downloaded by the target machine:

  • Now we'll run sudo -l to get permissions of james

  • Ever though james was added to sudo group, the /etc/sudoers file didn't contain james.

  • So, we need to add that to our script file.

  • I also changed the permission of /bin/bash to 4777. (As a backup, incase if modifying sudoers file didn't work)

Modified buildscript.sh


root.txt

  • Answer: thm{7f336f8c359dbac18d54fdd64ea753bb}

  • Finally both worked!!

  • Using sudo bash and james' password:

  • Using /bin/bash -p:

Overpass - root.txt

Last updated