forked from radareorg/radare2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of r_io.zip plugin
Allows to: r2 zip://foo.apk//classes.dex Honor LDFLAGS in r_bin Fix filename issue in r_io_redirect Add testing on-activate event in r2w2
- Loading branch information
Showing
27 changed files
with
134 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* radare - LGPL - Copyright 2012 - pancake */ | ||
|
||
#include <r_io.h> | ||
#include <r_lib.h> | ||
#include <r_util.h> | ||
|
||
static int __plugin_open(RIO *io, const char *file) { | ||
if (!memcmp (file, "zip://", 6) && file[6]) | ||
return R_TRUE; | ||
return R_FALSE; | ||
} | ||
|
||
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) { | ||
char *p, *str, cmd[1024]; | ||
if (__plugin_open (io, file)) { | ||
str = strdup (file+6); | ||
p = (char *)r_str_casestr (str, "//"); | ||
if (p) { | ||
*p++ = 0; | ||
// TODO: escape quotes | ||
// TODO: add support for directories | ||
snprintf (cmd, sizeof (cmd), "unzip -o '%s' '%s'", str, p+1); | ||
if (system (cmd) == 0) | ||
r_io_redirect (io, p+1); | ||
} else { | ||
snprintf (cmd, sizeof (cmd), "unzip -l '%s' |grep -e '[0-9][0-9]-[0-9][0-9]'| awk '{print $4}'", str); | ||
if (system (cmd) != 0) | ||
eprintf ("Use zip://<path-to-zip>//<path-inside-zip>\n"); | ||
} | ||
free (str); | ||
return NULL; | ||
} | ||
r_io_redirect (io, NULL); | ||
return NULL; | ||
} | ||
|
||
struct r_io_plugin_t r_io_plugin_zip = { | ||
.name = "zip", | ||
.desc = "Open files inside zip archives zip://whatsapp.apk/classes.dex", | ||
.open = __open, | ||
.plugin_open = __plugin_open, | ||
.lseek = NULL, | ||
.system = NULL, | ||
.debug = (void *)1, | ||
}; | ||
|
||
#ifndef CORELIB | ||
struct r_lib_struct_t radare_plugin = { | ||
.type = R_LIB_TYPE_IO, | ||
.data = &r_io_plugin_zip | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
OBJ_ZIP=io_zip.o | ||
|
||
STATIC_OBJ+=${OBJ_ZIP} | ||
TARGET_ZIP=io_zip.${EXT_SO} | ||
ALL_TARGETS+=${TARGET_ZIP} | ||
|
||
ifeq (${WITHPIC},0) | ||
LINKFLAGS+=../../util/libr_util.a | ||
LINKFLAGS+=../../lib/libr_lib.a | ||
LINKFLAGS+=../../io/libr_io.a | ||
else | ||
LINKFLAGS+=-L../../lib -lr_lib | ||
LINKFLAGS+=-L../../util -lr_util | ||
LINKFLAGS+=-L.. -L../../lib -lr_lib -lr_io | ||
endif | ||
|
||
${TARGET_ZIP}: ${OBJ_ZIP} | ||
${CC_LIB} $(call libname,io_zip) ${CFLAGS} -o ${TARGET_ZIP} ${OBJ_ZIP} ${LINKFLAGS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ fs.ufs | |
fs.posix | ||
fs.jfs | ||
fs.minix | ||
io.zip | ||
fs.fb | ||
fs.sfs | ||
io.debug | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters