IClean
Last updated
Last updated
If we try to visit the http://iclean.htb
page we're redirected to http://capiclean.htb
:
Add this FQDN to /etc/hosts
and retry to navigate the webpage:
At /team
page we can have info disclosure about possible employee's names/usernames:
We have also to analyze a login page with a form at /login
:
The directory listing using FFUF show us a /dashboard
with a 302 - Redirect
to homepage and a /server-status
with response code 403 - Forbidden
:
There is also another interesting page /quote
about a kind of page to request a quote:
That send the POST request to /sendMessage
endpoint:
Intercepting the POST request in BurpSuite we obtain this one:
If there is a contact form, it is possible that the submitted requests will be monitored by some site administrator user. We can see if the form is vulnerable to an XSS...
Using the stealed cookie and Cookie-Editor Firefox Plugin we can now access the /dashboard
page which previously returned a 403 - Forbidden
:
As you can see, several features can be accessed including generating an invoice:
Intercepting in BurpSuite:
And some QR code to view it via the web:
Then the backend return to us a QR Code link:
Submitting the QR Code link:
It appears that the fields entered within the invoice generation are not then rendered in the generated HTML:
The QR Code that we see in Web-version invoice in right-bottom is represented as base64 encoded image as showed by BurpSuite and seems to be the only one input reflected in the server’s response:
If we try to change the value of this parameter we see that the response change in consistent way...
But things get interesting when we notice that by trying to inject template syntax, it is evaluated by the server:
We have in this case a Server-Side Template Injection (SSTI). Considering that the backend language obtained from the previous enumeration step turns out to be Python it is likely that we are working with Jinja2 or Mako.
The classic SSTI JInja2 exploit tecniques seems to not work, so searching on the Web i've found this article about bypassing restriction.
After checking for python and its version and after trying different type of reverse shells:
I've used the following POST body request:
And using the magic pwncat-cs finally we obtain a reverse shell:
Inside the app.py file we find DB credentials (iclean:pxCsmnGLckUb):
Viewing the /etc/passwd file, we have confirmation that there is a mysql server and a user named consuela
:
Enumerating and accessing mysql with the credentials found we see that there is a user
table having 2 census users: admin
and consuela
Try to cracking the admin password we will not obtain any result instead the consuela password is in our wordlist and so we obtain it:
Logging using SSH as consuela
user, we obtain the user flag:
As a first attempt we type the classic sudo -l
to see what commands we are allowed to execute as root:
It would appear to be a tool for managing and creating/editing pdfs from the command line.
Searching GTFObins or the Internet, there appears to be no standard technique for privilege escalation exploiting this binary.
Analyzing in more detail the features offered by this tool the most interesting ones turn out to be the following:
The basic parameters to be used involve an input file and an output file. However, there is a --empty
option that saves us from having to bring a dummy PDF file to the victim machine by using a blank PDF as input instead:
There doesn't seem to be the ability to run commands so the fastest way turns out to be to read the root user's SSH private key and add to PDF as attachment, which is possible to do since we can run qpdf as administrative users.
Since we cannot view the file with a graphical PDF Viewer we have to use the option --qdf
:
Analyzing the entire generated PDF we notice that the root SSH key has been added as an attachment and we can now use it to log in via SSH: