<?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 Ammar Mostafa on Medium]]></title>
        <description><![CDATA[Stories by Ammar Mostafa on Medium]]></description>
        <link>https://medium.com/@ammarmostafa89?source=rss-977a06b625a6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pB21IhsqUqbdzqUX</url>
            <title>Stories by Ammar Mostafa on Medium</title>
            <link>https://medium.com/@ammarmostafa89?source=rss-977a06b625a6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 10:27:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ammarmostafa89/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[INE ByteGuard: Cyber Sentinel CTF WRITEUP.]]></title>
            <link>https://medium.com/@ammarmostafa89/ine-byteguard-cyber-sentinel-ctf-writeup-f8cefbb6d018?source=rss-977a06b625a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8cefbb6d018</guid>
            <category><![CDATA[log-analysis]]></category>
            <category><![CDATA[ine]]></category>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[soc]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Ammar Mostafa]]></dc:creator>
            <pubDate>Sat, 25 May 2024 02:24:07 GMT</pubDate>
            <atom:updated>2024-05-25T02:24:07.772Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xt9qS-lmsn4MOSbdgciUdQ.png" /><figcaption>Challenge description.</figcaption></figure><p>The challenge give you two files. first one is the security event logs of the system that we investigate and the second is the powershell logs. You can find the files here &gt;&gt; <a href="https://drive.google.com/file/d/1IHK0eaTfmK3IT13Sl674BIUmvKEBRYCe/view">https://drive.google.com/file/d/1IHK0eaTfmK3IT13Sl674BIUmvKEBRYCe/view</a><br>and this is the challenge link&gt;&gt; <a href="https://showcase.ine.com/ctf/challenge/nzLir9sTygi7cP25rOX2">https://showcase.ine.com/ctf/challenge/nzLir9sTygi7cP25rOX2</a></p><p>where you can find the questions but you can’t submit any answers because the challenge ended 20/5/2024, but you can use the answers here to check your answers.</p><p>Before we start opening the file there is a great tool form EZ tools is used to parse evtx files to csv files which you can use excel to view it and make filter as much as you can and of course you can use xpath filters and Get-WinEvent and even the event viewer but I will use the EZ tool called EvtxECmd and you can download it from here :<a href="https://ericzimmerman.github.io/#!index.md">https://ericzimmerman.github.io/#!index.md</a><br>After downloading the tool this is the basic and the way we will use</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6zJvXMXFONhDbbYmfMrZ2A.png" /><figcaption>The usage of the EvtxECmd tool</figcaption></figure><p>after you do this you will get a file with csv extension in the same folder as the EvtxECmd tool and this file that we will use to get all the answers. After opening the csv file save it as xlsx file and open xlsx file and press ctrl+A to select all rows and columns and go to insert tab and choose table.</p><p>NOTE1: Try to get the answers of all questions before looking to the solution.</p><p>NOTE2:Convert your computer time zone to UTC+00 while opening the evtx file or converting it to csv and you will know later :)</p><p>Let’s goooo!</p><p>Question 1: <strong>Who is relentlessly pursuing access to users (IP Address)?</strong></p><p>This question seem to be asking for somebody how conducting a brute force attack to access to users in windows typing the user name or password in wrong way will produce an event id 4625 so we will filter with this event ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*duOJ9viEEAI20x2VmOPTYw.png" /></figure><p>After doing this you will find a lot of events with event id and more than one source is trying to conduct brute force attack but I realized that the question want the one who conducted the biggest number of guesses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rL5QL9V0P-FMEnItfsn9Lg.png" /><figcaption>All the sources who generated failed login events</figcaption></figure><p>You can quickly use excel feature called pivot table to count how much a source occurred and this will give you the count of the 4625 events that this source made and you can do it manually by select source by source and see the number of rows at the left bottom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*cOzvId26bE0tN_hM6ItaLg.png" /><figcaption>The number of each source occurred with Event ID 4625</figcaption></figure><p>from the image above we can tell that the source who conducted the biggest number of wrong guesses for password or user names is</p><p>WIN-I219UGQJ7H8 (13.212.176.193) so the answer of the first question is <strong>13.212.176.193</strong></p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>Question 2:<strong>Do I appear to be a compromised user? (Flag Format — user:date:time) eg: “alice:3/9/2024:8:44:17PM”</strong><br>This one is tricky not from technical perspective but the reason is that INE want you to submit the result and the time zone is UTC+00 and if you open the log file it will show the logs with your computer time zone.</p><p>now we want to figure who is the compromised user and when he get compromised. we will see if any of the sources who conducted a brute force attack managed to get successful login(EventID 4624).</p><p>Using the image above we can filter for these sources to see if they managed to get a successful login we have around 8 sources which we will use them as a filter with EventID 4624.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_g1R6R-d3SA4I0tPFYoarA.png" /><figcaption>The compromised user</figcaption></figure><p>so the answer is <strong>EmilyJohnson:4/5/2024:5:18:17</strong></p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>Question 3: <strong>The vulnerable door left open due to admin’s negligence in patching it. What’s it’s name? (Short Name Only)</strong></p><p>From this question I used a EventID 4688 which indicate process creation.</p><p>After filter out the noise you will see more than one process started and seem very suspicious. For our question I found an exe that was executed from the startup folder and I found that it refer to a service called HTTP File Server that is some versions of it is vulnerable for Remote code execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hrv8pI4YJJSMRG-j1k86MQ.png" /></figure><p>and you can see that there are suspicious VBS scripts which its parent process is hfs.exe</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Oa5ftlvnw5NygMkIzurcA.png" /><figcaption>hfs.exe is parent process for malicious VBS script</figcaption></figure><p>So the answer is <strong>hfs</strong> because INE want the answer to be the short name.</p><p>NOTE: These scripts that will be used to open CMD and run malicious PowerShell commands as we will see in the next questions.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>Question 4: <strong>Any attempt to establish persistent access, and if so, what method have been employed? (Type Without Space)</strong></p><p>To solve this question we need to decode the encoded PowerShell commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_eB5Ky1-jOq_3DH_UBBP0Q.png" /></figure><p>After base64 decode the first script you will find this output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gB7PWf2GnU0crxJKA51MeA.png" /></figure><p>will find that the method he used to obfuscate the code such as gzip compress, another base64 encode and formatting operation. You’ll first use any text editor to do the formatting operation every {0} will be replaced by = and every {1} will replaced by U and every {2} will replaced by I and every ‘+’ will replaced by nothing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WqHZBh9tuInIy8OI_m3zog.png" /><figcaption>The base64 string after doing the formatting operation</figcaption></figure><p>After doing that you will get the base64 encoded code that will be decompressed using gzip method I go to ChatGPT to help me with this one and it gives me this code to reverse the function of the code and get the final code that will run on the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gx4-gQVRY7wEa4WJ_hQsig.png" /><figcaption>The code that used to reverse the obfuscation method.</figcaption></figure><p>After feed the $base64String variable with the base64 string we get from the formatting method and run the above code you will get this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RvLaXPjDdfEKQwp2nm2yjw.png" /><figcaption>The output of the code above</figcaption></figure><p>Another base64code so after decoding it also you will find the same method of obfuscation as above but it seems to have another part because it missing the formatting key and you can notice in the image above that this script has environment variable start with 00001 as it seems to be the first part of another big code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6x02EFahfXTIVNaFNNJNWA.png" /><figcaption>The same method as above but incomplete</figcaption></figure><p>So will move to the second PowerShell Command and after decode it you will find this (same method again)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dUBVR-PKBbEPJU5-T-M7bg.png" /></figure><p>So we will do the same steps as above you will get the below code and you can notice that it has environment variable start with 00002 as it seems that is the second part of the above incomplete code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xBWzfN--FfKLDWqsu6DnHQ.png" /></figure><p>and after decoding it you will get the below code which is for sure the complete of the above code as it complete the usual method that the attacker used and the formatting key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2PQjgXSjCKeIrZFofpl-SA.png" /></figure><p>combining the two codes will give us this code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AMLvErw5PPxEIvvFya0Uzw.png" /><figcaption>Combined code give us the same method of obfuscation</figcaption></figure><p>The same method again and after doing the same steps from using formatting and use our small script to get the readable code we get this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zw-iPVNsBdQYH1rgBcPUvw.png" /><figcaption>The Method he used to achieve persistence</figcaption></figure><p>This Method is used by attacker called <a href="https://attack.mitre.org/techniques/T1546/003/">WMI subscription</a>. Attackers use WMI (Windows Management Instrumentation) subscriptions to maintain persistence on a compromised system. They do this by creating WMI event filters and consumers that trigger malicious actions when certain system events occur, such as user logins or system startups. This allows their malicious code to run automatically, helping them to stay hidden and maintain control over the system. Here the attacker script will run after the system startup using the system uptime.</p><p>NOTE: you can read more about this technique here &gt;&gt; <a href="https://pentestlab.blog/2020/01/21/persistence-wmi-event-subscription/">https://pentestlab.blog/2020/01/21/persistence-wmi-event-subscription/</a></p><p>So the answer will be <strong>WMI subscription.</strong></p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>Question 5: <strong>What is the name of the persistent access backdoor?</strong></p><p>Using the same output above you will get the name of the Event Filter and Event Consumer is boss so the answer will be <strong>boss.</strong></p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>Question 6: Has any sensitive file been accessed/exfiltrated?</p><p>We will go back again to oure interesting process creation events(EventID 4688)</p><p>and you will notice this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gu6EENu8vjppL1bFy9PAwQ.png" /><figcaption>The exfiltration method</figcaption></figure><p>He used curl to make a post request contain the data he want to exfiltrate to his c2 server at Ip:13.212.120.12 and port 8080.</p><p>and the data exfiltrated is in base64 encoding so let’s decode it and see what we will get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*dS5tKRtxPk71Bpwy6v27MA.png" /><figcaption>The exfiltrated data :)</figcaption></figure><p>So the answer of this question is <strong>b9000157cabe9126896e1c254642c61b</strong></p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>Question 7: <strong>What is the name of the malicious script that has been executed on the machine?</strong></p><p>Back again to the EventID 4688 we will notice that a malicious PowerShell script was executed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*guq9laQ5FE9-offgZ3Z9Ig.png" /><figcaption>Mimikatz</figcaption></figure><p>And this script is Mimikatz which is both an exploit on Microsoft Windows that extracts passwords stored in memory and software that performs that exploit.</p><p>so the answer of this question will be <strong>Invoke-Mimikatz.ps1</strong></p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>At the end I hope you understand my simple explanation and if you need any help or inquiry don’t hesitate to contact me on my LinkedIn profile :<a href="https://www.linkedin.com/in/ammar-mostafa/">https://www.linkedin.com/in/ammar-mostafa/</a></p><p>I wish the best to all of you .(إن شاء اللَّه)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8cefbb6d018" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Investigation Blue Team Lab(CyberDefenders)]]></title>
            <link>https://medium.com/@ammarmostafa89/web-investigation-blue-team-lab-cyberdefenders-16561d635f13?source=rss-977a06b625a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/16561d635f13</guid>
            <dc:creator><![CDATA[Ammar Mostafa]]></dc:creator>
            <pubDate>Thu, 21 Mar 2024 20:33:27 GMT</pubDate>
            <atom:updated>2024-03-21T20:33:27.885Z</atom:updated>
            <content:encoded><![CDATA[<p>By opening the PCAP file Wireshark and Network miner we will see that there are 2 external connections to the online bookstore. In Wireshark go Statistics tap and from the list choose conversations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Yi0J2OycpdvQ9mFf8GZJ8w.png" /></figure><p>One of the two external IPs that connected with the online store has a large number of packets compared with the other IP.<br> So I started with the IP:111.224.250.131.</p><p>In Network Miner I saw the host details and I found that he used malicious tools that appeared in the user agent section such as go buster and SQLMap.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*PCqSG3cokgT9c1IfwVvFMw.png" /></figure><p>so the attacker IP will be 111.224.250.131.</p><p>**************************************************************************</p><p>In the Second question we need to identify the geographical address of the IP address we can use online website such as (<a href="https://www.iplocation.net/">https://www.iplocation.net/</a>) and search with the IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*J04RaapXfMHobxaHgGHLxQ.png" /></figure><p>Almost all the results say that the city is <strong>Shijiazhuang</strong>.</p><p>***************************************************************************</p><p>In the third question we want to find the exploited script on the website. In the first question we identified that the attacker uses malicious tools such as SQLMap.<br> <strong><em>SQLMap </em></strong><em>is a software utility for automated discovering of SQL injection vulnerabilities in web applications.</em></p><p>In Wireshark we will go to Statistics tap and go to http option and from it we will choose Requests.</p><p>Statistics &gt;&gt; HTTP &gt;&gt; Requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*amkPWaryps0vWXRG727lKw.png" /></figure><p>After Correlate the tool the attacker used with the requests (SQL Injection), he made we Identified that the exploited script was search.php.</p><p>****************************************************************************</p><p>For q4 we need to identify the URI request of the first SQLI .<br>we used the 1=1 that is used in SQL Injection attacks to search for the first request we will use find option in Wireshark.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vWoBbsQAixkxgFxzBOgrGA.png" /></figure><p>After clicking “find,” we will obtain the URI of the first SQL injection (SQLI) as Wireshark searches in chronological order by time.</p><p>You can also use search.php as a keyword to search with.</p><p>****************************************************************************</p><p>In q5, we aim to obtain the URI that was responded by the available databases. I reached to this answer with two ways.<br> The first approach involves using “mysql” as a keyword for searching, as it is a widely recognized database type and only search in successful responses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*1H7JpUKP4P2Uisue1OVAZA.png" /></figure><p>The second approach is to manually inspect the successful responses to GET requests that contain exploited script “search.php” as a keyword and you will find the response that contains the database response.<br>The second approach is to manually inspect the successful responses to GET requests that contain exploited script “search.php” as a keyword and you will find the response that contains the database response.<br> <br> You can also use Network Miner to see the responses that have size larger than the normal as you see below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*MywNpMVuQqZyKnrgmpJv4A.png" /></figure><p>and after inspecting the anomalies manually you will see the response that contains the available databases, then we use the destination port as a filter or by the frame number to reach to the packet and then you will find the URI in the request using follow HTTP stream option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WlQGHRiTD70Nn3nAXFX6Yg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*oOd9xAKKnSkT57I7yUufRA.png" /></figure><p>****************************************************************************</p><p>In q6 we want the table name that contain the users’ data. We can use the same approaches as q5.<br> I will use the second approach (Network Miner).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*e7srH9CaGFWfKh09CJDojw.png" /></figure><p>we will use the frame number or the destination port of the response as a filter in Wireshark to obtain the get request to obtain the result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OTfYrpRoZy0jzPy5I9uhAg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*1dKYrSglR8DobpN-wv5rLA.png" /></figure><p>We also found a request that returns with all tables and customers table exists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*laCrcnsco4xvj6NaerEN4g.png" /></figure><p>****************************************************************************</p><p>In q7 we want to know the hidden panel that the attacker enabled to reach to it. If the attacker enabled to reach to this hidden panel (most famous panels that attackers try to reach is admin panel) it will be a 200-response code so we will filter for this, but first in the previous questions we found that all the tables that the attacker get through an SQLI attack and “admin” is exist, so I started with this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eV0mdO7XnGPFxXvzcV2fJg.png" /></figure><p>And here the proof that the attacker reached to the admin panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*vSulwGgTKJJNFslIlqXg-g.png" /></figure><p>and if you manually inspect the successful responses, you will also reach to this.<br>****************************************************************************</p><p>In q8 we want to get the credentials that attacker used to successfully login.<br> We filter for POST requests, or we can use credentials tap in Network Miner.</p><p>First, we will use credentials tap In Network Miner we found four different credentials but by logic it appears that he tried three different credentials, but the last one worked with him and we will prove that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m5juJ14HZ7QPaGHjrlElKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ya_FhUMh94YdRDrpQEuVFA.png" /></figure><p>We found 5 POST requests. We will walk through the five frames and follow the HTTP stream and as example for invalid credentials see the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*ydNjNVdZzLSLIqODhUp0ZQ.png" /></figure><p>And for the valid credentials see the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*L37XNmq6211gLm2OIl8_ig.png" /></figure><p>*************************************************************************</p><p>In q9 we need to identify the uploaded script by the attacker, and this will be the fifth frame when we filter for POST requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*rX1ojKn3NmRwwzLyP82ABQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16561d635f13" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>