nowsecure / r2frida

Radare2 and Frida better together.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

alongj opened this issue · comments

commented
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  
commented

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;
	}
...

dupe of #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.

_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?