/* * DLC (Download Link Container) Decrypter in PHP * * @param $str_filename path to dlc file * @param $return_array return links in an array or as a string seperated by a new-line character * * @author * Christian Lange - * * @link * http://www.ganz-sicher.net/chlange * * @date * 03 November 2010 */ function decrypt_dlc($str_filename, $return_array) { if(!isset($str_filename) || !isset($return_array) || empty($str_filename) || empty($str_filename) || !file_exists($str_filename)) die("Pass correct parameter"); $return_array ? $links = array() : $links = ''; $key = 'xxxx'; $IV = 'xxxx'; $dlc_whole_content = file_get_contents($str_filename); $dlc_content = substr($dlc_whole_content, 0, -88); //base64 encoded dlc content $dlc_content = base64_decode($dlc_content); //dlc content $dlc_key = substr($dlc_whole_content, -88); //dlc key /* * Send an HTTP-Request, remove and of response and decode it with base64 */ $result = file_get_contents("http://service.jdownloader.org/dlcrypt/service.php?destType=load&srcType=dlc&data=$dlc_key"); $result = explode("", $result); $result = explode("",$result[1]); $result = $result[0]; $result = base64_decode($result); if(empty($result)) die("Got wrong or no response from server!"); /* * Decrypt the base64 decoded server response * (128 Bit AES in CBC mode with your key and IV) */ $hdlDLCCrypt = mcrypt_module_open(MCRYPT_RIJNDAEL_128,'','cbc',''); @mcrypt_generic_init($hdlDLCCrypt,$key,$IV); $dlckey = mdecrypt_generic($hdlDLCCrypt, $result); /* * Decrypt your content * (128 Bit AES in CBC mode with your previously decrypted result as key and IV) */ $hdlDLCCrypt = mcrypt_module_open(MCRYPT_RIJNDAEL_128,'','cbc',''); @mcrypt_generic_init($hdlDLCCrypt,$dlckey,$dlckey); $data = mdecrypt_generic($hdlDLCCrypt, $dlc_content); $data = base64_decode($data); /* * Simple and dirty XML parsing */ $parser = xml_parser_create(); xml_parse_into_struct($parser, $data, $vals); xml_parser_free($parser); for($i = 0;; ++$i) { if($vals[$i]["tag"] == "DLC" && $vals[$i]["type"] == "close") // break at (end of dlc content) break; if($vals[$i]["tag"] == "URL") // filter the links { /* * [...]___LINKS___[...] */ $return_array ? $links[] = base64_decode($vals[$i]["value"]) // append link to array : $links .= base64_decode($vals[$i]["value"])."\n"; // append link to string } } return $links; }