<?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 Vighnesh Srinivas on Medium]]></title>
        <description><![CDATA[Stories by Vighnesh Srinivas on Medium]]></description>
        <link>https://medium.com/@srinivasvighnesh?source=rss-10062f9f314d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9dNsFTQkqmzukz1Nq6Zlxw.jpeg</url>
            <title>Stories by Vighnesh Srinivas on Medium</title>
            <link>https://medium.com/@srinivasvighnesh?source=rss-10062f9f314d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 22:36:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@srinivasvighnesh/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[Bypassing Windows’ Credential Guard]]></title>
            <link>https://srinivasvighnesh.medium.com/bypassing-windows-credential-guard-536713fc4620?source=rss-10062f9f314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/536713fc4620</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[av-bypass]]></category>
            <category><![CDATA[password-attacks]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[credential-guard]]></category>
            <dc:creator><![CDATA[Vighnesh Srinivas]]></dc:creator>
            <pubDate>Tue, 28 Jan 2025 00:33:28 GMT</pubDate>
            <atom:updated>2025-01-28T00:33:28.565Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello,</p><p>Today, we will talk about Microsoft Windows’ Credential Guard and how to bypass it.</p><p>Before we go in depth about what is credential guard and how to bypass it, we need some context. So, lets get into it! One of the most common attacks in a penetration test is <strong>Pass-the-Password </strong>or <strong>Pass-the-Hash</strong>.</p><h4>Pass-The-Hash or <strong>Pass-the-Password</strong></h4><ul><li>A Pass-the-hash or Pass-the-Password attack is basically passing the found password hash/password around the network with a list of usernames to see what else you get access to.</li><li>We perform this attack for lateral or vertical movement in a penetration test. In order to pass a hash/password, we need to obtain the hash.</li><li>A common method to obtain this hash is by dumping the memory of the machine using <strong>mimikatz</strong> and the <strong>sekurlsa module</strong>. When we run this module with the <strong>logonpasswords </strong>value, mimikatz will dump LSA secrets which will contain credentials of recently logged on users. <br><strong><em>LSA or lsass.exe is a process that handles user authentication, password changes and token creations.</em></strong></li><li>One of the things stored in the lsass.exe’s memory is password hashes of domain users who recently logged on. After dumping the LSA secrets which contains, among other things, password hashes of domain users, we can either crack it or pass it around the network.</li></ul><p>In order to mitigate this, Microsoft came up with various methods, one of which is <strong>Virtualization Based Security(VBS)</strong>.</p><ul><li><strong>Virtualization Based Security : </strong>A software technology that leverages the CPU’s virtualization capabilities and enables the creation of isolated regions of memory in a secure way. This is the foundation on which the operating system security of windows is built.</li><li><strong>VBS</strong> runs a hypervisor on the physical hardware instead of running it on the operating system. Microsoft also built the <strong>Virtual Secure Mode(VSM)</strong> which is a set of hypervisor capabilities offered to the Hyper-V partitions.</li><li><strong>VSM</strong> creates isolated regions in memory where the OS can store sensitive information. These isolated regions in the memory can only be accessed through the hypervisor which runs at a higher privilege than kernel.</li></ul><p>Now, <strong>VSM</strong> and <strong>VBS</strong> might confuse you because I said they do the same thing — <strong><em>Create the isolated region in the memory to store sensitive data</em></strong>.</p><h4>D<strong>ifference between VBS and VSM</strong></h4><ul><li><strong>VBS</strong> is the umbrella technology which leverages the hypervisor and hardware capabilities of the CPU to enforce system security. The specific implementation of creating an isolated memory to store sensitive data is done by <strong>VSM</strong>.</li><li><strong>VSM</strong> uses the capabilities provided by <strong>VBS</strong> to create the isolated memory regions. Now going back to accessing this secure memory region, since the permissions required are higher than the kernel itself, we cannot access it with SYSTEM privileges.</li></ul><p>VSM maintains the isolation through different trust levels known as Virtual Trust Levels(VTL).</p><h4>Virtual trust Levels (VTL)</h4><p>Different VTL represent different isolation memory region. Microsoft currently supports 16 levels ranging from <strong>VTL 0</strong> to <strong>VTL 1.</strong></p><p>The two important trust levels we will focus on are <strong>VTL 0</strong> and <strong>VTL 1.</strong></p><ul><li><strong>VTL 0 (VSM Normal Mode)</strong> — In this mode, the isolated memory region contains the regular user mode processes, normal kernel and kernel-mode data.</li><li><strong>VTL 1 (VSM Secure Mode) </strong>— In this mode, the secure memory region stores critical functionalities and data.</li></ul><p>Microsoft has used <strong>VSM</strong> as a foundation for several mitigations, one of which is the Windows Credential Guard.</p><p>When Credential Guard is enabled, the <strong>lSASS</strong> runs a trustlet in VTL1 as LSAISO.exe (LSA Isolated). <strong><em>A trustlet is basically a special and secure process used to handle critical and sensitive information</em></strong><em>.</em> This trustlet or the process LSAISO.exe is where sensitive information such as the domain user credential hashes are stored.</p><p>From windows PowerShell, we run the following command to check if credential guard is enabled on our target computer:</p><pre>Get-ComputerInfo</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*4KsPDGlFNG9OmLEQ92svFA.png" /></figure><p>The screenshot above shows that Credential Guard is enabled. Next, we will launch mimikatz and try to dump all of the LSA secrets using the following commands:</p><pre>privilege::debug<br>sekurlsa::logonpasswords full</pre><p>Here, you will notice that you are able to dump hashes for Local Accounts, but not for Domain Accounts. You should see the below error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*w0agyS1c9NUX5Ryi25-M4g.png" /><figcaption>Unable to dump domain hashes</figcaption></figure><h4>Bypass Credential Guard — Exploit Security Support Provider Interfaces(SSPI)</h4><p>Now in order to bypass credential guard, instead of trying to extract hashes from the cache, we need to change our approach and intercept the login credentials while the users are trying to log in.</p><p>In order to do this, we use an authentication mechanism supported by Microsoft called<strong> Security Support Provider Interfaces(SSPI)</strong>.</p><ul><li>All applications and services that require authentication use <strong>SSPI</strong>.</li><li>Some of the more well known <strong>SSPs</strong> are <strong>kerberos</strong> and <strong>NTLM</strong>.</li><li>These providers are included in the <strong>SSPI</strong> as <strong>DLLs</strong>, and when authentication takes place, <strong>SSPI</strong> decides which one to use.</li></ul><p>Windows also gives us the option to register our own <strong>SSP</strong> through the <strong>AddSecurityPackage API </strong>and through the <strong><em>HKEY_LOCAL_Machine/System/currentcontrolset/control/LSA/Security Packages</em> </strong>registry key.</p><p>When a system starts up, the <strong>LSASS</strong> loads the <strong>DLLs</strong> present in the list pointed to by this registry key. This means if we develop our own <strong>SSP</strong> and register it with <strong>LSASS</strong>, we can force the <strong>SSPI</strong> to use our malicious authentication <strong>SSP DLL</strong> for authentication.</p><p>Fortunately, <strong>mimikatz </strong>does this whole process for us. It will provide the required custom <strong>SSP</strong> and inject it directly in the memory of <strong>lsass.exe </strong>process without dropping the <strong>DLL</strong> on the disk.</p><p><strong>Mimikatz</strong> leverages the fact that the <strong>SSP</strong> are called with plaintext credentials through the <strong>SSPI</strong>. This eliminates the whole processes of capturing a hash and cracking it.</p><p>Let’s run <strong>mimikatz</strong> and enable privileged mode. We will then run the misc module with the <strong>memssp</strong> command:</p><pre>.\mimikatz.exe<br>privilege::debug<br>misc::memssp</pre><p>Now, we sit and wait for a domain user to login with their credentials. We can view the captured credentials stored at : <br><strong><em>C:\Windows\System32\mimilsa.log</em>. </strong>We can open this file and locate the domain user credentials.</p><p><em>Disclaimer : I could not attach few screenshots in the post to show what the outputs look like due to some issues with my lab environment.</em></p><p>I hope this helped you in understanding the underlying technology of the Windows Credential Guard and how to bypass it using mimikatz.</p><p>Comment below if you have any doubts or feedback.</p><p>Thanks for reading it and I will see you in the next one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=536713fc4620" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[picoCTF — GET aHEAD]]></title>
            <link>https://srinivasvighnesh.medium.com/picoctf-get-ahead-e66a00433f9b?source=rss-10062f9f314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e66a00433f9b</guid>
            <category><![CDATA[picoctf]]></category>
            <category><![CDATA[web-hacking]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[burpsuite]]></category>
            <dc:creator><![CDATA[Vighnesh Srinivas]]></dc:creator>
            <pubDate>Mon, 07 Jun 2021 09:50:27 GMT</pubDate>
            <atom:updated>2021-06-07T09:50:27.846Z</atom:updated>
            <content:encoded><![CDATA[<h3>picoCTF — GET aHEAD</h3><p>Hello Hackers,</p><p>Today we will solve the “<strong>Get aHEAD</strong>” challenge from <strong>picoCTF</strong>. This is a beginner-level/easy challenge based on web exploitation. Let’s dive right into it!</p><p>We see that there’s a link given to us. When we open the link, we are presented with a web page that changes its colour by pressing a button. So the background colour changes to red when you click on “choose red”, and it changes to blue when you click on “choose blue”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FPuraoiTzmEWRA-CKoThDw.png" /><figcaption><strong>Background — Red</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tCeGK0oiQ7V8uZQsKZdXDA.png" /><figcaption><strong>Background — Blue</strong></figcaption></figure><p>Since this page does not do anything else, we’ll have to look a bit deeper to see how to exploit this. Let’s take a look at the HTTP requests that are sent by the website when we click on each of the two buttons. To do this, we can use a tool called <strong>Burp Suite</strong> developed by <strong><em>Portswigger. </em></strong>We can manipulate HTTP requests and view their responses using Burp Suite. It is the most widely used tool in Web app testing. If you’re using <strong>Kali Linux, </strong>you will have it preinstalled, if you’re on some other distro of Linux, you can download it from <a href="https://portswigger.net/burp/communitydownload"><strong>here</strong></a>. Once you’ve downloaded and installed it, configured it, click on the “<strong>choose red</strong>” button, intercept its request, and examine it. Now do the same for the “<strong>choose blue</strong>” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*cq-jsPhj1IF2ZylPzIijNQ.png" /><figcaption><strong>HTTP request for the red button</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*ZlmoXxuevEUEoWxkHm6zfA.png" /><figcaption><strong>HTTP request for the blue button</strong></figcaption></figure><p>As you can see, when we click on the red button, the browser sends a “<strong>GET</strong>” request. On the other hand, by clicking the blue button, the browser sends a “<strong>POST</strong>” request. If you don’t know what these are, I highly recommend that you read up on <strong>HTTP methods</strong>. The “<strong>GET</strong>” method is used to retrieve a resource from the server, which in this case will be the web page with red background. “<strong>GET ”</strong>requests do not have a message body. The request parameters are sent in the URL. The “<strong>Post</strong>” method is used to perform some kind of action, which in this case is to change the background colour to blue. The “<strong>Post” </strong>method has a message body where all the request parameters are passed. Now that we know that the website uses two different HTTP methods for each button, maybe we can change the method and get the flag. Let’s try and change the “<strong>GET</strong>” method to “<strong>HEAD</strong>”. We can do this by right-clicking on the HTTP request and select “<strong>send to repeater</strong>”. Then switch to the repeater tab and click on send. In the response panel, you can see the flag!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*DxRG_iIVs8wX0uTXoUaZsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lgQ4MPnEeM09tWqVKSO74w.png" /><figcaption><strong>Flag</strong></figcaption></figure><p>Congratulations on finding the flag!.</p><p>Happy Hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e66a00433f9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OverTheWire-Leviathan]]></title>
            <link>https://srinivasvighnesh.medium.com/overthewire-leviathan-39f15939f1e6?source=rss-10062f9f314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/39f15939f1e6</guid>
            <dc:creator><![CDATA[Vighnesh Srinivas]]></dc:creator>
            <pubDate>Sun, 16 May 2021 08:59:50 GMT</pubDate>
            <atom:updated>2021-05-16T08:59:50.767Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello People,</p><p>Today we will take a look at <strong>Leviathan </strong>at <strong>OverTheWire. </strong>This is an easy wargame that revolves around basic Linux commands. This wargame is a place where we can apply everything we have learned from bandit. Let’s jump right in!</p><h3>Level 0 -&gt; Level 1</h3><p>At Level 0, we can “<strong>SSH</strong>” into the machine with the username “<strong>leviathan0</strong>” and the password “<strong>leviathan0</strong>”. So we use the command “<strong><em>ssh leviathan0@leviathan.labs.overthewire.org -p 2223</em></strong>”. The terminal will then prompt us for the password, which will then give us access to the machine. Now unlike bandit, in this wargame, there are no hints, so we’re on our own. So let’s look around and see what we can find. We run the command “<strong><em>pwd</em></strong>” and see that we are in “/home/leviathan0” directory. On running “<strong><em>ls</em></strong>”, we don’t see any directory. Interesting. We again run the same command with 2 new flags “<strong>ls -la</strong>”. This command basically lists the hidden directories and files. We see a directory called “<strong>backup</strong>”. We “<strong><em>cd</em></strong>” into the directory and a “<strong>bookmarks.html</strong>” file. We open the file and search for the password hoping we find it here. We can run the command “cat bookmarks.html | grep pass” search the file for password and voila! We find the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezGFsT1qNDWWBmgQuKniWg.png" /><figcaption>Password for leviathan1</figcaption></figure><h3>Level 1 -&gt; Level 2</h3><p>We can ssh with leviathan1’s credentials with the command mentioned above. Here we again list contents in the current directory with the “<strong><em>ls</em></strong>” command and see a file called “<strong>Check</strong>”. This file is highlighted in red, which means it a <strong>setuid binary</strong>. We can find that out by running the “<strong><em>file check</em></strong>” command. “<strong>Setuid binaries</strong>” are files that run with admin privileges. So when we execute the file, we can execute it with root privileges. These are usually used as privilege escalation vectors. So we can run the file to see what it does with the command “<strong><em>./check</em></strong>”. When we run the binary, it prompts us to enter a password. We can enter leviathan1’s password but it says “wrong password”. This means that we need to find a key that we can enter with the binary, and it will give the password for the next level. We can view the contents of the binary but it’s all gibberish. Here we can use a command called “<strong><em>ltrace</em></strong>” which when run with a binary, will intercept every system call, function call and display every parameter a function can take. This will help us understand the binary a little better. So let’s try running the command “<strong><em>ltrace ./check</em></strong>”. Initially, you’ll only see the first two lines. You have to keep pressing the enter key to see more lines. Now here we see a “<strong>Strcmp</strong>” function that takes in a string and compares it to “<strong>sex</strong>”. We enter the word when the binary prompts us for a password and it accepts it! Now it gives us a shell. Let’s try to retrieve the password from “<strong>/etc/leviathan_pass</strong>” directory. And we get the password!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9MBIz0nNVZfTijvMrtLBQQ.png" /><figcaption>Password for leviathan2</figcaption></figure><h3>Level 2 -&gt; Level 3</h3><p>On this level, we have another setuid binary called “<strong>printfile</strong>”. We run the binary, and as the name suggests, it prints a file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*t8lvDfb6ZxizCu6nGdNdhw.png" /></figure><p>Let’s try to access the “<strong>/etc/leviathan_pass/leviathan3</strong>&quot; file. Looks like we can’t access the file. We can try “<strong>/etc/pass</strong>” since it’s readable by all users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*6pOoGYhCyXTFoD-ZKqeuUA.png" /></figure><p>We can see that the program is using the “<strong>access</strong>” method to check if we have the permissions to read the file. It then passes our string, which in this case is the file path to “<strong>snprintf</strong>” which generates the command to be executed. This method then passes the command to “<strong>system()</strong>” where it is executed. This is a very basic understanding of what the program is doing. Please read the <strong>man pages </strong>of each of these functions to understand them better. So we can see that the access() method is used to check for permissions and then execute the operation, which in this case is print the contents of the file. So to get the password for leviathan3, we can do the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*TBotzaiiO5jkpm2pAMpj1A.png" /><figcaption>Password for leviathan3</figcaption></figure><p>Here we create a file followed by the command “<strong><em>bash</em></strong>”. Since there is no proper validation, we are having the system() method execute multiple commands. Now since this is a suid binary, it will execute “<strong>bash</strong>” with leviathan3’s permissions and we get the shell as leviathan3. We can now view the password file for the user. Now, I’ll admit that this level was a bit challenging for me and I had to go around looking for some help since I’m also still learning.</p><h3>Level 3 -&gt; Level 4</h3><p>Here on the home page, there is a setuid binary with the name “level3”. We run the binary and see that it is asking us for a password. We can try leviathan3’s password but it doesn’t work. Let’s run “<strong>ltrace</strong>” again and see what get. It prompts us for the password again. Let’s enter the same password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*Nic03y84p_O-XpDy3s0maA.png" /></figure><p>We can see that the program is comparing our password to “<strong>snlprintf</strong>”. We can try this password and it works! We are now leviathan4. We can now view the password for leviathan4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*nBxkM6ztsn8YCrIh7sepkg.png" /><figcaption>Password for leviathan4</figcaption></figure><h3>Level 4 -&gt; Level 5</h3><p>On running “<strong><em>ls</em></strong>” command, no file or directories show up. So we list all files with the command “<strong><em>ls -la</em></strong>”. We see a “.trash” directory. We move in to this directory and see a setuid binary with the name “<strong>bin</strong>”. We execute the file with the command “<strong><em>./bin</em></strong>” and it displays a binary output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*zwPhLrhpby5NsMbnlHsP9A.png" /></figure><p>This could be the password converted to binary. We can use <a href="https://codebeautify.org/binary-string-converter">this</a> decoder to convert this binary output to string and voila! It gives us the password for the next level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*ZHu8L-ClMcouzu1oSPka7A.png" /><figcaption>Password for leviathan5</figcaption></figure><h3>Level 5 -&gt; Level 6</h3><p>We can see there’s <strong>another </strong>setuid binary in the home directory with the name “<strong>leviathan5</strong>”. We can the binary and it displays the message “<strong>Cannot find /tmp/file.log</strong>”. We can try to create this file. Let’s do it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oyVR5_BkvOS7IPI6W6VAvw.png" /></figure><p>So we can create and write to this file. Let’s try to copy the contents of the file <strong>“/etc/leviathan_pass/leviathan6&quot; </strong>but it will tell us that we don’t have the permissions to do that. We can create a symbolic link to that file. So let’s do that. Now we can run the binary again and we see the password! Sweet!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*WKzLpsccisCucWfmo-Zbkw.png" /><figcaption>Password for leviathan6</figcaption></figure><h3>Level 6 -&gt; Level 7</h3><p>On this level, we have a setuid binary with the name “<strong>leviathan6</strong>” in the home directory. We run the binary and it asks us to supply a 4 digit code. So we need to brute force the binary to find the correct code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*yY3jJAonlU7PzftxTqDbFg.png" /></figure><p>So we use the code “<strong><em>for i in $(seq 0000 9999); do ./leviathan6 $i ; done</em></strong>”. A number of “<strong>Wrong</strong>” messages will be displayed until the correct code is found. We then get a shell. We can run “<strong><em>whoami</em></strong>” and see that we are <strong>leviathan7. </strong>We can now retrieve the user’s password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*-T3F2u8oPPyHryG08i6fjA.png" /><figcaption>Password for leviathan7</figcaption></figure><h3>Level 6 -&gt; Level 7</h3><p>We can login with leviathan7’s credentials and it will display a <strong>Congratulations</strong> message.</p><p>We have successfully completed the wargame. Congratulations!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39f15939f1e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OverTheWire — Bandit(11–20) Walkthrough]]></title>
            <link>https://srinivasvighnesh.medium.com/overthewire-bandit-11-20-walkthrough-974ae513837c?source=rss-10062f9f314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/974ae513837c</guid>
            <category><![CDATA[overthewire]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[bandit]]></category>
            <category><![CDATA[war-games]]></category>
            <dc:creator><![CDATA[Vighnesh Srinivas]]></dc:creator>
            <pubDate>Mon, 19 Apr 2021 05:16:04 GMT</pubDate>
            <atom:updated>2021-04-19T06:08:08.999Z</atom:updated>
            <content:encoded><![CDATA[<h3>OverTheWire — Bandit(11–20) Walkthrough</h3><p>This is the second part of my bandit walkthrough. You can find the first part <a href="https://systemweakness.com/overthewire-bandit-0-10-walkthrough-e66cc30e1453">here</a>. In this part, we will cover levels 11 through 20. So let’s jump right in!</p><h3>Level 10 -&gt; Level 11</h3><p>Here the password for the next level is stored in the file <strong>“data.txt”</strong> in the home directory. The data in this file is base64 encoded. We can “<strong><em>cat</em></strong>” the file and see that there’s just one word in it. So we run the command ‘<strong><em>base64 -d data.txt’ </em></strong>and get the password for the next level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*w8nBNQ_u0MIbl_fyM3VQxw.png" /><figcaption>Password for bandit11</figcaption></figure><h3>Level 11 -&gt; Level 12</h3><p>Here we see another <strong>“data.txt” </strong>file in the home directory. The webpage for this level says that there are upper and lower case characters in this file which are rotated by 13 positions. So basically each letter in a string is replaced by a character at the 13th position from it. So <strong>a</strong> will be replaced by <strong>n</strong>, <strong>b </strong>will be replaced by <strong>o, </strong>and so on. This is basically a special type of Ceaser&#39;s cipher. After reading around for a bit, I found a StackOverflow link explaining to decrypt this cipher using the <strong><em>‘tr’ </em></strong>command which stands for translate. This command translates a set of characters into another set of characters. So we can then run the command “<strong><em>tr ‘[a-z][A-Z]’ ‘[n-za-m][N-ZA-M]’</em></strong>”<em>. </em>This command will basically rearrange the characters decrypt the data in the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*2evwSJNldOqK2NC4AaT7GQ.png" /><figcaption>Password for bandit12</figcaption></figure><h3>Level 12 -&gt; Level 13</h3><p>In this level, the password is stored in “<strong>data.txt</strong>” which is a hexdump of a file that’s been repeatedly compressed. The webpage for this level suggests that we make a folder in the /tmp directory, copy the file in this directory and work on it. So we can create a directory using ‘<strong><em>mkdir /tmp/shirahoshi</em></strong>’ and copy the file in this location by running the command ‘<strong><em>cp data.txt /tmp/shirahoshi</em></strong>’. We then rename the file using the command ‘<strong><em>mv data.txt hex.txt</em></strong>’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*9ravLcsHVyT4tV36vZAEtg.png" /></figure><p>Here we need to first decrypt the hex dump file and for that, we use a tool called <strong>xxd</strong>. <strong>xxd</strong> is a tool that can make a hex dump and reverse it. So we use ‘<strong><em>xxd -r hexdump.txt &gt; new</em></strong>’. This should reverse the hex dump file and store its content in the file “new”. Now we know that this file has been repeatedly compressed. On running ‘<strong><em>file new</em></strong>’, we find out that it has been zipped by using gzip. Now before we start decompressing the file, we need to make sure that it has the proper extension else the tools won’t work. So we first change the extension and rename the file <strong>new.gz</strong>. We can now unzip the file using ‘<strong><em>gzip -d new.gz</em></strong>’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*sbYFPcVn3Z7715Fv0cD2Zw.png" /></figure><p>Now after decompressing the file, we check the file type again using the ‘<strong><em>file</em></strong>’ command. We see that it is of file type bzip2. So we use the tool bzip to decompress this file by using the command ‘<strong><em>bunzip2 new</em></strong>’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*k87OXwPe9j9BUhFEVfL0QQ.png" /></figure><p>Now we have another compressed file! We run the ‘<strong><em>file</em></strong>’ command again and see that it is a gzip file. So we rename it again decompress it using gunzip as described above. Now when we check the file type, we find out that it’s a <strong>tar</strong> file. So we rename the file with <strong>.tar</strong> extension and then run the command ‘<strong><em>tar -xf new.tar</em></strong>’. The ‘<strong>-x</strong>’ flag tells tar to extract from the file and ‘<strong>-f</strong>’ flags tells it that it is a regular file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*VlcAzk5vvIpcbRjGi_s39w.png" /></figure><p>On running the ‘<strong><em>ls</em></strong>’ command, we see a new file named “<strong>data5.bin</strong>”. We check the file type and figure out that it is a .tar file. We know that this file has been compressed several times, so we go through the same process of finding the file, changing the extension in case it’s a gzip file, and then decompress it using the methods described above. We continue doing this until we finally get the text file. We then ‘<strong><em>cat</em></strong>’ out the “<strong>data8</strong>” file which has our password. Sweet!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*s7L6JcH-lOhzNw0k_NqSVw.png" /><figcaption>Password for bandit13</figcaption></figure><h3>Level 13 -&gt; Level 14</h3><p>Here, to get access to the next level, we will need an SSH key which can be used to get access to level 14. In the home directory, we can find the said ssh key by running ‘<strong><em>ls</em></strong>’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*shM_WOp5l7iAwpbLK_bTng.png" /></figure><p>We can then copy this file to our local system and change its permission to 600, which is required for ssh private keys to work. We can then use this key to login as <em>bandit14</em> using the command ‘<strong><em>ssh -i id_rsa bandit14@bandit.labs.overthewire.org -p 2220</em></strong>’. Here ‘<strong><em>id_rsa</em></strong>’ file has our private key.</p><h3>Level 14 -&gt; Level 15</h3><p>The webpage for this level says “The password for the next level can be retrieved by submitting the password of the current level to <strong>port 30000 on localhost</strong>.” So we first need to find the password of <em>bandit14</em> as we only have a private key and not the actual password for this user. Since we are the owner of the file “<strong>etc/bandit_pass/bandit14</strong>”, we can read the contents of this file and retrieve the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*FkJZ9BBvgd98_VasJkxY4w.png" /><figcaption>Password for bandit14</figcaption></figure><p>Now that we have <em>bandit14</em>’s password, all we have to do is connect to the localhost at port 30000 and supply the password. We can use <strong>netcat</strong> to open a connection to our localhost.<strong> Netcat </strong>is a tool that can be used for a variety of things including port scanning and listening for traffic. We can connect to the localhost by running the command ‘<strong><em>nc localhost 30000</em></strong>’ and we get the password for <em>bandit15</em>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*GIWxVBQzJ0XoN92Nm1dbnA.png" /><figcaption>Password for bandit15</figcaption></figure><h3>Level 15 -&gt; Level 16</h3><p>To get the password for the next level, we will have to connect to the localhost over SSL on port 30001 and submit the current user’s password. We can do this by using “<strong>openssl</strong>”. We run the command ‘<strong><em>openssl s_client -connect localhost:30001</em></strong>’. This opens up the connection to the localhost. We then provide the password and retrieve <em>bandit16</em>’s password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*mfrNnZ3tDhltXtmrnARlIw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*pkIyk9EWBVdrY4t2hCz3QA.png" /><figcaption>Password for bandit16</figcaption></figure><h3>Level 16 -&gt; Level 17</h3><p>On this level, we first have to find the correct port in the range 31000 to 32000, connect to it on localhost over SSL, and submit the current user’s password to get the password for the next level. First, we need to find the correct port to connect to. We can do this using <strong>nmap</strong>. Nmap is a port scanner that tells us about all the open ports and the services they are running. So we do a quick nmap scan by running the command ‘<strong><em>nmap -p 31000–32000 localhost</em></strong>’. This shows us the following output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*gW8-06FjdtHD64sggNShmw.png" /><figcaption>nmap output.</figcaption></figure><p>We can then manually connect to each port till we find the correct one. Once we have the correct port, we can use the same openssl tool to connect to the localhost and retrieve the password in the similar fashion. The command is ‘<strong><em>openssl s_client -connect localhost:31790</em></strong>’. Here we submit the current user’s password and it then gives us an RSA private key for the next user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*9wKChkB5vA8MJA9TEyM8tg.png" /><figcaption>Private key for bandit17</figcaption></figure><h3>Level 17 -&gt; Level 18</h3><p>In the home directory of <em>bandti17</em>, there are two files with almost the same content except for one line. That line has the password for the next level. We can find this line by using a tool called “<strong>diff</strong>”. We can run the command ‘<strong><em>diff passwords.old passwords.new</em></strong>’. This will give us the password for the next level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*pGgQrcAd1ej79ZgybCZ3ww.png" /><figcaption>Password for bandit18</figcaption></figure><h3>Level 18 -&gt; Level 19</h3><p>This is an interesting challenge! When you login with <em>bandit18</em>’s credentials, we get access, see a “<strong>Byebye !</strong>” message and the session terminates. This is because the configuration in .bashrc is such that it will log you out when you try to log in. After looking around for a while, I figured out that ssh lets you execute a command when trying to open a connection. Amazing! So even if our shell terminates, it will retrieve the results of the command we execute. So Let’s try to list files in the home directory first. We run the command ‘<strong><em>ssh </em></strong><a href="/service/mailto:bandit18@bandit.labs.overthewire.org"><strong><em>bandit18@bandit.labs.overthewire.org</em></strong></a><strong><em> -p 2220 ls</em></strong>’. Here as you can see, I am trying to execute the ‘<strong><em>ls</em></strong>’ command. Let’s see what this does.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*2w-GsV-EARdWFBav_9geSQ.png" /></figure><p>ssh executed the ‘<strong><em>ls</em></strong>’ command and displayed the “<strong>readme</strong>” file in the home directory. Sweet! So this means we can also read the contents of this file. We run the command ‘<strong><em>ssh </em></strong><a href="/service/mailto:bandit18@bandit.labs.overthewire.org"><strong><em>bandit18@bandit.labs.overthewire.org</em></strong></a><strong><em> -p 2220 cat readme</em></strong>’ and voila! We get the password for <em>bandit19</em>.</p><h3>Level 19 -&gt; Level 20</h3><p>The webpage for this level says that we need to use the setuid binary in the home directory to get the password for the user <em>bandit20</em>. Now setuid binary are files which let you run the file as if you were the owner of that file. It is a special type of user privilege. If you run the command ‘<strong><em>ls -la</em></strong>’ in the home directory, you will see “<strong>s</strong>” in the user permissions. You can also see that the owner of this suid binary is <em>bandit20</em>. So we can execute this binary as <em>bandit20</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ygphvJMGcYLCKs6owdFYhg.png" /></figure><p>Now to figure out what this binary does, we have to execute it. So we run the command ‘<strong><em>./bandit20-do</em></strong>’. On running this command, the binary tells us to “run a command as another user”. So we basically have to execute this binary along with a command of another user. So let’s try to print<em> bandit20</em>’s password as that user is the owner of this binary. we run the command ‘<em>./bandir20-do cat /etc/bandit_pass/bandit20</em>’. This gives us the password for the user <em>bandit20</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*CWTzwCAU3Lhbs7JaDlPb0A.png" /><figcaption>Password for bandit20.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=974ae513837c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OverTheWire — Bandit(0–10) Walkthrough]]></title>
            <link>https://systemweakness.com/overthewire-bandit-0-10-walkthrough-e66cc30e1453?source=rss-10062f9f314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e66cc30e1453</guid>
            <category><![CDATA[wargames-online]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[overthewire]]></category>
            <dc:creator><![CDATA[Vighnesh Srinivas]]></dc:creator>
            <pubDate>Sat, 03 Apr 2021 20:13:20 GMT</pubDate>
            <atom:updated>2021-05-01T05:19:10.751Z</atom:updated>
            <content:encoded><![CDATA[<h3>OverTheWire — Bandit(0–10) Walkthrough</h3><p>Hello hackers,</p><p>Today we will solve a “CTF” called bandit by OverTheWire. This is a Linux wargame aimed at absolute beginners. It teaches us Linux fundamentals and privilege escalation. Bandit currently has 34 challenges. This blog will be a three-part series and this is the first part and will cover the first 14 challenges. You can find the second part <a href="https://srinivasvighnesh.medium.com/overthewire-bandit-11-20-walkthrough-974ae513837c">here</a>. So let’s jump right in!</p><h3><strong>Level 0</strong></h3><p>The goal of this level is to connect to <strong>bandit.labs.overthewire.org </strong>on port 2220 via ssh. The username and password for this account are bandit0. We can log in using the command “<strong><em>ssh bandit0@bandit.labs.overthewire.org -p 2220</em></strong>”. After pressing enter, the shell will prompt us for a password. Password is bandit0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*pn-I2f0u5WYiZfCLIzB1HA.png" /><figcaption>login to bandit0</figcaption></figure><h3>Level 0 -&gt; Level <strong>1</strong></h3><p>The goal here is to access the readme file in the current directory. This file contains the password for bandit1. We can run the “<strong><em>ls</em></strong>” command to see what’s present in the current Directory. We see that there’s a readme file here. This contains the password for the next level. We can use <strong><em>cat</em> </strong>command to print out the contents of this file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*O9JK3eb2DyrEC_62BAJVGQ.png" /><figcaption>Password for bandit1</figcaption></figure><h3><strong>Level 1 -&gt; Level 2</strong></h3><p>The goal of this level is to access the “<strong>-</strong>” file to get the password for the next level. When we execute the <strong><em>ls</em></strong> command in the shell, we see a file with the name “<strong>-</strong>”, which is very weird. Let us understand why this file name is so weird. The symbol “<strong>-</strong>” can also mean stdin or stdout. So when the shell sees this particular symbol, it treats it as either of the two. For a detailed explanation, refer <a href="https://unix.stackexchange.com/questions/16357/usage-of-dash-in-place-of-a-filename">this</a> link. So to view the contents of this file, we need to enter the full path of the file so that the shell understands that this symbol refers to a file and not stdin. We execute “<strong><em>cat ./-</em></strong>” and voila! We have the password. Here “<strong>.</strong>” refers to the current directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*jjJrmPlvhlnu6hjVHJBuaw.png" /><figcaption>Password for bandit2</figcaption></figure><h3>Level 2 -&gt; Level 3</h3><p>In the home directory, we have a file with a filename that has spaces in it. We can still use the <strong><em>cat</em></strong> command to print its content by enclosing the name in single/double-quotes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*yBcr20E6UKKzg8rEAzwbrA.png" /><figcaption>Password for bandit3</figcaption></figure><h3>Level 3 -&gt; Level 4</h3><p>There is a directory inside of the current directory named “<strong>inhere</strong>”. We can see that there no file is found by <strong><em>ls</em></strong> command. That is because the file is hidden. We can use <em>“</em><strong><em>ls -la</em></strong>” to list all files within a directory and it will show us all the hidden files. A file in Linux can be hidden by appending a period(.) before the filename. We can then <strong><em>cat </em></strong>the contents of this hidden file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*xIowj3odOypRGypMQncJmA.png" /><figcaption>Password for bandit4</figcaption></figure><h3>Level 4 -&gt; Level 5</h3><p>In this next level, we find the same inhere directory inside which there are 9 files. Out of these 9 files, only has human-readable contents. Running a quick “<strong><em>file</em> </strong>.” will show us the file types of all 9 files. We can see that -file07 is human readable. We can then <strong><em>cat</em></strong> its contents to get the password for the next level. Whew! That was a lot of “files” for one level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*rtFd5Nfrz8lDnKO67-o3Rg.png" /><figcaption>Password for bandit5</figcaption></figure><h3>Level 5 -&gt; Level 6</h3><p>The OTW website for this level says that the password for the next level is in a file that is <strong>human readable, 1033 bytes in size, and not executable.</strong> Inside the inhere directory, there are 19 more directories. Each directory has some files with the same name. Here we can manually inspect the properties of each file until we find the correct one. However, this will consume a lot of time. We can, instead, use the <strong><em>find</em></strong> command. “<strong>f<em>ind \! -executable -size 1033c</em></strong>” command will fetch us the required password file. Here, the backslash and exclamation mark with executable flag tell the shell to look for files for which this user does not have executable permission. The “-size 1033c” tells the shell to look for a file that is 1033 bytes in size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wZxtDSAkBY3U7fwOQfeQDA.png" /><figcaption>Password for bandit6</figcaption></figure><h3>Level 6 -&gt; Level 7</h3><p>The password for the next level is stored somewhere on the server and has the following properties:</p><ol><li>owned by user bandit7</li><li>owned by group bandit6</li><li>33 bytes in size</li></ol><p>Here we first need to change the directory to root. We can then run the <strong><em>find</em></strong> command with <strong>-user, -group, and -size flags</strong> to fetch us the required file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*lJupdFcLiyb8ci2ZrdDBcg.png" /><figcaption>Password for bandit7</figcaption></figure><h3>Level 7 -&gt; Level 8</h3><p>The password for the next level is stored in “<strong>data.txt</strong>” next to the word “<strong>millionth”. </strong>We can try to<strong><em> cat</em></strong> out the contents of this file but it is too big to manually go through. We can instead use another command called “<strong><em>sort</em></strong>” which will sort the lines alphabetically for us. We can then use the <strong><em>grep</em></strong> command to fetch and print all the lines with the word millionth in them. Now we have our password for bandit8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*62PTcy45KlXnJZTMTS5thg.png" /><figcaption>Password for bandit8</figcaption></figure><h3>Level 8 -&gt; Level 9</h3><p>Here, we have a file called “<strong>data.txt</strong>”. The password is in the line that appears only once in the entire file. So we can use the <strong><em>uniq</em></strong> command with the -c flag. This will retrieve all the unique lines in the file along with a count of its occurrences. The <strong><em>uniq</em></strong> command will only work if a line occurs multiple times subsequently. Meaning that if a line occurs multiple times in a file but not one after the other, <strong><em>uniq</em></strong> command will not work. Hence we will first sort the document alphabetically. As you can see, there is only one line that has occurred once throughout the document.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*mvvmlbdKxIW9wDC8yicJPA.png" /><figcaption>Password for bandit9</figcaption></figure><h3>Level 9 -&gt; Level 10</h3><p>There is a “<strong>data.txt” </strong>file in the current directory. We can <strong><em>cat</em></strong> the contents and see that all it contains is gibberish. We know that the password is preceded by several “=”. So we use a command called <strong>“<em>strings</em>” </strong>which retrieves all the printable characters in a file. It basically retrieves human-readable strings from a file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*HIn0HjsqxGA1O8XmAZ_FCA.png" /><figcaption>Password for bandit10</figcaption></figure><p>That’s it for this part. I’ll add the links for the next 2 parts in the introduction.</p><p>Happy Hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e66cc30e1453" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/overthewire-bandit-0-10-walkthrough-e66cc30e1453">OverTheWire — Bandit(0–10) Walkthrough</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>