bool init_plugin(void *self) { //panda_arg_list *args = panda_get_args("loaded"); panda_require("osi_linux"); assert(init_osi_linux_api()); panda_require("osi"); assert(init_osi_api()); panda_require("syscalls2"); #if defined(TARGET_I386) { panda_cb pcb; pcb.before_block_exec = osi_foo; panda_register_callback(self, PANDA_CB_BEFORE_BLOCK_EXEC, pcb); } PPP_REG_CB("syscalls2", on_sys_mmap_pgoff_return, linux_mmap_pgoff_return); #else fprintf(stderr, "The loaded plugin is not currently supported on this platform.\n"); return false; #endif return true; }
bool init_plugin(void *self) { printf("Initializing plugin file_taint\n"); #ifdef TARGET_I386 panda_cb pcb; panda_arg_list *args; args = panda_get_args("file_taint"); taint_filename = panda_parse_string(args, "filename", "abc123"); positional_labels = panda_parse_bool(args, "pos"); no_taint = panda_parse_bool(args, "notaint"); end_label = panda_parse_ulong(args, "max_num_labels", 1000000); end_label = panda_parse_ulong(args, "end", end_label); start_label = panda_parse_ulong(args, "start", 0); enable_taint_on_open = panda_parse_bool(args, "enable_taint_on_open"); first_instr = panda_parse_uint64(args, "first_instr", 0); taint_stdin = panda_parse_string(args, "use_stdin_for", nullptr); printf ("taint_filename = [%s]\n", taint_filename); printf ("positional_labels = %d\n", positional_labels); printf ("no_taint = %d\n", no_taint); printf ("end_label = %d\n", end_label); printf ("first_instr = %" PRId64 " \n", first_instr); // you must use '-os os_name' cmdline arg! assert (!(panda_os_type == OST_UNKNOWN)); panda_require("osi"); assert(init_osi_api()); panda_require("syscalls2"); if (taint_stdin) { printf("tainting stdin\n"); assert (panda_os_type == OST_LINUX); } if (panda_os_type == OST_LINUX) { panda_require("osi_linux"); assert(init_osi_linux_api()); PPP_REG_CB("syscalls2", on_sys_open_enter, linux_open_enter); PPP_REG_CB("syscalls2", on_sys_read_enter, linux_read_enter); PPP_REG_CB("syscalls2", on_sys_read_return, linux_read_return); PPP_REG_CB("syscalls2", on_sys_pread64_enter, linux_pread_enter); PPP_REG_CB("syscalls2", on_sys_pread64_return, linux_pread_return); } if (panda_os_type == OST_WINDOWS) { panda_require("wintrospection"); assert(init_wintrospection_api()); PPP_REG_CB("syscalls2", on_NtOpenFile_enter, windows_open_enter); PPP_REG_CB("syscalls2", on_NtOpenFile_return, windows_open_return); PPP_REG_CB("syscalls2", on_NtCreateFile_enter, windows_create_enter); PPP_REG_CB("syscalls2", on_NtCreateFile_return, windows_create_return); PPP_REG_CB("syscalls2", on_NtReadFile_enter, windows_read_enter); PPP_REG_CB("syscalls2", on_NtReadFile_return, windows_read_return); } // this sets up the taint api fn ptrs so we have access if (!no_taint) { if (debug) printf("file_taint: initializing taint2 plugin\n"); panda_require("taint2"); assert(init_taint2_api()); if (!enable_taint_on_open && first_instr == 0) { if (debug) printf("file_taint: turning on taint at replay beginning\n"); taint2_enable_taint(); } } if (!no_taint && first_instr > 0) { if (debug) printf ("file_taint: turning on taint at instruction %" PRId64 "\n", first_instr); // only need this callback if we are turning on taint late pcb.before_block_translate = file_taint_enable; panda_register_callback(self, PANDA_CB_BEFORE_BLOCK_TRANSLATE, pcb); } pcb.before_block_exec = osi_foo; panda_register_callback(self, PANDA_CB_BEFORE_BLOCK_EXEC, pcb); #else printf ("file_taint: only works for x86 target (really just 32-bit)\n"); return false; #endif return true; }