Go Back   HostGator Peer Support Forums > HostGator Peer Support Forums > WHM Complete Solution

Notices

Reply
 
Thread Tools
  #1  
Old 01-26-2012, 05:11 PM
zomex's Avatar
zomex zomex is offline
Swamp Croc
 
Join Date: Apr 2011
Posts: 245
Default Script from WHMCS to stop hack attempts

Hello,

Someone on webhostingtalk.com post a script which they got from WHMCS that stops people being able to open tickets with the exploit code.

Note: You must install the security patch below if you haven't already. This script in this post is not a replacement for the security patch:

http://blog.whmcs.com/?t=43462

The code I'll post below is simply to stop people being able to open tickets containing {php} or {/php} which will stop you having to delete multiple tickets each day.

PHP Code:
<?php
$checkvars 
= array('subject','message');
foreach (
$checkvars AS $checkvar) if (strpos($_REQUEST[$checkvar],'{php}')!==false) die("We're sorry, but you cannot use \"{php}\" in a ticket submission. If you do have a legitimate issue, please press the back button in your browser and then change any instances of \"{php}\" to \"(php)\" so that your ticket may be submitted.  Keep in mind that neither {php} nor (php) will function.");
?>
Save this code in a PHP file of your choice. e.g ticketexploit.php and upload to:

whmcs/includes/hooks/

Jack
__________________
Zomex - The best WHMCS templates - Admin-based SETTINGS AREA!
█ A complete WHMCS Setup service including automatic cPanel account creation!
View our clients testimonials about our WHMCS services > WHMCS Testimonials
Reply With Quote
  #2  
Old 01-28-2012, 01:01 PM
tletourneau tletourneau is offline
Baby Croc
 
Join Date: Dec 2007
Posts: 76
Default Re: Script from WHMCS to stop hack attempts

Thanks for posting this!
__________________
Thanks,

Tom
Reply With Quote
  #3  
Old 01-28-2012, 02:42 PM
freeman's Avatar
freeman freeman is offline
Swamp Croc
 
Join Date: Jan 2006
Location: Montreal, QC, Canada
Posts: 308
Default Re: Script from WHMCS to stop hack attempts

Quote:
Originally Posted by zomex View Post
The code I'll post below is simply to stop people being able to open tickets containing {php} or {/php} which will stop you having to delete multiple tickets each day.

PHP Code:
<?php
$checkvars 
= array('subject','message');
foreach (
$checkvars AS $checkvar) if (strpos($_REQUEST[$checkvar],'{php}')!==false) die("We're sorry, but you cannot use \"{php}\" in a ticket submission. If you do have a legitimate issue, please press the back button in your browser and then change any instances of \"{php}\" to \"(php)\" so that your ticket may be submitted.  Keep in mind that neither {php} nor (php) will function.");
?>
Save this code in a PHP file of your choice. e.g ticketexploit.php and upload to:

whmcs/includes/hooks/

Jack
or you can deny this with ModSec:
PHP Code:
SecRuleEngine On
SecRule ARGS_POST 
"{php}" "deny,log,auditlog" 
Reply With Quote
  #4  
Old 01-29-2012, 01:00 AM
naushad naushad is offline
Junior Croc
 
Join Date: Aug 2007
Posts: 103
Default Re: Script from WHMCS to stop hack attempts

Thanks very much for this.
Reply With Quote
  #5  
Old 01-30-2012, 05:49 PM
zomex's Avatar
zomex zomex is offline
Swamp Croc
 
Join Date: Apr 2011
Posts: 245
Default Re: Script from WHMCS to stop hack attempts

No problem, glad I could help.
__________________
Zomex - The best WHMCS templates - Admin-based SETTINGS AREA!
█ A complete WHMCS Setup service including automatic cPanel account creation!
View our clients testimonials about our WHMCS services > WHMCS Testimonials
Reply With Quote
  #6  
Old 02-01-2012, 12:20 PM
justMe justMe is offline
Swamp Croc
 
Join Date: Mar 2008
Location: Tonasket, Wa.
Posts: 232
Default Re: Script from WHMCS to stop hack attempts

Quote:
Originally Posted by zomex View Post
PHP Code:
<?php
$checkvars 
= array('subject','message');
foreach (
$checkvars AS $checkvar) if (strpos($_REQUEST[$checkvar],'{php}')!==false) die("We're sorry, but you cannot use \"{php}\" in a ticket submission. If you do have a legitimate issue, please press the back button in your browser and then change any instances of \"{php}\" to \"(php)\" so that your ticket may be submitted.  Keep in mind that neither {php} nor (php) will function.");
?>
Note, this code will not prevent a person submitting a ticket directly using an email client. (if you have email piping or similar set up)

Also note, this code will prevent editing/saving email templates from the whmcs admin area.

Below is a modification to get around the email template issue while still using the hook that Jack posted.

PHP Code:
    $file pathinfo($_SERVER['SCRIPT_NAME']);
    
$callingScript $file['basename'];

    
$checkvars = array('subject''message');
    foreach (
$checkvars AS $checkvar) if ($callingScript != 'configemailtemplates.php' && strpos($_REQUEST[$checkvar], '{php}') !== false) die("We're sorry, but you cannot use \"{php}\" in a ticket submission. If you do have a legitimate issue, please press the back button in your browser and then change any instances of \"{php}\" to \"(php)\" so that your ticket may be submitted.  Keep in mind that neither {php} nor (php) will function.");
?> 
@freeman
Code:
SecRuleEngine On
SecRule ARGS_POST "{php}" "deny,log,auditlog"
Where is this code placed? .htaccess?

__________________
~ Leighton
Reply With Quote
  #7  
Old 02-01-2012, 02:28 PM
zomex's Avatar
zomex zomex is offline
Swamp Croc
 
Join Date: Apr 2011
Posts: 245
Default Re: Script from WHMCS to stop hack attempts

Quote:
Originally Posted by justMe View Post
Note, this code will not prevent a person submitting a ticket directly using an email client. (if you have email piping or similar set up)

Also note, this code will prevent editing/saving email templates from the whmcs admin area.

Below is a modification to get around the email template issue while still using the hook that Jack posted.

PHP Code:
    $file pathinfo($_SERVER['SCRIPT_NAME']);
    
$callingScript $file['basename'];

    
$checkvars = array('subject''message');
    foreach (
$checkvars AS $checkvar) if ($callingScript != 'configemailtemplates.php' && strpos($_REQUEST[$checkvar], '{php}') !== false) die("We're sorry, but you cannot use \"{php}\" in a ticket submission. If you do have a legitimate issue, please press the back button in your browser and then change any instances of \"{php}\" to \"(php)\" so that your ticket may be submitted.  Keep in mind that neither {php} nor (php) will function.");
?> 

Thanks for the updated hook
__________________
Zomex - The best WHMCS templates - Admin-based SETTINGS AREA!
█ A complete WHMCS Setup service including automatic cPanel account creation!
View our clients testimonials about our WHMCS services > WHMCS Testimonials
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
strange tickets (hack attempts?) naushad WHM Complete Solution 9 01-26-2012 05:03 PM
phpMyAdmin hack attempts LittleTiger Security Issues 6 05-22-2011 03:36 PM

All times are GMT -5. The time now is 04:01 AM.