# Exploit Title: New exploit to Oracle CVE-2007-4517 vulnerability
# Date: 11,2,2011
# Author: David Maman and the GreenSQL Team
# Software Link: http://blog.greensql.com/2011/11/02/new-exploit-to-oracle-vulnerability/
# Version: 0.1
# Tested on: Oracle Database 10g Express Edition
# CVE : New exploit to CVE-2007-4517
As part of GreenSQL?s Database security research, we?ve been validating and extending coverage of known and unknown vulnerabilities in order to increase GreenSQL product security, at this post we will reveal a full working Prove of Concept for the CVE-2007-4517 vulnerability which executes arbitrary code.
The Exploit: PL/SQL/2007-4517 exploit is a PL/SQL procedure that exploits the CVE-2007-4517 vulnerability, also known as Oracle Database XDB.XDB_PITRIG_PKG.PITRIG_DROPMETADATA Procedure Multiple Argument Remote Overflow.
The vulnerability is caused due to a boundary error in the XDB.XDB_PITRIG_PKG.PITRIG_DROPMETADATA procedure when processing the OWNER and NAME arguments to create an SQL query.
This can be exploited to cause a buffer overflow by passing overly long OWNER and NAME arguments to the affected procedure.
New administrative user account.
(Username: GreenSQL, Password:GreenSQL)
OracleServiceXE service turns off.
The exploits has been tested on:
? Windows XP Professional SP3.
? Oracle Database 10g Express Edition.
All the known exploits and POC?s developed for this vulnerability so far are Denial-of-Service exploits.
This is a New exploit that actually executes arbitrary code and adds a new user account to the database host operating system.
The PL/SQL procedure calls to the xDb.XDB_PITRIG_PKG.PITRIG_DROPMETADATA() function with two arguments:
2. Buffer (2305 bytes)
The buffer consists of payload, jmp instructions, arithmetic instructions and garbage.
When executing the code, the EBX contains the starting address of the buffer + 0x7A5.
In order to execute the payload in the buffer, the following steps needs to be performed:
1. The EIP should point to an address contains the jmp EBX instruction.
2. At the [EBX] address, the exploit needs to jmp -0x7A5 to the start of the buffer.
Jumping to EBX
In order to jump to the address in the EBX register, the EIP should be set to 0x 095F7160.
Jumping to the Payload
In order to execute the payload, the following instructions needs to be performed:
sub ebx, 0x7a5
The opcodes of the first instruction are:
One of the limitations of HEXTORAW() function, is that its not able to deal with 000 characters.
Because of that reason, instead of using the sub ebx, 0x7a5 instruction, the following instructions need to be performed:
Which are equivalent to:
sub ebx, 0x5b0
Which is equivalent to jmp ebx-0x5b0.
The opcodes of those instructions are:
080, 0xEB, 0xB0, 080, 0xC7, 0xFA, 0xFF, 0xE3, which are able to be processed by the HEXTORAW() function.
The payload?s size is 308 bytes (of 0x7A5-0x5B0 = 0x1F5 = 501 payload?s space)
The payload creates a new user account, called greenSQL, with the password GreenSQL.
After creating the user account, it adds the user to the Administrators group.