def import_file(self, widget): """ import nmap xml """ dialog = Gtk.FileChooserDialog("Please choose a file", None, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) file_filters.add_filter_nmap(dialog) response = dialog.run() if response == Gtk.ResponseType.OK: file_selected = dialog.get_filename() try: if self.identify_scan(file_selected) == "nmap": self.database.import_nmap(file_selected) elif self.identify_scan(file_selected) == "masscan": self.database.import_masscan(file_selected) elif self.identify_scan(file_selected) == "smap": self.database.import_shodan(file_selected) except Exception as e: print (e) elif response == Gtk.ResponseType.CANCEL: dialog.destroy() dialog.destroy() self._sync()
def import_file(self, widget): """ import nmap xml """ dialog = Gtk.FileChooserDialog( "Please choose a file", None, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) file_filters.add_filter_nmap(dialog) response = dialog.run() if response == Gtk.ResponseType.OK: file_selected = dialog.get_filename() with open(file_selected) as myfile: head = "".join(myfile.readlines()[0:5]).replace('\n', '') for extension in self.ext_session.modules: if self.ext_session.modules[extension]["module"].match( head): try: self.ext_session.modules[extension][ "module"].parse(file_selected) except Exception as E: print(self.ext_session.modules[extension] ["module"].name) print("---") print(E) elif response == Gtk.ResponseType.CANCEL: dialog.destroy() dialog.destroy() self._sync()
def import_file(self, widget): """ import nmap xml """ dialog = Gtk.FileChooserDialog( "Please choose a file", None, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) file_filters.add_filter_nmap(dialog) response = dialog.run() if response == Gtk.ResponseType.OK: file_selected = dialog.get_filename() self.engine.import_file(file_selected) self._sync() elif response == Gtk.ResponseType.CANCEL: dialog.destroy() dialog.destroy()