-
Notifications
You must be signed in to change notification settings - Fork 0
/
webos-ipk-dump.php
101 lines (79 loc) · 2.29 KB
/
webos-ipk-dump.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
<?php
$token = 'PALM_PROFILE_TOKEN';
$deviceId = 'DEVICE_PROFILE_NDUID';
// Save "Installed Apps" from Impostah as plaintext .json
$inputFile = 'ipkdump.json';
function downloadIPK($token, $deviceId, $IPKUrl)
{
$IPKUrl = str_replace('cdn.downloads.palm.com', 'cdn.downloads.hpsvcs.com', $IPKUrl);
$savefile = getAppFilename($IPKUrl);
$outputfile = "./cache/{$savefile}";
echo "{$savefile}";
if(!file_exists("{$outputfile}")) {
$cmd = "wget -q \"$IPKUrl\" -O {$outputfile} --header=\"Auth-Token: {$token}\" --header=\"Device-Id: {$deviceId}\"";
exec($cmd);
echo "...saved!\r\n";
} else {
echo "...already cached!\r\n";
}
}
function getAppFilename($IPKUrl)
{
return basename(parse_url($IPKUrl, PHP_URL_PATH));
}
function readIPKjson($inputFile)
{
$contents = file_get_contents($inputFile);
$contents = utf8_encode($contents);
$results = json_decode($contents);
return $results;
}
function createZip($appList, $deviceId)
{
$z = new ZipArchive();
$z->open("ipkdump_{$deviceId}.zip", ZIPARCHIVE::CREATE);
foreach($appList as $app) {
$appFilename = getAppFilename($app->appLocation);
$z->addFile("./cache/{$appFilename}", $appFilename);
}
$z->close();
echo "\r\nDone saving ipkdump_{$deviceId}.zip\r\n";
}
function createTar($appList, $deviceId)
{
$a = new PharData("ipkdump_{$deviceId}.tar");
foreach($appList as $app) {
$appFilename = getAppFilename($app->appLocation);
$a->addFile("./cache/{$appFilename}", $appFilename);
}
echo "\r\nDone saving ipkdump_{$deviceId}.tar\r\n";
}
function createTarExec($appList, $deviceId)
{
$files = "";
$a = new PharData("ipkdump_{$deviceId}.tar");
foreach($appList as $app) {
$appFilename = getAppFilename($app->appLocation);
$files = $files . " ./cache/{$appFilename}";
}
$cmd = "tar -cvf ipkdump_{$deviceId}.tar{$files}";
exec($cmd);
echo "\r\nDone saving ipkdump_{$deviceId}.tar\r\n";
}
if (!file_exists('./cache')) {
mkdir('./cache', 0777, true);
}
$appList = readIPKjson($inputFile);
foreach($appList as $app) {
echo "\r\n{$app->title}\r\n";
downloadIPK($token, $deviceId, "{$app->appLocation}");
}
echo "\r\nCreating archive of all your IPKs...";
// Fastest
createTarExec($appList, $deviceId);
// Only use these if exec is not available
// Medium
// createTar($appList, $deviceId);
// Slowest
//createZip($appList, $deviceId);
?>