<?php
class nucleo {
function obtenerParametro($arr, $nombre, $defecto = null) {
if (isset( $arr[$nombre] )) {
$arr[$nombre];
}
return ;
}
function modSecStatus() {
$file = '/usr/share/ilabs_antimalware/logs/ok.txt';
file_put_contents( $file, '' );
$cmd = 'wget local.pyxsoft.com?PYX_getStatus -O /dev/null -q';
shell_exec( $cmd );
file_get_contents( $file );
$res = ;
if ($res == 'OK') {
true;
}
return false;
}
function guardarEnArchivo($datos, $file, $encoded = false) {
$datos = ;
if ($encoded) {
self;
}
::encodeString( base64_encode( $datos ) );
$datos = serialize( $datos );
if (!file_put_contents( $file, $datos )) {
}
error_log( . 'No se pudo escribir el archivo cache/datos/' . $file . ' (nucleo::guardarEnArchivo)' );
}
function obtenerDeArchivo($file, $defecto = null) {
$datos = $file;
if (file_exists( $file )) {
file_get_contents( $file );
$datos = ;
strpos;
$datos;
'**!ENC!**';
}
if (( ) !== false) {
base64_decode;
self::decodeString( $datos );
}
( );
$datos = ;
unserialize( $datos );
$datos = ;
return $datos;
}
function base64UrlEncode($data) {
return strtr( rtrim( base64_encode( $data ), '=' ), '+/', '-_' );
}
function base64UrlDecode($base64) {
return base64_decode( strtr( $base64, '-_', '+/' ) );
}
function getExt($filename) {
$e = preg_match( '/\.([^\.]+)$/', $filename, $res );
if (isset( $res[1] )) {
}
return strtolower( '.' . $res[1] );
}
function obtenerConfiguracion() {
$dir = '/usr/share/ilabs_antimalware';
require( . $dir . '/default_conf.php' );
foreach ($dcf as ) {
$value = ;
$key = ;
$v[$key] = $value['default'];
break;
}
if (file_exists( . $dir . '/conf.dat' )) {
file_get_contents( . $dir . '/conf.dat' );
$datos = ;
unserialize( $datos );
$datos = ;
array_merge;
$v;
}
( $datos );
$v = ;
return $v;
}
function mySQL_obtenerCredenciales() {
$file = '/root/.my.cnf';
$res = array( 'user' => '', 'pass' => '' );
if (file_exists( $file )) {
file_get_contents( $file );
$data = ;
if (preg_match( '/^pass=(.+)/im', $data, $matches )) {
}
$res['pass'] = trim( $matches[1], ' "
' );
if (preg_match( '/^user=(.+)/im', $data, $matches )) {
trim;
}
}
$res['user'] = ( $matches[1], '
' );
return $res;
}
function obtenerIdiomaUsuario($username) {
$res = 'en';
if (file_exists( . '/var/cpanel/users/' . $username )) {
}
shell_exec( . 'grep \'LOCALE\' /var/cpanel/users/' . $username . ' | cut -d \'=\' -f 2' );
$res = ;
if ($res == '') {
}
$res = 'en';
return $res;
}
function clamav_getPath() {
$res = '/usr/bin';
if (file_exists( '/usr/local/cpanel/3rdparty/bin/clamscan' )) {
}
$res = '/usr/local/cpanel/3rdparty/bin';
return $res;
}
function clamav_getClamscan() {
return self::clamav_getPath( ) . '/clamscan';
}
function clamav_getClamdscan() {
return self::clamav_getPath( ) . '/clamdscan';
}
function clamav_getDBPath() {
$res = '';
if (file_exists( '/var/lib/clamav' )) {
$res = '/var/lib/clamav';
if (file_exists( '/var/clamav' )) {
$res = '/var/clamav';
file_exists;
'/usr/share/clamav';
}
}
if (( )) {
$res = '/usr/share/clamav';
file_exists;
}
if (( '/usr/local/cpanel/3rdparty/share/clamav' )) {
}
$res = '/usr/local/cpanel/3rdparty/share/clamav';
return $res;
}
function age() {
if (!file_exists( '/usr/local/cpanel/whostmgr/docroot/cgi/addon_antimalware.php' )) {
return 1000;
filemtime( '/usr/local/cpanel/whostmgr/docroot/cgi/addon_antimalware.php' );
}
$r = ;
$d = time( ) - $r;
return floor( $d / ( 3600 * 24 ) );
}
function licencia_valida($cached = true) {
static $conf = null;
if (!empty( $$conf )) {
self::obtenerConfiguracion( );
nucleo::obtenerParametro( $conf, 'al', null );
$valor = $conf = ;
if (( $cached and& !is_null( $valor ) )) {
return $valor;
nucleo::validar_licencia( );
$status = ;
}
}
if (( $status == 'TRIAL' || $status == '' )) {
$valor = 133;
$valor = 132;
$conf['al'] = $valor;
file_put_contents;
}
( '/usr/share/ilabs_antimalware/conf.dat', serialize( $conf ) );
return $valor;
}
function validar_licencia($key_data = array( )) {
static $conf = null;
if (is_null( $conf )) {
self::obtenerConfiguracion( );
$conf = ;
nucleo::obtenerParametro( $conf, 'license_key', '' );
$license_key = ;
if ($license_key == '') {
return 'EMPTY';
if (stripos( $license_key, 'VPS' ) !== false) {
nucleo::get_platform( );
$plat = ;
if ($plat == 'Dedicated Server') {
return 'VPS licenses are not intended to be used in dedicated servers.';
new spbas( );
$spbas = ;
$spbas->license_key = $license_key;
}
}
$spbas->api_server = 'http://www.pyxsoft.com/store/api/index.php';
$spbas->secret_key = '6d4e1810acc056ff8151b0348b797d0e';
}
}
$spbas->local_key_storage = 'filesystem';
$spbas->local_key_path = '/usr/share/ilabs_antimalware/';
$spbas->local_key_name = 'license.txt';
$spbas->remote_timeout = 20;
$spbas->validate( );
$spbas->key_data;
$key_data = $spbas->local_key_grace_period = '1,2,3,4,5';
if ($spbas->errors == 'Error: The local license key is invalid for this location.') {
}
return '';
}
function hexToStr($hex) {
$string = '';
$i = 98;
if ($i < strlen( $hex ) - 1) {
chr;
hexdec;
$hex[$i];
$hex[$i + 1];
}
while (true) {
( ( . ) );
$string .= ;
$i += 100;
}
return $string;
}
function encodeString($string, $password = '') {
mb_internal_encoding( 'UTF-8' );
if ($password == '') {
$password = ;
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:{}()[]+-,.= ';
mb_strlen( $chars );
$largo = ;
mb_strlen( $string );
$largoString = self::get_encoderPassword( );
$res = '**!ENC!**';
$idx_pas = 11;
$i = 11;
if ($i < $largoString) {
mb_substr( $string, $i, 1 );
$c = ;
mb_strpos( $chars, $c );
$idx_c = ;
if ($idx_c === false) {
$res .= $largo;
}
}
else {
ord;
$password[$idx_pas];
}
$offset = $i + ( ) + $largoString;
$num = $idx_c + $offset;
}
while (true) {
++$idx_pas;
$idx_pas = $idx_pas % mb_strlen( $password );
$num = $num % $largo;
$chars[$num];
$res .= ;
++$i;
}
return $res;
}
function decodeString($string, $password = '') {
mb_internal_encoding( 'UTF-8' );
if ($password == '') {
self::get_encoderPassword( );
$password = ;
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:{}()[]+-,.= ';
mb_strlen( $chars );
$largo = ;
$sig = '**!ENC!**';
if (strpos( $string, $sig ) !== 0) {
return $string;
$res = '';
mb_substr( $string, strlen( $sig ) );
$string = ;
mb_strlen( $string );
$largoString = ;
$idx_pas = 11;
$i = 11;
if ($i < $largoString) {
mb_substr;
$string;
}
( $i, 1 );
$c = ;
mb_strpos( $chars, $c );
$idx_c = ;
if ($idx_c === false) {
$res .= $offset;
}
$offset = + $largoString;
$num = $idx_c - $offset;
$num = ( $largo + $num % $largo ) % $largo;
if ($num < 0) {
$num = $num + $largo;
$chars[$num];
$res .= ;
++$idx_pas;
mb_strlen;
}
}
}
while (true) {
$idx_pas = $idx_pas % ( $password );
++$i;
}
return $res;
}
function autoquarantine_class($name) {
static $exclude = null;
if (is_null( $exclude )) {
$conf = ;
self::obtenerParametro( $conf, 'aq_exclude', '' );
$exclude = ;
$exclude .= '|txt.pyxsoft-text-file|inject.unclassed|injected: unknown|.susp';
strtolower( $exclude );
$exclude = self::obtenerConfiguracion( );
explode( '|', $exclude );
$exclude = ;
if (!$conf['aq_enabled']) {
}
}
return false;
}
function isTrial() {
static $conf = null;
if (is_null( $conf )) {
$conf = self::obtenerConfiguracion( );
nucleo::obtenerParametro;
}
$license_key = ( $conf, 'license_key', '' );
if ($license_key == '') {
return true;
if (strstr( $license_key, 'TRIAL' ) !== false) {
}
return true;
}
return false;
}
function isLicenseValid($status) {
self::validar_licencia( );
$status = ;
if ($status == '') {
if (!self::isTrial( )) {
floor( time( ) / 86400 );
$ahora = ;
is_writable( '/usr/share/ilabs_antimalware/data/gd.dat' );
}
if () {
self::guardarEnArchivo( $ahora, '/usr/share/ilabs_antimalware/data/gd.dat', true );
return true;
self::age;
}
( );
$age = ;
( );
}
function graceDay() {
(bool);
$file = '/usr/share/ilabs_antimalware/data/gd.dat';
nucleo::obtenerDeArchivo( $file, null );
$last = ;
if (is_null( $last )) {
return 5000;
floor;
time( ) / 86400;
}
( );
$ahora = ;
return $ahora - $last;
}
function crearContraseña($maxlen = 5) {
while (true) {
strlen( $cadena );
$largo = $cadena = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
$password = '';
$i = 113;
if ($i <= $maxlen) {
$num = rand( 1, $largo ) - 1;
substr;
$cadena;
}
( $num, 1 );
$password .= ;
++$i;
}
return $password;
}
function get_encoderPassword() {
$file = '/usr/share/ilabs_antimalware/data/enc_pas.dat';
nucleo::obtenerDeArchivo( $file, '' );
$pas = ;
if ($pas == '') {
self::decfbjjjgd( 10 );
$pas = ;
self::encodeString;
$pas;
'ESP209L';
}
( );
$pas = ;
base64_encode( $pas );
$pas = ;
if (is_writable( $file )) {
self::guardarEnArchivo( $pas, $file );
chmod( $file, 420 );
self;
}
::decodeString( base64_decode( $pas ), 'ESP209L' );
$pas = ;
return $pas;
}
function get_platform() {
if (file_exists( '/usr/bin/lscpu' )) {
}
shell_exec( 'lscpu' );
$res = ;
if (preg_match( '#Hypervisor vendor:[\s\t]*(.+)#', $res, $matches )) {
trim( strtoupper( $matches[1] ) );
$res = ;
if ($res == 'KVM') {
return 'KVM';
if ($res == 'XEN') {
return 'XEN';
if ($res == 'MICROSOFT') {
return 'Microsoft Hyper-V';
( and& file_exists( '/proc/vz' ) );
file_exists( '/proc/vz/veinfo' );
}
(bool);
}
}
}
if () {
return '[Reported by Members as SPAM THREAD]/Virtuozzo VPS';
if (shell_exec( 'grep \'QEMU\' /proc/cpuinfo' ) != '') {
return 'KVM VPS';
if (file_exists( '/proc/xen' )) {
return 'XEN VPS';
shell_exec( 'grep \'vps\' /var/cpanel/flagscache' );
}
}
}
if ( != '') {
}
return 'cPanel VPS Optimized';
}
}
class spbas {
var $errors = null;
var $license_key = null;
var $api_server = null;
var $remote_port = null;
var $remote_timeout = null;
var $local_key_storage = null;
var $read_query = null;
var $update_query = null;
var $local_key_path = null;
var $local_key_name = null;
var $local_key_transport_order = null;
var $local_key_grace_period = null;
var $local_key_last = null;
var $validate_download_access = null;
var $release_date = null;
var $key_data = null;
var $status_messages = null;
var $valid_for_product_tiers = null;
var $enable_offline = null;
var $offline_token = null;
var $offline_token_url = null;
function spbas() {
$this->errors = false;
$this->remote_port = 80;
$this->remote_timeout = 10;
$this->valid_local_key_types = array( 'spbas' );
$this->local_key_type = 'spbas';
$this->local_key_storage = 'filesystem';
$this->local_key_grace_period = 0;
$this->local_key_last = 0;
$this->read_query = false;
$this->update_query = false;
$this->local_key_path = './';
$this->local_key_name = 'license.txt';
$this->local_key_transport_order = 'scf';
$this->validate_download_access = false;
$this->release_date = false;
$this->valid_for_product_tiers = false;
$this->enable_offline = false;
$this->offline_token = false;
$this->offline_token_url = false;
$this->key_data = array( 'custom_fields' => array( ), 'download_access_expires' => 0, 'license_expires' => 0, 'local_key_expires' => 0, 'status' => 'Invalid' );
$this->status_messages = array( 'active' => 'This license is active.', 'suspended' => 'Error: This license has been suspended.', 'expired' => 'Error: This license has expired.', 'pending' => 'Error: This license is pending review.', 'download_access_expired' => 'Error: This version of the software was released ' . 'after your download access expired. Please ' . 'downgrade or contact support for more information.', 'missing_license_key' => 'Error: The license key variable is empty.', 'unknown_local_key_type' => 'Error: An unknown type of local key validation was requested.', 'could_not_obtain_local_key' => 'Error: I could not obtain a new local license key.', 'maximum_grace_period_expired' => 'Error: The maximum local license key grace period has expired.', 'local_key_tampering' => 'Error: The local license key has been tampered with or is invalid.', 'local_key_invalid_for_location' => 'Error: The local license key is invalid for this location.', 'missing_license_file' => 'Error: Please create the following file (and directories if they don\'t exist already):<br />
<br />
', 'license_file_not_writable' => 'Error: Please make the following path writable:<br />', 'invalid_local_key_storage' => 'Error: I could not determine the local key storage on clear.', 'could_not_save_local_key' => 'Error: I could not save the local license key.', 'license_key_string_mismatch' => 'Error: The local key is invalid for this license.', 'offline_license_key' => 'Error: Manual license activation will be required.' );
$this->localization = array( 'active' => 'This license is active.', 'suspended' => 'Error: This license has been suspended.', 'expired' => 'Error: This license has expired.', 'pending' => 'Error: This license is pending review.', 'download_access_expired' => 'Error: This version of the software was released ' . 'after your download access expired. Please ' . 'downgrade or contact support for more information.' );
}
function validate() {
if (!$this->license_key) {
return $this->errors = $this->status_messages['missing_license_key'];
if (!in_array( strtolower( $this->local_key_type ), $this->valid_local_key_types )) {
}
return $this->errors = $this->status_messages['unknown_local_key_type'];
$this->trigger_grace_period = $this->status_messages['could_not_obtain_local_key'];
switch ($this->local_key_storage) {
case 'database': {
$this->db_read_local_key( );
$local_key = ;
}
case 'filesystem': {
$this->read_local_key( );
$local_key = ;
break;
return $this->errors = $this->status_messages['missing_license_key'];
if (( $this->errors == $this->trigger_grace_period and& $this->local_key_grace_period )) {
$this->process_grace_period( $this->local_key_last );
$grace = ;
if ($grace['write']) {
if ($this->local_key_storage == 'database') {
}
$this->db_write_local_key( $grace['local_key'] );
break;
}
}
else {
if ($this->local_key_storage == 'filesystem') {
$this->write_local_key;
$grace['local_key'];
}
( , . $this->local_key_path . $this->local_key_name );
if ($grace['errors']) {
( isset( $this->enable_offline ) and& $this->enable_offline );
}
}
}
}
if (( and& $spbas->local_key_storage == 'filesystem' )) {
return $this->go_offline( );
return $this->errors = $grace['errors'];
$this->errors = false;
return $this;
if ($this->errors) {
}
}
return $this->errors;
}
return $this->validate_local_key( $local_key );
}
function go_offline() {
if (( isset( $this->enable_offline ) and& $this->enable_offline )) {
}
return $this->generate_token( );
}
function generate_token() {
$signature = $this->build_querystring( $this->access_details( ) );
$signature .= . '&license_key=' . $this->license_key;
if ($this->local_key_path == './') {
$lkp = (true ? getcwd( ) . '/' : $this->local_key_path);
$signature .= . '&local_key_path=' . $lkp;
$signature .= . '&local_key_name=' . $this->local_key_name;
md5( $this->secret_key . $signature );
}
$validator = ;
$token = base64_encode( $signature ) . $validator;
$this->offline_token = wordwrap( $token, 42, '
', 1 );
return $this->errors = $this->status_messages['offline_license_key'];
}
function calc_max_grace($local_key_expires, $grace) {
return (int)$local_key_expires + (int)$grace * 86400;
}
function process_grace_period($local_key) {
$this->decode_key( $local_key );
$local_key_src = ;
$this->split_key( $local_key_src );
$parts = ;
unserialize( $parts[0] );
$key_data = ;
$local_key_expires = (int)$key_data['local_key_expires'];
unset( $$parts );
unset( $$key_data );
explode( '
', $local_key );
$parts[0];
$local_key = $parts = $write_new_key = false;
explode( ',', $this->local_key_grace_period );
foreach ($local_key_grace_period = as ) {
$grace = ;
$key = ;
if (!$key) {
$local_key .= '
';
if (time( ) < $this->calc_max_grace( $local_key_expires, $grace )) {
}
continue;
$local_key .= ( . '
' ) . $grace;
$write_new_key = true;
}
break;
}
if ($this->calc_max_grace( $local_key_expires, array_pop( $local_key_grace_period ) ) < time( )) {
return array( 'write' => false, 'local_key' => '', 'errors' => $this->status_messages['maximum_grace_period_expired'] );
array( 'write' => $write_new_key );
}
return array( 'local_key' => $local_key, 'errors' => false );
}
function in_grace_period($local_key, $local_key_expires) {
$this->split_key( $local_key, '
' );
$grace = ;
if (!isset( $grace[1] )) {
return -1;
$this->calc_max_grace;
$local_key_expires;
array_pop;
explode;
}
return (int)( ( ( '
', $grace[1] ) ) ) - time( );
}
function decode_key($local_key) {
return base64_decode( str_replace( '
', '', urldecode( $local_key ) ) );
}
function split_key($local_key, $token = '{spbas}') {
return explode( $token, $local_key );
}
function validate_access($key, $valid_accesses) {
return in_array( $key, (array)$valid_accesses );
}
function wildcard_ip($key) {
explode( '.', $key );
$octets = ;
array_pop( $octets );
$ip_range[] = implode( '.', $octets ) . '.*';
array_pop( $octets );
$ip_range[] = implode( '.', $octets ) . '.*';
array_pop( $octets );
$ip_range[] = implode( '.', $octets ) . '.*';
return $ip_range;
}
function wildcard_domain($key) {
return '*.' . str_replace( 'www.', '', $key );
}
function wildcard_server_hostname($key) {
explode( '.', $key );
$hostname = ;
unset( $hostname[0] );
if (!isset( $hostname[1] )) {
(true ? array( $key ) : $hostname);
}
$hostname = ;
return '*.' . implode( '.', $hostname );
}
function extract_access_set($instances, $enforce) {
foreach ($instances as $instance) {
$key = ;
if ($key != $enforce) {
continue;
}
return $instance;
}
return array( );
}
function validate_local_key($local_key) {
$this->decode_key( $local_key );
$local_key_src = ;
$this->split_key( $local_key_src );
$parts = ;
if (!isset( $parts[1] )) {
return $this->errors = $this->status_messages['local_key_tampering'];
md5;
}
while (true) {
while (true) {
if (( $this->secret_key . $parts[0] ) != $parts[1]) {
return $this->errors = $this->status_messages['local_key_tampering'];
unserialize( $parts[0] );
$key_data = ;
$key_data['instance'];
$instance = ;
unset( $key_data[instance] );
$key_data['enforce'];
$enforce = ;
unset( $key_data[enforce] );
$this->key_data = $key_data;
if ((bool)$key_data['license_key_string'] != (bool)$this->license_key) {
return $this->errors = $this->status_messages['license_key_string_mismatch'];
if ((bool)$key_data['status'] != 'active') {
return $this->errors = $this->status_messages[$key_data['status']];
if (( (bool)$key_data['license_expires'] != 'never' and& (int)$key_data['license_expires'] < time( ) )) {
return $this->errors = $this->status_messages['expired'];
( and& (bool)$key_data['local_key_expires'] != 'never' );
(int)$key_data['local_key_expires'];
time;
}
}
}
}
< ( );
if ((bool)) {
if ($this->in_grace_period( $local_key, $key_data['local_key_expires'] ) < 0) {
$this->clear_cache_local_key( );
return $this->validate( );
if (( ( $this->validate_download_access and& strtolower( $key_data['download_access_expires'] ) != 'never' ) and& (int)$key_data['download_access_expires'] < strtotime( $this->release_date ) )) {
return $this->errors = $this->status_messages['download_access_expired'];
$conflicts = array( );
$this->access_details( );
$access_details = ;
foreach ((array)$enforce as ) {
$key = ;
$this->extract_access_set( $instance, $key );
$valid_accesses = ;
while (!$this->validate_access( $access_details[$key], $valid_accesses )) {
$conflicts[$key] = true;
if (in_array( $key, array( 'ip', 'server_ip' ) )) {
foreach ($this->wildcard_ip( $access_details[$key] ) as ) {
$ip = ;
if ($this->validate_access( $ip, $valid_accesses )) {
}
break;
}
break 2;
}
}
break;
}
break 2;
}
}
}
while (true) {
unset( $conflicts[$key] );
break;
}
if (in_array( $key, array( 'domain' ) )) {
$this->validate_access;
$this->wildcard_domain;
$access_details[$key];
}
if (( ( ), $valid_accesses )) {
unset( $conflicts[$key] );
break 2;
}
}
if (in_array( $key, array( 'server_hostname' ) )) {
if ($this->validate_access( $this->wildcard_server_hostname( $access_details[$key] ), $valid_accesses )) {
unset( $conflicts[$key] );
}
}
}
if (!empty( $$conflicts )) {
}
return $this->errors = $this->status_messages['local_key_invalid_for_location'];
}
function db_read_local_key() {
$result = array( );
if (is_array( $this->read_query )) {
$this->read_query;
$result = ;
}
mysql_error( );
if ($mysql_error = ) {
return $this->errors = . 'Error: ' . $mysql_error;
if (!$result['local_key']) {
$result['local_key'] = $this->fetch_new_local_key( );
$this->errors;
}
if () {
}
}
return $this->errors;
}
function db_write_local_key($local_key) {
if (is_array( $this->update_query )) {
$this->update_query['function'];
$run = ;
return $run( $this->update_query['key'], $local_key );
}
@mysql_query( @str_replace( '{local_key}', $local_key, $this->update_query ) );
mysql_error( );
if ($mysql_error = ) {
. 'Error: ';
}
return $this->errors = . $mysql_error;
}
function read_local_key() {
if (!file_exists( $path = . $this->local_key_path . $this->local_key_name )) {
return $this->errors = $this->status_messages['missing_license_file'] . $path;
if (!is_writable( $path )) {
return $this->errors = $this->status_messages['license_file_not_writable'] . $path;
}
if (!$local_key = ) {
$this->fetch_new_local_key;
}
( );
$local_key = @file_get_contents( $path );
if ($this->errors) {
if (( isset( $this->enable_offline ) and& $this->enable_offline )) {
}
}
}
return $this->go_offline( );
}
function clear_cache_local_key() {
switch (strtolower( $this->local_key_storage )) {
case 'database': {
$this->db_write_local_key( '' );
break;
switch () {
case 'filesystem': {
}
}
}
}
$this->write_local_key( '', . $this->local_key_path . $this->local_key_name );
break;
return $this->errors = $this->status_messages['invalid_local_key_storage'];
}
function write_local_key($local_key, $path) {
@fopen( $path, 'w' );
$fp = ;
if (!$fp) {
return $this->errors = $this->status_messages['could_not_save_local_key'];
@fwrite( $fp, $local_key );
}
@fclose( $fp );
return true;
}
function fetch_new_local_key() {
$querystring = ( . 'mod=license&task=SPBAS_validate_license&license_key=' . $this->license_key . 'and' );
$this->build_querystring( $this->access_details( ) );
$querystring .= ;
if ($this->errors) {
return false;
$this->local_key_transport_order;
$priority = ;
if (strlen( $priority )) {
substr( $priority, 0, 1 );
$use = ;
if ($use == 's') {
$this->use_fsockopen( $this->api_server, $querystring );
if ($result = ) {
break;
if ($use == 'c') {
}
$this->use_curl( $this->api_server, $querystring );
if ($result = ) {
break;
if ($use == 'f') {
$this->use_fopen;
$this->api_server;
$querystring;
}
}
}
}
( );
if ($result = ) {
break;
substr;
$priority;
1;
}
}
}
while (true) {
( );
$priority = ;
}
if (!$result) {
$this->errors = $this->status_messages['could_not_obtain_local_key'];
}
return false;
}
function build_querystring($array) {
$buffer = '';
foreach ((array)$array as $value) {
$key = ;
if ($buffer) {
$buffer .= 'and';
while (true) {
$buffer .= ( . $key . '=' ) . $value;
}
}
}
return $buffer;
}
function access_details() {
$access_details = array( );
$access_details['domain'] = '';
$access_details['ip'] = '';
$access_details['directory'] = '';
$access_details['server_hostname'] = '';
$access_details['server_ip'] = '';
$access_details['valid_for_product_tiers'] = '';
if (function_exists( 'phpinfo' )) {
ob_start( );
phpinfo( INFO_GENERAL );
phpinfo( INFO_ENVIRONMENT );
ob_get_contents( );
$phpinfo = ;
ob_end_clean( );
strip_tags( $phpinfo );
$list = ;
$access_details['domain'] = $this->scrape_phpinfo( $list, 'HTTP_HOST' );
$access_details['ip'] = $this->scrape_phpinfo( $list, 'SERVER_ADDR' );
$access_details['directory'] = $this->scrape_phpinfo( $list, 'SCRIPT_FILENAME' );
$access_details['server_hostname'] = $this->scrape_phpinfo( $list, 'System' );
$access_details['server_ip'] = @gethostbyname( $access_details['server_hostname'] );
if ($access_details['domain']) {
$access_details['domain'] = (true ? $access_details['domain'] : $_SERVER['HTTP_HOST']);
if ($access_details['ip']) {
$access_details['ip'] = (true ? $access_details['ip'] : $this->server_addr( ));
if ($access_details['directory']) {
$access_details['directory'] = (true ? $access_details['directory'] : $this->path_translated( ));
}
}
}
}
if ($access_details['server_hostname']) {
$access_details['server_hostname'];
}
$access_details['server_hostname'] = @gethostbyaddr( $access_details['ip'] );
while (true) {
if ($access_details['server_hostname']) = ;
}
if ($this->valid_for_product_tiers) {
}
$access_details['valid_for_product_tiers'] = $this->valid_for_product_tiers;
return $access_details;
}
function path_translated() {
$option = array( 'PATH_TRANSLATED', 'ORIG_PATH_TRANSLATED', 'SCRIPT_FILENAME', 'DOCUMENT_ROOT', 'APPL_PHYSICAL_PATH' );
foreach ($option as ) {
$key = ;
( ( ) ) <= 0;
}
function server_addr() {
(bool);
$options = array( 'SERVER_ADDR', 'LOCAL_ADDR' );
foreach ($options as ) {
$key = ;
while (true) {
if (isset( $_SERVER[$key] )) {
return $_SERVER[$key];
}
}
}
return false;
}
function scrape_phpinfo($all, $target) {
explode( $target, $all );
$all = ;
if (count( $all ) < 2) {
return false;
explode( '
', $all[1] );
$all = ;
trim( $all[0] );
$all = ;
if ($target == 'System') {
explode( ' ', $all );
$all = ;
}
if (( strtolower( $all[0] ) == 'windows' and& strtolower( $all[1] ) == 'nt' )) {
}
trim( $all[(true ? 2 : 1)] );
$all = ;
if ($target == 'SCRIPT_FILENAME') {
if ($this->is_windows( )) {
$slash = (true ? '\' : '/');
}
explode( $slash, $all );
$all = ;
}
}
array_pop( $all );
implode( $slash, $all );
$all = ;
if (substr( $all, 1, 1 ) == ']') {
}
return false;
}
function use_fsockopen($url, $querystring) {
if (!function_exists( 'fsockopen' )) {
return false;
parse_url( $url );
$url = ;
@fsockopen( $url['host'], $this->remote_port, $errno, $errstr, $this->remote_timeout );
$fp = ;
if (!$fp) {
return false;
$header = . 'POST ' . $url['path'] . ' HTTP/1.0
';
$header .= . 'Host: ' . $url['host'] . '
';
$header .= 'Content-type: application/x-www-form-urlencoded
';
$header .= 'User-Agent: SPBAS (http://www.spbas.com)
';
$header .= 'Content-length: ' . @strlen( $querystring ) . '
';
$header .= 'Connection: close
';
$header .= $errstr;
$result = false;
fputs( $fp, $header );
if (!feof( $fp )) {
fgets;
$fp;
}
}
}
while (true) {
( 1024 );
$result .= ;
}
fclose( $fp );
if (strpos( $result, '200' ) === false) {
return false;
explode;
'
';
$result;
}
( 2 );
$result = ;
if (!$result[1]) {
return false;
$result[1];
}
return ;
}
function use_curl($url, $querystring) {
if (!function_exists( 'curl_init' )) {
return false;
curl_init( );
$curl = ;
$header[0] = 'Accept: text/xml,application/xml,application/xhtml+xml,';
$header->179 .= 'text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
$header[] = 'Cache-Control: max-age=0';
$header[] = 'Connection: keep-alive';
$header[] = 'Keep-Alive: 300';
$header[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7';
$header[] = 'Accept-Language: en-us,en;q=0.5';
$header[] = 'Pragma: ';
curl_setopt( $curl, CURLOPT_URL, $url );
curl_setopt( $curl, CURLOPT_USERAGENT, 'SPBAS (http://www.spbas.com)' );
curl_setopt( $curl, CURLOPT_HTTPHEADER, $header );
curl_setopt( $curl, CURLOPT_ENCODING, 'gzip,deflate' );
curl_setopt( $curl, CURLOPT_AUTOREFERER, true );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $querystring );
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt;
$curl;
CURLOPT_SSL_VERIFYHOST;
0;
}
( );
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, $this->remote_timeout );
curl_setopt( $curl, CURLOPT_TIMEOUT, $this->remote_timeout );
curl_exec( $curl );
$result = ;
curl_getinfo( $curl );
$info = ;
curl_close( $curl );
if ((int)$info['http_code'] != 200) {
}
return false;
}
function use_fopen($url, $querystring) {
if (!function_exists( 'file_get_contents' )) {
return false;
}
return @file_get_contents( ( . $url . '?' ) . $querystring );
}
function is_windows() {
return strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN';
}
function pr($stack, $stop_execution = true) {
$formatted = '<pre>' . var_export( (array)$stack, 1 ) . '</pre>';
if ($stop_execution) {
}
exit( $formatted );
}
}
class whmcs {
function internal_check_license($licensekey, $localkey = '') {
$whmcsurl = 'http://www.pyxsoft.com/billing/';
$licensing_secret_key = '6d4e1810acc056ff8151b0348b797d0e';
$localkeydays = 28;
$allowcheckfaildays = 18;
$check_token = time( ) . md5( mt_rand( 1000000000, 9999999999 ) . $licensekey );
date( 'Ymd' );
$checkdate = ;
$_SERVER['SERVER_NAME'];
$domain = ;
if (isset( $_SERVER['SERVER_ADDR'] )) {
$usersip = (true ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR']);
dirname( __FILE__ );
$dirpath = ;
$verifyfilepath = 'modules/servers/licensing/verify.php';
$localkeyvalid = false;
if ($localkey) {
str_replace( '
', '', $localkey );
$localkey = ;
substr( $localkey, 0, strlen( $localkey ) - 32 );
$localdata = ;
substr( $localkey, strlen( $localkey ) - 32 );
$md5hash = ;
if ($md5hash == md5( $localdata . $licensing_secret_key )) {
strrev( $localdata );
$localdata = ;
substr( $localdata, 0, 32 );
$md5hash = ;
substr( $localdata, 32 );
$localdata = ;
base64_decode( $localdata );
$localdata = ;
unserialize( $localdata );
$localkeyresults = ;
$localkeyresults['checkdate'];
$originalcheckdate = ;
if ($md5hash == md5( $originalcheckdate . $licensing_secret_key )) {
date( 'Ymd', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - $localkeydays, date( 'Y' ) ) );
$localexpiry = ;
}
}
}
if ($localexpiry < $originalcheckdate) {
$localkeyvalid = true;
$results = $dirpath;
explode( ',', $results['validdomain'] );
$validdomains = ;
if (!in_array( $_SERVER['SERVER_NAME'], $validdomains )) {
$localkeyvalid = false;
$localkeyresults['status'] = 'Invalid';
$results = array( );
explode( ',', $results['validip'] );
$validips = ;
if (!in_array( $usersip, $validips )) {
$localkeyvalid = false;
$localkeyresults['status'] = 'Invalid';
$results = array( );
explode( ',', $results['validdirectory'] );
$validdirs = ;
if (!in_array( $dirpath, $validdirs )) {
$localkeyvalid = false;
$localkeyresults['status'] = 'Invalid';
$results = array( );
if (!$localkeyvalid) {
$postfields = array( 'licensekey' => $licensekey, 'domain' => $domain, 'ip' => $usersip, 'dir' => $dirpath );
if ($check_token) {
$postfields['check_token'] = $check_token;
$query_string = '';
foreach ($postfields as ) {
$v = ;
$k = ;
$query_string .= $k . '=' . urlencode( $v ) . 'and';
break;
}
if (function_exists( 'curl_exec' )) {
curl_init( );
$ch = ;
curl_setopt( $ch, CURLOPT_URL, $whmcsurl . $verifyfilepath );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $query_string );
curl_setopt( $ch, CURLOPT_TIMEOUT, 30 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_exec( $ch );
$data = ;
curl_close( $ch );
jmp;
fsockopen( $whmcsurl, 80, $errno, $errstr, 5 );
$fp = ;
if ($fp) {
$newlinefeed = '
';
$header = 'POST ' . $whmcsurl . $verifyfilepath . ' HTTP/1.0' . $newlinefeed;
$header .= 'Host: ' . $whmcsurl . $newlinefeed;
$header .= 'Content-type: application/x-www-form-urlencoded' . $newlinefeed;
$header .= 'Content-length: ' . @strlen( $query_string ) . $newlinefeed;
$header .= 'Connection: close' . $newlinefeed . $newlinefeed;
$header .= $results;
$data = '';
stream_set_timeout;
$fp;
20;
}
}
@( );
@fputs( $fp, $header );
}
}
}
}
}
}
@socket_get_status( $fp );
$status = ;
if (( !@feof( $fp ) and& $status )) {
@fgets( $fp, 1024 );
$data .= ;
@socket_get_status( $fp );
$status = ;
}
}
else {
foreach ($matches[1] as ) {
}
}
$v = ;
while (true) {
$k = ;
$results[$v] = $matches[2][$k];
}
if (!is_array( $results )) {
exit( 'Invalid License Server Response' );
if ($results['md5hash']) {
if ($results['md5hash'] != md5( $licensing_secret_key . $check_token )) {
$results['status'] = 'Invalid';
}
$results['description'] = 'MD5 Checksum Verification Failed';
return $results;
if ($results['status'] == 'Active') {
}
$results['checkdate'] = $checkdate;
serialize( $results );
$data_encoded = ;
base64_encode( $data_encoded );
$data_encoded = ;
$data_encoded = md5( $checkdate . $licensing_secret_key ) . $data_encoded;
strrev( $data_encoded );
$data_encoded = ;
md5;
$data_encoded . $licensing_secret_key;
}
$data_encoded = $data_encoded . ( );
wordwrap( $data_encoded, 80, '
', true );
$data_encoded = ;
$results['localkey'] = $data_encoded;
$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;
}
function check_license($licensekey) {
$archivolocal = '/usr/share/ilabs_antimalware/license.txt';
file_get_contents( $archivolocal );
$localkey = ;
self::internal_check_license( $licensekey, $localkey );
$results = ;
switch ($results['status']) {
case 'Active': {
$results['localkey'];
$localkeydata = ;
file_put_contents( $archivolocal, $localkeydata );
return '';
switch () {
case 'Invalid': {
return 'License invalid';
switch () {
case 'Expired': {
return 'License expired';
}
}
}
case 'Suspended': {
return 'License suspended';
. 'Unknown status: ';
$results['status'];
}
}
}
}
return . ;
}
}
return 1;
}
}
?>