Как расшифровать зашифрованные скрипты?

Нашел небольшой движок https://github.com/alsemany/phpmyvideo который парсит видео с ютуба по указанным тегам и выводит в виде ленты. Проблема в том что все закодировано base64, пример https://github.com/alsemany/phpmyvideo/blob/master...
Можно было бы вручную все расшифровать, но это много мороки из-за большого кол-ва зашифрованных файлов.

Как можно ускорить процесс?
  • Вопрос задан
  • 3775 просмотров
Решения вопроса 2
@mat0thew
phpmyvideo / application / libraries / getvids.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class getvids
{


 public function get($url)
    {


// make sure curl is installed
if (function_exists('curl_init')) {
   // initialize a new curl resource
   $ch = curl_init();

   // set the url to fetch
   curl_setopt($ch, CURLOPT_URL,$url);

   // don't give me the headers just the content
   curl_setopt($ch, CURLOPT_HEADER, 0);

   // return the value instead of printing the response to browser
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

   // use a user agent to mimic a browser
   curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7');

$resultdata  = curl_exec($ch);

   // remember to always close the session and free all resources
   curl_close($ch);
} else {
   // curl library is not installed so we better use something else
} 

$rssstring = $resultdata;

 preg_match_all("#<openSearch:totalResults>(.*?)</openSearch:totalResults>#s",$rssstring,$resultcount);

$resultcount = $resultcount[1][0];

preg_match_all("#<item(.*?)</item>#s",$rssstring,$items);
$n=count($items[0]);

for($i=0;$i<$n;$i++){
$rsstemp= $items[0][$i];

preg_match_all("#<media:title(.*?)>(.*?)</media:title>#s",$rsstemp,$titles);
if (isset($titles))
{
$title = $titles[2][0];
}
else
{
$title = 'No title for this video';
}

preg_match_all("#<yt:videoid>(.*?)</yt:videoid>#s",$rsstemp,$vidid);

$vidid = $vidid[1][0];

preg_match_all("#<author>(.*?)</author>#s",$rsstemp,$author);
$author = $author[1][0];

      


preg_match_all("#<yt:uploaded>(.*?)</yt:uploaded>#s",$rsstemp,$published);
$published= $published[1][0];



preg_match_all("#<yt:rating numDislikes='(.*?)' numLikes='(.*?)'/>#s",$rsstemp,$likesrat);
if (isset($likesrat[2][0]))
{
$likes = $likesrat[2][0];
$dislikes = $likesrat[1][0];
}
else
{
$likes = 0;
$dislikes =0;
}

preg_match_all("#<yt:statistics favoriteCount='(.*?)' viewCount='(.*?)'/>#s",$rsstemp,$fave);
if (isset($fave[1][0]))
{
$views = $fave[2][0];
$favecount = $fave[1][0];
}
else
{
$views = '0';
$favecount = '0';

}

preg_match_all("#<media:keywords>(.*?)</media:keywords>#s",$rsstemp,$keys);

if (empty($keys [1][0])) $keys [1][0] = "no, key, words, found, for, this , video";
$keys = $keys [1][0];

$keys = explode (', ',$keys);
  
foreach ($keys as $num => $key)
{

$keys[$num] = array('keyword'=>$key);

}


$thumb = "http://i2.ytimg.com/vi/".$vidid."/default.jpg";


$data[$i] = array( 
					'vidid' => $vidid ,
					'author' => $author ,					
					'vidtitle' => $title , 
					'vidthumb' => $thumb , 
					'vidpublished' => $published , 
					'views' => $views , 
					'favecount' => $favecount , 
					'uploadscount' => $resultcount, 
					'keys'=>$keys , 
					'likes' => $likes ,
					'dislikes' => $dislikes,
					'videofetched' => $n
					) ;

}

 if (empty($data)) { $data[] = 
 array( 
					'vidid' => '' , 
					'vidtitle' => '' , 
					'vidthumb' => '' , 
					'vidpublished' => '' , 
					'views' => '', 
					'favecount' => '' , 
					'uploadscount' => '', 
					'keys'=>'' , 
					'likes' => ''  ,
					'dislikes' => '' ,
					
					) ;
 ; }
return $data;

}


 public function getinfo($id)
    {


// make sure curl is installed
if (function_exists('curl_init')) {
   // initialize a new curl resource
   $ch = curl_init();

   // set the url to fetch
   curl_setopt($ch, CURLOPT_URL,'http://gdata.youtube.com/feeds/api/users/'.$id.'?v=2&alt=rss');

   // don't give me the headers just the content
   curl_setopt($ch, CURLOPT_HEADER, 0);

   // return the value instead of printing the response to browser
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

   // use a user agent to mimic a browser
   curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7');

$resultdata  = curl_exec($ch);

   // remember to always close the session and free all resources
   curl_close($ch);
} else {
   // curl library is not installed so we better use something else
} 

$rssstring = $resultdata;

 preg_match_all("#<author>(.*?)</author>#s",$rssstring,$author);
$data['title'] = $author[0][0];



preg_match_all("#<yt:aboutMe>(.*?)</yt:aboutMe>#s",$rssstring,$aboutme);
if (isset($aboutme[0][0]))
{
$data['aboutme'] = $aboutme[0][0];
}
else
{
$data['aboutme'] = 'nothing';
}

preg_match_all("#<yt:firstName>(.*?)</yt:firstName>#s",$rssstring,$firstname);
if (isset($firstname[1][0]))
{
$data['firstname'] = $firstname[1][0];
}
else
{
$data['firstname'] = $data['title'];
}

preg_match_all("#<yt:statistics lastWebAccess='(.*?)' subscriberCount='(.*?)' videoWatchCount='(.*?)' viewCount='(.*?)' totalUploadViews='(.*?)'/>#s",$rssstring,$info);

$data['lastaccess'] = $info[1][0];
$data['subscriberCount'] = $info[2][0];
$data['videoWatchCount'] = $info[3][0];
$data['viewCount'] = $info[4][0];
$data['totalUploadViews'] = $info[5][0];

preg_match_all("#<media:thumbnail url='(.*?)'/>#s",$rssstring,$thumb);
$data['thumb'] = $thumb[1][0];






preg_match_all("#<yt:location>(.*?)</yt:location>#s",$rssstring,$location);
$data['location'] = $location[1][0];

  
return $data;

}

}


?>
Ответ написан
Комментировать
@Ualde
function getListFiles($folder, &$all_files){
	$fp = opendir($folder);
	while ($cv_file = readdir($fp)) {
		if (is_file($folder."/".$cv_file)) $all_files[] = $folder . "/" . $cv_file;
		elseif ($cv_file != "." && $cv_file != ".." && is_dir($folder . "/" . $cv_file)) getListFiles($folder . "/" . $cv_file, $all_files);
	}
	closedir($fp);
}
$all_files = array();
getListFiles("alsemany/phpmyvideo", $all_files);


foreach ($all_files as $file) {
	$code = file_get_contents($file);
	$code = base64_decode($code);
	file_put_contents($file, $code);
}
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы