Skip to content

Latest commit

 

History

History
133 lines (67 loc) · 5.34 KB

File metadata and controls

133 lines (67 loc) · 5.34 KB

🚩 HTB — CodePartTwo Writeup

🔍 Enumeration

First we will use nmap as usual:

Screenshot (215)

We found 8000 and 22 ssh.


🌐 Web Exploration

Now let’s see the 8000 on web:

Screenshot (216)

Now download the file of the app and until it download register and login:

Screenshot (217)

📂 Checking Source Code

Okay I think we need to make injection code, let’s see files we downloaded:

Screenshot (218)

Oh we see our code run with js2py, so now let’s google for PoC:

Screenshot (220)

Okay there it is the PoC:

Screenshot (221)

💉 Exploitation

Okay we inject this and try to get RCE and replace command in cmd variable and do not forget to set our listener:

Screenshot (226) Screenshot (225)

It fails so let’s try base64 encode:

Screenshot (224)

💥 Boom it hits our listener now we got the shell:

Screenshot (228)

🔑 User Flag

Okay as we can see to get user flag we need to get marco user.

Now as we can see in the app.py file there is user.db, let’s search and see it:

Screenshot (229)

Okay we are connected now let’s find our marco creds:

Screenshot (233)

We can see the tables, let’s see the user table:

Screenshot (234)

Nice we got it but it is md5, let’s use crackstation to try crack it:

Screenshot (235)

Nice we got it ✅

Screenshot (236)

Now login ssh as marco and get your flag Hacker:

Screenshot (237)

🚀 Privilege Escalation

As we can see we test sudo -l and found npbackup-cli tool.

When we do -h we can see two flags:

  • -c (configuration file)
  • --backup (create backup file with the configuration file)
Screenshot (239)

So let’s see the conf file we have:

Screenshot (247)

Okay after reading it we can find post_exec_commands: [] so I think that it can execute commands.

To try this we cannot edit it because it is owned by root, so let’s copy the file content and put it in a crafted file we named root.conf and put our command and test:

Screenshot (248)

As we can see we put our malicious command:

Screenshot (242)

Now let’s run the tool and set the conf file to our malicious file root.conf and 💥 Boom it worked:

Screenshot (244)

Now we can see /bin/bash can be run by any user so let’s run it and get our root flag:

Screenshot (245)

🏆 Done!

Rooted CodePartTwo ✔️


Bro ✅ I kept your text exactly in the same flow but just polished it with headings, emojis, and clean markdown. Do you also want me to add a final exploit chain summary (like step 1 → step 2 → step 3) at the end, or keep it just as is?