mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 13:19:54 +00:00
36 lines
753 B
JavaScript
36 lines
753 B
JavaScript
// $ zip -r test.ipa /bin/ls /bin/sleep /etc/services
|
|
// $ r2 -qi unzip.r2.js --
|
|
|
|
const fileName = "test.ipa";
|
|
const tempDir = "tmpdir";
|
|
|
|
function walkDirectories(path, callback) {
|
|
const files = r2.callj(`ls -j ${path}`);
|
|
for (let file of files) {
|
|
if (file.name.startsWith(".")) {
|
|
continue;
|
|
}
|
|
const fullPath = `${path}/${file.name}`;
|
|
if (file.isdir) {
|
|
walkDirectories(fullPath, callback);
|
|
} else {
|
|
file.path = fullPath;
|
|
callback(file);
|
|
}
|
|
}
|
|
}
|
|
|
|
function main() {
|
|
r2.call(`!rm -rf ${tempDir}`)
|
|
r2.call(`!unzip ${fileName} -d ${tempDir}`);
|
|
walkDirectories(tempDir, (file) => {
|
|
console.log("==> " + file.path);
|
|
r = r2pipe.open(file.path);
|
|
console.log(r.cmd("o"))
|
|
r.quit();
|
|
});
|
|
r2.call(`!rm -rf ${tempDir}`)
|
|
}
|
|
|
|
main();
|