forked from dank074/habbo-asset-extractor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mask.php
255 lines (213 loc) · 7.26 KB
/
mask.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<?php
ini_set("display_errors", 1);
set_time_limit(0);
define('OUTPUT_DIRECTORY', dirname(__FILE__) . '/download/');
define('OFFICIAL_RES_URL', "https://www.habbo.com/");
define('FLASH_CLIENT_URL', "http://habboo-a.akamaihd.net/gordon/PRODUCTION-201506301513-456128588/");
?>
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: #000;
color: #fff;
font-family: monospace;
font-size: 12px;
}
ul {
padding: 0;
margin: 0;
display: block;
}
ul li {
display: block;
height: 1em;
line-height: 1em;
margin: 0;
position: relative;
}
ul li.remove-previous-line {
margin-top: -1em;
}
ul li.ta {
height: auto;
}
ul li.ta textarea {
width: 100em;
height: 10em;
}
ul li p {
padding: 0;
margin: 0;
width: 100%;
height: 1em;
}
ul li p span {
color: #f88;
}
ul li p:last-child {
background-color: #000;
}
</style>
<script>
var complete = false;
var flushingData = function () {
if (document.body) {
window.scrollTo(0, document.body.scrollHeight);
removePreviousLine();
}
if (complete) return;
if (requestAnimationFrame)
requestAnimationFrame(flushingData);
};
flushingData();
var removePreviousLine = function () {
var lines = document.getElementById('console-lines').children;
for (var i = 0; i < lines.length; i++) {
if (lines[i].nextSibling != null && lines[i].className == 'remove-previous-line' && lines[i].nextSibling.className == 'remove-previous-line') {
lines[i].remove();
}
}
};
window.onload = removePreviousLine;
</script>
</head>
<body>
<ul id="console-lines">
<?php
ob_end_flush();
ob_start('mb_output_handler');
function consoleLog($message, $prevRemove = false)
{
$sp = '';
if ($prevRemove) $sp = ' class="remove-previous-line"';
$message = str_replace("\r", '</p><p>', $message);
$message = str_replace(" ", ' ', $message);
echo '<li' . $sp . '><p>' . $message . '</p></li>';
ob_flush();
flush();
}
function consoleLogBlank()
{
echo '<li class="blank"></li>';
ob_flush();
flush();
}
function consoleLogProgressBar($current, $size, $unit = "kb")
{
$length = (int)(($current / $size) * 100);
$str = sprintf("\r[%-100s] %3d%% (%2d/%2d%s)", str_repeat("=", $length) . ($length == 100 ? "" : ">"), $length, ($current / ($unit == "kb" ? 1024 : 1)), $size / ($unit == "kb" ? 1024 : 1), " " . $unit);
consoleLog($str, true);
}
function checkDIR($path)
{
if (!is_dir($path)) mkdir($path, 0777);
}
function file_get_contents_with_console($filename)
{
consoleLog("Download: " . $filename);
$ctx = stream_context_create();
stream_context_set_params($ctx, array("notification" => "stream_notification_callback"));
$data = @file_get_contents($filename, false, $ctx);
if ($data !== false) {
$size = strlen($data);
consoleLogProgressBar($size, $size);
consoleLogBlank();
consoleLogBlank();
return $data;
}
$err = error_get_last();
consoleLog("<span>Error:</span> " . $err["message"]);
consoleLogBlank();
return false;
}
function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max)
{
static $filesize = null;
switch ($notification_code) {
case STREAM_NOTIFY_RESOLVE:
case STREAM_NOTIFY_COMPLETED:
case STREAM_NOTIFY_AUTH_REQUIRED:
case STREAM_NOTIFY_FAILURE:
case STREAM_NOTIFY_AUTH_RESULT:
break;
case STREAM_NOTIFY_REDIRECTED:
consoleLog("Being redirected to: " . $message);
break;
case STREAM_NOTIFY_CONNECT:
consoleLog("Connected...");
break;
case STREAM_NOTIFY_FILE_SIZE_IS:
$filesize = $bytes_max;
consoleLog("Filesize: " . $filesize);
break;
case STREAM_NOTIFY_MIME_TYPE_IS:
consoleLog("Mime-type: " . $message);
break;
case STREAM_NOTIFY_PROGRESS:
if ($bytes_transferred > 0) {
if ($filesize == 0) {
$str = sprintf("\rUnknown filesize.. %2d kb done..", $bytes_transferred / 1024);
consoleLog($str, true);
} else {
consoleLogProgressBar($bytes_transferred, $filesize);
}
}
break;
}
}
function DownloadAll($file_name_swf)
{
consoleLogBlank();
$data = file_get_contents_with_console($file_name_swf);
$file_name = OUTPUT_DIRECTORY . 'HabboRoomContent.swf';
file_put_contents($file_name, $data);
ExtractFlash($file_name);
unlink($file_name);
}
function ExtractFlash($flash_file)
{
consoleLog("Analyzing SWF: $flash_file");
$matches = [];
$swf_output = shell_exec("swfextract $flash_file");
preg_match("/PNGs: ID\(s\) (.+)/", $swf_output, $matches);
$ranges = explode(",", $matches[1]);
$new_ranges = [];
$count = 0;
foreach ($ranges as $index => $value):
if (strpos($value, '-') !== false):
$explode = explode('-', $value);
for ($i = $explode[0]; $i <= $explode[1];)
$new_ranges[$count++] = $i++;
else:
$new_ranges[$count++] = $value;
endif;
endforeach;
$kaka = [];
$hehe = shell_exec("swfdump -s $flash_file");
consoleLog("Extracting SWF: $flash_file");
foreach ($new_ranges as $index => $value):
$name = sprintf("%04d", $value);
preg_match("/exports $name as \"(.+)\"/", $hehe, $kaka);
$real_value = $kaka[1];
$real_value = str_replace('HabboRoomContent_', '', $real_value);
consoleLog("File Name: $real_value");
$file_name = OUTPUT_DIRECTORY . 'masks/' . $real_value . '.png';
shell_exec("swfextract $flash_file -p $value -o \"$file_name\"");
endforeach;
}
consoleLog("<b>Habbo SWF Room Textures resource dump Tool</b>");
consoleLogBlank();
consoleLog("OFFICIAL RESOURCE URL : " . OFFICIAL_RES_URL);
consoleLog("FLASH CLIENT URL : " . FLASH_CLIENT_URL);
consoleLog("OUTPUT PATH : " . OUTPUT_DIRECTORY);
consoleLogBlank();
DownloadAll(FLASH_CLIENT_URL . '/HabboRoomContent.swf');
consoleLog("update complete.");
?>
</ul>
<script> complete = true;
removePreviousLine(); </script>
</body>
</html>