Builder

https://app.hackthebox.com/machines/Builder

Builder was a medium machine focused on Jenkins vulnerability.

Builder - Medium box

Ports scan

Web page

  • Nmap scan found that port 8080 is running for Jenkins

Upon visiting the website, we found Jenkins dashboard and wapalyzer tells us the version.

  • Vulnerable Jenkins version 2.441

Web attack

The above link gives a better demonstration of how the attack works.

Let's downoad the jar file with:

  • Let's get file imp file contents now

Hmmm, we are just getting a single line.... We can use help and list all the commands to see what commands can help us to get how many lines.

My guess: the reason we have different size output with different command is because a particular command has that length of expected output size. I.e enable job i used above might give True or False or some other output that is of 1 line only.

Anyway let's continue with trying a perfect command that will result many lines. For this purpose I wrote a python script (yeah ippsec way didn't work for my shell)

I used and manually saved output in check file:

You can paste the commands in a file called check

  • I found out that connect node has max number of output lines

  • we found 2 users

I tired to get ssh private key from this, but no luck

Hmm, not a user I suppose

Upon searching the directory structure of Jenkins and how it store files, I found this blog:

I could have done like ippsec way : To pull dockerfile and install jenkins and look at the directory structure, but I didn't wanna install things lol.

  • If we looked at users part in the blog

  • the users.xml file seem intresting

  • We get the username: jennifer_12108429903186576833

  • Now we can get password inside file: /var/jenkins_home/users/jennifer_12108429903186576833/config.xml

  • Password hash: $2a$10$UwR7BpEH.ccfpi1tv6w/XuBtS44S7oUpR2JYiobqxcDQJeN/L4l1a

  • Crack hash with johnTheRipper

  • Credentials: jennifer:princess

User

After executing Java #3 payload, i get the reverse shell

And now we can grab user.txt from /var/jenkins_home

I've looked inside credentials.xml file and found a hashed ssh private key

  • We can see the ssh hashed key can be decrypted using:

Going back to the script console we can run the command provided and get private key

Root

We can save and login root with the above key.

________________heapbytes's still pwning.

Last updated