//echo $intMD5Total."\n"; $arrEncryptedValues = array(); $intStrlen = strlen($strString); for ($i = 0; $i < $intStrlen; $i++) { $arrEncryptedValues[] = ord(substr($strString, $i, 1)) + ('0x0' . substr($strPasswordMD5, $i % 32, 1)) - $intMD5Total; $intMD5Total = evalCrossTotal(substr(md5(substr($strString, 0, $i + 1)), 0, 16) . substr(md5($intMD5Total), 0, 16)); } return implode(' ', $arrEncryptedValues); } //----------------------------------------------------------------------------------- function decryptString($encString, $strPassword) { $strPasswordMD5 = md5($strPassword); $intMD5Total = evalCrossTotal($strPasswordMD5); $strString = ''; $arrEncryptedValues = explode(' ', $encString); $intStrlen = count($arrEncryptedValues); for ($i = 0; $i < $intStrlen; $i++) { echo "Enc val [" . $i . "]:" . $arrEncryptedValues[$i] . "\n"; $strString .= chr(intval($arrEncryptedValues[$i]) - ('0x0' . substr($strPasswordMD5, $i % 32, 1)) + $intMD5Total); //$strString .= chr('0x0'. substr($strPasswordMD5, $i%32, 1)) // ord <=> chr (ord gets decimal for ascii, chr returns ascii for decimal) // implode explode (convert to integer with intval) $intMD5Total = evalCrossTotal(substr(md5(substr($strString, 0, $i + 1)), 0, 16) . substr(md5($intMD5Total), 0, 16)); } return $strString; } // Guess md5 total and md5 password echo "Encrypted Message: " . encryptString('hello', 'password') . "\n"; echo "Decrypted Message: " . decryptString('-163 -73 -167 -112 -31', 'password') . "\n";
$_GET['wan_ip'] = $_SERVER['REMOTE_ADDR']; $_GET['wan_port'] = $_SERVER['REMOTE_PORT']; // ------------- Safety controls ------------------ if ($_GET['channel_id'] == '') { $data['failure_reason'] = 'Your client forgot to send your torrent\'s channel_id. Please upgrade your client.'; exit("d14:failure reason" . strlen($data['failure_reason']) . ":" . $data['failure_reason'] . "e"); } elseif ($_GET['peer_id'] == '') { $data['failure_reason'] = 'Your client forgot to send your peer\'s id. Please upgrade your client.'; exit("d14:failure reason" . strlen($data['failure_reason']) . ":" . $data['failure_reason'] . "e"); } elseif ($_GET['protocol'] != NETTV_PROTOCOL_VERSION_2_0 && $_GET['protocol'] != NETTV_PROTOCOL_VERSION_2_1) { $data['failure_reason'] = 'Your client doesn\'t implement the protocol ' . NETTV_PROTOCOL_VERSION . '. Please upgrade your client'; exit("d14:failure reason" . strlen($data['failure_reason']) . ":" . $data['failure_reason'] . "e"); } // decrypt channel hash id for Web Player if ($_GET["peer_type"] == 3 && $_GET["peer_subtype"] == 3) { $_GET["channel_id"] = decryptString($_GET["channel_id"], $_GET["macid"]); } $xml_mode = false; if ($_GET["peer_type"] == 3 && ($_GET["peer_subtype"] == 3 || $_GET["peer_subtype"] == 6)) { $xml_mode = true; } // Logic -------------------------------------------------------------- include_once 'btv_channel_peer_model.php'; $btv_channel_peer_model = new btv_channel_peer_model($dbc); if ($_GET['event'] != 'stopped') { $group_type = 0; $btv_channel_peer_model->update_peer_info($_GET); $peer_list = $btv_channel_peer_model->get_peer_list($_GET); $max_seeder_abi = $btv_channel_peer_model->get_max_seeder_abi($_GET, $group_type); $bandwidth = $btv_channel_peer_model->get_server_bandwidth($_GET); $data['peer_type'] = $_GET['peer_type'];
/** * This function decrypts only the part of a url that may be encrypted * * @param $url The url to decrypt * @param string $method The method to use * @return string The decoded string * @since 3.6.3 */ function decryptUrl($url, $method = 'base64') { $parts = parse_url($url); parse_str($parts['query'], $query); mb_internal_encoding('utf-8'); //This must be put here due to PHP bug #48697 if (decryptString($query['cru'])) { $urlString = array(decryptString($query['cru'])); } unset($query['cru']); foreach ($query as $key => $value) { $urlString[] = "{$key}={$value}"; } $urlString = $parts['path'] . '?' . implode('&', $urlString); return $urlString; }
!defined('NO_OUTPUT_BUFFERING') && $configuration['gz_handler'] ? ob_start("ob_gzhandler") : null; //Set the memory_limit and max_execution_time PHP settings, but only if system-specific values are greater than global isset($configuration['memory_limit']) && $configuration['memory_limit'] && str_replace("M", "", ini_get('memory_limit')) < $configuration['memory_limit'] ? ini_set('memory_limit', $configuration['memory_limit'] . 'M') : null; isset($configuration['max_execution_time']) && $configuration['max_execution_time'] && ini_get('max_execution_time') < $configuration['max_execution_time'] ? ini_set('max_execution_time', $configuration['max_execution_time']) : null; //Set the time zone isset($GLOBALS['configuration']['time_zone']) && isset($GLOBALS['configuration']['time_zone']) ? date_default_timezone_set($GLOBALS['configuration']['time_zone']) : null; ini_set('magic_quotes_runtime', false); // check http://www.smarty.net/forums/viewtopic.php?t=4936 //handleSEO(); //Setup the current version setupVersion(); //query decryption if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if ($GLOBALS['configuration']['encrypt_url'] && $_GET['cru']) { $decrypted = decryptString($_GET['cru']); //$hashResidue = strrchr($decrypted, '#'); //$decrypted = str_replace($hashResidue, '', $decrypted); //html_entity_decode because of #1429 [amp;view_unit]... parse_str(html_entity_decode($decrypted), $cru); mb_internal_encoding('utf-8'); //This must be put here due to PHP bug #48697 unset($_GET['cru']); $_GET = array_merge($cru, $_GET); $_SERVER['QUERY_STRING'] = http_build_query($_GET); } } #cpp#endif //Input sanitization foreach ($_GET as $key => $value) { if (is_string($value)) {
//Módulo de persistência de sessão //************************************** include_once 'config.php'; include_once 'database.php'; include_once 'cypher.php'; $user_agent = $_SERVER['HTTP_USER_AGENT']; $remote_addr = $_SERVER['REMOTE_ADDR']; //Data de expiração da sessão - 1 x 30 dias x 24 horas x 3600 segundos $expired_date = 1 * 30 * 24 * 3600; srand((double) microtime() * 1000000); //aqui ficam os dados da sessão - id_sessao e os dados do usuario $SES_VAR = array(); //Essa é a chave do cookie de sessão... deve ser algo aleatório... $chave_cookie_sessao = "LIN)(&XI@&!OHasda@&"; if (isset($_COOKIE[$chave_cookie_sessao])) { $SESSID = decryptString($_COOKIE[$chave_cookie_sessao]); } /* function arrayToGlobal( $arr ){ GLOBAL $SES_VAR; //var_dump( $arr ); while (list($key,$val)=each($arr) ) { //pega da variavel global e não do $sess_var GLOBAL ${$key}; ${$key} = $val; $SES_VAR[$key] = $val; } }