def Show(self): """ Creates the form and brings it to the front. """ try: input_md5 = idc.retrieve_input_file_md5() except: input_md5 = idc.GetInputMD5() if input_md5 is None: return else: name = "{}".format(config['name']) try: options = PluginForm.WCLS_CLOSE_LATER |\ PluginForm.WCLS_SAVE |\ PluginForm.WOPN_RESTORE except: options = PluginForm.FORM_CLOSE_LATER |\ PluginForm.FORM_SAVE |\ PluginForm.FORM_RESTORE return PluginForm.Show(self, name, options=options)
def find_input_file(): """ Description: Check whether or not IDA knows where the original file used to create the IDB is. If IDA doesn't know, check the IDA's directory for the file. Output: Returns True if the input file was located, False if it was not. """ global INPUT_FILE_PATH ida_path = INPUT_FILE_PATH if not os.path.exists(ida_path): # If IDA does not know, check if the (correct) file is sitting next to the IDB. local_path = os.path.join(idautils.GetIdbDir(), idc.get_root_filename()) if (os.path.exists(local_path) and hashlib.md5( open(local_path, "rb").read()).hexdigest().upper() == idc.retrieve_input_file_md5()): INPUT_FILE_PATH = local_path logger.debug("Guessed the input file path: " + INPUT_FILE_PATH) logger.debug("IDA thought it was: " + ida_path) return True else: return False else: return True
def GetInputFileMD5(): """ Return the MD5 hash of the input binary file @return: MD5 string or None on error """ return idc.retrieve_input_file_md5()
def Show(self): if idc.retrieve_input_file_md5() is None: return else: return PluginForm.Show( self, NAME, options=(PluginForm.WCLS_CLOSE_LATER | PluginForm.WOPN_RESTORE | PluginForm.WCLS_SAVE))
def PopulateForm(self): layout = QVBoxLayout() label = QtWidgets.QLabel() label.setText("Proposed function names for sample %s" % idc.retrieve_input_file_md5()) self.funcinfos_table = SkelFunctionInfosList(self.settings_filename) layout.addWidget(label) layout.addWidget(self.funcinfos_table) self.setLayout(layout)
def get_sample_id(self): """ Query the server for the sample ID """ endpoint = "/api/1.0/samples/" endpoint += lower(idc.retrieve_input_file_md5()) endpoint += "/" try: data = self.poli_get(endpoint) if data["sample_id"] is not None: return data["sample_id"] else: return False except BaseException: # 404? return False
def PopulateForm(self): layout = QVBoxLayout() label = QtWidgets.QLabel() label.setText("Notes about sample %s" % idc.retrieve_input_file_md5()) self.editor = QtWidgets.QTextEdit() self.editor.setFontFamily(self.skel_settings.notepad_font_name) self.editor.setFontPointSize(self.skel_settings.notepad_font_size) text = self.skel_conn.get_abstract() self.editor.setPlainText(text) # editor.setAutoFormatting(QtWidgets.QTextEdit.AutoAll) self.editor.textChanged.connect(self._OnTextChange) layout.addWidget(label) layout.addWidget(self.editor) self.setLayout(layout)
def binary_hash(self) -> str: return idc.retrieve_input_file_md5().hex()