58 return (
file && strstr(
file,
"://"));
101 if ((zipArch =
zip_open(archivename, perm, &zip_errorp))) {
105 eprintf(
"ZIP File Error: Invalid file name (NULL).\n");
107 eprintf(
"ZIP File Error: File could not be opened file name.\n");
109 eprintf(
"ZIP File Error: File does not exist.\n");
111 eprintf(
"ZIP File Error: Read error occurred.\n");
113 eprintf(
"ZIP File Error: File is not a valid ZIP archive.\n");
115 eprintf(
"ZIP File Error: ZIP file had some inconsistencies archive.\n");
117 eprintf(
"ZIP File Error: Something bad happened, get your debug on.\n");
134 if (zipArch && zfo && zfo->
entry != -1) {
162 ut64 num_entries = 0,
i = 0;
177 for (
i = 0;
i < num_entries;
i++) {
205 if (
s && zfo->
entry != -1) {
209 }
else if (
s && zfo->
name) {
262 for (
i = 0;
i < num_entries;
i++) {
290 char *filename_in_zipfile, *zip_filename =
NULL, *zip_uri;
301 zip_filename = strstr(zip_uri,
"//");
302 if (zip_filename && zip_filename[2]) {
303 if (zip_filename[0] && zip_filename[0] ==
'/' &&
304 zip_filename[1] && zip_filename[1] ==
'/') {
321 rz_list_foreach (filenames,
iter, filename_in_zipfile) {
322 size_t v = strlen(filename_in_zipfile);
324 if (filename_in_zipfile[
v - 1] ==
'/') {
331 if (zfo && zfo->
entry == -1) {
332 eprintf(
"Warning: File did not exist, creating a new one.\n");
354 if (!
idx || !zipArch) {
359 file_idx = atoi(
idx);
360 if ((file_idx == 0 &&
idx[0] !=
'0') || (file_idx >= num_entries)) {
364 for (
i = 0;
i < num_entries;
i++) {
381 const char *app_name;
382 const char *last_slash;
384 char *zip_filename =
NULL;
389 app_name = strstr(
name,
".app/");
397 app_size = (app_name - last_slash) - 1;
398 zip_filename =
rz_str_newf(
"//Payload/%.*s.app/%.*s", app_size, last_slash + 1, app_size, last_slash + 1);
399 if (zip_filename && !strcmp(
name, zip_filename + 2)) {
420 if (!strcmp(
name,
"classes.dex")) {
426 eprintf(
"Error: cannot allocate zip file object.\n");
429 if (zfo->
entry == -1) {
431 eprintf(
"Warning: File %s does not exist.\n",
name);
435 eprintf(
"Warning: File %s does not exist, creating a new one.\n",
name);
451 char *uri_path, *
tmp;
453 char *zip_uri =
NULL, *zip_filename =
NULL, *filename_in_zipfile =
NULL;
462 uri_path = strstr(zip_uri,
"://");
464 tmp = strstr(uri_path + 3,
"//");
468 if (!strncmp(zip_uri,
"apk://", 6)) {
470 }
else if (!strncmp(zip_uri,
"ipa://", 6)) {
473 zip_filename =
strdup(uri_path + 1);
477 zip_filename =
strdup(uri_path + 1);
481 if (zip_filename && zip_filename[1] && zip_filename[2]) {
482 if (zip_filename[0] && zip_filename[0] ==
'/' &&
483 zip_filename[1] && zip_filename[1] ==
'/') {
489 if ((filename_in_zipfile = strstr(zip_filename,
"//")) && filename_in_zipfile[2]) {
491 *filename_in_zipfile++ = 0;
492 *filename_in_zipfile++ = 0;
493 filename_in_zipfile =
strdup(filename_in_zipfile);
495 }
else if ((filename_in_zipfile = strstr(zip_filename,
"::")) &&
496 filename_in_zipfile[2]) {
498 *filename_in_zipfile++ = 0;
499 *filename_in_zipfile++ = 0;
501 zip_filename, filename_in_zipfile,
504 filename_in_zipfile =
rz_str_newf(
"%s", zip_filename);
506 zip_filename =
strdup(uri_path + 3);
507 if (!strcmp(zip_filename, filename_in_zipfile)) {
516 eprintf(
"usage: zip:///path/to/archive//filepath\n"
517 "usage: zip:///path/to/archive::[number]\n"
518 "Archive was not found.\n");
523 if (!filename_in_zipfile) {
546 if (zfo->
entry == -1) {
547 eprintf(
"Warning: File %s does not exist, creating a new one.\n", filename_in_zipfile);
555 eprintf(
"Failed to open the archive %s and file %s\n",
556 zip_filename, filename_in_zipfile);
562 free(filename_in_zipfile);
572 if (!
fd || !
fd->data) {
601 if (!
fd || !
fd->data || !
buf) {
625 if (!
fd || !
fd->data) {
640 if (!
fd || !
fd->data || !
buf) {
666 if (!
fd || !
fd->data) {
677 .desc =
"Open zip files",
678 .uris =
"zip://,apk://,ipa://,jar://,zipall://,apkall://,ipaall://,jarall://",
690 #ifndef RZ_PLUGIN_INCORE
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n output MIME type special files
RZ_API void Ht_() free(HtName_(Ht) *ht)
RzList * rz_io_zip_get_files(const char *archivename, ut32 perm, int mode, int rw)
static RzIOZipConstURI ZIP_ALL_URIS[]
static ut64 rz_io_zip_lseek(RzIO *io, RzIODesc *fd, ut64 offset, int whence)
static RzIODesc * rz_io_zip_open(RzIO *io, const char *file, int rw, int mode)
struct zip * rz_io_zip_open_archive(const char *archivename, ut32 perm, int mode, int rw)
static int rz_io_zip_read(RzIO *io, RzIODesc *fd, ut8 *buf, int count)
static bool rz_io_zip_resize(RzIO *io, RzIODesc *fd, ut64 size)
static RzIOZipConstURI ZIP_URIS[]
static int rz_io_zip_close(RzIODesc *fd)
static bool rz_io_zip_truncate_buf(RzIOZipFileObj *zfo, int size)
RzIOPlugin rz_io_plugin_zip
RZ_API RzLibStruct rizin_plugin
static bool rz_io_zip_plugin_open(RzIO *io, const char *file, bool many)
struct rz_io_zip_uri_const_t RzIOZipConstURI
RzIOZipFileObj * rz_io_zip_alloc_zipfileobj(const char *archivename, const char *filename, ut32 perm, int mode, int rw)
int rz_io_zip_flush_file(RzIOZipFileObj *zfo)
static char * find_apk_binary(const char *filename, int rw, int mode, RzIO *io)
static int rz_io_zip_realloc_buf(RzIOZipFileObj *zfo, int count)
static RzList * rz_io_zip_open_many(RzIO *io, const char *file, int rw, int mode)
static char * find_ipa_binary(const char *filename, int rw, int mode)
RzIOZipFileObj * rz_io_zip_create_new_file(const char *archivename, const char *filename, struct zip_stat *sb, ut32 perm, int mode, int rw)
static int rz_io_zip_has_uri_substr(const char *file)
static void rz_io_zip_free_zipfileobj(RzIOZipFileObj *zfo)
static int rz_io_zip_check_uri(const char *file)
char * rz_io_zip_get_by_file_idx(const char *archivename, const char *idx, ut32 perm, int mode, int rw)
static int rz_io_zip_check_uri_many(const char *file)
static int rz_io_zip_write(RzIO *io, RzIODesc *fd, const ut8 *buf, int count)
static int rz_io_zip_slurp_file(RzIOZipFileObj *zfo)
struct rz_io_zfo_t RzIOZipFileObj
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
ZIP_EXTERN zip_int64_t zip_name_locate(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t)
ZIP_EXTERN int zip_fclose(zip_file_t *_Nonnull)
ZIP_EXTERN zip_int64_t zip_add(zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull)
ZIP_EXTERN int zip_get_num_files(zip_t *_Nonnull)
ZIP_EXTERN void zip_stat_init(zip_stat_t *_Nonnull)
ZIP_EXTERN zip_int64_t zip_fread(zip_file_t *_Nonnull, void *_Nonnull, zip_uint64_t)
ZIP_EXTERN int zip_close(zip_t *_Nonnull)
ZIP_EXTERN void zip_source_free(zip_source_t *_Nullable)
ZIP_EXTERN zip_t *_Nullable zip_open(const char *_Nonnull, int, int *_Nullable)
ZIP_EXTERN int zip_replace(zip_t *_Nonnull, zip_uint64_t, zip_source_t *_Nonnull)
ZIP_EXTERN int zip_stat_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_stat_t *_Nonnull)
ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t)
ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer(zip_t *_Nonnull, const void *_Nullable, zip_uint64_t, int)
void * calloc(size_t number, size_t size)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RZ_API ut64 rz_buf_tell(RZ_NONNULL RzBuffer *b)
Return the current cursor position.
RZ_API bool rz_buf_resize(RZ_NONNULL RzBuffer *b, ut64 newsize)
Resize the buffer size.
RZ_API st64 rz_buf_seek(RZ_NONNULL RzBuffer *b, st64 addr, int whence)
Modify the current cursor position in the buffer.
RZ_API st64 rz_buf_write_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL const ut8 *buf, ut64 len)
Write len bytes of the buffer at the specified address.
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
RZ_API bool rz_buf_set_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len)
Replace the content of the buffer with the bytes array.
RZ_API RZ_OWN RzBuffer * rz_buf_new_with_bytes(RZ_NULLABLE RZ_BORROW const ut8 *bytes, ut64 len)
Creates a new buffer with a bytes array.
RZ_DEPRECATE RZ_API RZ_BORROW ut8 * rz_buf_data(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut64 *size)
Return a borrowed array of bytes representing the buffer data.
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
RZ_API void rz_io_desc_free(RzIODesc *desc)
RZ_API bool rz_io_desc_add(RzIO *io, RzIODesc *desc)
RZ_API RzIODesc * rz_io_desc_new(RzIO *io, RzIOPlugin *plugin, const char *uri, int flags, int mode, void *data)
#define RZ_LOG_INFO(fmtstr,...)
RZ_API int rz_num_rand(int max)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API const char * rz_str_rchr(const char *base, const char *p, int ch)
RZ_API bool rz_str_endswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string ends with a specifc sequence of characters (case sensitive)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]