Rip Webbuild
Hello,
Im trying to rip the webbuild with joopie's code but i dont know how to change the webbuild.
The code:
Spoiler :
Code:
<?php
$filter = array(
'://www.habbo.com',
'://images.habbo.com',
'://help.habbo.com',
'://img4.cdn1.habbo.com',
'://img3.cdn1.habbo.com',
'://img2.cdn1.habbo.com',
'://img1.cdn1.habbo.com'
);
$allowed = array(
'css',
'jpg',
'png',
'js',
'gif',
'swf',
'xml'
);
//Don't touch from here!
define('DS', DIRECTORY_SEPARATOR);
define('BASE', str_replace('\\', DS, dirname(__FILE__).DS));
class Grabber
{
private $url_assign;
private $offset = 0;
private $json;
function __Construct($json)
{
$json = json_decode($json);
$json = $this->ToArray($json);
$this->json = $json['log']['entries'];
}
public function ToArray($object = null)
{
$object = ($object == null) ? $this->json : $object;
$return = array();
foreach ((array)$object as $key => $value)
{
if (is_object($value) || is_array($value))
{
$return[$key] = $this->ToArray($value);
continue;
}
$return[$key] = $value;
}
return $return;
}
public function FindNextUrl()
{
if(!isset($this->json[$this->offset]))
{
return false;
}
$request = $this->json[$this->offset]['request'];
$this->url_assign = $request['url'];
$this->offset++;
return true;
}
public function Assign(&$var)
{
$this->url_assign =& $var;
}
public function ResetOffset()
{
$this->offset = 0;
}
public function MaxOffset()
{
return count($this->json);
}
public function CurrentOffset()
{
return $this->offset;
}
}
class Controller
{
public static $css = array();
public static $urls = array();
public static $filter;
public static $allowed;
public static function Handle($url)
{
if (in_array($url, self::$urls))
{
return false;
}
$return = true;
foreach (self::$filter as $check)
{
if (is_int(strpos($url, $check)))
{
$return = false;
}
}
if ($return)
{
return false;
}
$extention = self::Extention($url);
if (!in_array($extention, self::$allowed))
{
return false;
}
self::$urls[] = $url;
if ($extention == 'css')
{
self::$css[] = $url;
}
return true;
}
public static function Extention($url)
{
return end(explode('.', $url));
}
}
class Downloader
{
private $url;
public $file;
public $path;
function __Construct($url)
{
$this->url = $url;
if (!$this->MakePath())
{
echo 'Unable to make path for: '.$this->path."\r\n";
}
if (!$this->Download())
{
echo 'Unable to download: '.$this->file."\r\n";
}
echo 'File downloaded: '.$this->file."\r\n";
}
private function MakePath()
{
$path = str_replace(array('http://', 'https://'), '', $this->url);
$explode = explode('/', $path);
$this->file = array_pop($explode);
$this->path = BASE.'downloads'.DS.implode(DS, $explode);
$new_path = BASE.'downloads';
foreach ($explode as $folder)
{
$new_path .= DS.$folder;
if (file_exists($new_path))
{
continue;
}
if (!@mkdir($new_path))
{
return false;
}
}
return true;
}
private function Download()
{
if (file_exists($this->path.DS.$this->file))
{
return true;
}
$content = file_get_contents($this->url);
if (!($fp = @fopen($this->path.DS.$this->file, "w+")))
{
return false;
}
fputs($fp, $content, strlen($content));
fclose($fp);
return true;
}
}
class CssChecker
{
private $url_assign;
private $offset = 0;
private $content;
public $download;
function __Construct($download)
{
$this->download = $download;
$this->content = file_get_contents($this->download->path.DS.$this->download->file);
}
public function FindNextUrl()
{
if (!($this->offset = strpos($this->content, 'url(', $this->offset)))
{
return false;
}
$this->offset += strlen('url(');
$pos = strpos($this->content, ')', $this->offset);
$this->url_assign = substr($this->content, $this->offset, $pos -$this->offset);
return true;
}
public function ValidUrl($url)
{
$http = 'http://';
$https = 'https://';
if (is_int(strpos($url, $http)) || is_int(strpos($url, $https)))
{
return $url;
}
$url = str_replace('../', '', $url);
$url = 'http://images.habbo.com/habboweb/'.WEBBUILD.'/web-gallery/'.$url;
return str_replace(array('"', '\''), '', $url);
}
public function Assign(&$var)
{
$this->url_assign =& $var;
}
}
echo "\r\nInitialize\r\n\r\n";
Controller::$filter =& $filter;
Controller::$allowed =& $allowed;
$content = file_get_contents('http://www.habbo.com');
$pos = strpos($content, 'http://images.habbo.com/habboweb/') +strlen('http://images.habbo.com/habboweb/');
$pos1 = strpos($content, '/web-gallery/v2/favicon.ico', $pos);
$webbuild = substr($content, $pos, $pos1 -$pos);
define('WEBBUILD', $webbuild);
echo 'Webbuild: '.WEBBUILD."\r\n";
echo "\r\nChecking json files\r\n\r\n";
$glob = glob(BASE.'json_page'.DS.'*.json');
foreach ($glob as $json_url)
{
$url = null;
$json = file_get_contents($json_url);
$json = new Grabber($json);
$json->Assign($url);
echo 'Checking: '.$json_url."\r\n";
echo 'Requests: '.$json->MaxOffset()."\r\n";
while ($json->FindNextUrl())
{
Controller::Handle($url);
}
}
echo "\r\nDownload css files + check for urls\r\n\r\n";
foreach (Controller::$css as $url)
{
$download = new Downloader($url);
$link = null;
$css = new CssChecker($download);
$css->Assign($link);
while ($css->FindNextUrl())
{
$valid = $css->ValidUrl($link);
Controller::$urls[] = $valid;
}
}
echo "\r\nDownload all files\r\n\r\n";
foreach (Controller::$urls as $url)
{
$download = new Downloader($url);
}
echo "\r\nStats:\r\n";
echo 'Downloads: '.count(Controller::$urls)."\r\n";
?>
Re: Rip Webbuild
You need the old Jsons from the older webbuilds, I'm not going to recode this script to replace the webbuild. Well, you could do:
$content = file_get_contents($this->url);
to
$content = file_get_contents(str_replace('old webbuild', 'new webbuild', $this->url));
but I'm not sure if it's going to work.
Re: Rip Webbuild
I have the old one...
Verstuurd van mijn LG-E610 met Tapatalk