def update_exploits(self, widget): import lib.ui.exploits as exploits self.exploitsInst = exploits.Exploits(self.config) t = threading.Thread(target=self.exploitsInst.download_exploits, args=(self.gom, )) t.start() self.threadtv.add_action('Exploit-db Update', 'Exploits DB', t)
def update_exploits(self, widget): import lib.ui.exploits as exploits self.exploitsInst = exploits.Exploits(self.config) widget.set_sensitive(False) t = threading.Thread(target=self.exploitsInst.download_exploits, args=(self.gom,)) t.start() GObject.timeout_add(1000, self.reactivate_button, t, widget) self.threadtv.add_action('Exploit-db Update', 'Exploits DB', t)
def __init__(self): # ################################################################################################################################# # # Load and apply gtkrc # ################################################################# # # No exception control because rc_parse doesn't throw exception on fail... sad but true ;) # ORIGDIR = os.getcwd() # os.chdir('lib/ui/data/Brave/gtk-2.0/') # gtk.rc_parse('gtkrc') # os.chdir(ORIGDIR) # Load Output Manager self.gom = om.OutputManager('gui') ################################################################################################################################# # Create a new window ################################################################# splash.push(("Creatin main window...")) self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_focus = True # self.window.connect("destroy", lambda w: gtk.main_quit()) self.window.connect("delete_event", self.quit) splash.push(("Loading...")) gtk.settings_get_default().set_long_property("gtk-button-images", True, "main") # Title self.window.set_title(MAINTITLE) # Positions self.window.resize(800, 600) self.window.move(25, 25) # Maximize window self.window.maximize() ################################################################################################################################# # Load core... ################################################################# #Initialize KB splash.push(("Loading KB...")) self.uicore = core.UIcore() self.uicore.add_local_asn() self.gom.set_core(self.uicore) # Check module window prefs setattr(self.uicore, 'SHOW_MODULE_WIN', config.SHOW_MODULE_WIN) self.uicore.set_om(self.gom) ################################################################################################################################# # Main VBox ################################################################# mainvbox = gtk.VBox(False, 1) mainvbox.set_border_width(1) self.window.add(mainvbox) mainvbox.show() ################################################################################################################################# # Tool Bars HBox ################################################################# tbhbox = gtk.HBox(False, 1) mainvbox.pack_start(tbhbox, False, False, 1) tbhbox.show() ################################################################################################################################# # UIManager for MAP Toolbar ################################################################# # to make it nice we'll put the toolbar into the handle box, # so that it can be detached from the main window self.handlebox = gtk.HandleBox() tbhbox.pack_start(self.handlebox, True, True, 1) # Create a UIManager instance splash.push(("Creating menu and toolbar...")) uimanager = gtk.UIManager() accelgroup = uimanager.get_accel_group() self.window.add_accel_group(accelgroup) self._actiongroup = actiongroup = gtk.ActionGroup('UIManager') # Create actions actiongroup.add_actions([ # xml_name, icon, real_menu_text, accelerator, tooltip, callback ('Load', gtk.STOCK_OPEN, ('Load'), None, (''), self.loadKB), ('Save', gtk.STOCK_SAVE, ('Save'), None, (''), self.saveKB), ('Import', gtk.STOCK_CONVERT, ('Import'), None, (''), self.importScan), ('Edit', gtk.STOCK_EDIT, ('Edit'), None, (''), self.loadEditor), ('Proxy', gtk.STOCK_CONNECT, ('Proxy'), None, (''), gtk.main_quit), ('Web Server', gtk.STOCK_EXECUTE, ('Web'), None, ('Web'), gtk.main_quit), #('Sniffer', gtk.STOCK_NETWORK, ('Sniffer'), None, (''), gtk.main_quit), ('Sniffer', gtk.STOCK_NETWORK, ('Sniffer'), None, (''), self.run_sniffer), ('Scapy', gtk.STOCK_HELP, ('Scapy'), None, (''), self.show_term), ('Add Target', gtk.STOCK_ADD, ('Add Target'), None, (''), self.addTarget), ('Preferences', gtk.STOCK_PREFERENCES, ('Preferences'), None, (''), self.showPref), ('Show Log', gtk.STOCK_DND, ('Show Log'), None, (''), self.show_log), ('Show KB', gtk.STOCK_DND, ('Show KB'), None, (''), self.show_kb), ('Report', gtk.STOCK_DND, ('Report'), None, (''), self.report), ('Quit', gtk.STOCK_QUIT, ('Quit'), None, (''), gtk.main_quit), ]) # Add the actiongroup to the uimanager uimanager.insert_action_group(actiongroup, 0) uimanager.add_ui_from_string(ui_menu) # Toolbar toolbar = uimanager.get_widget('/Toolbar') toolbar.set_style(gtk.TOOLBAR_BOTH) # Disabled until I get them working button_proxy = uimanager.get_widget('/Toolbar/Proxy') button_proxy.set_sensitive(False) button_web = uimanager.get_widget('/Toolbar/Web Server') button_web.set_sensitive(False) # Disable if not GtkSourceView2 if not config.HAS_SOURCEVIEW: button_edit = uimanager.get_widget('/Toolbar/Edit') button_edit.set_sensitive(False) # Disable if not Vte if not config.HAS_VTE: button_sniffer = uimanager.get_widget('/Toolbar/Sniffer') button_sniffer.set_sensitive(False) button_scapy = uimanager.get_widget('/Toolbar/Scapy') button_scapy.set_sensitive(False) self.handlebox.add(toolbar) toolbar.show() self.handlebox.show() ################################################################################################################################# # Map tab ################################################################# # Will contain on top the notebook and on bottom log window self.vpaned = gtk.VPaned() # Will contain xdot widget and kb window self.hpaned = gtk.HPaned() ################################################################# # KB Textview ################################################################# self.textview = kbwin.KBwindow() #self.gom.set_kbwin(self.textview) ################################################################# # KB TreeView ################################################################# self.treeview = kbtree.KBtree() self.tree = self.treeview.createTree() self.treeview.updateTree() self.gom.set_kbwin(self.treeview) self.tree.show() ################################################################# # xdot map ################################################################# from . import inxdot # self.context = cmenu.contextMenu() # self.context.createMenus(self.textview, self.gom) # # self.xdotw = inxdot.MyDotWidget(self.context, self.uicore) # nodeMenu initialization stuff self.uiman = nodeMenu.UIManager(self.gom, self.uicore, config) self.uiman.set_data(None) accel = self.uiman.get_accel_group() self.window.add_accel_group(accel) # graphMenu initialization stuff self.graph_uiman = graphMenu.UIManager(self.gom, self.uicore) #self.graph_uiman.set_data(None) graph_accel = self.graph_uiman.get_accel_group() self.window.add_accel_group(graph_accel) self.xdotw = inxdot.MyDotWidget(self.uiman, self.graph_uiman, self.uicore) setattr(self.graph_uiman, 'xdot', self.xdotw) self.xdotw.set_size_request(900,450) self.gom.set_map(self.xdotw) setattr(self.uicore, 'xdot', self.xdotw) self.uicore.getDot(doASN=False) self.xdotw.set_dotcode( self.uicore.get_kbfield('dotcode') ) self.xdotw.zoom_image(1.0) ################################################################# # Graph Menu ################################################################# gmenu = graphTBar.GraphMenu(self.xdotw, self.uicore) ################################################################# # HBox for Map and GraphMenu ################################################################# menubox = gtk.HBox() menubox.pack_start(self.xdotw, True, True) menubox.pack_start(gmenu, False, False) # Show elements gmenu.show() menubox.show() ################################################################# # Scrolled Window ################################################################# self.scrolled_window = gtk.ScrolledWindow() self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrolled_window.set_size_request(100,100) # Add Textview to Scrolled Window #self.scrolled_window.add_with_viewport(self.textview) self.scrolled_window.add_with_viewport(self.tree) ################################################################# # Map Iface ################################################################# bufferf = "Map" frame = gtk.Frame(bufferf) frame.set_border_width(5) frame.show() label = gtk.Label('Map') # Test XDOT MAP frame.add(self.hpaned) #self.hpaned.add1(self.xdotw) self.hpaned.add1(menubox) self.hpaned.add2(self.scrolled_window) self.textview.show() # Check visibility on config preferences if config.SHOW_KBTREE: self.scrolled_window.show() self.scrolled_window.is_visible = True else: self.scrolled_window.is_visible = False self.hpaned.show() self.xdotw.show() label = gtk.Label('Map') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_SMALL_TOOLBAR) b.pack_start(label) b.pack_start(i) b.show_all() ################################################################# # Notebook ################################################################# self.notebook = gtk.Notebook() self.notebook.set_tab_pos(gtk.POS_LEFT) #notebook.append_page(frame, label) self.notebook.append_page(frame, b) self.notebook.connect("switch_page", self.onSwitch) ################################################################################################################################# # Consoles Tab ################################################################# label = gtk.Label('Term') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_SMALL_TOOLBAR) b.pack_start(label) b.pack_start(i) b.show_all() term_box = gtk.VBox() term_button = gtk.Button("New Tab") # Disable if VTE not available if not config.HAS_VTE: term_button.set_sensitive(False) term_box.pack_start(term_button,False) self.term_notebook = libTerminal.TerminalNotebook() #term_button.connect("clicked", term_notebook.new_tab) term_button.connect("clicked", self.new_tab) term_box.pack_start(self.term_notebook) setattr(self.uiman, 'termnb', self.term_notebook) setattr(self.uiman, 'mainnb', self.notebook) self.notebook.append_page(term_box, b) term_box.show_all() ################################################################################################################################# # RCE Iface ################################################################# # xdot rce import xdot self.xdotr = xdot.DotWidget() self.xdotr.set_size_request(600,512) self.xdotr.show() bufferf = "RCE" frame = gtk.Frame(bufferf) frame.set_border_width(5) frame.set_size_request(400, 400) label = gtk.Label('RCE') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_SMALL_TOOLBAR) b.pack_start(label) b.pack_start(i) b.show_all() self.notebook.append_page(frame, b) # RCE graph menu self.rmenu = rceTBar.RceMenu(self.xdotr, rcecore) self.dasmenu = rceTBar.DasmMenu() ################################################################################################################################# # UIManager for RCE Toolbar ################################################################# # to make it nice we'll put the toolbar into the handle box, # so that it can be detached from the main window self.rcehb = gtk.HandleBox() tbhbox.pack_start(self.rcehb, True, True, 1) # Create a UIManager instance rceuiman = gtk.UIManager() rceaccelgroup = rceuiman.get_accel_group() self.window.add_accel_group(rceaccelgroup) self._actiongroup = actiongroup = gtk.ActionGroup('UIManager') # Create actions actiongroup.add_actions([ # xml_name, icon, real_menu_text, accelerator, tooltip, callback ('New', gtk.STOCK_NEW, ('New'), None, (''), self.newBin), ('Load', gtk.STOCK_OPEN, ('Load'), None, (''), self.loadBin), ('Show Log', gtk.STOCK_DND, ('Show Log'), None, (''), self.show_log), #('Debugger', gtk.STOCK_EXECUTE, ('Debugger'), None, (''), gtk.main_quit), ('Debugger', gtk.STOCK_EXECUTE, ('Debugger'), None, (''), self.run_debugger), #('Report', gtk.STOCK_DND, ('Report'), None, (''), gtk.main_quit), ('Quit', gtk.STOCK_QUIT, ('Quit'), None, (''), gtk.main_quit), ]) # Add the actiongroup to the rceuiman rceuiman.insert_action_group(actiongroup, 0) rceuiman.add_ui_from_string(rce_menu) # Toolbar rcetoolbar = rceuiman.get_widget('/RceToolbar') self.rcehb.add(rcetoolbar) self.rcehb.hide() ################################################################# # RCE HBox and VBoxes ################################################################# rcepaned = gtk.HPaned() lrcevb = gtk.VBox(False, 1) rrcevb = gtk.VBox(False, 1) rcepaned.add1(lrcevb) rcepaned.add2(rrcevb) lrcevb.pack_start(self.rmenu, False, False, 1) rrcevb.pack_start(self.dasmenu, False, False, 1) rcepaned.show_all() ################################################################# # Textview RCE ################################################################# rcetv = gtk.TextView(buffer=None) rcetv.set_wrap_mode(gtk.WRAP_NONE) rcetv.set_editable(False) fontdesc = pango.FontDescription("MonoSpace 10") #fontdesc = pango.FontDescription("Purisa 10") rcetv.modify_font(fontdesc) rcetv.show() self.textbuffer = rcetv.get_buffer() # Scrolled Window rce_scrolled_window = gtk.ScrolledWindow() rce_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) rce_scrolled_window.show() # Add Textview to Scrolled Window rce_scrolled_window.add_with_viewport(rcetv) # Add xdotr and textview to rcehbox lrcevb.pack_start(self.xdotr, True, True, 2) rrcevb.pack_start(rce_scrolled_window, True, True, 2) frame.add(rcepaned) frame.show() rcepaned.show() ################################################################################################################################# # Xploit Iface ################################################################# bufferf = "Exploit" frame = gtk.Frame(bufferf) frame.set_border_width(5) frame.show() label = gtk.Label('Exploit') frame.add(label) label.show() label = gtk.Label('Exploit') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_SMALL_TOOLBAR) b.pack_start(label) b.pack_start(i) b.show_all() self.exploitsInst = exploits.Exploits(config, self.term_notebook) exploitsGui = self.exploitsInst.get_widget() exploitsGui.show_all() self.notebook.append_page(exploitsGui, b) #mainvbox.pack_start(notebook, True, True, 1) self.vpaned.add1(self.notebook) self.notebook.show() ################################################################################################################################# # Log Window ################################################################# self.logtext = gtk.TextView(buffer=None) self.logtext.set_wrap_mode(gtk.WRAP_NONE) self.logtext.set_editable(False) #self.logtext.set_size_request(40,40) self.logbuffer = self.logtext.get_buffer() self.logbuffer.set_text('Loading Inguma...\n') self.logtext.show() ################################################################# # Log Scrolled Window ################################################################# self.log_scrolled_window = gtk.ScrolledWindow() self.log_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) self.log_scrolled_window.is_visible = True #Always on bottom on change self.vajd = self.log_scrolled_window.get_vadjustment() self.vajd.connect('changed', lambda a, s=self.log_scrolled_window: self.rescroll(a,s)) #self.log_scrolled_window.set_size_request(40,40) #self.logtext.set_size_request(20,20) # Add Textview to Scrolled Window self.log_scrolled_window.add_with_viewport(self.logtext) # Set logtext as output for gui self.gom.set_gui(self.logbuffer) # Add Scrolled Log Window to Bottom Notebook ############################################ # Notebook for bottom panel self.bottom_nb = gtk.Notebook() self.bottom_nb.set_tab_pos(gtk.POS_LEFT) # Icon and label for Logs tab label = gtk.Label('Logs') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_JUSTIFY_FILL, gtk.ICON_SIZE_SMALL_TOOLBAR) b.pack_start(label) b.pack_start(i) b.show_all() self.bottom_nb.append_page(self.log_scrolled_window, b) # Icon and label for Actions tab label = gtk.Label('Actions') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_SMALL_TOOLBAR) b.pack_start(label) b.pack_start(i) b.show_all() # Add Threads TreeView self.threadsInst = threadstv.ThreadsTv() threadsGui = self.threadsInst.get_widget() setattr(self.threadsInst, 'uicore', self.uicore) threadsGui.show_all() self.bottom_nb.append_page(threadsGui, b) #self.bottom_nb.set_scrollable(True) self.bottom_nb.set_current_page(0) # Check visibility on config preferences if config.SHOW_LOG: self.bottom_nb.is_visible = True self.bottom_nb.show() else: self.bottom_nb.is_visible = False self.vpaned.add2(self.bottom_nb) mainvbox.pack_start(self.vpaned, True, True, 1) self.log_scrolled_window.show() # Add threadtv to core self.uicore.set_threadtv(self.threadsInst) setattr(self.graph_uiman, 'threadtv', self.threadsInst) # ################################################################################################################################# # # Progress Bar # ################################################################# # self.progressbar = pbar.PBar() # self.progressbar.set_stopped() # mainvbox.pack_start(self.progressbar, False, False, 1) ################################################################################################################################# #StatusBar ################################################################# statusbar = gtk.Statusbar() mainvbox.pack_end(statusbar, False, False, 1) context_id = statusbar.get_context_id("Inguma 0.2") message_id = statusbar.push(context_id, 'Inguma 0.2') statusbar.show() ################################################################################################################################# # finish it ################################################################# self.vpaned.show() self.window.show() splash.destroy() # Check for autosaved KB and ask for loading libAutosave.checkDir() if not libAutosave.checkKB(): print "Autosaved KB not found, skipping..." else: toload = libAutosave.askDialog() if toload: kbpath = libAutosave.getKbPath() self.uicore.loadKB(kbpath) libAutosave.removeKB() # Update KB textview self.textview.updateWin() self.treeview.updateTree() # Adding text to Log window self.gom.echo( 'Loaded' , False) else: libAutosave.removeKB() # Update Map self.xdotw.set_dotcode( self.uicore.get_kbfield('dotcode') ) self.xdotw.zoom_image(1.0) gtk.main()
def __init__(self): super(MainApp, self).__init__() # ################################################################# # # Load and apply gtkrc # ################################################################# # # No exception control because rc_parse doesn't throw exception on fail... sad but true ;) # ORIGDIR = os.getcwd() # os.chdir('lib/ui/data/Brave/gtk-2.0/') # Gtk.rc_parse('gtkrc') # os.chdir(ORIGDIR) from inguma import inguma_init self.ing = self # Load Output Manager self.gom = om.OutputManager('gui', self.ing) glob.gom = self.gom core.check_args() core.create_profile_dir() inguma_init() # Create config self.config = config ################################################################# # Create a new window ################################################################# splash.push(("Creating main window...")) self.set_icon_from_file(os.path.join('logo', 'inguma_16.png')) self.set_focus = True self.connect("delete_event", self.event_quit) splash.push(("Loading...")) Gtk.Settings.get_default().set_long_property("gtk-button-images", True, "main") # Title self.set_title(MAINTITLE) # Positions self.resize(800, 600) self.move(25, 25) # Maximize window self.maximize() ################################################################# # Load UIcore... ################################################################# # Initialize KB splash.push(("Loading KB...")) self.kb = glob.kb self.uicore = uicore.UIcore(self.gom) self.uicore.add_local_asn() self.gom.set_core(self.uicore) # Check module window prefs setattr(self.uicore, 'SHOW_MODULE_WIN', self.config.SHOW_MODULE_WIN) self.uicore.set_om(self.gom) ################################################################# # Main VBox ################################################################# mainvbox = Gtk.VBox(False, 1) mainvbox.set_border_width(1) self.add(mainvbox) mainvbox.show() ################################################################# # ToolBar ################################################################# splash.push(("Creating menu and toolbar...")) self.toolbar = toolbar.Toolbar(self.ing) mainvbox.pack_start(self.toolbar, False, False, 1) # Disable if not GtkSourceView2 if not self.config.HAS_SOURCEVIEW: self.toolbar.edit_tb.set_sensitive(False) # Disable if not Vte if not self.config.HAS_VTE: self.toolbar.sniffer_tb.set_sensitive(False) self.toolbar.scapy_tb.set_sensitive(False) ################################################################# # Map tab ################################################################# # Will contain on top the notebook and on bottom log window self.vpaned = Gtk.VPaned() # Will contain xdot widget and kb window self.network_paned = Gtk.HPaned() ################################################################# # xdot map ################################################################# from . import inxdot # node_menu initialization stuff self.uiman = node_menu.NodeMenu(self.gom, self.uicore, self.config) self.uiman.set_data(None) accel = self.uiman.get_accel_group() self.add_accel_group(accel) # graphMenu initialization stuff self.graph_uiman = graphMenu.UIManager(self.ing) graph_accel = self.graph_uiman.get_accel_group() self.add_accel_group(graph_accel) # altNodeMenu initialization stuff self.altnode_uiman = altNodeMenu.UIManager(self.gom, self.uicore) altnode_accel = self.altnode_uiman.get_accel_group() self.add_accel_group(altnode_accel) self.xdotw = inxdot.MyDotWidget(self.uiman, self.graph_uiman, self.altnode_uiman, self.uicore) setattr(self.graph_uiman, 'xdot', self.xdotw) setattr(self.altnode_uiman, 'xdot', self.xdotw) setattr(self.uicore, 'xdot', self.xdotw) self.uicore.getDot(doASN=False) self.xdotw.set_dotcode(self.uicore.get_last_dot()) self.xdotw.zoom_image(1.0) ################################################################# # Graph Menu ################################################################# gmenu = graphTBar.GraphMenu(self.xdotw, self.uicore) ################################################################# # HBox for Map and GraphMenu ################################################################# self.graph_box = Gtk.HBox() self.graph_box.pack_start(self.xdotw, True, True, 0) self.graph_box.pack_start(gmenu, False, False, 0) # Show elements gmenu.show() self.graph_box.show() ################################################################# # Right panel ################################################################# # Holds right tree and buttons self.right_hbox = Gtk.HBox(False) # KB TreeView self.treeview = right_tree.KBtree(self, self.uicore) self.gom.set_kbwin(self.treeview) self.gom.set_map(self.xdotw) self.right_vbox = self.treeview.right_vbox self.scrolled_window = self.treeview.scrolled_window # Right buttons self.btn_vbox = right_buttons.RightButtons(self.right_vbox, self.treeview) self.btn_vbox.create_buttons() ################################################################# # Map Iface ################################################################# label = Gtk.Label(label='Map') # Pack map and right tree self.network_paned.pack1(self.graph_box, True, True) self.network_paned.pack2(self.right_vbox, False, False) self.right_hbox.pack_start(self.network_paned, True, True, 1) self.right_hbox.pack_start(self.btn_vbox, False, False, 1) # Check visibility on config preferences if self.config.SHOW_KBTREE: self.scrolled_window.show_all() self.right_hbox.show_all() self.scrolled_window.is_visible = True else: self.scrolled_window.is_visible = False self.network_paned.show() self.xdotw.show() label = Gtk.Label(label=' Networking') label.set_angle(90) b_factory = Gtk.VBox b = b_factory(spacing=1) i = Gtk.Image() i.set_from_file(os.path.join('lib', 'ui', 'data', 'icons', 'map.png')) b.pack_start(label, True, True, 0) b.pack_start(i, True, True, 0) b.show_all() ################################################################# # Notebook ################################################################# self.notebook = Gtk.Notebook() self.notebook.set_tab_pos(Gtk.PositionType.LEFT) self.notebook.append_page(self.right_hbox, b) self.notebook.connect("switch_page", self.on_switch) # Log button self.log_btn = Gtk.Button() self.log_icn = Gtk.Image() self.log_icn.set_from_stock(Gtk.STOCK_GOTO_BOTTOM, Gtk.IconSize.MENU) self.log_btn.set_image(self.log_icn) self.log_btn.set_relief(Gtk.ReliefStyle.NONE) self.log_btn.set_tooltip_text('Show/Hide Log panel') self.log_btn.connect("clicked", self.show_log) self.notebook.set_action_widget(self.log_btn, Gtk.PackType.END) self.log_btn.show() ################################################################# # Consoles Tab ################################################################# label = Gtk.Label(label=' Terminals') label.set_angle(90) b_factory = Gtk.VBox b = b_factory(spacing=1) i = Gtk.Image() i.set_from_file( os.path.join('lib', 'ui', 'data', 'icons', 'terminal.png')) b.pack_start(label, True, True, 0) b.pack_start(i, True, True, 0) b.show_all() # Paned to contain left file manager tree and terminals notebook self.terms_paned = Gtk.HPaned() self.term_notebook = terminal_manager.TerminalNotebook(self) setattr(self.uiman, 'termnb', self.term_notebook) setattr(self.uiman, 'mainnb', self.notebook) self.file_notebook = filemanager_notebook.FileManagerNotebook(self) # Pack all terminals stuff self.terms_paned.pack1(self.file_notebook, resize=False, shrink=False) self.terms_paned.pack2(self.term_notebook, resize=True, shrink=False) self.terms_paned.show_all() self.notebook.append_page(self.terms_paned, b) ################################################################# # RCE Iface ################################################################# label = Gtk.Label(label=' Reversing') label.set_angle(90) b_factory = Gtk.VBox b = b_factory(spacing=1) i = Gtk.Image() i.set_from_stock(Gtk.STOCK_REFRESH, Gtk.IconSize.MENU) b.pack_start(label, True, True, 0) b.pack_start(i, True, True, 0) b.show_all() if self.config.HAS_SOURCEVIEW: # Create bokken UI and add to the Notebook self.bokken = bokken.MainApp('', 'pyew', self) self.bokken_tb = bokken_toolbar.TopButtons(self.bokken.uicore, self.bokken) mainvbox.pack_start(self.bokken_tb, False, False, 1) self.rcevb = self.bokken.get_supervb() self.rcevb.show_all() self.notebook.append_page(self.rcevb, b) # self.bokken_tb.init_core() self.bokken_tb.hide() ################################################################# # Xploit Iface ################################################################# # Exploits Notebook for Exploit DB, Fuzzing and Exploit Dev self.exploits_nb = Gtk.Notebook() self.exploits_nb.set_tab_pos(Gtk.PositionType.LEFT) # # Exploits DB # label = Gtk.Label(label=' Exploits DB') label.set_angle(90) b_factory = Gtk.VBox b = b_factory(spacing=1) i = Gtk.Image() i.set_from_stock(Gtk.STOCK_PREFERENCES, Gtk.IconSize.MENU) b.pack_start(label, True, True, 0) b.pack_start(i, True, True, 0) b.show_all() self.exploitsInst = exploits.Exploits(self.config, self.term_notebook) exploitsGui = self.exploitsInst.get_widget() setattr(self.exploitsInst, 'gom', self.gom) exploitsGui.show_all() self.exploits_nb.append_page(exploitsGui, b) # # Fuzzers # label = Gtk.Label(label=' Fuzzing') label.set_angle(90) b_factory = Gtk.VBox b = b_factory(spacing=1) i = Gtk.Image() i.set_from_stock(Gtk.STOCK_PREFERENCES, Gtk.IconSize.MENU) b.pack_start(label, True, True, 0) b.pack_start(i, True, True, 0) b.show_all() # Fuzzers Box to contain krash and scapy fuzzers self.fuzz_frame = fuzz_frame.FuzzFrame() setattr(self.fuzz_frame.scapyui, 'gom', self.gom) setattr(self.fuzz_frame.krashui, 'gom', self.gom) self.exploits_nb.append_page(self.fuzz_frame, b) setattr(self.uiman, 'fuzz_frame', self.fuzz_frame) # Add exploits notebook and text/label to main notebook label = Gtk.Label(label=' Exploiting') label.set_angle(90) b_factory = Gtk.VBox b = b_factory(spacing=1) i = Gtk.Image() i.set_from_stock(Gtk.STOCK_PREFERENCES, Gtk.IconSize.MENU) b.pack_start(label, True, True, 0) b.pack_start(i, True, True, 0) b.show_all() self.notebook.append_page(self.exploits_nb, b) setattr(self.uiman, 'notebook', self.notebook) self.vpaned.add1(self.notebook) self.exploits_nb.show_all() self.notebook.show() ################################################################# # Log Window ################################################################# self.logtext = Gtk.TextView(buffer=None) # Some eye candy self.logtext.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(16400, 16400, 16440)) self.logtext.override_color(Gtk.StateType.NORMAL, Gdk.RGBA(60535, 60535, 60535, 0)) self.logtext.set_left_margin(10) self.logtext.set_wrap_mode(Gtk.WrapMode.NONE) self.logtext.set_editable(False) self.logbuffer = self.logtext.get_buffer() self.logbuffer.set_text('Loading Inguma...\n') self.logtext.show() ################################################################# # Log Scrolled Window ################################################################# self.log_scrolled_window = Gtk.ScrolledWindow() self.log_scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS) self.log_scrolled_window.is_visible = True # Always on bottom on change self.vadj = self.log_scrolled_window.get_vadjustment() self.vadj.connect( 'changed', lambda a, s=self.log_scrolled_window: self.rescroll(a, s)) # Add Textview to Scrolled Window self.log_scrolled_window.add_with_viewport(self.logtext) # Set logtext as output for gui self.gom.set_gui(self.logbuffer) # Add Scrolled Log Window to Bottom Notebook ############################################ # Notebook for bottom panel self.bottom_nb = Gtk.Notebook() self.bottom_nb.set_size_request(-1, 110) self.bottom_nb.set_tab_pos(Gtk.PositionType.LEFT) self.bottom_nb.connect("switch_page", self.on_bottom_switch) # Icon and label for Logs tab label = Gtk.Label(label=' Logs') label.set_angle(90) b_factory = Gtk.VBox b = b_factory(spacing=1) self.log_icon = Gtk.Image() self.log_icon.set_from_stock(Gtk.STOCK_JUSTIFY_FILL, Gtk.IconSize.MENU) b.pack_start(label, True, True, 0) b.pack_start(self.log_icon, True, True, 0) b.show_all() self.bottom_nb.append_page(self.log_scrolled_window, b) # Icon and label for Actions tab label = Gtk.Label(label=' Actions') label.set_angle(90) b_factory = Gtk.VBox b = b_factory(spacing=1) i = Gtk.Image() i.set_from_stock(Gtk.STOCK_EXECUTE, Gtk.IconSize.MENU) b.pack_start(label, True, True, 0) b.pack_start(i, True, True, 0) b.show_all() # Add Threads TreeView self.threadsInst = threadstv.ThreadsTv(self) threadsGui = self.threadsInst.get_widget() setattr(self.threadsInst, 'uicore', self.uicore) threadsGui.show_all() self.bottom_nb.append_page(threadsGui, b) setattr(self.fuzz_frame.scapyui, 'bottom_nb', self.bottom_nb) setattr(self.fuzz_frame.krashui, 'bottom_nb', self.bottom_nb) # Check visibility on config preferences if self.config.SHOW_LOG: self.bottom_nb.is_visible = True self.bottom_nb.show() else: self.bottom_nb.is_visible = False self.vpaned.pack2(self.bottom_nb, False, False) mainvbox.pack_start(self.vpaned, True, True, 1) self.log_scrolled_window.show() self.bottom_nb.set_current_page(0) # Add threadtv to core self.uicore.set_threadtv(self.threadsInst) setattr(self.graph_uiman, 'threadtv', self.threadsInst) setattr(self.altnode_uiman, 'threadtv', self.threadsInst) # And to exploit management module setattr(self.exploitsInst, 'threadsInst', self.threadsInst) # Must be connected here to avoid errors due to bottom_nb not yet existing self.exploits_nb.connect("switch_page", self.on_exploits_switch) ################################################################# # StatusBar ################################################################# self.statusbar = statusbar.Statusbar() self.statusbar.create_statusbar() self.statusbar.add_text(None, glob.version) mainvbox.pack_end(self.statusbar, False, False, 1) if self.config.HAS_SOURCEVIEW: self.bokken_statusbar = bokken_statusbar.Statusbar( self.bokken.uicore, self.bokken.tviews) self.bokken_statusbar.create_statusbar() mainvbox.pack_end(self.bokken_statusbar, False, False, 1) self.bokken_statusbar.hide_all() self.statusbar.show_all() # Systray self.systray = systray.Systray(self) ################################################################# # finish it ################################################################# self.vpaned.show() self.show() splash.destroy() # Check for autosaved KB and ask for loading if not libAutosave.check_kb(): self.gom.echo('Autosaved KB not found, skipping...') else: toload = libAutosave.ask_dialog() if toload: kbpath = libAutosave.get_kb_path() glob.kb.load(kbpath) libAutosave.remove_kb() # Update KB Tree self.treeview.update_tree() # Adding text to Log window self.gom.echo('Loaded', False) else: libAutosave.remove_kb() # To keep record of kb file name self.kbfile = '' # Update Map self.uicore.getDot(False) self.xdotw.set_dotcode(self.uicore.get_last_dot()) self.treeview.update_tree() self.treeview.expand_all() self.xdotw.zoom_image(1.0) Gtk.main()
def __init__(self): # ################################################################################################################################# # # Load and apply gtkrc # ################################################################# # # No exception control because rc_parse doesn't throw exception on fail... sad but true ;) # ORIGDIR = os.getcwd() # os.chdir('lib/ui/data/Brave/gtk-2.0/') # gtk.rc_parse('gtkrc') # os.chdir(ORIGDIR) from lib.core import create_profile_dir create_profile_dir() self.ing = self # Load Output Manager self.gom = om.OutputManager('gui', self.ing) # Create config self.config = config ################################################################################################################################# # Create a new window ################################################################# splash.push(("Creating main window...")) self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_icon_from_file('logo' + os.sep + 'inguma_16.png') self.window.set_focus = True self.window.connect("delete_event", self.quit) splash.push(("Loading...")) gtk.settings_get_default().set_long_property("gtk-button-images", True, "main") # Title self.window.set_title(MAINTITLE) # Positions self.window.resize(800, 600) self.window.move(25, 25) # Maximize window self.window.maximize() ################################################################################################################################# # Load core... ################################################################# #Initialize KB splash.push(("Loading KB...")) self.uicore = core.UIcore() self.uicore.add_local_asn() self.gom.set_core(self.uicore) # Check module window prefs setattr(self.uicore, 'SHOW_MODULE_WIN', self.config.SHOW_MODULE_WIN) self.uicore.set_om(self.gom) ################################################################################################################################# # Main VBox ################################################################# mainvbox = gtk.VBox(False, 1) mainvbox.set_border_width(1) self.window.add(mainvbox) mainvbox.show() ################################################################################################################################# # ToolBar ################################################################# splash.push(("Creating menu and toolbar...")) self.toolbar = toolbar.Toolbar(self.ing) mainvbox.pack_start(self.toolbar, False, False, 1) if self.config.HAS_SOURCEVIEW: self.bokken_tb = bokken_toolbar.TopButtons(self.ing) mainvbox.pack_start(self.bokken_tb, False, False, 1) # Disable if not GtkSourceView2 if not self.config.HAS_SOURCEVIEW: self.toolbar.edit_tb.set_sensitive(False) # Disable if not Vte if not self.config.HAS_VTE: self.toolbar.sniffer_tb.set_sensitive(False) self.toolbar.scapy_tb.set_sensitive(False) ################################################################################################################################# # Map tab ################################################################# # Will contain on top the notebook and on bottom log window self.vpaned = gtk.VPaned() # Will contain xdot widget and kb window self.hpaned = gtk.HPaned() ################################################################# # KB Textview ################################################################# self.textview = kbwin.KBwindow() #self.gom.set_kbwin(self.textview) ################################################################# # KB TreeView ################################################################# self.treeview = kbtree.KBtree() self.tree = self.treeview.createTree() self.treeview.updateTree() self.gom.set_kbwin(self.treeview) self.tree.show() ################################################################# # xdot map ################################################################# from . import inxdot # nodeMenu initialization stuff self.uiman = nodeMenu.UIManager(self.gom, self.uicore, self.config) self.uiman.set_data(None) accel = self.uiman.get_accel_group() self.window.add_accel_group(accel) # graphMenu initialization stuff self.graph_uiman = graphMenu.UIManager(self.gom, self.uicore) graph_accel = self.graph_uiman.get_accel_group() self.window.add_accel_group(graph_accel) # altNodeMenu initialization stuff self.altnode_uiman = altNodeMenu.UIManager(self.gom, self.uicore) altnode_accel = self.altnode_uiman.get_accel_group() self.window.add_accel_group(altnode_accel) self.xdotw = inxdot.MyDotWidget(self.uiman, self.graph_uiman, self.altnode_uiman, self.uicore) setattr(self.graph_uiman, 'xdot', self.xdotw) setattr(self.altnode_uiman, 'xdot', self.xdotw) self.gom.set_map(self.xdotw) setattr(self.uicore, 'xdot', self.xdotw) self.uicore.getDot(doASN=False) self.xdotw.set_dotcode( self.uicore.get_kbfield('dotcode') ) self.xdotw.zoom_image(1.0) ################################################################# # Graph Menu ################################################################# gmenu = graphTBar.GraphMenu(self.xdotw, self.uicore) ################################################################# # HBox for Map and GraphMenu ################################################################# menubox = gtk.HBox() menubox.pack_start(self.xdotw, True, True) menubox.pack_start(gmenu, False, False) # Show elements gmenu.show() menubox.show() ################################################################# # Scrolled Window ################################################################# self.scrolled_window = gtk.ScrolledWindow() self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrolled_window.set_size_request(250,-1) # Add Textview to Scrolled Window self.scrolled_window.add_with_viewport(self.tree) ################################################################# # Map Iface ################################################################# label = gtk.Label('Map') # Test XDOT MAP self.hpaned.show() self.hpaned.pack1(menubox, True, True) self.hpaned.pack2(self.scrolled_window, False, False) self.textview.show() # Check visibility on config preferences if self.config.SHOW_KBTREE: self.scrolled_window.show() self.scrolled_window.is_visible = True else: self.scrolled_window.is_visible = False self.hpaned.show() self.xdotw.show() label = gtk.Label(' Map') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_MENU) b.pack_start(label) b.pack_start(i) b.show_all() ################################################################# # Notebook ################################################################# self.notebook = gtk.Notebook() self.notebook.set_tab_pos(gtk.POS_LEFT) self.notebook.append_page(self.hpaned, b) self.notebook.connect("switch_page", self.on_switch) ################################################################################################################################# # Consoles Tab ################################################################# label = gtk.Label(' Term') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU) b.pack_start(label) b.pack_start(i) b.show_all() term_box = gtk.VBox() term_button = gtk.Button("New Tab", gtk.STOCK_ADD) # Disable if VTE not available if not self.config.HAS_VTE: term_button.set_sensitive(False) term_box.pack_start(term_button,False) self.term_notebook = libTerminal.TerminalNotebook() term_button.connect("clicked", self.new_tab) term_box.pack_start(self.term_notebook) setattr(self.uiman, 'termnb', self.term_notebook) setattr(self.uiman, 'mainnb', self.notebook) self.notebook.append_page(term_box, b) term_box.show_all() ################################################################################################################################# # RCE Iface ################################################################# label = gtk.Label(' RCE') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_MENU) b.pack_start(label) b.pack_start(i) b.show_all() if self.config.HAS_SOURCEVIEW: # Create bokken UI and add to the Notebook self.bokken = bokken.MainApp('', self.ing) self.rcevb = self.bokken.get_supervb() self.rcevb.show_all() self.notebook.append_page(self.rcevb, b) self.bokken_tb.init_core() self.bokken_tb.hide() ################################################################################################################################# # Xploit Iface ################################################################# # Exploits Notebook for Exploit DB, Fuzzing and Exploit Dev self.exploits_nb = gtk.Notebook() self.exploits_nb.set_tab_pos(gtk.POS_LEFT) # # Exploits DB # label = gtk.Label(' Exploits DB') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU) b.pack_start(label) b.pack_start(i) b.show_all() self.exploitsInst = exploits.Exploits(self.config, self.term_notebook) exploitsGui = self.exploitsInst.get_widget() setattr(self.exploitsInst, 'gom', self.gom) exploitsGui.show_all() self.exploits_nb.append_page(exploitsGui, b) # # Fuzzers # label = gtk.Label(' Fuzzing') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU) b.pack_start(label) b.pack_start(i) b.show_all() # Fuzzers Box to contain krash and scapy fuzzers self.fuzz_frame = fuzz_frame.FuzzFrame() setattr(self.fuzz_frame.scapyui, 'gom', self.gom) setattr(self.fuzz_frame.krashui, 'gom', self.gom) self.exploits_nb.append_page(self.fuzz_frame, b) setattr(self.uiman, 'fuzz_frame', self.fuzz_frame) # Add exploits notebook and text/label to main notebook label = gtk.Label(' Exploit') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU) b.pack_start(label) b.pack_start(i) b.show_all() self.notebook.append_page(self.exploits_nb, b) setattr(self.uiman, 'notebook', self.notebook) self.vpaned.add1(self.notebook) self.exploits_nb.show_all() self.notebook.show() ################################################################################################################################# # Log Window ################################################################# self.logtext = gtk.TextView(buffer=None) # Some eye candy self.logtext.modify_base(gtk.STATE_NORMAL, gtk.gdk.Color(16400, 16400, 16440)) self.logtext.modify_text(gtk.STATE_NORMAL, gtk.gdk.Color(60535, 60535, 60535, 0)) self.logtext.set_left_margin(10) self.logtext.set_wrap_mode(gtk.WRAP_NONE) self.logtext.set_editable(False) self.logbuffer = self.logtext.get_buffer() self.logbuffer.set_text('Loading Inguma...\n') self.logtext.show() ################################################################# # Log Scrolled Window ################################################################# self.log_scrolled_window = gtk.ScrolledWindow() self.log_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) self.log_scrolled_window.is_visible = True #Always on bottom on change self.vajd = self.log_scrolled_window.get_vadjustment() self.vajd.connect('changed', lambda a, s=self.log_scrolled_window: self.rescroll(a,s)) # Add Textview to Scrolled Window self.log_scrolled_window.add_with_viewport(self.logtext) # Set logtext as output for gui self.gom.set_gui(self.logbuffer) # Add Scrolled Log Window to Bottom Notebook ############################################ # Notebook for bottom panel self.bottom_nb = gtk.Notebook() self.bottom_nb.set_size_request(-1, 110) self.bottom_nb.set_tab_pos(gtk.POS_LEFT) self.bottom_nb.connect("switch_page", self.on_bottom_switch) # Icon and label for Logs tab label = gtk.Label(' Logs') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) self.log_icon = gtk.Image() self.log_icon.set_from_stock(gtk.STOCK_JUSTIFY_FILL, gtk.ICON_SIZE_MENU) b.pack_start(label) b.pack_start(self.log_icon) b.show_all() self.bottom_nb.append_page(self.log_scrolled_window, b) # Icon and label for Actions tab label = gtk.Label(' Actions') label.set_angle(90) b_factory = gtk.VBox b = b_factory(spacing=1) i = gtk.Image() i.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU) b.pack_start(label) b.pack_start(i) b.show_all() # Add Threads TreeView self.threadsInst = threadstv.ThreadsTv(self) threadsGui = self.threadsInst.get_widget() setattr(self.threadsInst, 'uicore', self.uicore) threadsGui.show_all() self.bottom_nb.append_page(threadsGui, b) setattr(self.fuzz_frame.scapyui, 'bottom_nb', self.bottom_nb) setattr(self.fuzz_frame.krashui, 'bottom_nb', self.bottom_nb) # Check visibility on config preferences if self.config.SHOW_LOG: self.bottom_nb.is_visible = True self.bottom_nb.show() else: self.bottom_nb.is_visible = False self.vpaned.pack2(self.bottom_nb, False, False) mainvbox.pack_start(self.vpaned, True, True, 1) self.log_scrolled_window.show() self.bottom_nb.set_current_page(0) # Add threadtv to core self.uicore.set_threadtv(self.threadsInst) setattr(self.graph_uiman, 'threadtv', self.threadsInst) setattr(self.altnode_uiman, 'threadtv', self.threadsInst) # And to exploit management module setattr(self.exploitsInst, 'threadsInst', self.threadsInst) # Must be connected here to avoid errors due to bottom_nb not yet existing self.exploits_nb.connect("switch_page", self.on_exploits_switch) ################################################################################################################################# #StatusBar ################################################################# self.statusbar = statusbar.Statusbar() self.statusbar._create_helpers() mainvbox.pack_end(self.statusbar, False, False, 1) from lib.core import get_inguma_version self.gom.insert_sb_text('Inguma ' + get_inguma_version()) if self.config.HAS_SOURCEVIEW: self.bokken_sb = statusbar.Statusbar() mainvbox.pack_end(self.bokken_sb, False, False, 1) self.gom.insert_bokken_text({'Open a new file to start':''}, self.bokken.version) self.statusbar.show_all() # Systray self.systray = systray.Systray(self) ################################################################################################################################# # finish it ################################################################# self.vpaned.show() self.window.show() splash.destroy() # Check for autosaved KB and ask for loading if not libAutosave.check_kb(): print "Autosaved KB not found, skipping..." else: toload = libAutosave.ask_dialog() if toload: kbpath = libAutosave.get_kb_path() self.uicore.loadKB(kbpath) libAutosave.remove_kb() # Update KB textview self.textview.updateWin() self.treeview.updateTree() # Adding text to Log window self.gom.echo( 'Loaded' , False) else: libAutosave.remove_kb() # To keep record of kb file name self.kbfile = '' # Update Map self.xdotw.set_dotcode( self.uicore.get_kbfield('dotcode') ) self.xdotw.zoom_image(1.0) gtk.main()