def write_payload(self, fullpath, start, stop): step = self.dataBankTab.mainWindow.dbankGenStep.text() prepend = self.dataBankTab.mainWindow.dbankGenPre.text() postpend = self.dataBankTab.mainWindow.dbankGenPost.text() try: f = open(fullpath, "w") self.Progress = ProgressDialog() for item in range(int(start), int(stop), int(step)): f.write(prepend + str(item) + postpend +"\n") self.dataBankTab.fill_payload_combo_box() # Display a message since small payload generation will not show the progress dialog. message = "Payload Generated" dialog = SimpleDialog(message) dialog.exec_() except Exception as e: message = "An error occured:\n%s" % (e) dialog = SimpleDialog(message) dialog.exec_() # Remove the file created on error so a blank payload is not listed in the payload list os.remove(fullpath) finally: self.Progress.close()
def generate_payload(self): """ Generate a payload file and place it in the payloads directory. Payloads will be one item per line. """ filename = self.dataBankTab.mainWindow.dbankGenPayloadName.text() start = self.dataBankTab.mainWindow.dbankGenStart.text() stop = self.dataBankTab.mainWindow.dbankGenStop.text() step = self.dataBankTab.mainWindow.dbankGenStep.text() prepend = self.dataBankTab.mainWindow.dbankGenPre.text() postpend = self.dataBankTab.mainWindow.dbankGenPost.text() if filename == "": message = "You didn't specify a filename" dialog = SimpleDialog(message) dialog.exec_() return() if start == "": message = "You didn't specify a start of the range" dialog = SimpleDialog(message) dialog.exec_() return() if stop == "": message = "You didn't specify a end of the range" dialog = SimpleDialog(message) dialog.exec_() return() fullpath = self.payloads_dir + "/" + filename if os.path.exists(fullpath): message = "File already exists. Would you like to overwrite?" response = ConfirmDialog.display_confirm_dialog(self, message) if response == False: return() self.write_payload(fullpath, start, stop)
def display_message(self, message): dialog = SimpleDialog(message) dialog.exec_()