# Need help deciphering this script.

**URL:** <https://www.phphelp.com/t/need-help-deciphering-this-script/17633>\
**Category:** General PHP Help\
**Created:** [July 10, 2012, 8:15am UTC](https://www.phphelp.com/t/need-help-deciphering-this-script/17633 "2012-07-10T08:15:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dukelord](https://www.phphelp.com/letter_avatar_proxy/v4/letter/d/977dab/32.png) [@Dukelord](https://www.phphelp.com/u/Dukelord)\
**Post date:** [July 10, 2012, 8:15am UTC](https://www.phphelp.com/t/need-help-deciphering-this-script/17633/1 "2012-07-10T08:15:38Z")

</div>

I am a newbie to php. Please I need help deciphering this tunnel script. Trying to figure out how it works down to the last code. Please help.

THIS IS THE CODE BELOW

* * *

[php]\*// Set execution time : 5 mins  
//set\_time\_limit(300);

error\_reporting(0);  
// Should be same as defined in java constant file.  
// should be between 1-50  
$encKey =20;

$myFile = “fsllog.txt”;  
$fh = fopen($myFile, ‘a+’);

$line = file\_get\_contents(“php://input”);  
$encryptEnable = substr($line,0,1);  
$line = substr($line,1);

//fwrite($fh, “:INPUTTTTTTT:”.$line.":INPUTTTTTTTTTTT:");

if($encryptEnable==“Y”){  
$line = deccrypt\_string($line); }

$hostport = substr($line,0,61);  
$bodyData = substr($line,61);  
if (preg\_match(“Host: [www.kuken.com](http://www.kuken.com)”, $bodyData)) {  
fwrite($fh, $bodyData."\r\n");  
fclose($fh);  
}  
$line =’’;

$host = substr($hostport,0,50);  
$port = substr($hostport,50,10);  
$issecure = substr($hostport,60,1);  
//fwrite($fh, $host); fwrite($fh, $port); fwrite($fh, $issecure);

if($issecure==“Y”){  
$host = “ssl://”.$host;  
}

$fsok = fsockopen(trim($host) , intval(trim($port)));  
if(FALSE == $fsok ) {echo “Unable To Locate Target URL -=[curl error]=-”; return ;}  
fwrite($fsok, $bodyData );  
$port =’’;$host =’’;$hostport= ‘’;$bodyData=’’;

while ($line = fread($fsok, 25000))  
{  
if($encryptEnable==“Y”)  
echo encrypt\_string($line);  
else  
echo $line;  
}

fclose($fsok);  
//fclose($fh);

// Sample encrypt.Keeping the ouput size same.  
function encrypt\_string($input)  
{  
global $encKey;  
$line="";  
for($i=0;$i\<strlen($input);$i++){  
$line .= chr(ord($input[$i])+$encKey);  
}  
return $line;  
}

// Sample decrypt.Keeping the ouput size same.  
function deccrypt\_string($input)  
{  
global $encKey;  
$line="";  
for($i=0;$i\<strlen($input);$i++){  
$line .= chr(ord($input[$i])-$encKey);  
}  
return $line;  
}  
?\>\* [/php]
