def _set_xor_key(self, key=None): if key is None: key = ask_long(self.key, "Specify 8-Bit XOR key") self.key = key & 0xFF else: self.key = key & 0xFF return
def main(): size = ida_kernwin.ask_long(0x1000, "size of allocation") if not size: return ptr = idawilli.dbg.allocate_rwx(size) print('allocated 0x%x bytes at 0x%x' % (size, ptr))
def pp_main(): global pp if pp and not pp.is_dead(): pp.die() pp = None return w = ida_kernwin.get_current_widget() title = "IDA View-A" if w: title = ida_kernwin.get_widget_title(w) title = ida_kernwin.ask_str(title, 0, "Please specify title of widget") if title: path = ida_kernwin.ask_str( "", ida_kernwin.HIST_DIR, "Please specify path containing png files to play back") if path and os.path.exists(path): files = find_files(path, "*.png") print("found %d files" % len(files)) if len(files): interval = ida_kernwin.ask_long( 100, "Please specify timer interval") if interval: pp = png_player_t(title, files, interval=interval) print("PNGs playing in widget %s" % title)
def OnKeydown(self, vkey, shift): """ User pressed a key @param vkey: Virtual key code @param shift: Shift flag @return: Boolean. True if you handled the event """ print("OnKeydown, vk=%d shift=%d" % (vkey, shift)) # ESCAPE? if vkey == 27: self.Close() # VK_DELETE elif vkey == 46: n = self.GetLineNo() if n is not None: self.DelLine(n) self.Refresh() print("Deleted line %d" % n) # Goto? elif vkey == ord('G'): n = self.GetLineNo() if n is not None: v = ida_kernwin.ask_long(self.GetLineNo(), "Where to go?") if v: self.Jump(v, 0, 5) elif vkey == ord('R'): print("refreshing....") self.Refresh() elif vkey == ord('C'): print("refreshing current line...") self.RefreshCurrent() elif vkey == ord('A'): s = ida_kernwin.ask_str("NewLine%d" % self.Count(), 0, "Append new line") self.AddLine(s) self.Refresh() elif vkey == ord('X'): print("Clearing all lines") self.ClearLines() self.Refresh() elif vkey == ord('I'): n = self.GetLineNo() s = ida_kernwin.ask_str("InsertedLine%d" % n, 0, "Insert new line") self.InsertLine(n, s) self.Refresh() elif vkey == ord('E'): l = self.GetCurrentLine(notags=1) if not l: return False n = self.GetLineNo() print("curline=<%s>" % l) l = l + ida_lines.COLSTR("*", ida_lines.SCOLOR_VOIDOP) self.EditLine(n, l) self.RefreshCurrent() print("Edited line %d" % n) else: return False return True
def main(): print("[*] Start patching to XOR encoded blocks") ea = ida_kernwin.ask_addr(BADADDR, "What address is encoded block by xor?") xor_key = ida_kernwin.ask_long(0x00, "Waht is key for xor?(0-255)") valid_check(ea, xor_key) print hex(ea) print hex(xor_key) while True: b = ida_bytes.get_byte(ea) if b == 0: break ida_bytes.patch_byte(ea, b ^ xor_key) ea += 1 print("[*] Finished patching to XOR encoded blocks")
def askArchitecture(self, availList): prompt = ["What platform do you want to use?"] i = 1 for arch in availList: prompt.append("%d - %s" % (i, arch)) i = i + 1 sel = ask_long(1, "\n".join(prompt)) if sel is None: return None sel = int(sel) if sel > 0 and sel <= len(availList): return availList[sel - 1] return None
def ask_long(value, prompt): if idaapi.IDA_SDK_VERSION <= 699: retval = idc.AskLong(value, prompt) else: retval = ida_kernwin.ask_long(value, prompt) return retval
def AskLong(defval, prompt): return ida_kernwin.ask_long(defval, prompt)
def _set_threshold(self): res = ask_long(self.threshold, "Please specify minimum string length") if res is not None: self.threshold = res
import idaapi import ida_kernwin import idc struct_name = ida_kernwin.ask_str("", 4, "Enter struct name") start = ida_kernwin.ask_addr(0, "Enter start address") num_structs = ida_kernwin.ask_long(0, "Enter struct count") should_number = ida_kernwin.ask_yn(0, "Number the structs as they're created?") cur_struct_num = 0 struct_id = idaapi.get_struc_id(struct_name) if struct_id == -1: exit("No such struct {}".format(struct_name)) struct_size = idaapi.get_struc_size(struct_id) cur = start for i in range(num_structs): create_struct(cur, struct_size, struct_name) if should_number: set_cmt(cur, str(cur_struct_num), 0) cur_struct_num += 1 cur += struct_size
def ask(): import ida_kernwin ID = ida_kernwin.ask_long(1, "Enemy skill No.?") print(ID)
# Step Nr. 4: Let user select module moduleList = [] for module in modules: moduleList.append((str(module[0]), module[1])) a = SelectBox("Select a module", moduleList) selected_module = modules[a.Show(True)] print "Selected module: %d" % selected_module[0] rawModule = False if selected_module[1] == 'NULL': rawModule = True # Step Nr. 5: Let user change offset (optional) offset = ida_kernwin.ask_long(0, "Add offset (if it's hex prepend a 0x)") # Step Nr. 6: Retrieve covered blocks engine = create_engine(database_string) with engine.connect() as con: #blocksDB = con.execute('SELECT Offset FROM covered_blocks WHERE ModuleID = %d' % selected_module) blocksDistinctDB = con.execute( 'SELECT DISTINCT Offset FROM covered_blocks WHERE ModuleID = %d ORDER BY Offset ASC' % selected_module[0]) print "Found ? block(s) (%d distinct)" % (blocksDistinctDB.rowcount) # Step Nr. 7: Color the currently loaded binary for (bb, ) in blocksDistinctDB: absPos = bb + offset if not rawModule: absPos += ida_nalt.get_imagebase()
# Step Nr. 4: Let user select module moduleList = [] for module in modules.values(): moduleList.append((str(module[0]), module[1])) a = SelectBox("Select a module", moduleList) selected_module = a.Show(True) + 1 print "Selected module: %d" % selected_module rawModule = False if moduleList[selected_module - 1][1] == 'NULL': rawModule = True # Step Nr. 5: Let user change offset (optional) offset = ida_kernwin.ask_long(0, "Add offset") # Step Nr. 6: Retrieve covered blocks engine = create_engine(database_string) with engine.connect() as con: #blocksDB = con.execute('SELECT Offset FROM covered_blocks WHERE ModuleID = %d' % selected_module) blocksDistinctDB = con.execute( 'SELECT DISTINCT Offset FROM covered_blocks WHERE ModuleID = %d' % selected_module) print "Found ? block(s) (%d distinct)" % (blocksDistinctDB.rowcount) # Step Nr. 7: Color the currently loaded binary for (bb, ) in blocksDistinctDB: absPos = bb + offset if not rawModule: absPos += ida_nalt.get_imagebase()