Precious
Enumeration
First let's add precious.htb to /etc/hosts
Rustscan
mkdir rust; sudo rustscan -t 1500 -b 1500 --ulimit 65000 -a precious.htb -- -sV -sC -oA ./rust/{{ip}}.----. .-. .-. .----..---. .----. .---. .--. .-. .-.
| {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| |
| .-. \| {_} |.-._} } | | .-._} }\ }/ /\ \| |\ |
`-' `-'`-----'`----' `-' `----' `---' `-' `-'`-' `-'
The Modern Day Port Scanner.
________________________________________
: https://discord.gg/GFrQsGy :
: https://github.com/RustScan/RustScan :
--------------------------------------
Please contribute more quotes to our GitHub https://github.com/rustscan/rustscan
[~] The config file is expected to be at "/root/.rustscan.toml"
[~] Automatically increasing ulimit value to 65000.
Open 10.129.77.196:22
Open 10.129.77.196:80
PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 63 OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
80/tcp open http syn-ack ttl 63 nginx 1.18.0
|_http-title: Convert Web Page to PDF
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
| http-server-header:
| nginx/1.18.0
|_ nginx/1.18.0 + Phusion Passenger(R) 6.0.15
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel80
NGINX + Phusion Passenger
Phusion Passenger seems to be an extension to support various kinds of application type like ruby https://en.wikipedia.org/wiki/Phusion_Passenger
Webpage
Visiting http://precious.htb will display a page that says "Convert Web Page to PDF". A quick check using a locally setup webserver showed that the page is exactly doing that.
Using Burp we check our requests and can identify that Ruby is used!
Dirsearch
Found nothing
Feroxbuster
Also no results
Exploitation
Searching for Ruby and HTML to PDF vulnerabilities will lead you to PDFKIT - Command Injection
We'll use that POC to craft our payload and get a reverse shell
Payload
After submitting the malicious url on http://precious.htb we will receive a reverse shell as user ruby
Become User henry
In /home/ruby/.bundle is a file located that is called config. In that file you will find the password of user henry
Become User henry
Escalation
Local Enumeration
Always the first thing todo is to check for any sudo privileges
Looks like we are allowed to update dependencies as root user. Smells like a ruby deserialization attack
/opt/update_dependencies.rb
Checking the file we are allowed to run will confirm my assumption. YAML.load is extremely unsafe and shouldn't be used according to Ruby - YAML
Privilege Escalation
We will use a Universal RCE for Ruby YAML.load - YAML.load - RCE
dependencies.yaml
First we have to create the dependencies.yaml file in our current location and modify git_set to add suid on /bin/bash
Root
Last updated