Jump to content

License file validation bypass


abhivinay

Recommended Posts

HI i have following file which look for License file and do encryption and decryption of contents then if matches it forward the DB queries . I want to bypass the license check but keep the functionality as it is . I am not php expert please help

 

 

 

 

<?php 

class FreeSwitch
{
public $request = array( );
public $cdr_variable = array( );
public $auth_arry = array( );
public $cdrlogdata = NULL;
public $flag = 0;
public $fh = NULL;
public $fhquery = NULL;
public $lstr = NULL;
public $xmldata = NULL;
public $return_array = array( );
public $mac_addr = NULL;
public $auth_key = "2513^%edpceswitchv#@)KHGTRESBGFCD(NH^%#@\$%^&*N{}IU?\\|!@gh!12412ast8765%432133df121212x1as21%#&*#&jdh1asa!kdgakjakssjdhshmhsyw092)8@#!@)*9&&%^-+\$#2fyFADhdjshdijs";

public function GetAddress($os_type)
{
switch( strtolower($os_type) )
{
case "linux":
$this->forLinux();
break;
case "solaris":
break;
case "unix":
break;
case "aix":
break;
default:
$this->forWindows();
break;
}
$temp_array = array( );
foreach( $this->return_array as $value )
{
if( preg_match("/[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f]/i", $value, $temp_array) )
{
$this->mac_addr[] = $temp_array[0];
}

}
unset($temp_array);
return $this->mac_addr;
}

public function encrypt($string)
{
$result = "";
for( $i = 0; $i < strlen($string); $i++ )
{
$char = substr($string, $i, 1);
$keychar = substr($this->auth_key, $i % strlen($this->auth_key) - 1, 1);
$char = chr(ord($char) + ord($keychar));
$result .= $char;
}
return base64_encode($result);
}

public function decrypt($string)
{
$result = "";
$string = base64_decode($string);
for( $i = 0; $i < strlen($string); $i++ )
{
$char = substr($string, $i, 1);
$keychar = substr($this->auth_key, $i % strlen($this->auth_key) - 1, 1);
$char = chr(ord($char) - ord($keychar));
$result .= $char;
}
return $result;
}

public function forWindows()
{
@exec("ipconfig /all", $this->return_array);
if( $this->return_array )
{
return $this->return_array;
}

$ipconfig = $_SERVER["WINDIR"] . "system32ipconfig.exe";
if( is_file($ipconfig) )
{
@exec($ipconfig . " /all", $this->return_array);
}
else
{
@exec($_SERVER["WINDIR"] . "systemipconfig.exe /all", $this->return_array);
}

return $this->return_array;
}

public function forLinux()
{
@exec("ifconfig ", $this->return_array);
return $this->return_array;
}

public function manageKey()
{
$this->writelog($this->request["hostmac"]);
if( file_exists("license") )
{
$dump_linfo = file("license");
$response = json_decode($this->decrypt($dump_linfo[0]));
$this->GetAddress(PHP_OS);
foreach( $response as $value )
{
$linfo[] = trim($value);
}
$dt = date("Ymd");
if( $linfo[2] <= $dt )
{
return 0;
}

if( $linfo[3] == "00:00:00:00:00:00" )
{
return 0;
}

if( in_array($linfo[3], $this->mac_addr) )
{
$reg = $this->getRegNum();
if( $reg < $linfo[0] )
{
return 1;
}

return 0;
}

}

return 0;
}

public function dialplanstatus()
{
$this->writelog($this->request["hostmac"]);
if( file_exists("license") )
{
$dump_linfo = file("license");
$response = json_decode($this->decrypt($dump_linfo[0]));
$this->GetAddress(PHP_OS);
foreach( $response as $value )
{
$linfo[] = trim($value);
}
$dt = date("Ymd");
if( $linfo[2] <= $dt )
{
return 0;
}

if( $linfo[3] == "00:00:00:00:00:00" )
{
return 0;
}

if( in_array($linfo[3], $this->mac_addr) )
{
$calls = $this->runningcall();
if( $calls < $linfo[1] )
{
return 1;
}

return 0;
}

}

return 0;
}

public function runningcall()
{
$value = 0;
$query = sprintf("SELECT count( DISTINCT uuid) FROM `live_activecall`");
$this->db->query($query);
$rs = $this->db->resultset();
foreach( $rs[0] as $key => $value )
{
return $value;
}
return $value;
}

public function logfile_open()
{
$this->fh = fopen(LOGFILE, "a");
}

public function logfile_openquery()
{
$this->fhquery = fopen(QUERYLOGFILE, "a");
}

public function writelogquey($log)
{
$log = $log . "\n";
fwrite($this->fhquery, $log);
}

public function writelog($log)
{
date_default_timezone_set("Asia/Kolkata");
$datestr = date("M d H:i:s");
$log = "" . $datestr . " :: " . $log . "\n";
fwrite($this->fh, $log);
}

public function set_requestdata($_REQUEST)
{
$this->xmldata = serialize($_REQUEST);
foreach( $_REQUEST as $key => $value )
{
$this->lstr .= "" . "[" . $key . " : " . urldecode($value) . ]";
$this->request[$key] = mysql_real_escape_string(trim(urldecode($value)));
}
}

public function set_flag()
{
$this->flag = 1;
}

public function reset_flag()
{
$this->flag = 0;
}

public function blank_responce()
{
$this->responce = "<?xml version=\"1.0\"?>\n <document type=\"freeswitch/xml\">\n <section name=\"dialplan\" description=\"Regex/XML Dialplan\">\n <context name=\"default\"> \n <action application=\"info\"/>\n <action application=\"respond\" data=\"503\"/>\n <action application=\"hangup\"/>\n </context>\n </section>\n </document>";
}

public function get_cdrvariable($str)
{
$str = json_decode(json_encode((array) simplexml_load_string($str)), 1);
$this->xmldata = serialize($str);
foreach( $str as $key => $value )
{
if( $key == "variables" && is_array($value) )
{
foreach( $value as $key1 => $value1 )
{
$this->cdr_variable[$key1] = mysql_real_escape_string(trim(urldecode($value1)));
$this->cdrlogdata .= "" . "[" . $key1 . " : " . urldecode($value1) . "]";
$this->cdrlogdata1 .= "" . $key1 . " : " . urldecode($value1) . "\n";
}
}

}
}

public function minute_calculation($rate, $inittine, $credit)
{
$this->timeout = intVal($credit / $rate);
}

public function getRegNum()
{
$value = 0;
$query = sprintf("SELECT count(registrations.reg_user) FROM `registrations`");
$this->db->query($query);
$rs = $this->db->resultset();
foreach( $rs[0] as $key => $value )
{
return $value;
}
return $value;
}

}



?>

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.