nowsecure / r2frida

Radare2 and Frida better together.
MIT License
1.18k stars 121 forks source link

Using r2 to attached android app on win10 , then return ERROR: Cannot create script: Malformed package #491

Closed alongj closed 1 year ago

alongj commented 1 year ago
r2 frida://attach/usb//1553  
ERROR: Cannot create script: Malformed package  
ERROR: Cannot open 'frida://attach/usb//1553'
r2 -L  
rw_  frida    MIT    io plugin for Frida 16.0.19. frida://  
frida  16.0.19  
radare2 5.8.6  
alongj commented 1 year ago

some source code of __open in io_frida.c . where i can find the R2FRIDA_AGENT_SCRIPT

...
    char *r2f_as = r_sys_getenv ("R2FRIDA_AGENT_SCRIPT");
    if (r2f_as) {
        code_malloc_data = r_file_slurp (r2f_as, &code_size);
        code_buf = code_malloc_data;
        if (!code_buf) {
            R_LOG_ERROR ("Cannot slurp R2FRIDA_AGENT_SCRIPT");
        }
        free (r2f_as);
    }

    if (code_buf == NULL) {
        code_size = sizeof (r_io_frida_agent_code);
        code_malloc_data = malloc (code_size + 1);
        if (!code_malloc_data) {
            R_LOG_ERROR ("Cannot allocate enough memory for the agent");
            goto error;
        }
        memcpy (code_malloc_data, r_io_frida_agent_code, code_size);
        code_malloc_data[code_size] = 0;
        code_buf = code_malloc_data;
    }

    rf->script = frida_session_create_script_sync (rf->session, code_buf, options, rf->cancellable, &error);

    free (code_malloc_data);

    if (error) {
        if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
            R_LOG_ERROR ("Cannot create script: %s", error->message);
        }
        goto error;
    }
...
trufae commented 1 year ago

dupe of https://github.com/nowsecure/r2frida/issues/444 (there are 5 issues about r2frida not working on windows) when thats a known issue and probably a bug in frida, i'm slowly investigating the issue but i didnt managed to find the reason why the compiled scripts are not parsed properly by frida inside r2frida.

alongj commented 10 months ago

_agent.txt rf->script = frida_session_create_script_sync (rf->session, code_buf, options, rf->cancellable, &error); The attached file is a memory dump for code_buff. Is the parameter content correct?