try: tag = child['toc_title'].decode() if 'function' in tag: href = child['href'].decode() fn = tag.split()[0] # print "Func: ", fn funcDB[ fn] = 'https://docs.microsoft.com/en-us/' + href except Exception as e: import traceback print(child) traceback.print_exc() return cache("https://docs.microsoft.com/en-us/windows/win32/api/") cache("https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/") with open(TARGET, "w") as fp: fp.write(json.dumps(funcDB)) print("Done!") def F**k(): InitFn() name, _ = idaapi.get_highlight(idaapi.get_current_viewer()) if name in funcDB.keys(): os.startfile(funcDB[name], 'open') idaapi.CompileLine('static xFuck() { RunPythonStatement("F**k()"); }') AddHotkey("Ctrl+,", "xFuck")
modified = {} for ident in sb.symbols.symbols_id: if ident in sb.ir_arch.arch.regs.regs_init and \ ident in sb.symbols.symbols_id and \ sb.symbols.symbols_id[ident] == sb.ir_arch.arch.regs.regs_init[ident]: continue modified[ident] = sb.symbols.symbols_id[ident] for ident in sb.symbols.symbols_mem: modified[sb.symbols.symbols_mem[ident] [0]] = sb.symbols.symbols_mem[ident][1] view = symbolicexec_t() if not view.Create(modified, machine, "Symbolic Execution - 0x%x to 0x%x" % (start, end)): return view.Show() if __name__ == "__main__": idaapi.CompileLine( 'static key_F3() { RunPythonStatement("symbolic_exec()"); }') idc.AddHotkey("F3", "key_F3") print "=" * 50 print """Available commands: symbolic_exec() - F3: Symbolic execution of current selection """
def compile(self, statement): return idaapi.CompileLine(statement)
info = idaapi.get_inf_structure() BITS = None if info.is_64bit(): BITS = 64 elif info.is_32bit(): BITS = 32 else: BITS = 16 FILE_TYPE = ENUM_FILE_TYPE[info.filetype] #print FILE_TYPE # must be created idaapi.CompileLine( 'static LoadStrings() { RunPythonStatement("LoadStrings()"); }') idaapi.CompileLine( 'static LoadMethods() { RunPythonStatement("LoadMethods()"); }') idaapi.CompileLine('static AutoLoad() { RunPythonStatement("AutoLoad()"); }') idaapi.CompileLine( 'static LocationHelper() { RunPythonStatement("LocationHelper()"); }') # Add the hotkey AddHotkey("Ctrl-Alt-S", 'LoadStrings') AddHotkey("Ctrl-Alt-M", 'LoadMethods') AddHotkey("Ctrl-Alt-A", 'AutoLoad') AddHotkey("Ctrl-Alt-L", 'LocationHelper') print "Ctrl-Alt-S : Load String Literals" print "Ctrl-Alt-M : Load Methods" print "Ctrl-Alt-A : Automatically Load Everything (iOS and Android Only)"
def enable_shortcut(): idaapi.CompileLine('static copy2clip() { RunPythonStatement("copy2clip()"); }') idc.AddHotkey(PLUGIN_HOTKEY, "copy2clip") return
if not os.path.isfile(complete_path): src = str(idaapi.decompile(idaapi.get_screen_ea())) self.tools.save_file(complete_path, src) self.tools.set_file_path(complete_path) max_title = self.config_main.getint('etc', 'max_title') self.gui = include.gui.Canvas(self.config_main, self.config_theme, self.tools, demangled_name[:max_title]) self.gui.Show('HRDEV') self.parser = include.syntax.Parser(self) self.parser.run(complete_path) return def main(real_dir): '''Simple wrapper.''' try: Plugin(real_dir).run() except Exception, error: print error return if __name__ == '__main__': PLUGIN_PATH = os.path.realpath(__file__) idaapi.CompileLine('static __run_main()' '{ RunPythonStatement("main(PLUGIN_PATH)"); }') idc.AddHotkey('Alt-,', '__run_main')
def registerHotkey(shortcut): idaapi.CompileLine(r'static extractCode() { RunPythonStatement("tq.extractCode()"); }') idc.AddHotkey(shortcut, "extractCode")
def make_hotkey(): idaapi.CompileLine('static key_F3() { RunPythonStatement("main(idc.ScreenEA())"); }') AddHotkey("F3", 'key_F3') print "F3 Hotkey Added"
def registerHotkey_2(shortcut): idaapi.CompileLine( r'static Run_2() { RunPythonStatement("Fix_Vmp_Dump_API.Run_2()"); }') idc.AddHotkey(shortcut, "Run_2")
function = idaapi.func_item_iterator_t() function.set(idaapi.get_func(eip)) b_ok = function.first() while b_ok: pc = function.current() inslen = idaapi.decode_insn(function.current()) if inslen == 0: b_ok = function.next_code() continue if inst_is_call(pc): color = get_blue() if is_indirect(pc): color = get_green() idc.SetColor(pc, CIC_ITEM, color) elif inst_is_ret(pc): color = get_red() idc.SetColor(pc, CIC_ITEM, color) elif inst_is_jcc(pc): color = get_yellow() if is_indirect(pc): color = get_green() idc.SetColor(pc, CIC_ITEM, color) b_ok = function.next_code() if __name__ == "__main__": idaapi.CompileLine('static color_key() { RunPythonStatement("main()"); }') # Add the hotkey AddHotkey("i", 'color_key')
# print "Value: "+str(operand_val) #lnum = GetLineNumber(sEA) #comment = sys.stdin.readlines() #comment_dict[lnum] = comment #MakeComm(sEA,"Test Comment") SetFunctionCmt(sEA, "Test Comment", 0) graph() def go_callback(*args): go() return 1 # IDA binds hotkeys to IDC functions so a trampoline IDC function must be created idaapi.CompileLine('static flopy_key() { RunPythonStatement("on_hotkey()"); }') add_idc_hotkey(hotkey_str, 'flopy_key') idaapi.CompileLine( 'static flopy_click() { RunPythonStatement("on_click()"); }') add_idc_hotkey(hotkey_str2, 'flopy_click') # Add menu item try: if ctx: idaapi.del_menu_item(ctx) except: pass ctx = idaapi.add_menu_item("Search/", "Go", "", 0, go_callback, tuple("hello world")) if ctx is None:
arrId = GetArrayId('__uselessaddon__') if False == arrId: print '[!] failed to get array' return if SetArrayLong(arrId, IDX_SETBASEADDR, addr): print '[*] set baseaddr to 0x%08x' % addr else: print '[!] failed to set baseaddr for some reason I dunno why :P' except Exception as ex: print '[!] failed to set baseaddr. now in EXCEPT!' print ex return idaapi.CompileLine('static getbytes() { RunPythonStatement("getbytes()");}') idaapi.CompileLine( 'static setbaseaddr() { RunPythonStatement("setbaseaddr()");}') AddHotkey(hotkey_getbytes, 'getbytes') AddHotkey(hotkey_setbaseaddr, 'setbaseaddr') helpmsg = ''' ===== SOME USELESS ADDON ===== [shift+c] show address information & hexdump (for copy/paste when write some stuff.. exploit.. exploit.. exploit.) [shift+h] set image base address (when binary compiled with PIE.. 0x0000555555554000!?) ============================== ''' print helpmsg