Skip to content

Instantly share code, notes, and snippets.

@bayleedev
Created June 14, 2016 07:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bayleedev/7282dbd2ef125b89f28ecd2d82675909 to your computer and use it in GitHub Desktop.
Save bayleedev/7282dbd2ef125b89f28ecd2d82675909 to your computer and use it in GitHub Desktop.
extract slack
<?php
function isDirectory($file, $items) {
if (strpos($file, '.') !== false) {
return false; // nothing with a dot is a directory
}
$regex = "/^" . preg_quote($file, '/') . "\//";
foreach ($items as $item) {
if (!!preg_match($regex, $item)) {
return true; // it found things inside!
}
}
}
$files = explode("\n", trim(file_get_contents('./file.data')));
$extractDir = getcwd() . DIRECTORY_SEPARATOR . 'ext';
$prefix = '../';
echo "cd " . $extractDir . PHP_EOL;
foreach ($files as $key => $file) {
if (isDirectory($file, array_slice($files, $key))) {
echo "cd " . $extractDir . PHP_EOL;
echo "mkdir -p $file" . PHP_EOL;
echo "cd $file" . PHP_EOL;
$prefix = str_repeat('../', 1 + count(explode('/', $file)));
} else if (strpos($file, '/.') === false) {
echo "asar extract-file {$prefix}app.asar {$file}" . PHP_EOL;
}
}
rm -rf ext && mkdir ext
asar list ./app.asar | sed 's/^.//' | grep -v '\.cache' > file.data
php extract.php > extract.sh
chmod +x extract.sh
./extract.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment