after Roku/
if ($this->getVersion() === self::VERSION_UNKNOWN) {
if (preg_match('#Roku/[^-\s]+-([0-9.]+)#i', $this->_agent, $m)) {
$this->setVersion($m[1]);
}
}
// Platform & device type
$this->setPlatform(self::PLATFORM_ROKU);
$this->setMobile(false);
$this->setTablet(false);
return true;
}
/**
* Determine the user's platform (last updated 1.7)
*/
protected function checkPlatform()
{
if (stripos($this->_agent, 'windows') !== false)
{
$this->_platform = self::PLATFORM_WINDOWS;
}
else if (stripos($this->_agent, 'iPad') !== false)
{
$this->_platform = self::PLATFORM_IPAD;
}
else if (stripos($this->_agent, 'iPod') !== false)
{
$this->_platform = self::PLATFORM_IPOD;
}
else if (stripos($this->_agent, 'iPhone') !== false)
{
$this->_platform = self::PLATFORM_IPHONE;
}
elseif (stripos($this->_agent, 'mac') !== false)
{
$this->_platform = self::PLATFORM_APPLE;
}
elseif (stripos($this->_agent, 'android') !== false)
{
$this->_platform = self::PLATFORM_ANDROID;
}
elseif (stripos($this->_agent, 'linux') !== false)
{
$this->_platform = self::PLATFORM_LINUX;
}
else if (stripos($this->_agent, 'Nokia') !== false)
{
$this->_platform = self::PLATFORM_NOKIA;
}
else if (stripos($this->_agent, 'BlackBerry') !== false)
{
$this->_platform = self::PLATFORM_BLACKBERRY;
}
elseif (stripos($this->_agent, 'FreeBSD') !== false)
{
$this->_platform = self::PLATFORM_FREEBSD;
}
elseif (stripos($this->_agent, 'OpenBSD') !== false)
{
$this->_platform = self::PLATFORM_OPENBSD;
}
elseif (stripos($this->_agent, 'NetBSD') !== false)
{
$this->_platform = self::PLATFORM_NETBSD;
}
elseif (stripos($this->_agent, 'OpenSolaris') !== false)
{
$this->_platform = self::PLATFORM_OPENSOLARIS;
}
elseif (stripos($this->_agent, 'SunOS') !== false)
{
$this->_platform = self::PLATFORM_SUNOS;
}
elseif (stripos($this->_agent, 'OS\/2') !== false)
{
$this->_platform = self::PLATFORM_OS2;
}
elseif (stripos($this->_agent, 'BeOS') !== false)
{
$this->_platform = self::PLATFORM_BEOS;
}
elseif (stripos($this->_agent, 'win') !== false)
{
$this->_platform = self::PLATFORM_WINDOWS;
}
}
}
class DeviceCode
{
private $key;
private $b32;
function __construct($key, $b32)
{
$this->key = $key;
$this->b32 = $b32;
}
public function encode($id)
{
$id = (int)$id;
if ($id < 0) {
return false;
}
$tag = $this->tag($id);
// [32-bit id][8-bit tag] = 40 bits
$x = (($id & 0xFFFFFFFF) << 8) | $tag;
$x = $this->permute($x);
return strtoupper($this->b32->fromBin($this->toBits40($x)));
}
public function decode($code)
{
$code = strtoupper(trim($code));
if (strlen($code) !== 8) {
return false;
}
$bits = $this->b32->toBin($code);
if ($bits === false) {
return false;
}
// keep only first 40 bits in case your class pads
$bits = substr($bits, 0, 40);
if (strlen($bits) !== 40 || preg_match('/[^01]/', $bits)) {
return false;
}
$x = $this->fromBits40($bits);
$x = $this->unpermute($x);
$id = ($x >> 8) & 0xFFFFFFFF;
$tag = $x & 0xFF;
if ($tag !== $this->tag($id)) {
return false;
}
return $id;
}
private function tag($id)
{
$mac = hash_hmac('sha256', pack('N', $id), $this->key, true);
return ord($mac[0]);
}
private function permute($x)
{
$l = ($x >> 20) & 0xFFFFF;
$r = $x & 0xFFFFF;
$i = 0;
while ($i < 4) {
$f = $this->round($r, $i);
$tmp = $r;
$r = ($l ^ $f) & 0xFFFFF;
$l = $tmp;
$i++;
}
return (($l << 20) | $r);
}
private function unpermute($x)
{
$l = ($x >> 20) & 0xFFFFF;
$r = $x & 0xFFFFF;
$i = 3;
while ($i >= 0) {
$f = $this->round($l, $i);
$tmp = $l;
$l = ($r ^ $f) & 0xFFFFF;
$r = $tmp;
$i--;
}
return (($l << 20) | $r);
}
private function round($v, $i)
{
$mac = hash_hmac('sha256', chr($i) . pack('N', $v), $this->key, true);
$u = unpack('N', substr($mac, 0, 4));
return $u[1] & 0xFFFFF;
}
private function toBits40($x)
{
$out = '';
$i = 39;
while ($i >= 0) {
$out .= (($x >> $i) & 1) ? '1' : '0';
$i--;
}
return $out;
}
private function fromBits40($bits)
{
$x = 0;
$len = strlen($bits);
$i = 0;
while ($i < $len) {
$x = ($x << 1) | ($bits[$i] === '1' ? 1 : 0);
$i++;
}
return $x;
}
}
class Base32 {
/**
* csRFC3548
*
* The character set as defined by RFC3548
* @link http://www.ietf.org/rfc/rfc3548.txt
*/
const csRFC3548 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
/**
* csSafe
*
* This character set is designed to be more human friendly
* For example: i, I, L, l and 1 all map to 1
* Also: there is no U - to help prevent offencive output
* @link http://www.crockford.com/wrmg/base32.html
*
*/
const csSafe = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
/**
* cs09AV
*
* This character set follows the example of the hex
* character set and is included to make this class
* compatible with MIME::Base32
* @link http://search.cpan.org/~danpeder/MIME-Base32-1.01/Base32.pm
*
*/
const cs09AV = '0123456789ABCDEFGHIJKLMNOPQRSTUV';
/**
* _charset
*
* Internal holder of the current character set.
*
* @access protected
* @var string
*/
protected $_charset;
/**
* Constructor
*
* Call to create a new object.
*
* @param string $charset (optional) The character set to use
* @see setCharset
*/
public function __construct($charset = self::csRFC3548) {
$this->setCharset($charset);
}
/**
* str2bin
*
* Converts any ascii string to a binary string
*
* @param string $str The string you want to convert
* @return string String of 0's and 1's
*/
public function str2bin($str) {
$chrs = unpack('C*', $str);
return vsprintf(str_repeat('%08b', count($chrs)), $chrs);
}
/**
* bin2str
*
* Converts a binary string to an ascii string
*
* @param string $str The string of 0's and 1's you want to convert
* @return string The ascii output
* @throws Exception
*/
public function bin2str($str) {
if ($str == '') return '';
if (strlen($str) % 8 > 0)
throw new Exception('Length must be divisible by 8');
if (!preg_match('/^[01]+$/', $str))
throw new Exception('Only 0\'s and 1\'s are permitted');
preg_match_all('/.{8}/', $str, $chrs);
$chrs = array_map('bindec', $chrs[0]);
// I'm just being slack here
array_unshift($chrs, 'C*');
return call_user_func_array('pack', $chrs);
}
/**
* fromBin
*
* Converts a correct binary string to base32
*
* @param string $str The string of 0's and 1's you want to convert
* @return string String encoded as base32
* @throws exception
*/
public function fromBin($str) {
if (strlen($str) % 8 > 0)
throw new Exception('Length must be divisible by 8');
if (!preg_match('/^[01]+$/', $str))
throw new Exception('Only 0\'s and 1\'s are permitted');
// Base32 works on the first 5 bits of a byte, so we insert blanks to pad it out
$str = preg_replace('/(.{5})/', '000$1', $str);
// We need a string divisible by 5
$length = strlen($str);
$rbits = $length & 7;
if ($rbits > 0) {
// Excessive bits need to be padded
$ebits = substr($str, $length - $rbits);
$str = substr($str, 0, $length - $rbits);
$str .= "000$ebits".str_repeat('0', 5 - strlen($ebits));
}
preg_match_all('/.{8}/', $str, $chrs);
$chrs = array_map(array($this, '_mapcharset'), $chrs[0]);
return join('', $chrs);
}
/**
* toBin
*
* Accepts a base32 string and returns an ascii binary string
*
* @param string $str The base32 string to convert
* @return string Ascii binary string
*/
public function toBin($str) {
if (!preg_match('/^['.$this->_charset.']+$/', $str))
return '';
// Convert the base32 string back to a binary string
$str = join('',array_map(array($this, '_mapbin'), str_split($str)));
// Remove the extra 0's we added
$str = preg_replace('/000(.{5})/', '$1', $str);
// Unpad if nessicary
$length = strlen($str);
$rbits = $length & 7;
if ($rbits > 0)
$str = substr($str, 0, $length - $rbits);
return $str;
}
/**
* fromString
*
* Convert any string to a base32 string
* This should be binary safe...
*
* @param string $str The string to convert
* @return string The converted base32 string
*/
public function fromString($str) {
return $this->fromBin($this->str2bin($str));
}
/**
* toString
*
* Convert any base32 string to a normal sctring
* This should be binary safe...
*
* @param string $str The base32 string to convert
* @return string The normal string
*/
public function toString($str) {
$str = strtoupper($str);
// csSave actually has to be able to consider extra characters
if ($this->_charset == self::csSafe) {
$str = str_replace('O','0',$str);
$str = str_replace(array('I','L'),'1',$str);
}
return $this->bin2str($this->tobin($str));
}
/**
* _mapcharset
*
* Used with array_map to map the bits from a binary string
* directly into a base32 character set
*
* @access private
* @param string $str The string of 0's and 1's you want to convert
* @return char Resulting base32 character
*/
private function _mapcharset($str) {
return $this->_charset[bindec($str)];
}
/**
* _mapbin
*
* Used with array_map to map the characters from a base32
* character set directly into a binary string
*
* @access private
* @param char $chr The caracter to map
* @return str String of 0's and 1's
*/
private function _mapbin($chr) {
return sprintf('%08b',strpos($this->_charset,$chr));
}
/**
* setCharset
*
* Used to set the internal _charset variable
* I've left it so that people can arbirtrarily set their
* own charset
*
* Can be called with:
* * Base32::csRFC3548
* * Base32::csSafe
* * Base32::cs09AV
*
* @param string $charset The character set you want to use
* @throws Exception
*/
public function setCharset($charset = self::csRFC3548) {
if (strlen($charset) == 32) {
$this->_charset = strtoupper($charset);
} else {
throw new Exception('Length must be exactly 32');
}
}
}
class Encryptor
{
protected $_key;
protected $_method;
protected $_cipher;
protected $_decipher;
protected $_bytesToKeyResults = array();
protected static $_cachedTables = array();
protected static $_encryptTable = array();
protected static $_decryptTable = array();
protected $_cipherIv;
protected $_ivSent;
protected static $_methodSupported = array(
'aes-128-cfb'=> array(16, 16),
'aes-192-cfb'=> array(24, 16),
'aes-256-cfb'=> array(32, 16),
'bf-cfb'=> array(16, 8),
'camellia-128-cfb'=> array(16, 16),
'camellia-192-cfb'=> array(24, 16),
'camellia-256-cfb'=> array(32, 16),
'cast5-cfb'=> array(16, 8),
'des-cfb'=> array(8, 8),
'idea-cfb'=>array(16, 8),
'rc2-cfb'=> array(16, 8),
'rc4'=> array(16, 0),
'rc4-md5'=> array(16, 16),
'seed-cfb'=> array(16, 16)
);
public static function initTable($key)
{
$_ref = self::getTable($key);
self::$_encryptTable = $_ref[0];
self::$_decryptTable = $_ref[1];
}
public function __construct($key, $method)
{
$this->_key = $key;
$this->_method = $method;
if($this->_method == 'table')
{
$this->_method = null;
}
if($this->_method)
{
$iv_size = openssl_cipher_iv_length($this->_method);
$iv = openssl_random_pseudo_bytes($iv_size);
$this->_cipher = $this->getcipher($this->_key, $this->_method, 1, $iv);
}
else
{
if(!self::$_encryptTable)
{
$_ref = self::getTable($this->_key);
self::$_encryptTable = $_ref[0];
self::$_decryptTable = $_ref[1];
}
}
}
protected static function getTable($key)
{
if (isset(self::$_cachedTables[$key]))
{
return self::$_cachedTables[$key];
}
$int32Max = pow(2, 32);
$table = array();
$decrypt_table = array();
$hash = md5($key, true);
$tmp = unpack('V2', $hash);
$al = $tmp[1];
$ah = $tmp[2];
$i = 0;
while ($i < 256) {
$table[$i] = $i;
$i++;
}
$i = 1;
while ($i < 1024) {
$table = merge_sort($table, function($x, $y)use($ah, $al, $i, $int32Max) {
return (($ah % ($x + $i)) * $int32Max + $al) % ($x + $i) - (($ah % ($y + $i)) * $int32Max + $al) % ($y + $i);
});
$i++;
}
$table = array_values($table);
$i = 0;
while ($i < 256) {
$decrypt_table[$table[$i]] = $i;
++$i;
}
ksort($decrypt_table);
$decrypt_table = array_values($decrypt_table);
$result = array($table, $decrypt_table);
self::$_cachedTables[$key] = $result;
return $result;
}
public static function substitute($table, $buf)
{
$i = 0;
$len = strlen($buf);
while ($i < $len) {
$buf[$i] = chr($table[ord($buf[$i])]);
$i++;
}
return $buf;
}
protected function getCipher($password, $method, $op, $iv)
{
$method = strtolower($method);
$m = $this->getCipherLen($method);
if($m)
{
$ref = $this->EVPBytesToKey($password, $m[0], $m[1]);
$key = $ref[0];
$iv_ = $ref[1];
if ($iv == null)
{
$iv = $iv_;
}
if ($op === 1)
{
$this->_cipherIv = substr($iv, 0, $m[1]);
}
$iv = substr($iv, 0, $m[1]);
if ($method === 'rc4-md5')
{
return $this->createRc4Md5Cipher($key, $iv, $op);
}
else
{
if($op === 1)
{
return new Encipher($method, $key, $iv);
}
else
{
return new Decipher($method, $key, $iv);
}
}
}
}
public function encrypt($buffer)
{
if($this->_method)
{
$result = $this->_cipher->update($buffer);
if ($this->_ivSent)
{
return $result;
}
else
{
$this->_ivSent = true;
return $this->_cipherIv.$result;
}
}
else
{
return self::substitute(self::$_encryptTable, $buffer);
}
}
public function decrypt($buffer, $block_byte_start = 0)
{
if($this->_method)
{
if(!$this->_decipher)
{
$decipher_iv_len = $this->getCipherLen($this->_method);
$decipher_iv_len = $decipher_iv_len[1];
$decipher_iv = substr($buffer, $block_byte_start, $decipher_iv_len);
$this->_decipher = $this->getCipher($this->_key, $this->_method, 0, $decipher_iv);
$result = $this->_decipher->update(substr($buffer, $decipher_iv_len));
return $result;
}
else
{
$result = $this->_decipher->update($buffer);
return $result;
}
}
else
{
return self::substitute(self::$_decryptTable, $buffer);
}
}
protected function createRc4Md5Cipher($key, $iv, $op)
{
$rc4_key = md5($key.$iv);
if($op === 1)
{
return new Encipher('rc4', $rc4_key, '');
}
else
{
return Decipher('rc4', $rc4_key, '');
}
}
protected function EVPBytesToKey($password, $key_len, $iv_len)
{
$cache_key = "$password:$key_len:$iv_len";
if(isset($this->_bytesToKeyResults[$cache_key]))
{
return $this->_bytesToKeyResults[$cache_key];
}
$m = array();
$i = 0;
$count = 0;
while ($count < $key_len + $iv_len)
{
$data = $password;
if ($i > 0)
{
$data = $m[$i-1] . $password;
}
$d = md5($data, true);
$m[] = $d;
$count += strlen($d);
$i += 1;
}
$ms = '';
foreach($m as $buf)
{
$ms .= $buf;
}
$key = substr($ms, 0, $key_len);
$iv = substr($ms, $key_len, $key_len + $iv_len);
$this->bytesToKeyResults[$password] = array($key, $iv);
return array($key, $iv);
}
protected function getCipherLen($method)
{
$method = strtolower($method);
return isset(self::$_methodSupported[$method]) ? self::$_methodSupported[$method] : null;
}
}
class Encipher
{
protected $_algorithm;
protected $_key;
protected $_iv;
protected $_tail;
protected $_ivLength;
public function __construct($algorithm, $key, $iv)
{
$this->_algorithm = $algorithm;
$this->_key = $key;
$this->_iv = $iv;
$this->_ivLength = openssl_cipher_iv_length($algorithm);
}
public function update($data)
{
if (strlen($data) == 0)
return '';
$tl = strlen($this->_tail);
if ($tl)
$data = $this->_tail . $data;
$b = openssl_encrypt($data, $this->_algorithm, $this->_key, 1, $this->_iv);
$result = substr($b, $tl);
$dataLength = strlen($data);
$mod = $dataLength%$this->_ivLength;
if ($dataLength >= $this->_ivLength) {
$iPos = -($mod + $this->_ivLength);
$this->_iv = substr($b, $iPos, $this->_ivLength);
}
$this->_tail = $mod!=0 ? substr($data, -$mod):'';
return $result;
}
}
class Decipher extends Encipher
{
public function update($data)
{
if (strlen($data) == 0)
return '';
$tl = strlen($this->_tail);
if ($tl)
$data = $this->_tail . $data;
$b = openssl_decrypt($data, $this->_algorithm, $this->_key, 1, $this->_iv);
$result = substr($b, $tl);
$dataLength = strlen($data);
$mod = $dataLength%$this->_ivLength;
if ($dataLength >= $this->_ivLength) {
$iPos = -($mod + $this->_ivLength);
$this->_iv = substr($data, $iPos, $this->_ivLength);
}
$this->_tail = $mod!=0 ? substr($data, -$mod):'';
return $result;
}
}
function merge_sort($array, $comparison)
{
if (count($array) < 2) {
return $array;
}
$middle = ceil(count($array) / 2);
return merge(merge_sort(slice($array, 0, $middle), $comparison), merge_sort(slice($array, $middle), $comparison), $comparison);
}
function slice($table, $start, $end = null)
{
$table = array_values($table);
if($end)
{
return array_slice($table, $start, $end);
}
else
{
return array_slice($table, $start);
}
}
function merge($left, $right, $comparison)
{
$result = array();
while ((count($left) > 0) && (count($right) > 0)) {
if(call_user_func($comparison, $left[0], $right[0]) <= 0){
$result[] = array_shift($left);
} else {
$result[] = array_shift($right);
}
}
while (count($left) > 0) {
$result[] = array_shift($left);
}
while (count($right) > 0) {
$result[] = array_shift($right);
}
return $result;
}
function get_mime_type($file) {
$mime_types = array(
"pdf" => "application/pdf",
"exe" => "application/octet-stream",
"zip" => "application/zip",
"docx" => "application/msword",
"doc" => "application/msword",
"xls" => "application/vnd.ms-excel",
"ppt" => "application/vnd.ms-powerpoint",
"gif" => "image/gif",
"png" => "image/png",
"jpeg" => "image/jpg",
"jpg" => "image/jpg",
"mp3" => "audio/mpeg",
"aif" => "audio/aiff",
"wav" => "audio/x-wav",
"mpeg" => "video/mpeg",
"mpg" => "video/mpeg",
"mpe" => "video/mpeg",
"mp4" => "video/mp4",
"m4v" => "video/mp4",
"m3u8" => "application/x-mpegURL",
"m3u" => "application/x-mpegURL",
"flv" => "video/x-flv",
"mov" => "video/quicktime",
"avi" => "video/x-msvideo",
"3gp" => "video/3gpp",
"wmv" => "video/x-ms-wmv",
"mkv" => "video/x-matroska",
"ts" => "video/MP2T",
"css" => "text/css",
"jsc" => "application/javascript",
"js" => "application/javascript",
"php" => "text/html",
"htm" => "text/html",
"html" => "text/html",
"tar" => "application/x-tar",
"rar" => "application/x-rar-compressed"
);
$extension = strtolower(end(explode('.',$file)));
return $mime_types[$extension];
}
function decrypt_captcha_image($image_data, $backup = 0, $numeric = 0, $min_len = 0, $max_len = 0, $best_effort = false) {
$rand_out_ip = rand_out_ip();
if ($backup == 0) {
if ($best_effort === true) {
$api_key = 'bf5883c44c6d8fa48247a0924ccc8e86'; // admin@xtnetwork.fr
} else {
$api_key = 'd8407647ddc8fee8e80cf4b641ee19b4'; // support@xtnetwork.fr
}
do {
$n++;
if (base64_decode($image_data) != '') {
$api_captcha = header_cookie_post('http://2captcha.com/in.php', 'key='.$api_key.'&method=base64&numeric='.$numeric.'&min_len='.$min_len.'&max_len='.$max_len.'&body='.urlencode($image_data));
}
if (preg_match('/OK\|([0-9]+)$/', $api_captcha, $match) !== false) {
$work_id = $match[1];
if ($debug)
echo 'Work ID: '.$work_id;
$start_captcha = time();
do {
sleep(3);
$api_captcha_2 = header_cookie_get('http://2captcha.com/res.php?key='.$api_key.'&action=get&id='.$work_id);
if ($debug)
echo $api_captcha_2;
if (preg_match('/OK\|(.*)$/', $api_captcha_2, $match) !== false) {
$answer = $match[1];
}
} while ($answer == '' AND ($start_captcha + 120) >= time());
}
} while ($answer == '' AND $n <= $retry);
} elseif ($backup == 1) {
$api_captcha = header_cookie_post_ip($rand_out_ip, 'http://bypasscaptcha.com/upload.php', 'base64_code=1&gen_task_id=1&submit=Submit&file='.urlencode($image_data).'&key=df06053556220a7f2c1c44e1c75b92e6').'|';
$answer = trim(pregme($api_captcha, "Value ", 'TaskId'));
}
return $answer;
}
function decrypt_recaptcha_v1($recaptcha_key, $ip = '') {
if ($ip == '') $ip = rand_out_ip();
$google_recaptcha = header_cookie_get_ip($ip, 'http://www.google.com/recaptcha/api/challenge?k='.urlencode($recaptcha_key));
$challenge_image = pregme($google_recaptcha, "challenge : '", "',");
$image_data = header_cookie_get_ip($ip, 'http://www.google.com/recaptcha/api/image?c='.$challenge_image);
$image_data = base64_encode(substr($image_data, strpos($image_data, "\r\n\r\n")+4));
return array('challenge' => $challenge_image, 'response' => decrypt_captcha_image($image_data));
}
function decrypt_cloudflare_turnstile($captcha_sitekey, $turnstile_origin = '', $retry = 1, $ip = '', $invisible = false, $best_effort = false, $debug = false, $userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0') {
$answer = '';
$n = 0;
if ($best_effort === true) {
$api_key = 'bf5883c44c6d8fa48247a0924ccc8e86'; // admin@xtnetwork.fr
} else {
$api_key = 'd8407647ddc8fee8e80cf4b641ee19b4'; // support@xtnetwork.fr
}
do {
$n++;
$api_captcha = header_cookie_get('http://2captcha.com/in.php?key='.$api_key.'&method=turnstile&sitekey='.$captcha_sitekey.'&pageurl='.urlencode($turnstile_origin).'&here=now&userAgent='.urlencode($userAgent));
if (preg_match('/OK\|([0-9]+)$/', $api_captcha, $match) !== false) {
$work_id = $match[1];
if ($debug)
echo 'Work ID: '.$work_id;
$start_captcha = time();
do {
sleep(3);
$api_captcha_2 = header_cookie_get('http://2captcha.com/res.php?key='.$api_key.'&action=get&id='.$work_id);
if ($debug)
echo $api_captcha_2;
if (preg_match('/OK\|(.*)$/', $api_captcha_2, $match) !== false) {
$answer = $match[1];
}
} while ($answer == '' AND ($start_captcha + 120) >= time());
}
} while ($answer == '' AND $n <= $retry);
return $answer;
}
function decrypt_hcaptcha($hcaptcha_key, $hcaptcha_origin = '', $retry = 1, $ip = '', $invisible = false, $best_effort = false, $debug = false, $domain = 'hcaptcha.com', $userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0') {
$answer = '';
$n = 0;
if ($best_effort === true) {
$api_key = 'bf5883c44c6d8fa48247a0924ccc8e86'; // admin@xtnetwork.fr
} else {
$api_key = 'd8407647ddc8fee8e80cf4b641ee19b4'; // support@xtnetwork.fr
}
do {
$n++;
$api_captcha = header_cookie_get('http://2captcha.com/in.php?key='.$api_key.'&method=hcaptcha&sitekey='.$hcaptcha_key.'&pageurl='.urlencode($hcaptcha_origin).'&here=now&domain='.urlencode($domain).'&userAgent='.urlencode($userAgent));
if (preg_match('/OK\|([0-9]+)$/', $api_captcha, $match) !== false) {
$work_id = $match[1];
if ($debug)
echo 'Work ID: '.$work_id;
$start_captcha = time();
do {
sleep(3);
$api_captcha_2 = header_cookie_get('http://2captcha.com/res.php?key='.$api_key.'&action=get&id='.$work_id);
if ($debug)
echo $api_captcha_2;
if (preg_match('/OK\|(.*)$/', $api_captcha_2, $match) !== false) {
$answer = $match[1];
}
} while ($answer == '' AND ($start_captcha + 120) >= time());
}
} while ($answer == '' AND $n <= $retry);
return $answer;
}
function decrypt_recaptcha_v3($recaptcha_key, $recaptcha_origin = '', $retry = 1, $ip = '', $enterprise = false, $action = '', $best_effort = false, $debug = false, $userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0') {
$answer = '';
$n = 0;
if ($best_effort === true) {
$api_key = 'bf5883c44c6d8fa48247a0924ccc8e86'; // admin@xtnetwork.fr
} else {
$api_key = 'd8407647ddc8fee8e80cf4b641ee19b4'; // support@xtnetwork.fr
}
do {
$n++;
$api_captcha = header_cookie_get('http://2captcha.com/in.php?key='.$api_key.'&method=userrecaptcha&googlekey='.$recaptcha_key.'&version=v3&min_score=0.9&pageurl='.urlencode($recaptcha_origin).'&here=now'.(($enterprise)?'&enterprise=1&invisible=1':'').'&action='.$action.'&userAgent='.urlencode($userAgent));
if (preg_match('/OK\|([0-9]+)$/', $api_captcha, $match) !== false) {
$work_id = $match[1];
if ($work_id > 0) {
if ($debug)
echo 'Work ID: '.$work_id;
$start_captcha = time();
do {
sleep(3);
$api_captcha_2 = header_cookie_get('http://2captcha.com/res.php?key='.$api_key.'&action=get&id='.$work_id);
if ($debug)
echo $api_captcha_2;
if (preg_match('/OK\|(.*)$/', $api_captcha_2, $match) !== false) {
$answer = $match[1];
}
} while ($answer == '' AND ($start_captcha + 120) >= time());
}
}
} while ($answer == '' AND $n <= $retry);
return $answer;
}
function decrypt_recaptcha_v2($recaptcha_key, $recaptcha_origin = '', $retry = 1, $ip = '', $invisible = false, $best_effort = false, $debug = false, $userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0') {
$answer = '';
$n = 0;
if ($best_effort === true) {
$api_key = 'bf5883c44c6d8fa48247a0924ccc8e86'; // admin@xtnetwork.fr
} else {
$api_key = 'd8407647ddc8fee8e80cf4b641ee19b4'; // support@xtnetwork.fr
}
do {
$n++;
$api_captcha = header_cookie_get('http://2captcha.com/in.php?key='.$api_key.'&method=userrecaptcha&googlekey='.$recaptcha_key.'&pageurl='.urlencode($recaptcha_origin).'&here=now'.(($invisible)?'&invisible=1':'').'&userAgent='.urlencode($userAgent));
if (preg_match('/OK\|([0-9]+)$/', $api_captcha, $match) !== false) {
$work_id = $match[1];
if ($debug)
echo 'Work ID: '.$work_id;
$start_captcha = time();
do {
sleep(3);
$api_captcha_2 = header_cookie_get('http://2captcha.com/res.php?key='.$api_key.'&action=get&id='.$work_id);
if ($debug)
echo $api_captcha_2;
if (preg_match('/OK\|(.*)$/', $api_captcha_2, $match) !== false) {
$answer = $match[1];
}
} while ($answer == '' AND ($start_captcha + 120) >= time());
}
} while ($answer == '' AND $n <= $retry);
/*
if (!is_numeric($retry)) return false;
if ($retry < 0 OR $retry > 25) return false;
if ($recaptcha_origin == '') $recaptcha_origin = 'https://google.com';
if ($ip == '') $ip = rand_out_ip();
$recaptcha_api_js = header_cookie_get_ip($ip, 'https://www.google.com/recaptcha/api.js?hl=en', '', $recaptcha_origin);
$recaptcha_api_data = header_cookie_get_ip($ip, pregme($recaptcha_api_js, ".src = '", "'"), '', $recaptcha_origin);
$recaptcha_revision = pregme($recaptcha_api_js, 'api2/', '/');
$recaptcha_rresp = '';
$resolutionId = '';
$recaptcha_token = '';
$retry_counter = 0;
do {
$retry_counter++;
if ($retry_counter > 1 AND $debug) echo "Retrying ...\n";
if ($recaptcha_rresp == '') {
$google_recaptcha = header_cookie_get_ip($ip, 'https://www.google.com/recaptcha/api2/anchor?k='.urlencode($recaptcha_key).'&hl=en&co='.str_replace('=', '', base64_encode($recaptcha_origin)).'', '', $recaptcha_origin);
$recaptcha_token = pregme($google_recaptcha, 'id="recaptcha-token" value="', '"');
$recaptcha_data = header_cookie_get_ip($ip, 'https://www.google.com/recaptcha/api2/frame?k='.urlencode($recaptcha_key).'&hl=en&c='.urlencode($recaptcha_token), '', 'https://www.google.com/recaptcha/api2/anchor?k='.urlencode($recaptcha_key).'&hl=en');
$resolutionId = pregme($recaptcha_data, '[\\x22pmeta\\x22,[\\x22', '\\x22');
$recaptcha_rresp = pregme($recaptcha_data, '[\\x22rresp\\x22,\\x22', '\\x22');
}
$recaptcha_image = header_cookie_get_ip($ip, 'https://www.google.com/recaptcha/api2/payload?k='.urlencode($recaptcha_key).'&hl=en&c='.urlencode($recaptcha_rresp), '', 'https://www.google.com/recaptcha/api2/anchor?k='.urlencode($recaptcha_key).'&hl=en');
$recaptcha_payload = base64_encode(substr($recaptcha_image, strpos($recaptcha_image, "\r\n\r\n") + 4));
$recaptcha_banner_txt = str_replace(array('', '', 'Select all images with'), array('', '', 'All images with'), pregme(pregme($recaptcha_api_data, '"'.$resolutionId.'"', '";').'";', '+="', '";'));
if ($debug) echo "Payload: ".$recaptcha_rresp."\nQuestion: ".$recaptcha_banner_txt."\n";
$recaptcha_banner_img = '/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCACAAIADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAj/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AKpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB//9k=';
$api_captcha = header_cookie_post_ip($ip, 'http://api.dbcapi.me/api/captcha', 'username=RealDebrid&password=prg9gEw1YRSAqVll5OAHp&captchafile=base64:'.urlencode($recaptcha_payload).'&banner=base64:'.urlencode($recaptcha_banner_img).'&banner_text='.urlencode($recaptcha_banner_txt).'&type=3');
$captcha_id = pregme($api_captcha, 'captcha=', '&');
if (strpos($api_captcha, 'is_correct=1') === false OR strpos($api_captcha, '500 Internal Server Error') !== false) {
if ($debug) echo "Deathbycaptcha ERROR!\n";
$recaptcha_rresp = '';
$resolutionId = '';
continue;
}
$start_captcha = time();
do {
sleep(3);
$api_captcha_2 = header_cookie_get_ip($ip, pregme($api_captcha, 'Location: ', "\r\n"));
$answer = trim(urldecode(pregme($api_captcha_2, "&text=", '&')));
} while ($answer == '' AND ($start_captcha + 45) >= time());
if ($debug) echo "Answer: ".$answer."\n";
$recaptcha_response = '';
if (substr($answer, 0, 1) == '[') {
$response_data = "";
$explode_answer = explode(',', pregme($answer, '[', ']'));
foreach ($explode_answer as $response_part) {
$response_data .= ($response_part - 1).",";
}
$response_data = "response=".base64_encode('{"response":[['.substr($response_data, 0, -1).']]}');
$rand = rand(1000,9999);
$google_recaptcha = header_cookie_post_ip($ip, 'https://www.google.com/recaptcha/api2/userverify?k='.urlencode($recaptcha_key).'&hl=en', $response_data.'&v='.$recaptcha_revision.'&c='.urlencode($recaptcha_rresp).'&t='.$rand.'&ct='.$rand.'&bg=!RUOgQ2JHl8quEYUiA-5BZc2JbbLI6TEHAAAAG1cAAABFnAOjgF-dUrw-3qLQHpwC9WTpv7Al5AKgr29maHtccAv3oGl1sitlNjKRfPdL_hhtYmD8oq1Gd0B4t7tFBybOfCpi_leeqVYPpBoN1yE04oZBItJD8y_kbELz2hH0dUBzKms_vlNUMXkYUozoRJA1nJlT15J6OYdi6uQsa4wFwnLlyOwOSMJenxBfA3_YTI3rksTIWa5bVQwsUQl0ho8hBbzqc3rPIfb4e_NhHaWY8t7wZNLYIl2b1wBVD7dcNkZ2KazW775pCj5KSixw77aUS_T941vKb-hEue7-z5K9t6rygd35-NKB1UEl81TC09CSjcyKL84wifeFQSF8ZGQZXy4Y3qtVvdtgI0rgSuj-jOYKM6k21_Im67HkN5r_1tUYKDzAIZmzo5XoZqwHLLg7wrQNXx_RCeeKWEXzuZ29obyi9sn8qzoRPnlVndBbRchDclFUVywj3v_M3aXCtADTl3rUmTogd4T0ZaohUyIxZf1-DBRixG4wKBv7IsAgQyJt771ZBU7JrAfluhQ0yJDaA_OK-soEBc0gCXiq_Jf4br2L6m7pBvXgm3zZFWYIvIUrgQKeP0ZoGQRJXegeag0Y9-Ew_nmKDD7XbW20wuNfbBVqXPnGBTMIzielZ3m1WEzHJrGIjQF_KUypW9qw2bGtdMwVDqcxxNPS0Bnw3SV1OGOkpuhIYdGfhS4CgGHmCeGR6fLY_scvc7AYQdmonrvBMiJvQ0apTAmCVjoatD0VAIlOiDXbQEG1k_eMTgXXCtexwp5pxm6nJkwzzm95SQAzpTaS_dgg7dQEozYnfQyQj2sZpmptHv2f73VYuWhe8fIOFlaZLnzzaLGHLbAfiVT-yDCA3ZsYiNfQC3GkGdZ4V1LXPmgkFVuE4u7JKMHV2cprHwhMY0463d6hFwBQFp6rZWm0U2qt8Y_rIzXqs4Ie3ZMLmelmfL3xilLBHXKhFxRjeRPE4fY8553WQWVf0TdpwLHrdBQrc9G5zrS0Q4bJ4clwHKLo9wR5rTbayFOQfJ_Zxod4-Wpp7scFl49DZ6sZFSzCmfNXwHzDNpl9WB0m2-6VayRoMnxlLaxA0ecOPxJxNiSFoimuK1Feluf9n5FdZPlr5Jl7t0aK8_8DyDFOFKaX53KZRN2lTh-4wqJ_MWg6qxajPR0ZhdzVztvzePjvluoum8LEUCto27BBoZ-smJCkUVtixAh_Iph2v12dEwYKF3X2SFT6tOu9l1eguATMG7cOFcaHlQ', ' ', 'https://www.google.com/recaptcha/api2/frame?k='.urlencode($recaptcha_key).'&hl=en&c='.urlencode($recaptcha_token));
$recaptcha_response = pregme($google_recaptcha, '"uvresp","', '"');
$recaptcha_rresp = pregme($google_recaptcha, '"rresp","', '"');
$resolutionId = pregme($google_recaptcha, '"pmeta",["', '"');
if ($debug) echo 'Response: '.$recaptcha_response."\n";
}
if (strpos($google_recaptcha, '"rresp","') !== false) {
$recaptcha_response = '';
} else {
$recaptcha_rresp = '';
$resolutionId = '';
}
if ($recaptcha_response != '') {
break;
}
if ($recaptcha_response == '' AND $retry_counter > 1) {
header_cookie_post('http://api.dbcapi.me/api/captcha/'.$captcha_id.'/', 'username=RealDebrid&password=prg9gEw1YRSAqVll5OAHp');
}
} while ($retry > 0 AND $retry_counter < $retry);
*/
return $answer;
}
function json_indent($json) {
if (!is_string($json)) {
if (phpversion() && phpversion() >= 5.4) {
return json_encode($json, JSON_PRETTY_PRINT);
}
$json = json_encode($json);
}
$result = '';
$pos = 0; // indentation level
$strLen = strlen($json);
$indentStr = "\t";
$newLine = "\n";
$prevChar = '';
$outOfQuotes = true;
for ($i = 0; $i < $strLen; $i++) {
// Speedup: copy blocks of input which don't matter re string detection and formatting.
$copyLen = strcspn($json, $outOfQuotes ? " \t\r\n\",:[{}]" : "\\\"", $i);
if ($copyLen >= 1) {
$copyStr = substr($json, $i, $copyLen);
// Also reset the tracker for escapes: we won't be hitting any right now
// and the next round is the first time an 'escape' character can be seen again at the input.
$prevChar = '';
$result .= $copyStr;
$i += $copyLen - 1; // correct for the for(;;) loop
continue;
}
// Grab the next character in the string
$char = substr($json, $i, 1);
// Are we inside a quoted string encountering an escape sequence?
if (!$outOfQuotes && $prevChar === '\\') {
// Add the escaped character to the result string and ignore it for the string enter/exit detection:
$result .= $char;
$prevChar = '';
continue;
}
// Are we entering/exiting a quoted string?
if ($char === '"' && $prevChar !== '\\') {
$outOfQuotes = !$outOfQuotes;
}
// If this character is the end of an element,
// output a new line and indent the next line
else if ($outOfQuotes && ($char === '}' || $char === ']')) {
$result .= $newLine;
$pos--;
for ($j = 0; $j < $pos; $j++) {
$result .= $indentStr;
}
}
// eat all non-essential whitespace in the input as we do our own here and it would only mess up our process
else if ($outOfQuotes && false !== strpos(" \t\r\n", $char)) {
continue;
}
// Add the character to the result string
$result .= $char;
// always add a space after a field colon:
if ($outOfQuotes && $char === ':') {
$result .= ' ';
}
// If the last character was the beginning of an element,
// output a new line and indent the next line
else if ($outOfQuotes && ($char === ',' || $char === '{' || $char === '[')) {
$result .= $newLine;
if ($char === '{' || $char === '[') {
$pos++;
}
for ($j = 0; $j < $pos; $j++) {
$result .= $indentStr;
}
}
$prevChar = $char;
}
return $result;
}
function truncateFilename($filename, $max = 40) {
if (strlen($filename) <= $max) {
return $filename;
}
if ($max <= 3) {
return '...';
}
if (!preg_match('/^(.+?)(\.[^\.]+)?$/', $filename, $match)) {
// has newlines or is an empty string
return $filename;
}
list (, $name, $ext) = $match;
$extLen = strlen($ext);
$nameMax = $max - ($extLen == 0 ? 3 : $extLen + 2); // 2 for two dots of the elipses
if ($nameMax <= 1) {
$truncated = mb_substr($filename, 0, $max - 3) . ' ...';
}
else {
$truncated = mb_substr($name, 0, $nameMax) . ' ... ' . substr($ext, 1);
}
return $truncated;
}
function censore_email($email) {
$exp = explode('@', $email);
return substr($exp[0], 0, 3).preg_replace('#[a-zA-Z0-9]#', '*', substr($exp[0], 3)).'@'.$exp[1];
}
function minify_js($buffer) {
if(trim($buffer) === "") return $buffer;
$buffer = preg_replace("/((?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:\/\/.*))/", "", $buffer);
$buffer = str_replace(array("\r\n","\r","\t","\n",' ',' ',' '), '', $buffer);
$buffer = preg_replace(array('(( )+\))','(\)( )+)'), ')', $buffer);
return $buffer;
}
function get_mx_records($ip) {
$string = '';
$return = array();
exec("timeout --signal=SIGINT 2 dig +short mx \"".$ip."\" 2>&1", $output, $retval);
if ($retval != 0) {
} else {
$x=0;
while ($x < (sizeof($output))) {
$string.= $output[$x]."\n";
$x++;
}
}
if (empty($string))
$return[] = $ip;
else {
$explode = explode("\n", $string);
foreach ($explode as $mx_host) {
if (!empty($mx_host)) {
$explode2 = explode(' ', $mx_host);
$return[] = trim(substr($explode2[1], 0, -1));
}
}
}
return $return;
}
function get_mx_records_ips($ip, $getRecords = false, $type = '') {
$string = '';
$return = array();
$result = array();
$ip = str_replace(array('@', '!'), '', $ip); // Secure
exec("timeout --signal=SIGINT 2 dig +short mx \"".$ip."\" 2>&1", $output, $retval);
if ($retval != 0) {
} else {
$x=0;
while ($x < (sizeof($output))) {
$string.= $output[$x]."\n";
$x++;
}
}
if (empty($string))
$return[] = $ip;
elseif (strpos($string, ' ') !== false) {
$explode = explode("\n", $string);
foreach ($explode as $mx_host) {
if (!empty($mx_host)) {
$explode2 = explode(' ', $mx_host);
$return[] = trim(substr($explode2[1], 0, -1));
}
}
}
foreach ($return as $ip) {
if ($ip != '') {
$string = '';
$output = $retval = NULL;
if ($type == 'v6') {
exec("timeout --signal=SIGINT 2 dig +short aaaa \"".$ip."\" 2>&1", $output, $retval);
} else {
exec("timeout --signal=SIGINT 2 dig +short a \"".$ip."\" 2>&1", $output, $retval);
}
if ($retval != 0) {
} else {
$x=0;
while ($x < (sizeof($output))) {
$string.= $output[$x]."\n";
$x++;
}
}
if (!empty($string)) {
$explode = explode("\n", $string);
foreach ($explode as $mx_host) {
if (!empty($mx_host) AND substr($mx_host, -1) != '.') {
$result[] = trim($mx_host);
}
}
}
}
}
if ($getRecords) {
return array('records' => $return, 'ips' => $result);
} else {
return $result;
}
}
function get_dns_ip_records($host, $ipv6Only = false) {
$string = '';
$output = $retval = NULL;
if ($ipv6Only) {
exec("timeout --signal=SIGINT 2 dig \"".$host."\" AAAA +short 2>&1", $output, $retval);
} else {
exec("timeout --signal=SIGINT 2 dig \"".$host."\" A \"".$host."\" AAAA +short 2>&1", $output, $retval);
}
if ($retval != 0) {} else {
$x = 0;
while ($x < (sizeof($output))) {
$string .= $output[$x]."\n";
$x++;
}
}
if (!empty($string)) {
$explode = explode("\n", $string);
foreach($explode as $ip) {
if (!empty($ip) AND substr($ip, -1) != '.') {
$result[] = trim($ip);
}
}
}
return $result;
}
function generate_fake_email($variant = 0, $exclude_domains = array(), $lang = '') {
// str_replace(array('ë', 'é', 'è', 'à', 'ï', ' '), array('e', 'e', 'e', 'a', 'i', ''),
if ($lang == '') {
$lang = 'us,fr,gb,de,nl,ie';
}
$data = header_cookie_get_ip(rand_out_ip(), 'https://randomuser.me/api/?nat='.$lang);
if (strpos($data, '","last":"') !== false) {
$name = str_replace(' ', '', remove_accents(strtolower(pregme($data, '"first":"', '"'))));
$surname = str_replace(' ', '', remove_accents(strtolower(pregme($data, '"last":"', '"'))));
} else { // Backup
$data = header_cookie_post_ip(rand_out_ip(), 'https://api.name-fake.com/english-united-states', 'con%5B%5D=en_US&perc=50&miny=19&maxy=57');
$full_name = pregme(str_replace(array('"name": "Name', '"name": "United'), '', $data), '"name": "', '"');
if (strpos($data, '"name": "') !== false) {
$name = remove_accents(strtolower(substr($full_name, 0, strpos($full_name, ' '))));
$surname = remove_accents(strtolower(substr($full_name, strpos($full_name, ' ') + 1)));
} else {
return false;
}
}
$email_alias = '';
if ($variant == 1) {
$email_alias = $name.'.'.$surname.substr(str_shuffle('0123456789'), 0, mt_rand(1,3));
} elseif ($variant == 1) {
$email_alias = $surname.'.'.$name.substr(str_shuffle('0123456789'), 0, mt_rand(1,3));
} elseif ($variant == 3) {
$email_alias = $name.'.'.$surname.substr(str_shuffle('0123456789'), 0, mt_rand(1,3));
} elseif ($variant == 4) {
if (mt_rand(0,1) == 1) {
$email_alias = $name;
if (mt_rand(0,2) == 1) {
$email_alias .= $surname;
} else {
$email_alias .= substr(str_shuffle('0123456789'), 0, mt_rand(1,3));
}
} else {
$email_alias = $surname;
if (mt_rand(0,2) == 1) {
$email_alias .= $name;
} else {
$email_alias .= substr(str_shuffle('0123456789'), 0, mt_rand(1,3));
}
}
} elseif ($variant == 5) {
if (mt_rand(0,1) == 1) {
$email_alias = $name;
if (mt_rand(0,2) == 1) {
$email_alias .= $surname;
}
} else {
$email_alias = $surname;
if (mt_rand(0,2) == 1) {
$email_alias .= $name;
}
}
} else {
if (mt_rand(0,1) == 1) {
$email_alias = $name;
if (mt_rand(0,1) == 1) {
$email_alias .= $surname;
if (mt_rand(0,2) == 1) {
$email_alias .= mt_rand(1960,2020);
}
} else {
$email_alias .= substr(str_shuffle('0123456789'), 0, mt_rand(1,3));
}
} else {
$email_alias .= $name;
if (mt_rand(0,1) == 1) {
if (mt_rand(0,1) == 1) {
$email_alias .= mt_rand(1960,2020);
}
$email_alias .= $surname;
} else {
$email_alias .= substr(str_shuffle('0123456789'), 0, mt_rand(1,3));
}
}
}
$email_domains = array("gmx.bz", "gmx.ac"); // "secmail.be", "kermail.eu", "webmel.xyz", "flowmail.info", "mailgen.me", "cooool.eu", "zymbra.eu", "heromail.xyz", "zoezgz.me", "superbmail.uk", "jolimail.fr", "lookmail.be", "yeahmail.eu", "legacymail.xyz", "privamail.me", "hoaxmail.net", "justmail.mx", "privamail.fr", "topemail.be", "zeomail.net", "obomel.be", "sumail.fr", "alimel.net", "mdss.be", "hopmail.be", "ideamail.eu", "barmel.xyz", "pogbamail.eu", "atozmel.info", "elgato.cc", "elpotro.xyz", "megusto.me", "supersecuremail.com", "pobremail.net", "mymailin.net", "mailprotredir.co", "fwmail.eu"
foreach ($exclude_domains as $i => $exclude_domain) {
if (in_array($exclude_domain, $email_domains)) {
unset($email_domains[$i]);
}
}
$email_domains = array_values($email_domains);
return array('name' => $name, 'surname' => $surname, 'alias' => $email_alias, 'domain' => $email_domains[mt_rand(0, count($email_domains) - 1)]);
}
/**
* Extract txid from different response formats:
* - Already a 64-char txid
* - JSON string with "hex" field
* - "true,[hex]" CSV-style
*
* @param string $input
* @return string|null
*/
function extract_crypto_txid($input, $input2 = '') {
$input = trim($input);
// Case 1: Already a txid (64 hex chars)
if (preg_match('/^[0-9a-fA-F]{64}$/', $input)) {
return strtolower($input);
}
// Case 2: Electrum JSON with "hex"
$data = json_decode($input, true);
if (json_last_error() === JSON_ERROR_NONE && isset($data['hex'])) {
return get_crypto_txid($data['hex']);
}
// Case 3: "true,[hex]"
if (preg_match('/^true,\s*([0-9a-fA-F]+)$/i', $input, $m)) {
return get_crypto_txid($m[1]);
}
if ($input2 != '') {
$input2 = trim($input2);
// Case 4: Already a txid (64 hex chars)
if (preg_match('/^[0-9a-fA-F]{64}$/', $input2)) {
return strtolower($input2);
}
}
return null;
}
/**
* Compute crypto transaction ID (txid) from raw hex.
*
* @param string $hex Raw transaction hex
* @return string Transaction ID (big-endian hex)
*/
function get_crypto_txid($hex) {
// hex → binary
$bin = hex2bin($hex);
if ($bin === false) {
return null; // invalid hex
}
// double SHA256
$hash1 = hash("sha256", $bin, true);
$hash2 = hash("sha256", $hash1, true);
// reverse byte order for display
return bin2hex(strrev($hash2));
}
function isoToSqlDatetime($isoString) {
// Example input: 2025-11-30T18:14:50.2630613Z
// 1. Remove trailing Z if present
$clean = rtrim($isoString, 'Z');
// 2. Cut off everything after the seconds (first 19 chars)
// Result: 2025-11-30T18:14:50
$clean = substr($clean, 0, 19);
// 3. Replace T with a space for MySQL compatibility
$clean = str_replace('T', ' ', $clean);
// 4. Convert to DateTime (UTC assumed if Z present)
$dt = new DateTime($clean . ' UTC');
$dt->setTimezone(new DateTimeZone('Europe/Paris'));
// 5. Return MySQL datetime format
return $dt->format('Y-m-d H:i:s');
}
function remove_emojis($text) {
return trim(str_replace(' ', ' ', preg_replace(
'/[\x{1F300}-\x{1F6FF}'
. '\x{1F700}-\x{1F77F}'
. '\x{1F780}-\x{1F7FF}'
. '\x{1F800}-\x{1F8FF}'
. '\x{1F900}-\x{1F9FF}'
. '\x{1FA00}-\x{1FAFF}'
. '\x{2600}-\x{26FF}'
. '\x{2700}-\x{27BF}]/u',
'',
$text
)));
}
function remove_accents($string) {
if ( !preg_match('/[\x80-\xff]/', $string) )
return $string;
$chars = array(
// Decompositions for Latin-1 Supplement
chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
chr(195).chr(191) => 'y',
// Decompositions for Latin Extended-A
chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
);
$string = strtr($string, $chars);
return $string;
}
function remove4ByteUtf8($string) {
// Match all valid UTF-8 sequences up to 3 bytes, excluding 4-byte sequences
return preg_replace('/[\xF0-\xF7][\x80-\xBF]{3}/', '', $string);
}
function expand_ipv6($ip) {
// Handle ::
if (strpos($ip, '::') !== false) {
$parts = explode('::', $ip, 2);
$left = ($parts[0] !== '') ? explode(':', $parts[0]) : array();
$right = ($parts[1] !== '') ? explode(':', $parts[1]) : array();
$missing = 8 - (count($left) + count($right));
$mid = array_fill(0, $missing, '0000');
$full = array_merge($left, $mid, $right);
} else {
$full = explode(':', $ip);
}
// Zero-pad 4 hex digits
foreach ($full as $k => $v) {
$full[$k] = str_pad($v, 4, '0', STR_PAD_LEFT);
}
return $full;
}
function ipv6_to_prefix($ip, $prefix) {
$parts = expand_ipv6($ip); // always 8 hextets
// Number of full hextets included by prefix
$full = floor($prefix / 16);
$bits = $prefix % 16; // leftover bits (0,4,8,12)
$out = array();
// Copy fully included hextets
for ($i = 0; $i < $full; $i++) {
$out[] = $parts[$i];
}
// Handle partial hextet
if ($bits > 0) {
// each hextet = 4 hex digits = 16 bits → each nibble = 4 bits
$nibbles = $bits / 4;
$h = substr($parts[$full], 0, $nibbles) . str_repeat("0", 4 - $nibbles);
$out[] = $h;
}
// Fill the rest with 0000
while (count($out) < 4) {
$out[] = "0000";
}
return implode(":", $out) . "::/" . $prefix;
}
function rsa_mgf1($mgfSeed, $maskLen) {
$hashType = 'sha256';
$hashLen = 32;
$t = '';
$count = ceil($maskLen / $hashLen);
for ($i = 0; $i < $count; $i++) {
$c = pack('N', $i);
$t .= hash($hashType, $mgfSeed . $c, true);
}
return substr($t, 0, $maskLen);
}
function rsa_emsa_pss_encode($m, $emBits, $saltLen = 32) {
$hashType = 'sha256';
$hashLen = 32;
$emLen = $emBits + 1 >> 3;
$mHash = hash($hashType, $m, true);
if ($emLen < $hashLen + $saltLen + 2) {
return false;
}
$salt = openssl_random_pseudo_bytes($saltLen);
$m2 = "\0\0\0\0\0\0\0\0" . $mHash . $salt;
$h = hash($hashType, $m2, true);
$ps = str_repeat(chr(0), $emLen - $saltLen - $hashLen - 2);
$db = $ps.chr(1).$salt;
$dbMask = rsa_mgf1($h, $emLen - $hashLen - 1);
$maskedDB = $db ^ $dbMask;
$maskedDB[0] = ~chr(0xff << ($emBits & 7)) & $maskedDB[0];
$em = $maskedDB . $h . chr(0xbc);
return $em;
}
function rsassa_pss_sign($key, $plainText, $rawOutput = false) {
$privatePEMKey = openssl_pkey_get_private($key);
$privateKeyDetails = openssl_pkey_get_details($privatePEMKey);
$encryptedData = rsa_emsa_pss_encode($plainText, $privateKeyDetails['bits'] - 1);
if ($encryptedData) {
$signature = '';
$encryptionOk = openssl_private_encrypt($encryptedData, $signature, $privatePEMKey, OPENSSL_NO_PADDING);
if ($encryptionOk === false) {
return false;
}
if ($rawOutput) {
return $signature;
} else {
return base64_encode($signature);
}
}
return false;
}
function guidv4() {
$data = openssl_random_pseudo_bytes(16);
$data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}
function cloudflare_clearance($cloudflare_domain, $ip = '', $https = true, $proxy = false, $proxy_port = 80) {
$cloudflare_html = '';
if (strpos($cloudflare_domain, 'before accessing ') !== false) {
$cloudflare_html = $cloudflare_domain;
$cloudflare_domain = pregme($cloudflare_html, 'before accessing ', '.');
}
$filename = '/tmp/cloudflare_'.str_replace('.', '_', $ip).'_'.str_replace('.', '_', $cloudflare_domain).'.cookie';
if (is_file($filename)) {
$cookie_cloudflare = file_get_contents($filename);
} else {
$cookie_cloudflare = '';
}
if ($cloudflare_html == '') {
if ($proxy) {
$cloudflare_html = proxy_cookie_get($ip, $proxy_port, (($https)?'https://':'http://').$cloudflare_domain.'/', $cookie_cloudflare);
} else {
$cloudflare_html = header_cookie_get_ip($ip, (($https)?'https://':'http://').$cloudflare_domain.'/', $cookie_cloudflare);
}
}
if (strpos($cloudflare_html, 'cf-browser-verification') !== false OR strpos($cloudflare_html, 'complete_sec_check') !== false) {
if (strpos($cloudflare_html, 'complete_sec_check') !== false) { // Direct Captcha
$cloudflare_clear = $cloudflare_html;
} else {
if (get_cookies($cloudflare_html, '__cfduid') != '') {
$cookie_cloudflare = get_cookies($cloudflare_html, '__cfduid');
}
$enc_js = "var document = {};
var location = {hash:''};
document.getElementById = (function (id) { return document.documentElement; });
document.createElement = (function (id) { return {firstChild:{href:'".(($https)?'https://':'http://').$cloudflare_domain.'/'."'}}; });
document.documentElement = {};
document.documentElement.innerHTML = ".((strpos($cloudflare_html, '&1'); $js_output = ob_get_contents();
ob_end_clean();
$out = (float)$js_output;
unlink('/tmp/'.$rand.'.js');
}
sleep(4);
if (strpos($cloudflare_html, 'name="r" value="') !== false) {
if ($proxy) {
$cloudflare_clear = proxy_cookie_post($ip, $proxy_port, (($https)?'https://':'http://').$cloudflare_domain.pregme($cloudflare_html, 'id="challenge-form" action="', '"'), "r=".rawurlencode(trim(pregme($cloudflare_html, 'name="r" value="', '"')))."&jschl_vc=".rawurlencode(trim(pregme($cloudflare_html, 'get_config();
if (isset($_SERVER['HTTP_USER_AGENT'])) {
header('X-Served-By: '.get_server_name());
}
?>