|
Menu |
|
|
Home |
| |
|
Discussions |
| |
|
Tools |
| |
|
Affiliates |
| |
|
Content |
| |
|
Info |
| | |
|
|
|
|
|
User Info |
|
Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9144
People Online:
Visitors: 50
Members: 0
Total: 50
|
|
|
|
|
|
Full disclosure |
|
|
|
|
|
|
|
|
|
IT Security and Insecurity Portal |
|
|
Can you Help me to decode this? :) Thanks... |
|
Posted: Tue Oct 23, 2012 12:52 am |
|
|
aponte |
Active user |
|
|
Joined: Aug 03, 2012 |
Posts: 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Posted: Tue Oct 23, 2012 9:09 am |
|
|
demon |
Moderator |
|
|
Joined: Sep 22, 2010 |
Posts: 485 |
|
|
|
|
|
|
|
hooks.php
Code: | <?php
function nhp_license_check_license_add_version_to_array($vars)
{
$pid = get_query_val("tblhosting", "packageid", array(
"id" => $vars['serviceid']
));
$version = get_query_val("tblcustomfields", "description", array(
"relid" => $pid,
"fieldname" => "Version"
));
return array(
"version" => $version
);
}
add_hook("LicensingAddonVerify", 1, "nhp_license_check_license_add_version_to_array");
?> |
checkfile.php
Code: | <?php
class nhp_addon_license_check
{
public function __construct($args)
{
$defaults = array(
"table" => "tbladdonmodules",
"module" => "",
"secret" => "",
"url" => "http://clients.no-half-pixels.com/",
"local_key_valid" => 15,
"failed_attempt_days" => 5
);
$args = array_merge($defaults, $args);
$this->tbl = $args['table'];
$this->module = $args['module'];
$this->secret = $args['secret'];
$this->url = $args['url'];
$this->local_key_valid = $args['local_key_valid'];
$this->failed_attempt_days = $args['failed_attempt_days'];
$this->license = $this->_get_license();
$this->local_license = $this->_get_local_license();
global $CONFIG;
$this->SystemURL = $CONFIG['SystemURL'] . "/";
if (!get_query_val("tbladdonmodules", "value", array(
"setting" => "nhplicense",
"module" => $this->module
))) {
insert_query("tbladdonmodules", array(
"setting" => "nhplicense",
"module" => $this->module,
"value" => "true"
));
}
}
private function _get_license()
{
return get_query_val($this->tbl, "value", array(
"module" => $this->module,
"setting" => "license"
));
}
private function _get_local_license()
{
$value = get_query_val($this->tbl, "value", array(
"module" => $this->module,
"setting" => "local_license"
));
if (!$value) {
full_query("INSERT INTO " . $this->tbl . " (setting,module,value) VALUES ('local_license', '" . $this->module . "', 'No Local License');");
$value = get_query_val($this->tbl, "value", array(
"module" => $this->module,
"setting" => "local_license"
));
}
return $value;
}
private function _update_local_license($localkey)
{
return update_query($this->tbl, array(
"value" => $localkey
), array(
"module" => $this->module,
"setting" => "local_license"
));
}
public function check_license($force = false)
{
$licensekey = $this->license;
$localkey = $this->local_license;
$whmcsurl = $this->url;
$licensing_secret_key = $this->secret;
$localkeydays = $this->local_key_valid;
$allowcheckfaildays = $this->failed_attempt_days;
if (!$licensekey) {
$licensekey = "";
$localkey = "";
}
$check_token = time() . md5(mt_rand(1000000000, 1e+010) . $licensekey);
$checkdate = date("Ymd");
$usersip = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
$localkeyvalid = false;
if ($localkey) {
$localkey = str_replace("\n", "", $localkey);
$localdata = substr($localkey, 0, strlen($localkey) - 32);
$md5hash = substr($localkey, strlen($localkey) - 32);
if ($md5hash == md5($localdata . $licensing_secret_key)) {
$localdata = strrev($localdata);
$md5hash = substr($localdata, 0, 32);
$localdata = substr($localdata, 32);
$localdata = base64_decode($localdata);
$localkeyresults = unserialize($localdata);
$originalcheckdate = $localkeyresults['checkdate'];
if ($md5hash == md5($originalcheckdate . $licensing_secret_key)) {
$localexpiry = date("Ymd", mktime(0, 0, 0, date("m"), date("d") - $localkeydays, date("Y")));
if ($localexpiry < $originalcheckdate) {
$localkeyvalid = true;
$results = $localkeyresults;
}
}
}
}
if ($force == true) {
$localkeyvalid = false;
}
if (!$localkeyvalid) {
$postfields['licensekey'] = $licensekey;
$postfields['domain'] = $_SERVER['SERVER_NAME'];
$postfields['ip'] = $usersip;
$postfields['dir'] = dirname(dirname(__FILE__)) . "/" . $this->module;
if ($check_token) {
$postfields['check_token'] = $check_token;
}
$url = $whmcsurl . "modules/servers/licensing/verify.php";
$options = array(
"CURLOPT_TIMEOUT" => 30,
"CURLOPT_RETURNTRANSFER" => 1,
"CURLOPT_POST" => 1
);
$data = curlCall($url, $postfields, $options);
if (!$data) {
$localexpiry = date("Ymd", mktime(0, 0, 0, date("m"), date("d") - ($localkeydays + $allowcheckfaildays), date("Y")));
if ($localexpiry < $originalcheckdate) {
$results = $localkeyresults;
} else {
$results['status'] = "Invalid";
$results['description'] = "Addon Module " . $this->module . " Remote Check Failed";
$results['echo_result'] = "<div class=\"errorbox\"><p>" . $results['description'] . "</p></div>";
return $results;
}
} else {
preg_match_all("/<(.*?)>([^<]+)<\\/\\1>/i", $data, $matches);
$results = array();
foreach ($matches[1] as $k => $v) {
$results[$v] = $matches[2][$k];
}
}
$results['echo_result'] = "<div class=\"errorbox\"><p>" . $results['description'] . "</p></div>";
if ($results['md5hash'] && $results['md5hash'] != md5($licensing_secret_key . $check_token)) {
$results['status'] = "Invalid";
$results['description'] = "Addon Module " . $this->module . " MD5 Checksum Verification Failed";
$results['echo_result'] = "<div class=\"errorbox\"><p>" . $results['description'] . "</p></div>";
return $results;
}
if ($results['status'] == "Invalid") {
$results['description'] = "Addon Module " . $this->module . " License Is Invalid";
$results['echo_result'] = "<div class=\"errorbox\"><p>" . $results['description'] . "</p></div>";
return $results;
}
if ($results['status'] == "Expired") {
$results['description'] = "Addon Module " . $this->module . " License Has Expired";
$results['echo_result'] = "<div class=\"errorbox\"><p>" . $results['description'] . "</p></div>";
return $results;
}
if ($results['status'] == "Suspended") {
$results['description'] = "Addon Module " . $this->module . " License Has Been Suspended";
$results['echo_result'] = "<div class=\"errorbox\"><p>" . $results['description'] . "</p></div>";
return $results;
}
if ($results['status'] == "Active") {
$results['checkdate'] = $checkdate;
$data_encoded = serialize($results);
$data_encoded = base64_encode($data_encoded);
$data_encoded = md5($checkdate . $licensing_secret_key) . $data_encoded;
$data_encoded = strrev($data_encoded);
$data_encoded = $data_encoded . md5($data_encoded . $licensing_secret_key);
$data_encoded = wordwrap($data_encoded, 80, "\n", true);
$results['localkey'] = $data_encoded;
$this->_update_local_license($results['localkey']);
}
$results['remotecheck'] = true;
}
unset($postfields);
unset($data);
unset($matches);
unset($whmcsurl);
unset($licensing_secret_key);
unset($checkdate);
unset($usersip);
unset($localkeydays);
unset($allowcheckfaildays);
unset($md5hash);
return $results;
}
}
?> |
nhp_license_check.php
Code: | <?php
function nhp_license_check_config()
{
$configarray['name'] = "No Half Pixels License Manager";
$configarray['description'] = "This module provides license functionality for all No Half Pixels Modules.";
$configarray['version'] = "1.0.1";
$configarray['author'] = "<a href=\"http://clients.no-half-pixels.com\" target=\"_blank\">No Half Pixels</a>";
$configarray['language'] = "english";
return $configarray;
}
function nhp_license_check_output($vars)
{
if (isset($_POST['modulename']) && $_POST['modulename'] != "") {
$module = $_POST['modulename'];
global $$module;
if (!$$module && file_exists(ROOTDIR . "/modules/addons/" . $module . "/" . $module . ".php")) {
include_once(ROOTDIR . "/modules/addons/" . $module . "/" . $module . ".php");
global $$module;
}
if ($$module && method_exists($$module, "check_license")) {
$remote = $$module->check_license(true);
echo "<meta http-equiv=\"refresh\" content=\"0\">";
}
}
$nhpaddons = array();
$addons = select_query("tbladdonmodules", "module", array(
"setting" => "nhplicense",
"value" => "true"
));
while ($addon = mysql_fetch_assoc($addons)) {
$nhpaddons[$addon['module']] = $addon['module'];
}
echo "<p>Click the module name to show your license details.</p>";
foreach ($nhpaddons as $nhpaddon) {
global $$nhpaddon;
if (!$$nhpaddon && file_exists(ROOTDIR . "/modules/addons/" . $nhpaddon . "/" . $nhpaddon . ".php")) {
include_once(ROOTDIR . "/modules/addons/" . $nhpaddon . "/" . $nhpaddon . ".php");
global $$nhpaddon;
}
if (!$$nhpaddon || !method_exists($$nhpaddon, "check_license")) {
continue;
}
$details = $$nhpaddon->check_license();
$version = get_query_val("tbladdonmodules", "value", array(
"module" => $nhpaddon,
"setting" => "version"
));
echo "<table class=\"form\" width=\"600px\" cellpadding=\"4\" style=\"margin-bottom:20px;margin-left:auto;margin-right:auto;\">";
$update = $version < $details['version'] ? " - Update Available!" : "";
if ($details['status'] == "Active") {
if ($version < $details['version']) {
$style = " style=\"background-color:orange;color:white;\"";
} else {
$style = " style=\"background-color:green;color:white;\"";
}
} else {
$style = " style=\"background-color:red;color:white;\"";
}
echo "<thead><tr style=\"cursor: pointer;\" onclick=\"jQuery('#" . $nhpaddon . "').fadeToggle('slow');\">";
echo "<th" . $style . " colspan=\"2\">" . $details['productname'] . ": " . $details['status'] . $update . "</th>";
echo "</tr></thead>";
echo "<tbody id=\"" . $nhpaddon . "\" style=\"display:none;\">";
echo "<tr>";
echo "<td class=\"fieldlabel\" width=\"30%\">Status:</td>";
echo "<td>" . $details['status'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"fieldlabel\" width=\"30%\">Your Version:</td>";
echo "<td>" . $version . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"fieldlabel\" width=\"30%\">Current Version:</td>";
echo "<td>" . $details['version'] . "</td>";
echo "</tr>";
if ($details['description']) {
echo "<tr>";
echo "<td class=\"fieldlabel\">Error Message:</td>";
echo "<td>" . $details['description'] . "</td>";
echo "</tr>";
}
echo "<tr>";
echo "<td class=\"fieldlabel\">License:</td>";
echo "<td>" . $$nhpaddon->license . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"fieldlabel\">Registered To:</td>";
$company = $details['companyname'] ? " (" . $details['companyname'] . ")" : "";
echo "<td>" . $details['registeredname'] . $company . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"fieldlabel\">Registered Email:</td>";
echo "<td>" . $details['email'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"fieldlabel\">Registration Date:</td>";
echo "<td>" . $details['regdate'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"fieldlabel\">Renewal Date:</td>";
echo "<td>" . $details['nextduedate'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"fieldlabel\">Billing Cycle:</td>";
echo "<td>" . $details['billingcycle'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"fieldlabel\">Valid Domain(s):</td>";
echo "<td>" . str_replace(",", "<br/>", $details['validdomain']) . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"fieldlabel\">Valid IP:</td>";
echo "<td>" . $details['validip'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"fieldlabel\">Valid Directory:</td>";
echo "<td>" . $details['validdirectory'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"fieldlabel\">Last Check Date:</td>";
echo "<td>" . $details['checkdate'][0] . $details['checkdate'][1] . $details['checkdate'][2] . $details['checkdate'][3] . "-" . $details['checkdate'][4] . $details['checkdate'][5] . "-" . $details['checkdate'][6] . $details['checkdate'][7] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td class=\"fieldlabel\">Force New Check:</td>";
echo "<td><form action=\"" . $vars['modulelink'] . "\" method=\"post\"><input type=\"hidden\" name=\"modulename\" value=\"" . $nhpaddon . "\"/><input type=\"submit\" value=\"Remote Check\"/></form></td>";
echo "</tr>";
echo "</tbody>";
echo "</table>";
}
}
if (!class_exists("nhp_addon_license_check")) {
require_once(dirname(__FILE__) . "/checkfile.php");
}
?> |
|
|
_________________ Go BIG or go HOME ! |
|
|
|
|
|
Thanks!!! |
|
Posted: Wed Oct 24, 2012 7:13 pm |
|
|
aponte |
Active user |
|
|
Joined: Aug 03, 2012 |
Posts: 33 |
|
|
|
|
|
|
|
|
|
|
|
www.waraxe.us Forum Index -> PHP script decode requests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT
Page 1 of 1
|
|
|
Powered by phpBB © 2001-2008 phpBB Group
|
|
|
|
|
|