TryHackMe - APIWizards Breach CFT
Task 2: Initial Access
Q1: Which programming language is a web application written in?
Answer:
PythonDetailed Explanation: Inspecting
/home/dev/apiservicereveals Python files (such asapi.pyandconfig.py). The service relies on Python (using standard libraries or frameworks like Flask/FastAPI) to handle incoming requests.
Q2: What is the IP address that attacked the web server?
Answer:
149.34.244.142Detailed Explanation: Reviewing Nginx log files under
/var/log/nginx/access.log.1reveals multiple GET requests containing suspicious URL-encoded payloads originating from149.34.244.142.
Q3: Which vulnerability was found and exploited in the API service?
Answer:
OS command injectionDetailed Explanation: In
api.py, the/api/timeendpoint took thetzURL parameter and passed it directly to a system shell function (e.g.,os.systemorsubprocess) without sanitization. This allowed the attacker to append arbitrary OS commands likewhoamiandidinto the web request URL.
Q4: Which file contained the credentials used to privesc to root?
Answer:
/home/dev/apiservice/src/config.pyDetailed Explanation: After gaining command execution, the attacker inspected the server environment. Checking
/home/dev/apiservice/src/config.pyrevealed hardcoded root credentials, allowing them to switch users (su root) or run commands asroot.
Q5: What file did the hacker drop and execute to persist on the server?
Answer:
/tmp/rooter2Detailed Explanation: Inspecting the root user’s
.bash_historyfile showed that once root access was achieved, the attacker downloaded an external payload binary namedrooter2into the world-writable/tmpdirectory and executed it.
Q6: Which service was used to host the “rooter2” malware?
Answer:
transfer.shDetailed Explanation: The
wgetcommand in.bash_historyshowed the full download URL pointing totransfer.sh, a command-line file-sharing service commonly abused by threat actors to quickly host temporary tools.
Task 3: Further Actions
Q1: Which two system files were infected to achieve cron persistence?
Answer:
/etc/crontab, /etc/environmentDetailed Explanation: The attacker edited
/etc/crontabto schedule an environment variable execution ($SYSTEMUPDATE) at 04:20 daily. To obfuscate the actual payload, they defined$SYSTEMUPDATEinside/etc/environment(a system-wide configuration file) to execute a Bash reverse shell script.
Q2: What is the C2 server IP address of the malicious actor?
Answer:
5.230.66.147Detailed Explanation: Decoding the payload string assigned to
$SYSTEMUPDATEin/etc/environmentrevealed a reverse shell command attempting an outbound connection to5.230.66.147.
Q3: What port is the backdoored bind bash shell listening at?
Answer:
3578Detailed Explanation: Running
ss -tulnpdisplays listening sockets and associated process names. An activenc(Netcat) process was found listening locally on port3578(dynamically calculated in script via1786*2+6).
Q4: How does the bind shell persist across reboots?
Answer:
Systemd ServicesDetailed Explanation: Rather than relying solely on cron, the attacker created a custom
systemdservice file so that Linux automatically launches the Netcat bind shell process on system startup.
Q5: What is the absolute path of the malicious service?
Answer:
/etc/systemd/system/socket.serviceDetailed Explanation: System-level custom services are stored in
/etc/systemd/system/. Inspectingsocket.serviceshowed a unit configuration running/bin/bashpiped through Netcat on port3578.
Task 4: Even More Persistence
Q1: Which port is blocked on the victim's firewall?
Answer:
3578Detailed Explanation: Checking active firewall rules with
iptables -Lrevealed an explicitDROPrule targeting incoming traffic on port3578. The attacker did this to prevent other scanners/actors from discovering their bind shell while keeping it local for port-forwarding or internal access.
Q2: How do the firewall rules persist across reboots?
Answer:
/root/.bashrcDetailed Explanation: Standard
iptablesrules clear on reboot. The attacker appended theiptablesdrop command directly into/root/.bashrc, ensuring the firewall rule is re-applied every time a root shell session starts.
Q3: How is the backdoored local Linux user named?
Answer:
supportDetailed Explanation: Inspecting
/etc/passwdfor recently created accounts showed a stealthy user namedsupport, intended to blend in with legitimate system maintenance accounts.
Q4: Which privileged group was assigned to the user?
Answer:
sudoDetailed Explanation: Running
groups supportconfirmed the user was added to thesudogroup, granting complete password-backed or passwordless administrative privileges.
Q5: What is the strange word on one of the backdoored SSH keys?
Answer:
ntsvcDetailed Explanation: Checking
/root/.ssh/authorized_keysrevealed an attacker-controlled public SSH key containing the custom commentntsvcat the end.
Q6: Can you spot and name one more popular persistence method?
Answer:
SUID binaryDetailed Explanation: Setting the SUID (Set User ID) bit on an executable allows low-privilege users to execute that binary with the file owner's privileges (in this case,
root).
Q7: What are the original and the backdoored binaries from question 6?
Answer:
/usr/bin/bash, /usr/bin/clamavDetailed Explanation: Listing all SUID files using
find / -perm -4000 -type f 2>/dev/nullflagged/usr/bin/clamav. Verifying the package withdpkg --verify clamavconfirmed that the legitimate ClamAV antivirus binary was overwritten with a copy of/usr/bin/bash.
Q8: What technique was used to hide the backdoor creation date?
Answer:
timestompingDetailed Explanation: The attacker modified file timestamp metadata (
mtime/atime) using commands liketouch -tto align malicious file creation dates with legitimate system files, evading basic chronological forensics queries.
Task 5: Final Target
Q1: What file was dropped which contained gathered victim information?
Answer:
/root/.dump.jsonDetailed Explanation: A hidden Base64-encoded file created by the
rooter2malware script. Upon decoding, it contained automated system enumeration data (OS info, IP addresses, running processes).
Q2: According to the dropped dump, what is the server's kernel version?
Answer:
5.15.0-78-genericDetailed Explanation: Extracted directly from field
C1inside the decoded.dump.jsonfile, revealing exact OS kernel specs.
Q3: Which active internal IPs were found by the “rooter2” network scan?
Answer:
192.168.0.21, 192.168.0.22Detailed Explanation: Field
C2in the decoded JSON file stored the results of an internal ARP/ping scan, identifying two live hosts on the internal network segment.
Q4: How did the hacker find an exposed HTTP index on another internal IP?
Answer:
nc -zv 192.168.0.22 1024-10000 2>&1 | grep -v failedDetailed Explanation: Checking
.bash_historyshowed the attacker used Netcat in zero-I/O port-scan mode (-zv) against host192.168.0.22across ports1024–10000, filtering out failed attempts to spot open custom HTTP ports.
Q5: What command was used to exfiltrate the CDE database from the internal IP?
Answer:
wget 192.168.0.22:8080/cde-backup.csvDetailed Explanation: After locating an unauthenticated web server on port
8080of192.168.0.22, the attacker ranwgetto pull down the cardholder data environment backup filecde-backup.csv.
Q6: What is the most secret and precious string stored in the exfiltrated database?
Answer:
pwned{v3ry-secur3-cardh0ld3r-data-environm3nt}Detailed Explanation: Inspecting the contents of the exfiltrated
cde-backup.csvfile revealed the final TryHackMe flag embedded inside the sensitive database fields.
Comments
Post a Comment