def create_url_tree(self, links): # Create the column imports = gtk.TreeViewColumn() imports.set_title("URL") cell = gtk.CellRendererText() rendererPix = gtk.CellRendererPixbuf() imports.pack_start(rendererPix, False) imports.pack_start(cell, True) imports.set_attributes(cell, text=1) imports.set_attributes(rendererPix, pixbuf=0) #imports.add_attribute(cell, "text", 0) self.treestore = gtk.TreeStore(gtk.gdk.Pixbuf, str) self.remote_pix = gtk.gdk.pixbuf_new_from_file(datafile_path('function.png')) self.local_pix = gtk.gdk.pixbuf_new_from_file(datafile_path('block.png')) self.exp_pix = gtk.gdk.pixbuf_new_from_file(datafile_path('export.png')) self.data_sec_pix = gtk.gdk.pixbuf_new_from_file(datafile_path('data-sec.png')) # Iterate links and add to the tree it = self.treestore.append(None, [self.remote_pix, 'Remote links']) for element in links['remotes']: self.treestore.append(it, [self.remote_pix, element + '\t' + '']) it = self.treestore.append(None, [self.local_pix, 'Local resources']) for element in links['locals']: self.treestore.append(it, [self.local_pix, element + '\t' + '']) # Add column to tree self.append_column(imports) self.set_model(self.treestore) self.expand_all()
def __init__(self, core, textviews): self.store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str, str) super(TreeViews, self).__init__(self.store) self.uicore = core self.textviews = textviews self.set_rules_hint(True) self.set_has_tooltip(True) # Connect right click popup search menu self.popup_handler = self.connect('button-press-event', self.popup_menu) self.popup_handler = self.connect('row-activated', self.popup_menu) self.fcn_pix = GdkPixbuf.Pixbuf.new_from_file( datafile_path('function.png')) self.bb_pix = GdkPixbuf.Pixbuf.new_from_file( datafile_path('block.png')) self.data_sec_pix = GdkPixbuf.Pixbuf.new_from_file( datafile_path('data-sec.png')) self.exp_pix = GdkPixbuf.Pixbuf.new_from_file( datafile_path('export.png')) self.imp_pix = GdkPixbuf.Pixbuf.new_from_file( datafile_path('import.png'))
def create(toolbar): '''Set of instructions to create the search widget in a toolbar.''' # Search components toolbar.search_combo_tb = Gtk.ToolItem() toolbar.search_combo_align = Gtk.Alignment.new(0, 0.5, 0, 0) store = Gtk.ListStore(GdkPixbuf.Pixbuf, str) toolbar.search_combo = Gtk.ComboBox.new_with_model(store) rendererText = Gtk.CellRendererText() rendererPix = Gtk.CellRendererPixbuf() toolbar.search_combo.pack_start(rendererPix, False) toolbar.search_combo.pack_start(rendererText, True) toolbar.search_combo.add_attribute(rendererPix, 'pixbuf', 0) toolbar.search_combo.add_attribute(rendererText, 'text', 1) options = { 'String': GdkPixbuf.Pixbuf.new_from_file(datafile_path('icon_string_16.png')), 'String no case': GdkPixbuf.Pixbuf.new_from_file( datafile_path('icon_string_no_case_16.png')), 'Hexadecimal': GdkPixbuf.Pixbuf.new_from_file( datafile_path('icon_hexadecimal_16.png')), 'Regexp': GdkPixbuf.Pixbuf.new_from_file(datafile_path('icon_regexp_16.png')) } for option in options.keys(): store.append([options[option], option]) toolbar.search_combo.set_active(0) toolbar.search_combo_align.add(toolbar.search_combo) toolbar.search_combo_tb.add(toolbar.search_combo_align) toolbar.main_tb.insert(toolbar.search_combo_tb, -1) # Separator toolbar.sep = Gtk.SeparatorToolItem() toolbar.sep.set_draw(False) toolbar.main_tb.insert(toolbar.sep, -1) toolbar.search_entry_tb = Gtk.ToolItem() toolbar.search_entry = Gtk.Entry() toolbar.search_entry.set_max_length(100) toolbar.search_entry.set_text('Text to search') toolbar.search_entry.set_icon_from_stock(1, Gtk.STOCK_FIND) toolbar.search_entry.set_icon_tooltip_text(1, 'Search') toolbar.search_entry.connect("activate", toolbar.search) toolbar.search_entry.connect("icon-press", toolbar.search) toolbar.search_entry.connect('focus-in-event', toolbar._clean, 'in') toolbar.search_entry.connect('focus-out-event', toolbar._clean, 'out') toolbar.search_entry_tb.add(toolbar.search_entry) # We use the AccelGroup object from the main window. my_accel = Gtk.accel_groups_from_object(toolbar.main.window)[0] key, mod = Gtk.accelerator_parse('<Control>F') toolbar.search_entry.set_tooltip_text('Control-F to search') toolbar.search_entry.add_accelerator('grab-focus', my_accel, key, mod, Gtk.AccelFlags.MASK) toolbar.main_tb.insert(toolbar.search_entry_tb, -1)
def create(toolbar): '''Set of instructions to create the search widget in a toolbar.''' # Search components toolbar.search_combo_tb = gtk.ToolItem() toolbar.search_combo_align = gtk.Alignment(yalign=0.5) store = gtk.ListStore(gtk.gdk.Pixbuf, str) toolbar.search_combo = gtk.ComboBox(store) rendererText = gtk.CellRendererText() rendererPix = gtk.CellRendererPixbuf() toolbar.search_combo.pack_start(rendererPix, False) toolbar.search_combo.pack_start(rendererText, True) toolbar.search_combo.add_attribute(rendererPix, 'pixbuf', 0) toolbar.search_combo.add_attribute(rendererText, 'text', 1) options = { 'String': gtk.gdk.pixbuf_new_from_file(datafile_path('icon_string_16.png')), 'String no case': gtk.gdk.pixbuf_new_from_file( datafile_path('icon_string_no_case_16.png')), 'Hexadecimal': gtk.gdk.pixbuf_new_from_file(datafile_path('icon_hexadecimal_16.png')), 'Regexp': gtk.gdk.pixbuf_new_from_file(datafile_path('icon_regexp_16.png')) } for option in options.keys(): store.append([options[option], option]) toolbar.search_combo.set_active(0) toolbar.search_combo_align.add(toolbar.search_combo) toolbar.search_combo_tb.add(toolbar.search_combo_align) toolbar.main_tb.insert(toolbar.search_combo_tb, -1) # Separator toolbar.sep = gtk.SeparatorToolItem() toolbar.sep.set_draw(False) toolbar.main_tb.insert(toolbar.sep, -1) toolbar.search_entry_tb = gtk.ToolItem() toolbar.search_entry = gtk.Entry(100) toolbar.search_entry.set_text('Text to search') toolbar.search_entry.set_icon_from_stock(1, gtk.STOCK_FIND) toolbar.search_entry.set_icon_tooltip_text(1, 'Search') toolbar.search_entry.connect("activate", toolbar.search) toolbar.search_entry.connect("icon-press", toolbar.search) toolbar.search_entry.connect('focus-in-event', toolbar._clean, 'in') toolbar.search_entry.connect('focus-out-event', toolbar._clean, 'out') toolbar.search_entry_tb.add(toolbar.search_entry) # We use the AccelGroup object from the main window. my_accel = gtk.accel_groups_from_object(toolbar.main.window)[0] key, mod = gtk.accelerator_parse('<Control>F') toolbar.search_entry.set_tooltip_text('Control-F to search') toolbar.search_entry.add_accelerator('grab-focus', my_accel, key, mod, gtk.ACCEL_MASK) toolbar.main_tb.insert(toolbar.search_entry_tb, -1)
def __init__(self): self.img_static = Gtk.Image() self.img_static.set_from_file(datafile_path('throbber_static.gif')) self.img_static.show() self.img_animat = Gtk.Image() self.img_animat.set_from_file(datafile_path('throbber_animat.gif')) self.img_animat.show() super(Throbber, self).__init__(self.img_static, "") self.set_sensitive(False)
def __init__(self): self.img_static = Gtk.Image() self.img_static.set_from_file(datafile_path('throbber_static.gif')) self.img_static.show() self.img_animat = Gtk.Image() self.img_animat.set_from_file(datafile_path('throbber_animat.gif')) self.img_animat.show() super(Throbber,self).__init__(self.img_static, "") self.set_sensitive(False)
def __init__(self, text, menu): gtk.Button.__init__(self) self.menu = menu hbox1 = gtk.HBox() hbox2 = gtk.HBox() icon = gtk.Image() icon.set_from_file(datafile_path('bokken-small.svg')) hbox1.pack_start(icon, True, True, 3) label = gtk.Label(text) hbox1.pack_start(label, True, True, 3) arrow = gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_IN) hbox1.pack_start(arrow, False, False, 3) hbox2.pack_start(hbox1, True, True, 0) # Text settings attrs = pango.AttrList() attrs.change(pango.AttrWeight(pango.WEIGHT_SEMIBOLD, 0, -1)) label.set_attributes(attrs) self.add(hbox2) self.set_relief(gtk.RELIEF_NORMAL) self.set_can_focus(True) self.set_can_default(False) self.connect("toggled", self.on_toggled) for sig in "selection-done", "deactivate", "cancel": menu.connect(sig, self.on_menu_dismiss)
def __init__(self, uicore, textviews): super(SectionsView ,self).__init__() self.uicore = uicore self.set_shadow_type(Gtk.ShadowType.ETCHED_IN) self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.sections_tree = SectionsTreeView(self.uicore, textviews) self.fcn_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('function.png')) self.data_sec_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('data-sec.png')) # Add Textview to Scrolled Window self.add(self.sections_tree) self.show_all()
def __init__(self, text, menu): GObject.GObject.__init__(self) self.menu = menu hbox1 = Gtk.HBox() hbox2 = Gtk.HBox() icon = Gtk.Image() icon.set_from_file(datafile_path('bokken-small.svg')) hbox1.pack_start(icon, True, True, 3) label = Gtk.Label() label.set_markup("<b>" + text + "</b>") hbox1.pack_start(label, True, True, 3) arrow = Gtk.Arrow(Gtk.ArrowType.DOWN, Gtk.ShadowType.IN) hbox1.pack_start(arrow, False, False, 3) hbox2.pack_start(hbox1, True, True, 0) # MEOW Text settings #attrs = Pango.AttrList() #attrs.change(Pango.AttrWeight(Pango.Weight.SEMIBOLD, 0, -1)) #label.set_attributes(attrs) self.add(hbox2) self.set_relief(Gtk.ReliefStyle.NORMAL) self.set_can_focus(True) self.set_can_default(False) self.connect("toggled", self.on_toggled) for sig in "selection-done", "deactivate", "cancel": menu.connect(sig, self.on_menu_dismiss)
def create_tree(self, imps): # Create the column imports = Gtk.TreeViewColumn() imports.set_title("Imports") imports.set_spacing(5) self.treestore = Gtk.TreeStore(GdkPixbuf.Pixbuf, str) self.imp_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('import.png')) rendererPix = Gtk.CellRendererPixbuf() rendererText = Gtk.CellRendererText() imports.pack_start(rendererPix, False) imports.pack_start(rendererText, True) imports.set_attributes(rendererText, text=1) imports.set_attributes(rendererPix, pixbuf=0) # Iterate imports and add to the tree for element in imps.keys(): it = self.treestore.append(None, [self.fcn_pix, element]) for imp in imps[element]: self.treestore.append(it, [self.imp_pix, imp[0] + '\t' + imp[1]]) # Add column to tree self.append_column(imports) self.set_model(self.treestore) self.expand_all()
def create_relocs_columns(self): self.data_sec_pix = GdkPixbuf.Pixbuf.new_from_file( datafile_path('data-sec.png')) rendererPix = Gtk.CellRendererPixbuf() rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Name") column.set_spacing(5) column.pack_start(rendererPix, False) column.pack_start(rendererText, True) column.set_attributes(rendererText, text=1) column.set_attributes(rendererPix, pixbuf=0) column.set_sort_column_id(0) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Virtual Address", rendererText, text=2) self.store.set_sort_column_id(2, Gtk.SortType.ASCENDING) column.set_sort_column_id(2) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Size", rendererText, text=3) column.set_sort_column_id(3) self.append_column(column)
def create_exports_columns(self): self.exp_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('export.png')) rendererPix = Gtk.CellRendererPixbuf() rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Offset") column.set_spacing(5) column.pack_start(rendererPix, False) column.pack_start(rendererText, True) column.set_attributes(rendererText, text=1) column.set_attributes(rendererPix, pixbuf=0) self.store.set_sort_column_id(1,Gtk.SortType.ASCENDING) column.set_sort_column_id(1) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Name", rendererText, text=2) column.set_sort_column_id(2) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Ordinal", rendererText, text=3) column.set_sort_column_id(3) self.append_column(column) self.set_model(self.store)
def __init__(self, uicore, textviews): super(SectionsView ,self).__init__() self.uicore = uicore self.set_shadow_type(gtk.SHADOW_ETCHED_IN) self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.sections_tree = SectionsTreeView(self.uicore, textviews) self.fcn_pix = gtk.gdk.pixbuf_new_from_file(datafile_path('function.png')) self.data_sec_pix = gtk.gdk.pixbuf_new_from_file(datafile_path('data-sec.png')) # Add Textview to Scrolled Window self.add(self.sections_tree) self.show_all()
def create_exports_columns(self): self.exp_pix = gtk.gdk.pixbuf_new_from_file(datafile_path('export.png')) rendererPix = gtk.CellRendererPixbuf() rendererText = gtk.CellRendererText() column = gtk.TreeViewColumn("Offset") column.set_spacing(5) column.pack_start(rendererPix, False) column.pack_start(rendererText, True) column.set_attributes(rendererText, text=1) column.set_attributes(rendererPix, pixbuf=0) self.store.set_sort_column_id(1,gtk.SORT_ASCENDING) column.set_sort_column_id(1) self.append_column(column) rendererText = gtk.CellRendererText() column = gtk.TreeViewColumn("Name", rendererText, text=2) column.set_sort_column_id(2) self.append_column(column) rendererText = gtk.CellRendererText() column = gtk.TreeViewColumn("Ordinal", rendererText, text=3) column.set_sort_column_id(3) self.append_column(column) self.set_model(self.store)
def create_functions_columns(self): rendererText = gtk.CellRendererText() rendererPix = gtk.CellRendererPixbuf() self.fcn_pix = gtk.gdk.pixbuf_new_from_file(datafile_path('function.png')) self.bb_pix = gtk.gdk.pixbuf_new_from_file(datafile_path('block.png')) column = gtk.TreeViewColumn("Function") column.set_spacing(5) column.pack_start(rendererPix, False) column.pack_start(rendererText, True) column.set_attributes(rendererText, text=1) column.set_attributes(rendererPix, pixbuf=0) column.set_sort_column_id(1) self.store.set_sort_column_id(1,gtk.SORT_ASCENDING) self.append_column(column) self.set_model(self.store)
def create_tree(self, imps): # Create the column imports = gtk.TreeViewColumn() imports.set_title("Imports") imports.set_spacing(5) self.treestore = gtk.TreeStore(gtk.gdk.Pixbuf, str) self.imp_pix = gtk.gdk.pixbuf_new_from_file(datafile_path('import.png')) rendererPix = gtk.CellRendererPixbuf() rendererText = gtk.CellRendererText() imports.pack_start(rendererPix, False) imports.pack_start(rendererText, True) imports.set_attributes(rendererText, text=1) imports.set_attributes(rendererPix, pixbuf=0) # Iterate imports and add to the tree for element in imps.keys(): it = self.treestore.append(None, [self.fcn_pix, element]) for imp in imps[element]: self.treestore.append(it, [self.imp_pix, imp[0] + '\t' + imp[1]]) # Add column to tree self.append_column(imports) self.set_model(self.treestore) self.expand_all()
def __init__(self, text, menu): GObject.GObject.__init__(self) self.menu = menu hbox1 = Gtk.HBox() hbox2 = Gtk.HBox() icon = Gtk.Image() icon.set_from_file(datafile_path('bokken-small.svg')) hbox1.pack_start(icon, True, True, 3) label = Gtk.Label() label.set_markup("<b>"+ text + "</b>") hbox1.pack_start(label, True, True, 3) arrow = Gtk.Arrow(Gtk.ArrowType.DOWN, Gtk.ShadowType.IN) hbox1.pack_start(arrow, False, False, 3) hbox2.pack_start(hbox1, True, True, 0) # MEOW Text settings #attrs = Pango.AttrList() #attrs.change(Pango.AttrWeight(Pango.Weight.SEMIBOLD, 0, -1)) #label.set_attributes(attrs) self.add(hbox2) self.set_relief(Gtk.ReliefStyle.NORMAL) self.set_can_focus(True) self.set_can_default(False) self.connect("toggled", self.on_toggled) for sig in "selection-done", "deactivate", "cancel": menu.connect(sig, self.on_menu_dismiss)
def create_sections_columns(self): self.data_sec_pix = gtk.gdk.pixbuf_new_from_file(datafile_path('data-sec.png')) rendererPix = gtk.CellRendererPixbuf() rendererText = gtk.CellRendererText() column = gtk.TreeViewColumn("Section") column.set_spacing(5) column.pack_start(rendererPix, False) column.pack_start(rendererText, True) column.set_attributes(rendererText, text=1) column.set_attributes(rendererPix, pixbuf=0) column.set_sort_column_id(0) self.append_column(column) rendererText = gtk.CellRendererText() column = gtk.TreeViewColumn("Virtual Address", rendererText, text=2) self.store.set_sort_column_id(2,gtk.SORT_ASCENDING) column.set_sort_column_id(2) self.append_column(column) rendererText = gtk.CellRendererText() column = gtk.TreeViewColumn("Virtual Size", rendererText, text=3) column.set_sort_column_id(3) self.append_column(column) rendererText = gtk.CellRendererText() column = gtk.TreeViewColumn("Raw Size", rendererText, text=4) column.set_sort_column_id(4) self.append_column(column) self.set_model(self.store)
def __init__(self, uicore, main): super(XrefsMenu,self).__init__() self.uicore = uicore self.main = main self.fcn_img = gtk.Image() self.fcn_img.set_from_file(datafile_path('function.png'))
def create_functions_columns(self): rendererText = Gtk.CellRendererText() rendererText.tooltip_handle = self.connect('motion-notify-event', self.fcn_tooltip) rendererPix = Gtk.CellRendererPixbuf() self.fcn_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('function.png')) self.bb_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('block.png')) column = Gtk.TreeViewColumn("Function") column.set_spacing(5) column.pack_start(rendererPix, False) column.pack_start(rendererText, True) column.set_attributes(rendererText, text=1) column.set_attributes(rendererPix, pixbuf=0) column.set_sort_column_id(1) self.store.set_sort_column_id(1,Gtk.SortType.ASCENDING) self.append_column(column) self.set_model(self.store)
def __init__(self, uicore, main): super(XrefsMenu, self).__init__() self.uicore = uicore self.main = main self.fcn_img = Gtk.Image() self.fcn_img.set_from_file(datafile_path('function.png'))
def __init__(self, core, tviews): super(Statusbar,self).__init__() self.uicore = core self.tviews = tviews self.icons = {'processor':datafile_path('processor_small.png'), 'name':gtk.STOCK_FILE, 'format':gtk.STOCK_EXECUTE, 'size':gtk.STOCK_PREFERENCES, 'OS':gtk.STOCK_INFO, 'type':gtk.STOCK_INFO, 'va':gtk.STOCK_UNINDENT, 'ep': gtk.STOCK_INDENT}
def popup_stack(self, widget): dialog = Gtk.Dialog('The stack', self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CLOSE,Gtk.ResponseType.CLOSE)) ui.gtk3.common.set_bokken_icon(dialog) stack_img = Gtk.Image() stack_img.set_from_file(datafile_path('stack.png')) dialog.vbox.pack_start(self.create_h1_label("The stack"), False, False, 2) dialog.vbox.pack_start(stack_img, True, True, 2) dialog.show_all() dialog.run() dialog.destroy()
def popup_stack(self, widget): dialog = gtk.Dialog('The stack', None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CLOSE,gtk.RESPONSE_CLOSE)) ui.gtk2.common.set_bokken_icon(dialog) stack_img = gtk.Image() stack_img.set_from_file(datafile_path('stack.png')) dialog.vbox.pack_start(self.create_h1_label("The stack"), False, False, 2) dialog.vbox.pack_start(stack_img, True, True, 2) dialog.show_all() dialog.run() dialog.destroy()
def add_text(self, data_dict, version): '''data_dict ontains text to be added. Key will be the title Value will be... well, the value :)''' self.box = gtk.HBox(False, 1) self._statusbar.pack_start(self.box, False, False, 1) ellipsize=pango.ELLIPSIZE_NONE for element in data_dict.keys(): # Element icon if element == 'processor': _icon = gtk.image_new_from_file(datafile_path('processor_small.png')) self.box.pack_start(_icon, False, False, 0) else: _icon = gtk.image_new_from_stock(self.icons[element], gtk.ICON_SIZE_MENU) self.box.pack_start(_icon, False, False, 0) # Element label label = gtk.Label() label.set_markup('<b>' + element.capitalize() + ':</b>') label.set_padding(1, 5) label.set_max_width_chars(len(element) + 1) label.set_single_line_mode(True) label.set_ellipsize(ellipsize) self.box.pack_start(label, True, True, 1) # Element content label = gtk.Label(str(data_dict[element])) label.set_padding(1, 5) label.set_max_width_chars(len(str(data_dict[element]))) label.set_single_line_mode(True) label.set_ellipsize(ellipsize) self.box.pack_start(label, True, True, 1) sep = gtk.VSeparator() self.box.pack_start(sep, True, True, 1) if version: _icon = gtk.image_new_from_file(datafile_path('bokken-small.svg')) self.pack_start(_icon, False, False, 1) label = gtk.Label() label.set_markup('<b>Bokken ' + version + '</b> (' + self.uicore.backend.capitalize() + ' ' + self.uicore.version + ')') label.set_padding(3, 3) self.pack_end(label, False) self.show_all()
def popup_registers(self, widget): dialog = gtk.Dialog('16bit and 8bit registers', None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CLOSE,gtk.RESPONSE_CLOSE)) ui.gtk2.common.set_bokken_icon(dialog) reg_img = gtk.Image() reg_img.set_from_file(datafile_path('registers.png')) reg_label = gtk.Label("The four primary general purpose registers (EAX, EBX, ECX and EDX)\nhave 16 and 8 bit overlapping aliases.") reg_label.set_alignment(0.1, 0.1) reg_label.set_padding (0, 3) dialog.vbox.pack_start(reg_label, False, False, 2) dialog.vbox.pack_start(reg_img, True, True, 2) dialog.show_all() dialog.run() dialog.destroy()
def popup_stack(self, widget): dialog = Gtk.Dialog( 'The stack', self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)) ui.gtk3.common.set_bokken_icon(dialog) stack_img = Gtk.Image() stack_img.set_from_file(datafile_path('stack.png')) dialog.vbox.pack_start(self.create_h1_label("The stack"), False, False, 2) dialog.vbox.pack_start(stack_img, True, True, 2) dialog.show_all() dialog.run() dialog.destroy()
def create_dialog(self): about = Gtk.AboutDialog() about.set_program_name("Bokken") ui.gtk3.common.set_bokken_icon(about) about.set_version(glob.version) about.set_copyright("(c) Hugo Teso <*****@*****.**>") about.set_comments("A GUI for radare2!") about.set_website("http://www.bokken.re") about.set_authors(["Hugo Teso <*****@*****.**>", "David Martínez <*****@*****.**>"]) about.set_artists(["Ana Muniesa <*****@*****.**>", "Huahe <*****@*****.**> twitter: @huahe", "Marcos Gómez <*****@*****.**>"]) about.set_logo(GdkPixbuf.Pixbuf.new_from_file(datafile_path('bokken.svg'))) return about
def __init__(self, core, tviews): super(Statusbar, self).__init__() self.uicore = core self.tviews = tviews self.icons = { 'Arch': datafile_path('processor_small.png'), 'Name': Gtk.STOCK_FILE, 'Format': Gtk.STOCK_EXECUTE, 'Size': Gtk.STOCK_PREFERENCES, 'OS': Gtk.STOCK_INFO, 'Type': Gtk.STOCK_INFO, 'va': Gtk.STOCK_UNINDENT, 'ep': Gtk.STOCK_INDENT, }
def popup_registers(self, widget): dialog = Gtk.Dialog( '16-bit and 8-bit registers', self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)) ui.gtk3.common.set_bokken_icon(dialog) reg_img = Gtk.Image() reg_img.set_from_file(datafile_path('registers.png')) reg_label = Gtk.Label( "The four primary general purpose registers (EAX, EBX, ECX and EDX)\nhave 16 and 8 bit overlapping aliases." ) reg_label.set_alignment(0.1, 0.1) reg_label.set_padding(0, 3) dialog.vbox.pack_start(reg_label, False, False, 2) dialog.vbox.pack_start(reg_img, True, True, 2) dialog.show_all() dialog.run() dialog.destroy()
def add_text(self, data_dict, version): '''data_dict ontains text to be added. Key will be the title Value will be... well, the value :)''' self.box = Gtk.HBox(False, 1) self._statusbar.pack_start(self.box, False, False, 1) ellipsize = Pango.EllipsizeMode.NONE for element in data_dict.keys(): if element == 'Arch': _icon = Gtk.Image.new_from_file(self.icons[element]) else: _icon = Gtk.Image.new_from_stock(self.icons[element], Gtk.IconSize.MENU) self.box.pack_start(_icon, False, False, 0) # Element label label = Gtk.Label() label.set_markup('<b>%s:</b>' % element) label.set_padding(1, 0) label.set_max_width_chars(len(element) + 1) label.set_single_line_mode(True) label.set_ellipsize(ellipsize) self.box.pack_start(label, True, True, 1) # Element content label = Gtk.Label(label=str(data_dict[element])) label.set_padding(1, 0) label.set_max_width_chars(len(str(data_dict[element]))) label.set_single_line_mode(True) label.set_ellipsize(ellipsize) self.box.pack_start(label, True, True, 1) sep = Gtk.VSeparator() self.box.pack_start(sep, True, True, 1) if version: _icon = Gtk.Image.new_from_file(datafile_path('bokken-small.svg')) self.pack_start(_icon, False, False, 1) label = Gtk.Label() label.set_markup('<b>Bokken ' + version + '</b> (' + self.uicore.backend.capitalize() + ' ' + self.uicore.version + ')') label.set_padding(1, 0) self.pack_end(label, False, True, 0) self.show_all()
def create_dialog(self): about = Gtk.AboutDialog() about.set_program_name("Bokken") ui.gtk3.common.set_bokken_icon(about) about.set_version(glob.version) about.set_copyright("(c) Hugo Teso <*****@*****.**>") about.set_comments("A GUI for radare2!") about.set_website("http://www.bokken.re") about.set_authors([ "Hugo Teso <*****@*****.**>", "David Martínez <*****@*****.**>" ]) about.set_artists([ "Ana Muniesa <*****@*****.**>", "Huahe <*****@*****.**> twitter: @huahe", "Marcos Gómez <*****@*****.**>" ]) about.set_logo( GdkPixbuf.Pixbuf.new_from_file(datafile_path('bokken.svg'))) return about
def add_text(self, data_dict, version): '''data_dict ontains text to be added. Key will be the title Value will be... well, the value :)''' self.box = Gtk.HBox(False, 1) self._statusbar.pack_start(self.box, False, False, 1) ellipsize = Pango.EllipsizeMode.NONE for element in data_dict.keys(): if element == 'Arch': _icon = Gtk.Image.new_from_file(self.icons[element]) else: _icon = Gtk.Image.new_from_stock(self.icons[element], Gtk.IconSize.MENU) self.box.pack_start(_icon, False, False, 0) # Element label label = Gtk.Label() label.set_markup('<b>%s:</b>' % element) label.set_padding(1, 0) label.set_max_width_chars(len(element) + 1) label.set_single_line_mode(True) label.set_ellipsize(ellipsize) self.box.pack_start(label, True, True, 1) # Element content label = Gtk.Label(label=str(data_dict[element])) label.set_padding(1, 0) label.set_max_width_chars(len(str(data_dict[element]))) label.set_single_line_mode(True) label.set_ellipsize(ellipsize) self.box.pack_start(label, True, True, 1) sep = Gtk.VSeparator() self.box.pack_start(sep, True, True, 1) if version: _icon = Gtk.Image.new_from_file(datafile_path('bokken-small.svg')) self.pack_start(_icon, False, False, 1) label = Gtk.Label() label.set_markup('<b>Bokken ' + version + '</b> (' + self.uicore.backend.capitalize() + ' ' + self.uicore.version + ')') label.set_padding(1, 0) self.pack_end(label, False, True, 0) self.show_all()
def __init__(self, main): super(TextViews,self).__init__(False, 1) self.main = main self.uicore = self.main.uicore self.match_start = None self.match_end = None ################################################################# # Main HBox (self) and HPaned ################################################################# # Left and right Vertical Boxes self.left_paned = Gtk.HPaned() self.left_paned.set_position(125) ################################################################# # Left mini-toolbar ################################################################# self.left_buttons = left_buttons.LeftButtons(self.main) self.pack_start(self.left_buttons, False, False, 1) self.pack_start(self.left_paned, True, True, 1) ################################################################# # Left ListView and TreeView ################################################################# # Scrolled Window self.left_scrolled_window = Gtk.ScrolledWindow() self.left_scrolled_window.set_shadow_type(Gtk.ShadowType.ETCHED_IN) self.left_scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) # self.left_scrolled_window.set_size_request(100, 1) self.left_scrolled_window.show() # Create left TreeView self.left_treeview = treeviews.TreeViews(self.uicore, self) self.left_scrolled_window.add(self.left_treeview) self.left_paned.pack1(self.left_scrolled_window, True, True) ################################################################# # Right Textview ################################################################# self.right_textview = right_textview.RightTextView(self.main) self.buffer = self.right_textview.buffer self.view = self.right_textview.view self.mgr = self.right_textview.mgr ################################################################# # Hexdump Textview ################################################################# self.hexdump_view = hexdump_view.HexdumpView(self.main) ################################################################# # Strings Treeview ################################################################# self.strings_treeview = strings_treeview.StringsView(self.uicore, self) ################################################################# # Sections Treeview ################################################################# self.sections_treeview = sections_treeview.SectionsView(self.uicore, self) ################################################################# # Bindiff widget ################################################################# self.bindiff_widget = bindiff.Bindiff(self.uicore, self) self.bindiff = self.bindiff_widget.dw ################################################################# # Full file info widget ################################################################# self.info_widget = info_tree.InfoWindow(self.uicore) ################################################################# # Right Paned ################################################################# # Paned for the right notebook and the bottom console self.right_paned = Gtk.VPaned() self.right_paned.set_position(300) ################################################################# # Right NoteBook ################################################################# self.right_notebook = rightnotebook.RightNotebook(self) ################################################################# # Right Paned ################################################################# # Terminals Notebook self.term_nb = Gtk.Notebook() self.term_nb.set_tab_pos(Gtk.PositionType.LEFT) # Console textview i = Gtk.Image() i.set_from_stock(Gtk.STOCK_EXECUTE, Gtk.IconSize.SMALL_TOOLBAR) self.console = console_textview.ConsoleTextView(self.main) self.term_nb.insert_page(self.console, i, 0) # Python textview self.py_pix = Gtk.Image() self.py_pix.set_from_file(datafile_path('python-icon.png')) self.python = python_textview.PythonTextView(self.main) self.term_nb.insert_page(self.python, self.py_pix, 1) # Add notebook to the paned self.right_paned.pack1(self.right_notebook, True, True) self.right_paned.pack2(self.term_nb, True, False) self.left_paned.pack2(self.right_paned, True, True) self.right_notebook.show()
def create_buttons(self, option): # Icons self.fcn_pix = Gtk.Image() self.fcn_pix.set_from_file(datafile_path('function.png')) self.bb_pix = Gtk.Image() self.bb_pix.set_from_file(datafile_path('block.png')) self.imp_pix = Gtk.Image() self.imp_pix.set_from_file(datafile_path('import.png')) self.exp_pix = Gtk.Image() self.exp_pix.set_from_file(datafile_path('export.png')) self.cls_pix = Gtk.Image() self.cls_pix.set_from_file( datafile_path('function.png')) # TODO: class icon # Show/hide toolbar and menu self.hide_tb = Gtk.ToggleButton() i = Gtk.Image() i.set_from_stock(Gtk.STOCK_GO_UP, Gtk.IconSize.MENU) self.hide_tb.set_image(i) self.hide_tb.set_tooltip_text('Toggle visibility of the top toolbar') handler = self.hide_tb.connect('toggled', self._hide_tb_toggled) self.hide_tb.handler = handler self.pack_start(self.hide_tb, False, False, 0) if 'bin' in option: # Functions a = Gtk.VBox(False, 1) fcntb = Gtk.ToggleButton() fcntb.set_active(True) fcntb.set_tooltip_text( 'List of function entrypoints in the binary') handler = fcntb.connect('toggled', self._on_toggle) fcntb.handler = handler l = Gtk.Label(label='Functions') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.fcn_pix, False, False, 1) fcntb.add(a) self.pack_start(fcntb, False, False, 0) if option == 'full_bin': # Imports imptb = Gtk.ToggleButton() imptb.set_tooltip_text('List of imported symbols') handler = imptb.connect('toggled', self._on_toggle) imptb.handler = handler a = Gtk.VBox(False, 1) l = Gtk.Label(label='Imports') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.imp_pix, False, False, 1) imptb.add(a) # Symbols exptb = Gtk.ToggleButton() exptb.set_tooltip_text('List of exported symbols') handler = exptb.connect('toggled', self._on_toggle) exptb.handler = handler a = Gtk.VBox(False, 1) l = Gtk.Label(label='Symbols') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.exp_pix, False, False, 1) exptb.add(a) # Relocs sectb = Gtk.ToggleButton() sectb.set_tooltip_text('List of relocs in the binary') handler = sectb.connect('toggled', self._on_toggle) sectb.handler = handler a = Gtk.VBox(False, 1) l = Gtk.Label(label='Relocs') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.bb_pix, False, False, 1) sectb.add(a) # Classes clstb = Gtk.ToggleButton() clstb.set_tooltip_text('List of classes and methods') handler = clstb.connect('toggled', self._on_toggle) clstb.handler = handler a = Gtk.VBox(False, 1) l = Gtk.Label(label='Classes') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.cls_pix, False, False, 1) clstb.add(a) self.pack_start(imptb, False, False, 0) self.pack_start(exptb, False, False, 0) self.pack_start(sectb, False, False, 0) self.pack_start(clstb, False, False, 0) self.show_all()
def __init__(self, file='', first_run=False): super(FileDialog,self).__init__('Select file', None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) self.file = file self.timer_id = None # Set dialog resizeable and auto-shrink self.set_resizable(False) ui.gtk2.common.set_bokken_icon(self) # The Ok Button. self.butt_ok = self.action_area.get_children()[0] self.butt_ok.connect("clicked", self.fast_start) self.butt_ok.set_sensitive(False) # The Cancel button. self.butt_cancel = self.action_area.get_children()[1] self.butt_cancel.connect("clicked", self.cancel) # Window position self.set_position(gtk.WIN_POS_CENTER) # Main Vertical Box self.main_vbox = gtk.VBox(False, 2) self.main_vbox.set_border_width(7) # Logo self.logo = gtk.Image() self.logo.set_from_file(datafile_path('bokken.svg')) # Logo label self.logo_text = gtk.Label() self.logo_text.set_markup('<span size=\'12000\'>Welcome to <b>Bokken '+glob.version+'</b></span>') # Common label self.label = gtk.Label('Select a target or enter the path manually.') self.label.set_padding(0, 3) self.label.set_alignment(0, 0.5) # Radare targets label self.radare_label = gtk.Label() self.radare_label.set_markup('Valid inputs are: <b>PE, ELF and mach0</b> files') self.radare_label.set_padding(0, 2) # Horizontal Separator self.hseparator1 = gtk.HSeparator() self.plugins = [] from ui.radare_core import Core as UICore self.plugins = UICore.get_plugins() # Horizontal Separator self.hseparator2 = gtk.HSeparator() # File selection Horizontal Box self.hbox = gtk.HBox(False, 0) # TextEntry self.model = gtk.ListStore(str) self.input_entry = gtk.ComboBoxEntry(self.model, column=0) self.input_entry.get_child().connect("activate", self.fast_start) self.input_entry.connect("changed", self._validate_cb) #self.input_entry = gtk.Entry(100) if self.file: self.input_entry.get_child().set_text(self.file) # Recent file manager self.manager = gtk.recent_manager_get_default() items = self.manager.get_items() for element in items[:10]: self.model.append([element.get_uri_display()]) # Select file button icon = gtk.Image() icon.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_MENU) self.select_button = gtk.Button() self.select_button.set_image(icon) self.select_button.connect("clicked", self.select_file) # Pack elements into hbox self.hbox.pack_start(self.input_entry, True, True, 2) self.hbox.pack_start(self.select_button, False, False, 2) # File options Horizontal Box self.options_hbox = gtk.HBox(False, 2) # Radare option Vertical Box self.radare_box = gtk.VBox(False, 0) self.vseparator = gtk.VSeparator() self.radare_box_2 = gtk.VBox(False, 0) self.radare_box_3 = gtk.VBox(False, 0) # pack the boxes self.options_hbox.pack_start(self.radare_box, True, True, 0) self.options_hbox.pack_start(self.vseparator, False, False, 5) self.options_hbox.pack_start(self.radare_box_2, True, True, 0) # HSeparator self.hseparator3 = gtk.HSeparator() # Analysis options label self.anal_label = gtk.Label() self.anal_label.set_markup("<b>Analysis options:</b>") # Advanced Analysis options label self.adv_anal_label = gtk.Label() self.adv_anal_label.set_markup("<b>Advanced options:</b>") # Radare options self.anal_bin = gtk.CheckButton(label='Analyze program') self.anal_bin.set_active(True) self.anal_bin.connect("toggled", self._no_anal) self.anal_depth_label = gtk.Label('Max analysis depth: ') self.anal_depth_entry = gtk.Entry(3) self.anal_depth_entry.set_width_chars(3) self.anal_depth_entry.set_text('16') self.radare_dasm = gtk.CheckButton(label='Lower case disassembly') self.radare_dasm.set_active(True) self.io_va = gtk.CheckButton(label='Don\'t use VA') self.asm_syntax = gtk.CheckButton(label='Use AT&T syntax') self.asm_bytes = gtk.CheckButton(label='Don\'t show asm bytes') # Bottom radare2 options self.hseparator5 = gtk.HSeparator() self.bits_label = gtk.Label('Bits:') self.bits = gtk.combo_box_new_text() #self.bits.set_size_request(70, -1) self.arch_label = gtk.Label('Architecture:') self.arch = gtk.combo_box_new_text() self.arch.connect("changed", self._arch_changed) self.arch.append_text('Auto') for plugin in self.plugins: self.arch.append_text('%s (%s)' % (plugin.name, plugin.arch)) #self.arch.append_text('%s (%s) - %s' % (plugin.name, plugin.arch, plugin.desc)) self.arch.set_active(0) self.start_addr = gtk.CheckButton(label='Start address: ') self.start_addr.connect("toggled", self._start_addr_ctl) self.start_addr_label = gtk.Label() self.start_addr_label.set_markup('<b>0x</b>') self.start_addr_label.set_padding(0, 5) self.start_addr_address = gtk.Entry(12) self.start_addr_address.set_width_chars(12) self.start_addr_address.set_sensitive(False) # More radare2 options self.stack_check = gtk.CheckButton(label='Show stack pointer') self.pseudo_check = gtk.CheckButton(label='Enable pseudo syntax') self.flow_lines = gtk.CheckButton(label='Show flow lines') self.flow_lines.connect("toggled", self._flow_lines_ctl) self.flow_lines_label = gtk.Label('Columns for flow lines: ') self.flow_lines_entry = gtk.Entry(3) self.flow_lines_entry.set_width_chars(3) self.flow_lines_entry.set_text('20') self.flow_lines_entry.set_sensitive(False) # Pack them self.flow_hbox = gtk.HBox(False) self.depth_hbox = gtk.HBox(False) self.radare_box_2.pack_start(self.pseudo_check, False, False, 2) self.radare_box_2.pack_start(self.stack_check, False, False, 2) self.radare_box_2.pack_start(self.asm_bytes, False, False, 2) self.radare_box_2.pack_start(self.flow_lines, False, False, 2) self.flow_hbox.pack_start(self.flow_lines_label, False, False, 2) self.flow_hbox.pack_start(self.flow_lines_entry, False, False, 2) self.radare_box_2.pack_start(self.flow_hbox, False, False, 2) self.depth_hbox.pack_start(self.anal_depth_label, False, False, 2) self.depth_hbox.pack_start(self.anal_depth_entry, False, False, 2) self.radare_box.pack_start(self.anal_bin, False, False, 2) self.radare_box.pack_start(self.depth_hbox, False, False, 2) self.radare_box.pack_start(self.radare_dasm, False, False, 2) self.radare_box.pack_start(self.io_va, False, False, 2) self.radare_box.pack_start(self.asm_syntax, False, False, 2) self.start_addr_hbox = gtk.HBox(False, 0) self.start_addr_hbox.pack_start(self.start_addr, False, False, 0) self.start_addr_hbox.pack_start(self.start_addr_label, False, False, 2) self.start_addr_hbox.pack_start(self.start_addr_address, True, True, 2) self.radare_box_3.pack_start(self.hseparator5, False, False, 5) self.radare_box_3.pack_start(self.adv_anal_label, False, False, 5) self.radare_box_3.pack_start(self.start_addr_hbox, False, False, 2) self.arch_hbox = gtk.HBox(False, 0) self.arch_hbox.pack_start(self.arch_label, False, False, 2) self.arch_hbox.pack_start(self.arch, True, True, 2) self.radare_box_3.pack_start(self.arch_hbox, False, False, 2) self.bits_hbox = gtk.HBox(False, 0) self.bits_hbox.pack_start(self.bits_label, False, False, 2) self.bits_hbox.pack_start(self.bits, False, False, 2) #self.radare_box_3.pack_start(self.bits_hbox, False, False, 2) self.arch_hbox.pack_start(self.bits_hbox, False, False, 2) # Pack elements into main_vbox self.main_vbox.pack_start(self.logo, False, False, 0) self.main_vbox.pack_start(self.logo_text, False, False, 0) self.main_vbox.pack_start(self.hseparator1, False, False, 2) self.main_vbox.pack_start(self.hseparator2, False, False, 2) self.main_vbox.pack_start(self.label, False, False, 2) self.main_vbox.pack_start(self.radare_label, False, False, 1) self.main_vbox.pack_start(self.hbox, False, False, 2) self.main_vbox.pack_start(self.hseparator3, False, False, 2) self.main_vbox.pack_start(self.anal_label, False, False, 2) self.main_vbox.pack_start(self.options_hbox, False, False, 2) self.main_vbox.pack_start(self.radare_box_3, False, False, 2) self.vbox.pack_start(self.main_vbox, True, True, 0) self.set_focus(self.input_entry.get_child()) self.show_all()
def __init__(self, main): super(TextViews, self).__init__(False, 1) self.main = main self.uicore = self.main.uicore self.match_start = None self.match_end = None ################################################################# # Main HBox (self) and HPaned ################################################################# # Left and right Vertical Boxes self.left_paned = Gtk.HPaned() self.left_paned.set_position(125) ################################################################# # Left mini-toolbar ################################################################# self.left_buttons = left_buttons.LeftButtons(self.main) self.pack_start(self.left_buttons, False, False, 1) self.pack_start(self.left_paned, True, True, 1) ################################################################# # Left ListView and TreeView ################################################################# # Scrolled Window self.left_scrolled_window = Gtk.ScrolledWindow() self.left_scrolled_window.set_shadow_type(Gtk.ShadowType.ETCHED_IN) self.left_scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) # self.left_scrolled_window.set_size_request(100, 1) self.left_scrolled_window.show() # Create left TreeView self.left_treeview = treeviews.TreeViews(self.uicore, self) self.left_scrolled_window.add(self.left_treeview) self.left_paned.pack1(self.left_scrolled_window, True, True) ################################################################# # Right Textview ################################################################# self.right_textview = right_textview.RightTextView(self.main) self.buffer = self.right_textview.buffer self.view = self.right_textview.view self.mgr = self.right_textview.mgr ################################################################# # Hexdump Textview ################################################################# self.hexdump_view = hexdump_view.HexdumpView(self.main) ################################################################# # Strings Treeview ################################################################# self.strings_treeview = strings_treeview.StringsView(self.uicore, self) ################################################################# # Sections Treeview ################################################################# self.sections_treeview = sections_treeview.SectionsView( self.uicore, self) ################################################################# # Classes Treeview ################################################################# self.classes_treeview = classes_treeview.ClassesView(self.uicore, self) ################################################################# # Bindiff widget ################################################################# self.bindiff_widget = bindiff.Bindiff(self.uicore, self) self.bindiff = self.bindiff_widget.dw ################################################################# # Full file info widget ################################################################# self.info_widget = info_tree.InfoWindow(self.uicore) ################################################################# # Right Paned ################################################################# # Paned for the right notebook and the bottom console self.right_paned = Gtk.VPaned() self.right_paned.set_position(300) ################################################################# # Right NoteBook ################################################################# self.right_notebook = rightnotebook.RightNotebook(self) ################################################################# # Right Paned ################################################################# # Terminals Notebook self.term_nb = Gtk.Notebook() self.term_nb.set_tab_pos(Gtk.PositionType.LEFT) # Console textview i = Gtk.Image() i.set_from_stock(Gtk.STOCK_EXECUTE, Gtk.IconSize.SMALL_TOOLBAR) self.console = console_textview.ConsoleTextView(self.main) self.term_nb.insert_page(self.console, i, 0) # Python textview self.py_pix = Gtk.Image() self.py_pix.set_from_file(datafile_path('python-icon.png')) self.python = python_textview.PythonTextView(self.main) self.term_nb.insert_page(self.python, self.py_pix, 1) # Add notebook to the paned self.right_paned.pack1(self.right_notebook, True, True) self.right_paned.pack2(self.term_nb, True, False) self.left_paned.pack2(self.right_paned, True, True) self.right_notebook.show()
def __init__(self, has_pyew, has_radare, core='', file='', first_run=False): super(FileDialog,self).__init__('Select file', None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) self.has_pyew = has_pyew self.has_radare = has_radare self.core = core self.file = file self.timer_id = None # Set dialog resizeable and auto-shrink self.set_resizable(False) ui.gtk2.common.set_bokken_icon(self) # The Ok Button. self.butt_ok = self.action_area.get_children()[0] self.butt_ok.connect("clicked", self.fast_start) self.butt_ok.set_sensitive(False) # The Cancel button. self.butt_cancel = self.action_area.get_children()[1] self.butt_cancel.connect("clicked", self.cancel) # Window position self.set_position(gtk.WIN_POS_CENTER) # Main Vertical Box self.main_vbox = gtk.VBox(False, 2) self.main_vbox.set_border_width(7) # Logo self.logo = gtk.Image() self.logo.set_from_file(datafile_path('bokken.svg')) # Logo label self.logo_text = gtk.Label() self.logo_text.set_markup('<span size=\'12000\'>Welcome to <b>Bokken '+glob.version+'</b></span>') # Common label self.label = gtk.Label('Select a target or enter the path manually.') self.label.set_padding(0, 3) self.label.set_alignment(0, 0.5) # Pyew targets label self.pyew_label = gtk.Label() self.pyew_label.set_markup('Valid inputs are: <b>PE/ELF, PDF, plain text files and URLs</b>') self.pyew_label.set_padding(0, 2) # Radare targets label self.radare_label = gtk.Label() self.radare_label.set_markup('Valid inputs are: <b>PE, ELF, mach0 and java/dex classes</b>') self.radare_label.set_padding(0, 2) # Horizontal Separator self.hseparator1 = gtk.HSeparator() # Core selection label and combo self.core_label = gtk.Label('Select backend to use: ') self.core_label.set_alignment(0, 0.5) self.core_combo = gtk.combo_box_new_text() if self.has_pyew: self.core_combo.append_text('Pyew') if self.has_radare: self.core_combo.append_text('Radare') if not self.core: self.core_combo.set_active(0) elif self.has_radare != self.has_pyew: self.core_combo.set_active(0) elif self.core == 'pyew': self.core_combo.set_active(0) if not first_run: self.core_combo.remove_text(1) elif self.core == 'radare': self.core_combo.set_active(1) if not first_run: self.core_combo.remove_text(0) self.core = self.core_combo.get_active_text().lower() # Core combo Horizontal Box self.core_hbox = gtk.HBox(False, 0) self.core_hbox.pack_start(self.core_label, True, True, 2) self.core_hbox.pack_start(self.core_combo, False, False, 2) # Horizontal Separator self.hseparator2 = gtk.HSeparator() # File selection Horizontal Box self.hbox = gtk.HBox(False, 0) # TextEntry self.model = gtk.ListStore(str) self.input_entry = gtk.ComboBoxEntry(self.model, column=0) self.input_entry.get_child().connect("activate", self.fast_start) self.input_entry.connect("changed", self._validate_cb) #self.input_entry = gtk.Entry(100) if self.file: self.input_entry.get_child().set_text(self.file) # Recent file manager self.manager = gtk.recent_manager_get_default() items = self.manager.get_items() for element in items[:10]: self.model.append([element.get_uri_display()]) # Select file button icon = gtk.Image() icon.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_MENU) self.select_button = gtk.Button() self.select_button.set_image(icon) self.select_button.connect("clicked", self.select_file) # Pack elements into hbox self.hbox.pack_start(self.input_entry, True, True, 2) self.hbox.pack_start(self.select_button, False, False, 2) # File options Horizontal Box self.options_hbox = gtk.HBox(False, 2) # Pyew option Vertical Box self.pyew_box = gtk.VBox(False, 0) # Radare option Vertical Box self.radare_box = gtk.VBox(False, 0) # pack the boxes self.options_hbox.pack_start(self.pyew_box, False, False, 0) self.options_hbox.pack_start(self.radare_box, False, False, 0) # HSeparator self.hseparator3 = gtk.HSeparator() # Analysis options label self.anal_label = gtk.Label() self.anal_label.set_markup("<b>Analysis options:</b>") # Pyew options self.deep_anal = gtk.CheckButton(label='Deep analysis') self.case_dasm = gtk.CheckButton(label='Lower case disassembly') self.case_dasm.set_active(True) self.pyew_box.pack_start(self.deep_anal, False, False, 2) self.pyew_box.pack_start(self.case_dasm, False, False, 2) # It's here to avoid errors during start up self.core_combo.connect("changed", self._on_change) # Radare options self.anal_bin = gtk.CheckButton(label='Analyze program') self.anal_bin.set_active(True) self.anal_bin.connect("toggled", self._no_anal) self.radare_dasm = gtk.CheckButton(label='Lower case disassembly') self.radare_dasm.set_active(True) self.io_va = gtk.CheckButton(label='Don\'t use VA') self.asm_syntax = gtk.CheckButton(label='Use AT&T syntax') self.asm_bytes = gtk.CheckButton(label='Don\'t show asm bytes') self.start_addr = gtk.CheckButton(label='Start address:') self.start_addr.connect("toggled", self._start_addr_ctl) self.start_addr_label = gtk.Label() self.start_addr_label.set_markup('<b>0x</b>') self.start_addr_label.set_padding(0, 2) self.start_addr_address = gtk.Entry() self.start_addr_address.set_sensitive(False) self.bits_16 = gtk.CheckButton(label='16-bit analysis (only x86)') self.radare_box.pack_start(self.anal_bin, False, False, 2) self.radare_box.pack_start(self.radare_dasm, False, False, 2) self.radare_box.pack_start(self.io_va, False, False, 2) self.radare_box.pack_start(self.asm_syntax, False, False, 2) self.radare_box.pack_start(self.asm_bytes, False, False, 2) self.start_addr_hbox = gtk.HBox(False, 0) self.start_addr_hbox.pack_start(self.start_addr, True, True, 2) self.start_addr_hbox.pack_start(self.start_addr_label, False, False, 2) self.start_addr_hbox.pack_start(self.start_addr_address, False, False, 2) self.radare_box.pack_start(self.start_addr_hbox, False, False, 2) self.radare_box.pack_start(self.bits_16, False, False, 2) # Pack elements into main_vbox self.main_vbox.pack_start(self.logo, False, False, 0) self.main_vbox.pack_start(self.logo_text, False, False, 0) self.main_vbox.pack_start(self.hseparator1, False, False, 2) self.main_vbox.pack_start(self.core_hbox, False, False, 2) self.main_vbox.pack_start(self.hseparator2, False, False, 2) self.main_vbox.pack_start(self.label, False, False, 2) self.main_vbox.pack_start(self.pyew_label, False, False, 1) self.main_vbox.pack_start(self.radare_label, False, False, 1) self.main_vbox.pack_start(self.hbox, False, False, 2) self.main_vbox.pack_start(self.hseparator3, False, False, 2) self.main_vbox.pack_start(self.anal_label, False, False, 2) self.main_vbox.pack_start(self.options_hbox, False, False, 2) self.vbox.pack_start(self.main_vbox) self.set_focus(self.input_entry.get_child()) self.show_all() if self.core == 'pyew': self.radare_box.set_visible(False) self.radare_label.set_visible(False) elif self.core == 'radare': self.pyew_box.set_visible(False) self.pyew_label.set_visible(False) else: self.radare_box.set_visible(False) self.radare_label.set_visible(False)
def __init__(self, core, main): super(TopButtons,self).__init__(False, 1) self.main = main self.uicore = core self.toolbox = self self.options_dict = {'Hexadecimal':'x', 'String':'s', 'String no case':'i', 'Regexp':'r', 'Unicode':'u', 'Unicode no case':'U'} self.main_tb = gtk.Toolbar() self.main_tb.set_style(gtk.TOOLBAR_ICONS) # Main Button self.menu = main_button_menu.MenuBar(self.main) self.menu_button = main_button.MainMenuButton("Bokken", self.menu) self.menu_button.set_border_width(0) menu_toolitem = gtk.ToolItem() menu_toolitem.add(self.menu_button) self.main_tb.insert(menu_toolitem, -1) # Separator self.sep = gtk.SeparatorToolItem() self.main_tb.insert(self.sep, -1) # PDF Streams search self.streams_tb = gtk.ToolButton(gtk.STOCK_INDEX) self.streams_tb.set_tooltip_text('Find PDF streams') self.streams_tb.connect("clicked", self.search_pdfstreams) self.streams_tb.set_sensitive(False) self.main_tb.insert(self.streams_tb, -1) # Separator self.sep = gtk.SeparatorToolItem() self.main_tb.insert(self.sep, -1) # URL related buttons i = gtk.Image() pixbuf = gtk.gdk.pixbuf_new_from_file(datafile_path('response-headers.png')) scaled_buf = pixbuf.scale_simple(24,24,gtk.gdk.INTERP_BILINEAR) i.set_from_pixbuf(scaled_buf) self.urls = gtk.MenuToolButton(i, 'URL') #self.urls.set_icon_widget(i) self.urls.set_tooltip_text('URL plugins') self.urls_menu = gtk.Menu() i = gtk.Image() pixbuf = gtk.gdk.pixbuf_new_from_file(datafile_path('response-headers.png')) scaled_buf = pixbuf.scale_simple(16,16,gtk.gdk.INTERP_BILINEAR) i.set_from_pixbuf(scaled_buf) item = gtk.ImageMenuItem('Search for URL') item.set_image(i) item.connect("activate", self.show_urls) self.urls_menu.append(item) i = gtk.Image() pixbuf = gtk.gdk.pixbuf_new_from_file(datafile_path('response-body.png')) scaled_buf = pixbuf.scale_simple(16,16,gtk.gdk.INTERP_BILINEAR) i.set_from_pixbuf(scaled_buf) item = gtk.ImageMenuItem('Check URL') item.set_image(i) item.connect("activate", self.check_urls) self.urls_menu.append(item) i = gtk.Image() pixbuf = gtk.gdk.pixbuf_new_from_file(datafile_path('request-body.png')) scaled_buf = pixbuf.scale_simple(16,16,gtk.gdk.INTERP_BILINEAR) i.set_from_pixbuf(scaled_buf) item = gtk.ImageMenuItem('Check bad URL') item.set_image(i) item.connect("activate", self.check_bad_urls) self.urls_menu.append(item) self.urls_menu.show_all() self.urls.set_menu(self.urls_menu) self.urls_menu.show_all() self.main_tb.insert(self.urls, -1) # Separator self.sep = gtk.SeparatorToolItem() self.main_tb.insert(self.sep, -1) # Visualization buttons self.visbin_tb = gtk.ToolButton(gtk.STOCK_ZOOM_FIT) self.visbin_tb.connect("clicked", self.execute, 'binvi') self.visbin_tb.set_tooltip_text('Visualize binary') self.visbin_tb.set_sensitive(False) self.main_tb.insert(self.visbin_tb, -1) # Separator self.sep = gtk.SeparatorToolItem() self.main_tb.insert(self.sep, -1) # Binary analysis buttons self.vtotal_tb = gtk.ToolButton(gtk.STOCK_CONNECT) self.vtotal_tb.connect("clicked", self.send_to_virustotal) self.vtotal_tb.set_tooltip_text('Send to VirusTotal') self.vtotal_tb.set_sensitive(False) self.main_tb.insert(self.vtotal_tb, -1) self.threat_tb = gtk.ToolButton(gtk.STOCK_JUMP_TO) self.threat_tb.connect("clicked", self.execute, 'threat') self.threat_tb.set_tooltip_text('Search in Threat Expert') self.threat_tb.set_sensitive(False) self.main_tb.insert(self.threat_tb, -1) self.shellcode_tb = gtk.ToolButton(gtk.STOCK_FIND) self.shellcode_tb.connect("clicked", self.search_shellcode) self.shellcode_tb.set_tooltip_text('Search for Shellcode') self.shellcode_tb.set_sensitive(False) self.main_tb.insert(self.shellcode_tb, -1) # not yet working properly self.antivm_tb = gtk.ToolButton(gtk.STOCK_FIND_AND_REPLACE) self.antivm_tb.connect("clicked", self.search_antivm) self.antivm_tb.set_tooltip_text('Search for antivm tricks') self.antivm_tb.set_sensitive(False) self.main_tb.insert(self.antivm_tb, -1) self.packed_tb = gtk.ToolButton(gtk.STOCK_CONVERT) self.packed_tb.connect("clicked", self.check_packer) self.packed_tb.set_tooltip_text('Check if the PE file is packed') self.packed_tb.set_sensitive(False) self.main_tb.insert(self.packed_tb, -1) # Separator self.sep = gtk.SeparatorToolItem() self.main_tb.insert(self.sep, -1) import ui.search_widget ui.search_widget.create(self) # Separator self.sep = gtk.SeparatorToolItem() self.main_tb.insert(self.sep, -1) # Cheatsheet button self.cheatsheet_tb = gtk.ToolButton(gtk.STOCK_JUSTIFY_FILL) self.cheatsheet_tb.set_tooltip_text('Show assembler reference sheet') self.cheatsheet_tb.connect("clicked", self.create_cheatsheet_dialog) self.main_tb.insert(self.cheatsheet_tb, -1) # Separator self.sep = gtk.SeparatorToolItem() self.sep.set_expand(True) self.sep.set_draw(False) self.main_tb.insert(self.sep, -1) # Throbber self.throbber = throbber.Throbber() self.throbber_tb = gtk.ToolItem() self.throbber_tb.add(self.throbber) self.main_tb.insert(self.throbber_tb, -1) self.toolbox.pack_start(self.main_tb, True, True) self.show_all()
def __init__(self, title='Reference Sheet for x86 Assembler'): super(CheatsheetDialog,self).__init__(title, None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_ABOUT, gtk.RESPONSE_ACCEPT, gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) import pango # The Cancel button. self.butt_cancel = self.action_area.get_children()[0] self.butt_cancel.connect("clicked", lambda x: self.destroy()) self.butt_about = self.action_area.get_children()[1] self.butt_about.connect("clicked", self._show_about) self.vbox.set_spacing(3) # Positions self.resize(600, 700) self.set_position(gtk.WIN_POS_CENTER) ui.gtk2.common.set_bokken_icon(self) self.pix = gtk.gdk.pixbuf_new_from_file(datafile_path('block.png')) # Font font_desc = pango.FontDescription("FreeSans 9") # Assembly Summary vbox_summary = gtk.VBox(False, 1) hbox_summary = gtk.HBox(False, 1) summ_icon = gtk.image_new_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_MENU) label_summary = gtk.Label() label_summary.set_markup(self.summary) #label_summary.modify_font(font_desc) #label_summary.set_line_wrap(True) label_summary.set_alignment(0, 0) # Pack icon and title hbox_summary.pack_start(summ_icon, False, False, 2) hbox_summary.pack_start(self.create_h1_label('Assembly language'), True, True, 2) # Pack contents vbox_summary.pack_start(hbox_summary, False, False, 2) vbox_summary.pack_start(label_summary, True, True, 2) self.vbox.pack_start(vbox_summary, False, False, 2) # Directives and operands VBox lang_vbox = gtk.VBox(False, 2) # Assembly directives directives_vbox = gtk.VBox(False, 2) directives_hbox = gtk.HBox(False, 1) directives_icon = gtk.image_new_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU) directives_hbox.pack_start(directives_icon, False, False, 2) directives_hbox.pack_start(self.create_h2_label('Assembly directives'), True, True, 2) directives_vbox.pack_start(directives_hbox, False, False, 2) assembler_directives_tv = self.populate_treeview(self.assembler_directives) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER) assembler_directives_tv = self.populate_treeview(self.assembler_directives) renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn("", renderer_text, text=0) assembler_directives_tv.append_column(column) renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn("", renderer_text, text=1) renderer_text.set_property("wrap_width", 300) renderer_text.set_property("wrap_mode", pango.WRAP_WORD_CHAR) assembler_directives_tv.append_column(column) assembler_directives_tv.set_headers_visible(False) sw.add(assembler_directives_tv) directives_vbox.add(sw) # Operand types operands_vbox = gtk.VBox(False, 2) operands_hbox = gtk.HBox(False, 1) operands_icon = gtk.image_new_from_stock(gtk.STOCK_PROPERTIES, gtk.ICON_SIZE_MENU) operands_hbox.pack_start(operands_icon, False, False, 2) operands_hbox.pack_start(self.create_h2_label('Operand Types'), True, True, 2) operands_vbox.pack_start(operands_hbox, False, False, 2) assembler_operands_tv = self.populate_treeview(self.operand_types) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER) assembler_operands_tv = self.populate_treeview(self.operand_types) renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn("", renderer_text, text=0) assembler_operands_tv.append_column(column) renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn("", renderer_text, text=1) renderer_text.set_property("wrap_width", 300) renderer_text.set_property("wrap_mode", pango.WRAP_WORD_CHAR) assembler_operands_tv.append_column(column) assembler_operands_tv.set_headers_visible(False) sw.add(assembler_operands_tv) operands_vbox.add(sw) # Terminology vbox_terminology = gtk.VBox(False, 1) terminology_hbox = gtk.HBox(False, 1) terminology_icon = gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_MENU) terminology_hbox.pack_start(terminology_icon, False, False, 2) terminology_hbox.pack_start(self.create_h1_label('Terminology and Functions'), True, True, 2) vbox_terminology.pack_start(terminology_hbox, False, False, 2) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) terminology_tv = self.populate_treeview(self.terms) renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn("", renderer_text, text=0) terminology_tv.append_column(column) renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn("", renderer_text, text=1) renderer_text.set_property("wrap_width", 300) renderer_text.set_property("wrap_mode", pango.WRAP_WORD_CHAR) terminology_tv.append_column(column) terminology_tv.set_headers_visible(False) sw.add(terminology_tv) vbox_terminology.add(sw) self.hbox = gtk.HBox(False, 3) lang_vbox.pack_start(directives_vbox, False, False, 0) lang_vbox.pack_start(operands_vbox, False, False, 0) self.hbox.add(lang_vbox) self.hbox.pack_start(gtk.VSeparator(), False, False, 0) self.hbox.add(vbox_terminology) # Hbox for instructions and registers self.bottom_hbox = gtk.HBox(False, 3) # Instructions instructions_vbox = gtk.VBox(False, 0) instructions_hbox = gtk.HBox(False, 0) instructions_icon = gtk.image_new_from_stock(gtk.STOCK_INDENT, gtk.ICON_SIZE_MENU) info_icon = gtk.image_new_from_stock(gtk.STOCK_SORT_ASCENDING, gtk.ICON_SIZE_MENU) stack_button = gtk.Button() stack_button.set_tooltip_text("Stack diagram") stack_button.set_image(info_icon) stack_button.set_label('The stack') stack_button.connect('clicked', self.popup_stack) instructions_hbox.pack_start(instructions_icon, False, False, 2) instructions_label = self.create_h1_label('Instructions') instructions_label.set_padding(0, 5) instructions_hbox.pack_start(instructions_label, True, True, 2) instructions_hbox.pack_end(stack_button, False, False, 2) self.sw = gtk.ScrolledWindow() self.sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.treeview = self.populate_treeview(self.instructions) renderer_text = gtk.CellRendererText() # font = pango.FontDescription('Bitstream Charter 9') # renderer_text.set_property('font-desc', font) column = gtk.TreeViewColumn("Instruction", renderer_text, text=0) column.set_sort_column_id(0) self.treeview.append_column(column) renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn("Description", renderer_text, text=1) renderer_text.set_property("wrap_width", 390) renderer_text.set_property("wrap_mode", pango.WRAP_WORD_CHAR) self.treeview.append_column(column) self.sw.add(self.treeview) instructions_vbox.pack_start(instructions_hbox, False, False, 1) instructions_vbox.pack_start(self.sw, True, True, 1) # Registers registers_vbox = gtk.VBox(False, 0) registers_hbox = gtk.HBox(False, 0) registers_icon = gtk.image_new_from_stock(gtk.STOCK_UNINDENT, gtk.ICON_SIZE_MENU) info_icon = gtk.image_new_from_stock(gtk.STOCK_LEAVE_FULLSCREEN, gtk.ICON_SIZE_MENU) registers_button = gtk.Button() registers_button.set_tooltip_text("16 and 8 bits registers") registers_button.set_image(info_icon) registers_button.set_label('16/8 Bits') registers_button.connect('clicked', self.popup_registers) registers_hbox.pack_start(registers_icon, False, False, 2) registers_label = self.create_h1_label('Registers') registers_label.set_padding(0, 5) registers_hbox.pack_start(registers_label, True, True, 2) registers_hbox.pack_end(registers_button, False, False, 2) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) treeview = self.populate_tree(self.all_registers) rendererPix = gtk.CellRendererPixbuf() renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn("Register") column.pack_start(rendererPix, False) column.pack_start(renderer_text, True) column.set_attributes(renderer_text, text=1) column.set_attributes(rendererPix, pixbuf=0) column.set_sort_column_id(0) # column.set_attributes(renderer_text, markup=0) # column.add_attribute(renderer_text, "markup", 1) # renderer_text.set_property("markup", 1) treeview.append_column(column) renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn("Description", renderer_text, text=2) renderer_text.set_property("wrap_width", 300) renderer_text.set_property("wrap_mode", pango.WRAP_WORD_CHAR) treeview.append_column(column) sw.add(treeview) registers_vbox.pack_start(registers_hbox, False, False, 1) registers_vbox.pack_start(sw, True, True, 1) self.bottom_hbox.pack_start(instructions_vbox, True, True, 1) self.bottom_hbox.pack_start(gtk.VSeparator(), False, False, 1) self.bottom_hbox.pack_start(registers_vbox, False, False, 1) # Last packaging self.vbox.pack_start(self.hbox, False, False, 1) self.vbox.pack_start(self.bottom_hbox, True, True, 1) self.show_all()
def __init__(self, target, backend): import time # Allow only the main thread to touch the GUI (gtk) part, while letting # other threads do background work. GObject.threads_init() self.target = target self.backend = backend self.empty_gui = False # Variable to hold the Process object in case we choose to disassemble a binary. self.dasm_process = False # Check if we have, at least, one available core; otherwise exit. # TODO: Should be removed? now with one core and dependency_check doing the core check... if not glob.has_radare: md = Gtk.MessageDialog(None, Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, None) md.set_markup("<big><b>No backend engine found!</b></big>") md.format_secondary_markup(( 'Install radare to run bokken:\n\n' '<b>Radare:</b>\t<a href="http://radare.org/">' 'http://radare.org</a>')) md.run() md.destroy() sys.exit(1) # Start up the HTTP server. if glob.http_server: import lib.http as httpd http = httpd.BokkenHttpServer(glob.http_server_bind_address, glob.http_server_port) print("\nBringing up HTTP server on %s:%d." % (glob.http_server_bind_address, glob.http_server_port)) # We start the thread. http.start() time.sleep(0.2) if not http.is_alive(): print('Unable to bind to %s:%d.' % (glob.http_server_bind_address, glob.http_server_port)) return None # We put the http structure in glob to have it accessible in the # global __main__ handler. glob.http = http # Create a main window before anything else. self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL) self.window.set_focus = True self.window.connect("delete_event", self.quit) ui.gtk3.common.set_bokken_icon(self.window) Gtk.Settings.get_default().set_long_property("gtk-button-images", True, "main") # Title self.window.set_title(MAINTITLE + glob.version + " - " + self.target) # Launch file selection dialog dialog = file_dialog.FileDialog(self, self.target, True) resp = dialog.run() if resp == Gtk.ResponseType.DELETE_EVENT or resp == Gtk.ResponseType.REJECT: return None # Get dialog selected file, backend and options self.target = dialog.file self.backend = 'radare' # I'm leaving that as may be needed in the future # Load core import ui.radare_core as core self.uicore = core.Core(dialog) # Create a global object under glob. glob.core = self.uicore if self.target: # Just open the target if path is correct or an url if not os.path.isfile(self.target): print(common.console_color('Incorrect file argument: %s' % self.target, 'red')) sys.exit(1) self.load_file(self.target) if not self.uicore.file_loaded: error_msg = "Error opening file " + self.target md = Gtk.MessageDialog(None, Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, None) md.set_markup("<big><b>File open error!</b></big>") md.format_secondary_markup(error_msg) md.run() md.destroy() print(error_msg) sys.exit(1) ui.gtk3.common.repaint() else: self.empty_gui = True # Positions #self.window.resize(1000, 700) #self.window.move(25, 25) self.window.set_position(Gtk.WindowPosition.CENTER) # Maximize window #self.window.maximize() # Create LanguageManager object to handle all the syntax highlighting. # Every textview in the app will use it. self.lm = GtkSource.LanguageManager.get_default() # Add UI data dir to language paths paths = self.lm.get_search_path() paths.append(common.datafile_path()) self.lm.set_search_path(paths) # Create VBox to contain top buttons and other VBox self.supervb = Gtk.VBox(False, 1) # Create top buttons and add to VBox import ui.radare_toolbar as toolbar self.topbuttons = toolbar.TopButtons(self.uicore, self) self.supervb.pack_start(self.topbuttons, False, True, 1) # Create VBox to contain textviews and statusbar self.mainvb = Gtk.VBox(False, 1) self.supervb.pack_start(self.mainvb, True, True, 1) # Initialize and add TextViews self.tviews = textviews.TextViews(self) # Create toolbar show/hide tabs menu self.topbuttons.menu.create_view_menu() # Initialize and add Statusbar self.sbar = statusbar.Statusbar(self.uicore, self.tviews) self.sbar.create_statusbar() # Add textviews and statusbar to the VBox self.mainvb.pack_start(self.tviews, True, True, 1) self.mainvb.pack_start(self.sbar, False, True, 1) self.window.add(self.supervb) # Disable all until file loads self.disable_all() if self.empty_gui: self.show_empty_gui() self.show_file_data() self.tviews.console.add_message('Bokken ' + glob.version + ' ready') self.tviews.console.add_message('Starting background analysis') self.window.show_all() # Hide left tree for plain or unsupported formats if self.uicore.core.format == 'Hexdump': self.tviews.left_scrolled_window.hide() if not self.uicore.do_anal: self.topbuttons.diff_tb.set_sensitive(False) self.topbuttons.sections_tb.set_sensitive(False) dialog.destroy() # We make sure that we remove the reference to the scrollbar to avoid errors. self.uicore.core.progress_bar = None Gtk.main()
def __init__(self, main, file='', first_run=False): super(FileDialog, self).__init__( 'Select file', main.window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) self.file = file self.timer_id = None # Set dialog resizeable and auto-shrink self.set_resizable(False) ui.gtk3.common.set_bokken_icon(self) # The Ok Button. self.butt_ok = self.action_area.get_children()[1] self.butt_ok.connect("clicked", self.fast_start) self.butt_ok.set_sensitive(False) # The Cancel button. self.butt_cancel = self.action_area.get_children()[0] self.butt_cancel.connect("clicked", self.cancel) # Window position self.set_position(Gtk.WindowPosition.CENTER) # Main Vertical Box self.main_vbox = Gtk.VBox(False, 2) self.main_vbox.set_border_width(7) # Logo self.logo = Gtk.Image() self.logo.set_from_file(datafile_path('bokken.svg')) # Logo label self.logo_text = Gtk.Label() self.logo_text.set_markup( '<span size=\'12000\'>Welcome to <b>Bokken ' + glob.version + '</b></span>') # Common label self.label = Gtk.Label( label='Select a target or enter the path manually.') self.label.set_padding(0, 3) self.label.set_alignment(0, 0.5) # Radare targets label self.radare_label = Gtk.Label() self.radare_label.set_markup( 'Valid inputs are: <b>PE, ELF and mach0</b> files') self.radare_label.set_padding(0, 2) # Horizontal Separator self.hseparator1 = Gtk.HSeparator() self.plugins = [] from ui.radare_core import Core as UICore self.plugins = UICore.get_plugins() # Horizontal Separator self.hseparator2 = Gtk.HSeparator() # File selection Horizontal Box self.hbox = Gtk.HBox(False, 0) # TextEntry self.model = Gtk.ListStore(str) self.input_entry = Gtk.ComboBox.new_with_model_and_entry(self.model) self.input_entry.get_child().connect("activate", self.fast_start) self.input_entry.connect("changed", self._validate_cb) #self.input_entry = Gtk.Entry(100) if self.file: self.input_entry.get_child().set_text(self.file) # Recent file manager self.manager = Gtk.RecentManager.get_default() items = self.manager.get_items() for element in items[:10]: if element.get_uri_display(): self.model.append([element.get_uri_display()]) # Select file button icon = Gtk.Image() icon.set_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.MENU) self.select_button = Gtk.Button() self.select_button.set_image(icon) self.select_button.connect("clicked", self.select_file) # Pack elements into hbox self.hbox.pack_start(self.input_entry, True, True, 2) self.hbox.pack_start(self.select_button, False, False, 2) # File options Horizontal Box self.options_hbox = Gtk.HBox(False, 2) # Radare option Vertical Box self.radare_box = Gtk.VBox(False, 0) self.vseparator = Gtk.VSeparator() self.radare_box_2 = Gtk.VBox(False, 0) self.radare_box_3 = Gtk.VBox(False, 0) # pack the boxes self.options_hbox.pack_start(self.radare_box, True, True, 0) self.options_hbox.pack_start(self.vseparator, False, False, 5) self.options_hbox.pack_start(self.radare_box_2, True, True, 0) # HSeparator self.hseparator3 = Gtk.HSeparator() # Analysis options label self.anal_label = Gtk.Label() self.anal_label.set_markup("<b>Analysis options:</b>") # Advanced Analysis options label self.adv_anal_label = Gtk.Label() self.adv_anal_label.set_markup("<b>Advanced options:</b>") # Radare options self.anal_bin = Gtk.CheckButton(label='Analyze program') self.anal_bin.set_active(True) self.anal_bin.connect("toggled", self._no_anal) self.anal_depth_label = Gtk.Label(label='Max analysis depth: ') self.anal_depth_entry = Gtk.Entry() self.anal_depth_entry.set_max_length(3) self.anal_depth_entry.set_width_chars(3) self.anal_depth_entry.set_max_width_chars(3) self.anal_depth_entry.set_text('16') self.radare_dasm = Gtk.CheckButton(label='Lower case disassembly') self.radare_dasm.set_active(True) self.io_va = Gtk.CheckButton(label='Don\'t use VA') self.asm_syntax = Gtk.CheckButton(label='Use AT&T syntax') self.asm_bytes = Gtk.CheckButton(label='Don\'t show asm bytes') # Bottom radare2 options self.hseparator5 = Gtk.HSeparator() self.bits_label = Gtk.Label(label='Bits:') self.bits = Gtk.ComboBoxText() #self.bits.set_size_request(70, -1) self.arch_label = Gtk.Label(label='Architecture:') self.arch = Gtk.ComboBoxText() self.arch.connect("changed", self._arch_changed) self.arch.append_text('Auto') for plugin in self.plugins: self.arch.append_text('%s (%s)' % (plugin.name, plugin.arch)) #self.arch.append_text('%s (%s) - %s' % (plugin.name, plugin.arch, plugin.desc)) self.arch.set_active(0) self.start_addr = Gtk.CheckButton(label='Start address: ') self.start_addr.connect("toggled", self._start_addr_ctl) self.start_addr_label = Gtk.Label() self.start_addr_label.set_markup('<b>0x</b>') self.start_addr_label.set_padding(0, 5) self.start_addr_address = Gtk.Entry() self.start_addr_address.set_max_length(12) self.start_addr_address.set_width_chars(12) self.start_addr_address.set_sensitive(False) # More radare2 options self.stack_check = Gtk.CheckButton(label='Show stack pointer') self.pseudo_check = Gtk.CheckButton(label='Enable pseudo syntax') self.flow_lines = Gtk.CheckButton(label='Show flow lines') self.flow_lines.connect("toggled", self._flow_lines_ctl) self.flow_lines_label = Gtk.Label(label='Columns for flow lines: ') self.flow_lines_entry = Gtk.Entry() self.flow_lines_entry.set_max_length(3) self.flow_lines_entry.set_width_chars(3) self.flow_lines_entry.set_max_width_chars(3) self.flow_lines_entry.set_text('20') self.flow_lines_entry.set_sensitive(False) # Pack them self.flow_hbox = Gtk.HBox(False) self.depth_hbox = Gtk.HBox(False) self.radare_box_2.pack_start(self.pseudo_check, False, False, 2) self.radare_box_2.pack_start(self.stack_check, False, False, 2) self.radare_box_2.pack_start(self.asm_bytes, False, False, 2) self.radare_box_2.pack_start(self.flow_lines, False, False, 2) self.flow_hbox.pack_start(self.flow_lines_label, False, False, 2) self.flow_hbox.pack_start(self.flow_lines_entry, False, False, 2) self.radare_box_2.pack_start(self.flow_hbox, False, False, 2) self.depth_hbox.pack_start(self.anal_depth_label, False, False, 2) self.depth_hbox.pack_start(self.anal_depth_entry, False, False, 2) self.radare_box.pack_start(self.anal_bin, False, False, 2) self.radare_box.pack_start(self.depth_hbox, False, False, 2) self.radare_box.pack_start(self.radare_dasm, False, False, 2) self.radare_box.pack_start(self.io_va, False, False, 2) self.radare_box.pack_start(self.asm_syntax, False, False, 2) self.start_addr_hbox = Gtk.HBox(False, 0) self.start_addr_hbox.pack_start(self.start_addr, False, False, 0) self.start_addr_hbox.pack_start(self.start_addr_label, False, False, 2) self.start_addr_hbox.pack_start(self.start_addr_address, True, True, 2) self.radare_box_3.pack_start(self.hseparator5, False, False, 5) self.radare_box_3.pack_start(self.adv_anal_label, False, False, 5) self.radare_box_3.pack_start(self.start_addr_hbox, False, False, 2) self.arch_hbox = Gtk.HBox(False, 0) self.arch_hbox.pack_start(self.arch_label, False, False, 2) self.arch_hbox.pack_start(self.arch, True, True, 2) self.radare_box_3.pack_start(self.arch_hbox, False, False, 2) self.bits_hbox = Gtk.HBox(False, 0) self.bits_hbox.pack_start(self.bits_label, False, False, 2) self.bits_hbox.pack_start(self.bits, False, False, 2) #self.radare_box_3.pack_start(self.bits_hbox, False, False, 2) self.arch_hbox.pack_start(self.bits_hbox, False, False, 2) # Pack elements into main_vbox self.main_vbox.pack_start(self.logo, False, False, 0) self.main_vbox.pack_start(self.logo_text, False, False, 0) self.main_vbox.pack_start(self.hseparator1, False, False, 2) #self.main_vbox.pack_start(self.hseparator2, False, False, 2) self.main_vbox.pack_start(self.label, False, False, 2) self.main_vbox.pack_start(self.radare_label, False, False, 1) self.main_vbox.pack_start(self.hbox, False, False, 2) self.main_vbox.pack_start(self.hseparator3, False, False, 2) self.main_vbox.pack_start(self.anal_label, False, False, 2) self.main_vbox.pack_start(self.options_hbox, False, False, 2) self.main_vbox.pack_start(self.radare_box_3, False, False, 2) self.vbox.pack_start(self.main_vbox, True, True, 0) self.set_focus(self.input_entry.get_child()) self.show_all()
def create_buttons(self, option): # Icons self.fcn_pix = gtk.Image() self.fcn_pix.set_from_file(datafile_path('function.png')) self.bb_pix = gtk.Image() self.bb_pix.set_from_file(datafile_path('block.png')) self.imp_pix = gtk.Image() self.imp_pix.set_from_file(datafile_path('import.png')) self.exp_pix = gtk.Image() self.exp_pix.set_from_file(datafile_path('export.png')) # Show/hide toolbar and menu self.hide_tb = gtk.ToggleButton() i = gtk.Image() i.set_from_stock(gtk.STOCK_GO_UP, gtk.ICON_SIZE_MENU) self.hide_tb.set_image(i) self.hide_tb.set_tooltip_text('Toggle visibility of the top toolbar') handler = self.hide_tb.connect('toggled', self._hide_tb_toggled) self.hide_tb.handler = handler self.pack_start(self.hide_tb, False, False, 0) if 'bin' in option: # Functions a = gtk.VBox(False, 1) fcntb = gtk.ToggleButton() fcntb.set_active(True) fcntb.set_tooltip_text('List of function entrypoints in the binary') handler = fcntb.connect('toggled', self._on_toggle) fcntb.handler = handler l = gtk.Label('Functions') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.fcn_pix, False, False, 1) fcntb.add(a) # Sections sectb = gtk.ToggleButton() sectb.set_tooltip_text('List of sections in the binary') handler = sectb.connect('toggled', self._on_toggle) sectb.handler = handler a = gtk.VBox(False, 1) l = gtk.Label('Sections') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.bb_pix, False, False, 1) sectb.add(a) self.pack_start(fcntb, False, False, 0) self.pack_start(sectb, False, False, 0) if option == 'full_bin': # Imports imptb = gtk.ToggleButton() imptb.set_tooltip_text('List of imported symbols') handler = imptb.connect('toggled', self._on_toggle) imptb.handler = handler a = gtk.VBox(False, 1) l = gtk.Label('Imports') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.imp_pix, False, False, 1) imptb.add(a) # Symbols exptb = gtk.ToggleButton() exptb.set_tooltip_text('List of exported symbols') handler = exptb.connect('toggled', self._on_toggle) exptb.handler = handler a = gtk.VBox(False, 1) l = gtk.Label('Symbols') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.exp_pix, False, False, 1) exptb.add(a) self.pack_start(imptb, False, False, 0) self.pack_start(exptb, False, False, 0) elif option == 'pdf': # PDF pdftb = gtk.ToggleButton() pdftb.set_inconsistent(True) a = gtk.VBox(False, 1) l = gtk.Label('PDF info') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.exp_pix, False, False, 1) pdftb.add(a) self.pack_start(pdftb, False, False, 0) elif option == 'url': # URL lnktb = gtk.ToggleButton() lnktb.set_active(True) handler = lnktb.connect('toggled', self._on_toggle) lnktb.handler = handler a = gtk.VBox(False, 1) l = gtk.Label('URL') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.fcn_pix, False, False, 1) lnktb.add(a) hdrtb = gtk.ToggleButton() handler = hdrtb.connect('toggled', self._on_toggle) hdrtb.handler = handler a = gtk.VBox(False, 1) l = gtk.Label('Headers') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.exp_pix, False, False, 1) hdrtb.add(a) ccktb = gtk.ToggleButton() handler = ccktb.connect('toggled', self._on_toggle) ccktb.handler = handler a = gtk.VBox(False, 1) l = gtk.Label('Cookies') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.imp_pix, False, False, 1) ccktb.add(a) self.pack_start(lnktb, False, False, 0) self.pack_start(hdrtb, False, False, 0) self.pack_start(ccktb, False, False, 0) self.show_all()
def __init__(self, core, main): super(TopButtons, self).__init__(False, 1) self.main = main self.uicore = core self.toolbox = self self.options_dict = { 'String': ' ', 'String no case': 'i ', 'Hexadecimal': 'x ', 'Regexp': 'e ' } self.main_tb = Gtk.Toolbar() self.main_tb.set_style(Gtk.ToolbarStyle.ICONS) # Main Button self.menu = main_button_menu.MenuBar(self.main) self.menu_button = main_button.MainMenuButton("Bokken", self.menu) self.menu_button.set_border_width(0) menu_toolitem = Gtk.ToolItem() menu_toolitem.add(self.menu_button) self.main_tb.insert(menu_toolitem, -1) # Separator self.sep = Gtk.SeparatorToolItem() self.main_tb.insert(self.sep, -1) # Assembler button self.asm_tb = Gtk.ToolButton(Gtk.STOCK_EXECUTE) self.asm_tb.set_tooltip_text('Open assembler dialog') self.asm_tb.connect("clicked", self._assembler) self.main_tb.insert(self.asm_tb, -1) # Bindiff button self.diff_tb = Gtk.ToolButton(Gtk.STOCK_REFRESH) self.diff_tb.set_tooltip_text('Do binary diffing') self.diff_tb.connect("clicked", self._do_diff) self.main_tb.insert(self.diff_tb, -1) # Section bars button self.sections_tb = Gtk.ToolButton(Gtk.STOCK_SORT_ASCENDING) self.sections_tb.set_tooltip_text('Extended sections information') self.sections_tb.connect("clicked", self._do_sections) self.main_tb.insert(self.sections_tb, -1) # Calculator button self.image = Gtk.Image() self.image.set_from_file(datafile_path('calc.png')) self.calc_tb = Gtk.ToolButton() self.calc_tb.set_icon_widget(self.image) self.calc_tb.set_tooltip_text('Show calculator') self.calc_tb.connect("clicked", self._do_calc) self.main_tb.insert(self.calc_tb, -1) # File magic button self.magic_tb = Gtk.ToolButton(Gtk.STOCK_INFO) self.magic_tb.set_tooltip_text('Show file magic') self.magic_tb.connect("clicked", self._do_file_magic) self.main_tb.insert(self.magic_tb, -1) # Separator self.sep = Gtk.SeparatorToolItem() self.main_tb.insert(self.sep, -1) import ui.search_widget ui.search_widget.create(self) # Separator self.sep = Gtk.SeparatorToolItem() self.main_tb.insert(self.sep, -1) # Cheatsheet button self.cheatsheet_tb = Gtk.ToolButton(Gtk.STOCK_JUSTIFY_FILL) self.cheatsheet_tb.set_tooltip_text('Show assembler reference sheet') self.cheatsheet_tb.connect("clicked", self.create_cheatsheet_dialog) self.main_tb.insert(self.cheatsheet_tb, -1) # Separator self.sep = Gtk.SeparatorToolItem() self.sep.set_expand(True) self.sep.set_draw(False) self.main_tb.insert(self.sep, -1) # Show/hide console console_toolitem = Gtk.ToolItem() a = Gtk.HBox(False, 1) self.hide = Gtk.ToggleButton('Console') i = Gtk.Image() i.set_from_stock(Gtk.STOCK_GO_DOWN, Gtk.IconSize.MENU) l = Gtk.Label(label='Console') self.hide.set_image(i) self.hide.set_tooltip_text('Show/hide console') self.hide.set_active(True) handler = self.hide.connect('toggled', self._hide_tb_toggled) console_toolitem.add(self.hide) self.main_tb.insert(console_toolitem, -1) # Throbber self.throbber = throbber.Throbber() self.throbber_tb = Gtk.ToolItem() self.throbber_tb.add(self.throbber) self.main_tb.insert(self.throbber_tb, -1) self.toolbox.pack_start(self.main_tb, True, True, 0) self.show_all()
def create_buttons(self, option): # Icons self.fcn_pix = Gtk.Image() self.fcn_pix.set_from_file(datafile_path('function.png')) self.bb_pix = Gtk.Image() self.bb_pix.set_from_file(datafile_path('block.png')) self.imp_pix = Gtk.Image() self.imp_pix.set_from_file(datafile_path('import.png')) self.exp_pix = Gtk.Image() self.exp_pix.set_from_file(datafile_path('export.png')) # Show/hide toolbar and menu self.hide_tb = Gtk.ToggleButton() i = Gtk.Image() i.set_from_stock(Gtk.STOCK_GO_UP, Gtk.IconSize.MENU) self.hide_tb.set_image(i) self.hide_tb.set_tooltip_text('Toggle visibility of the top toolbar') handler = self.hide_tb.connect('toggled', self._hide_tb_toggled) self.hide_tb.handler = handler self.pack_start(self.hide_tb, False, False, 0) if 'bin' in option: # Functions a = Gtk.VBox(False, 1) fcntb = Gtk.ToggleButton() fcntb.set_active(True) fcntb.set_tooltip_text('List of function entrypoints in the binary') handler = fcntb.connect('toggled', self._on_toggle) fcntb.handler = handler l = Gtk.Label(label='Functions') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.fcn_pix, False, False, 1) fcntb.add(a) self.pack_start(fcntb, False, False, 0) if option == 'full_bin': # Imports imptb = Gtk.ToggleButton() imptb.set_tooltip_text('List of imported symbols') handler = imptb.connect('toggled', self._on_toggle) imptb.handler = handler a = Gtk.VBox(False, 1) l = Gtk.Label(label='Imports') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.imp_pix, False, False, 1) imptb.add(a) # Symbols exptb = Gtk.ToggleButton() exptb.set_tooltip_text('List of exported symbols') handler = exptb.connect('toggled', self._on_toggle) exptb.handler = handler a = Gtk.VBox(False, 1) l = Gtk.Label(label='Symbols') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.exp_pix, False, False, 1) exptb.add(a) # Relocs sectb = Gtk.ToggleButton() sectb.set_tooltip_text('List of relocs in the binary') handler = sectb.connect('toggled', self._on_toggle) sectb.handler = handler a = Gtk.VBox(False, 1) l = Gtk.Label(label='Relocs') l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.bb_pix, False, False, 1) sectb.add(a) self.pack_start(imptb, False, False, 0) self.pack_start(exptb, False, False, 0) self.pack_start(sectb, False, False, 0) self.show_all()
def __init__(self, main, title='Reference Sheet for x86 Assembler'): super(CheatsheetDialog, self).__init__( title, main.window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_ABOUT, Gtk.ResponseType.ACCEPT, Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)) from gi.repository import Pango # The Cancel button. self.butt_cancel = self.action_area.get_children()[1] self.butt_cancel.connect("clicked", lambda x: self.destroy()) self.butt_about = self.action_area.get_children()[0] self.butt_about.connect("clicked", self._show_about) self.vbox.set_spacing(3) # Positions self.resize(600, 700) self.set_position(Gtk.WindowPosition.CENTER) ui.gtk3.common.set_bokken_icon(self) self.pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('block.png')) # Font font_desc = Pango.FontDescription("FreeSans 9") # Assembly Summary vbox_summary = Gtk.VBox(False, 1) hbox_summary = Gtk.HBox(False, 1) summ_icon = Gtk.Image.new_from_stock(Gtk.STOCK_INFO, Gtk.IconSize.MENU) label_summary = Gtk.Label() label_summary.set_markup(self.summary) #label_summary.modify_font(font_desc) #label_summary.set_line_wrap(True) label_summary.set_alignment(0, 0) # Pack icon and title hbox_summary.pack_start(summ_icon, False, False, 2) hbox_summary.pack_start(self.create_h1_label('Assembly language'), True, True, 2) # Pack contents vbox_summary.pack_start(hbox_summary, False, False, 2) vbox_summary.pack_start(label_summary, True, True, 2) self.vbox.pack_start(vbox_summary, False, False, 2) # Directives and operands VBox lang_vbox = Gtk.VBox(False, 2) # Assembly directives directives_vbox = Gtk.VBox(False, 2) directives_hbox = Gtk.HBox(False, 1) directives_icon = Gtk.Image.new_from_stock(Gtk.STOCK_EXECUTE, Gtk.IconSize.MENU) directives_hbox.pack_start(directives_icon, False, False, 2) directives_hbox.pack_start(self.create_h2_label('Assembly directives'), True, True, 2) directives_vbox.pack_start(directives_hbox, False, False, 2) assembler_directives_tv = self.populate_treeview( self.assembler_directives) sw = Gtk.ScrolledWindow() sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN) sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER) assembler_directives_tv = self.populate_treeview( self.assembler_directives) renderer_text = Gtk.CellRendererText() column = Gtk.TreeViewColumn("", renderer_text, text=0) assembler_directives_tv.append_column(column) renderer_text = Gtk.CellRendererText() column = Gtk.TreeViewColumn("", renderer_text, text=1) renderer_text.set_property("wrap_width", 300) renderer_text.set_property("wrap_mode", Pango.WrapMode.WORD_CHAR) assembler_directives_tv.append_column(column) assembler_directives_tv.set_headers_visible(False) sw.add(assembler_directives_tv) directives_vbox.add(sw) # Operand types operands_vbox = Gtk.VBox(False, 2) operands_hbox = Gtk.HBox(False, 1) operands_icon = Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES, Gtk.IconSize.MENU) operands_hbox.pack_start(operands_icon, False, False, 2) operands_hbox.pack_start(self.create_h2_label('Operand Types'), True, True, 2) operands_vbox.pack_start(operands_hbox, False, False, 2) assembler_operands_tv = self.populate_treeview(self.operand_types) sw = Gtk.ScrolledWindow() sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN) sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER) assembler_operands_tv = self.populate_treeview(self.operand_types) renderer_text = Gtk.CellRendererText() column = Gtk.TreeViewColumn("", renderer_text, text=0) assembler_operands_tv.append_column(column) renderer_text = Gtk.CellRendererText() column = Gtk.TreeViewColumn("", renderer_text, text=1) renderer_text.set_property("wrap_width", 300) renderer_text.set_property("wrap_mode", Pango.WrapMode.WORD_CHAR) assembler_operands_tv.append_column(column) assembler_operands_tv.set_headers_visible(False) sw.add(assembler_operands_tv) operands_vbox.add(sw) # Terminology vbox_terminology = Gtk.VBox(False, 1) terminology_hbox = Gtk.HBox(False, 1) terminology_icon = Gtk.Image.new_from_stock(Gtk.STOCK_INDEX, Gtk.IconSize.MENU) terminology_hbox.pack_start(terminology_icon, False, False, 2) terminology_hbox.pack_start( self.create_h1_label('Terminology and Functions'), True, True, 2) vbox_terminology.pack_start(terminology_hbox, False, False, 2) sw = Gtk.ScrolledWindow() sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN) sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) terminology_tv = self.populate_treeview(self.terms) renderer_text = Gtk.CellRendererText() column = Gtk.TreeViewColumn("", renderer_text, text=0) terminology_tv.append_column(column) renderer_text = Gtk.CellRendererText() column = Gtk.TreeViewColumn("", renderer_text, text=1) renderer_text.set_property("wrap_width", 300) renderer_text.set_property("wrap_mode", Pango.WrapMode.WORD_CHAR) terminology_tv.append_column(column) terminology_tv.set_headers_visible(False) sw.add(terminology_tv) vbox_terminology.add(sw) self.hbox = Gtk.HBox(False, 3) lang_vbox.pack_start(directives_vbox, False, False, 0) lang_vbox.pack_start(operands_vbox, False, False, 0) self.hbox.add(lang_vbox) self.hbox.pack_start(Gtk.VSeparator(), False, False, 0) self.hbox.add(vbox_terminology) # Hbox for instructions and registers self.bottom_hbox = Gtk.HBox(False, 3) # Instructions instructions_vbox = Gtk.VBox(False, 0) instructions_hbox = Gtk.HBox(False, 0) instructions_icon = Gtk.Image.new_from_stock(Gtk.STOCK_INDENT, Gtk.IconSize.MENU) info_icon = Gtk.Image.new_from_stock(Gtk.STOCK_SORT_ASCENDING, Gtk.IconSize.MENU) stack_button = Gtk.Button() stack_button.set_tooltip_text("Stack diagram") stack_button.set_image(info_icon) stack_button.set_label('The stack') stack_button.connect('clicked', self.popup_stack) instructions_hbox.pack_start(instructions_icon, False, False, 2) instructions_label = self.create_h1_label('Instructions') instructions_label.set_padding(0, 5) instructions_hbox.pack_start(instructions_label, True, True, 2) instructions_hbox.pack_end(stack_button, False, False, 2) self.sw = Gtk.ScrolledWindow() self.sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN) self.sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.treeview = self.populate_treeview(self.instructions) renderer_text = Gtk.CellRendererText() # font = Pango.FontDescription('Bitstream Charter 9') # renderer_text.set_property('font-desc', font) column = Gtk.TreeViewColumn("Instruction", renderer_text, text=0) column.set_sort_column_id(0) self.treeview.append_column(column) renderer_text = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Description", renderer_text, text=1) renderer_text.set_property("wrap_width", 390) renderer_text.set_property("wrap_mode", Pango.WrapMode.WORD_CHAR) self.treeview.append_column(column) self.sw.add(self.treeview) instructions_vbox.pack_start(instructions_hbox, False, False, 1) instructions_vbox.pack_start(self.sw, True, True, 1) # Registers registers_vbox = Gtk.VBox(False, 0) registers_hbox = Gtk.HBox(False, 0) registers_icon = Gtk.Image.new_from_stock(Gtk.STOCK_UNINDENT, Gtk.IconSize.MENU) info_icon = Gtk.Image.new_from_stock(Gtk.STOCK_LEAVE_FULLSCREEN, Gtk.IconSize.MENU) registers_button = Gtk.Button() registers_button.set_tooltip_text("16 and 8 bits registers") registers_button.set_image(info_icon) registers_button.set_label('16/8 Bits') registers_button.connect('clicked', self.popup_registers) registers_hbox.pack_start(registers_icon, False, False, 2) registers_label = self.create_h1_label('Registers') registers_label.set_padding(0, 5) registers_hbox.pack_start(registers_label, True, True, 2) registers_hbox.pack_end(registers_button, False, False, 2) sw = Gtk.ScrolledWindow() sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN) sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) treeview = self.populate_tree(self.all_registers) rendererPix = Gtk.CellRendererPixbuf() renderer_text = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Register") column.pack_start(rendererPix, False) column.pack_start(renderer_text, True) column.set_attributes(renderer_text, text=1) column.set_attributes(rendererPix, pixbuf=0) column.set_sort_column_id(0) # column.set_attributes(renderer_text, markup=0) # column.add_attribute(renderer_text, "markup", 1) # renderer_text.set_property("markup", 1) treeview.append_column(column) renderer_text = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Description", renderer_text, text=2) renderer_text.set_property("wrap_width", 300) renderer_text.set_property("wrap_mode", Pango.WrapMode.WORD_CHAR) treeview.append_column(column) sw.add(treeview) registers_vbox.pack_start(registers_hbox, False, False, 1) registers_vbox.pack_start(sw, True, True, 1) self.bottom_hbox.pack_start(instructions_vbox, True, True, 1) self.bottom_hbox.pack_start(Gtk.VSeparator(), False, False, 1) self.bottom_hbox.pack_start(registers_vbox, False, False, 1) # Last packaging self.vbox.pack_start(self.hbox, False, False, 1) self.vbox.pack_start(self.bottom_hbox, True, True, 1) self.show_all()
def __init__(self, core, main): super(TopButtons,self).__init__(False, 1) self.main = main self.uicore = core self.toolbox = self self.options_dict = {'String':' ', 'String no case':'i ', 'Hexadecimal':'x ', 'Regexp':'e '} self.main_tb = gtk.Toolbar() self.main_tb.set_style(gtk.TOOLBAR_ICONS) # Main Button self.menu = main_button_menu.MenuBar(self.main) self.menu_button = main_button.MainMenuButton("Bokken", self.menu) self.menu_button.set_border_width(0) menu_toolitem = gtk.ToolItem() menu_toolitem.add(self.menu_button) self.main_tb.insert(menu_toolitem, -1) # Separator self.sep = gtk.SeparatorToolItem() self.main_tb.insert(self.sep, -1) # Assembler button self.asm_tb = gtk.ToolButton(gtk.STOCK_EXECUTE) self.asm_tb.set_tooltip_text('Open assembler dialog') self.asm_tb.connect("clicked", self._assembler) self.main_tb.insert(self.asm_tb, -1) # Bindiff button self.diff_tb = gtk.ToolButton(gtk.STOCK_REFRESH) self.diff_tb.set_tooltip_text('Do binary diffing') self.diff_tb.connect("clicked", self._do_diff) self.main_tb.insert(self.diff_tb, -1) # Section bars button self.sections_tb = gtk.ToolButton(gtk.STOCK_SORT_ASCENDING) self.sections_tb.set_tooltip_text('Extended sections information') self.sections_tb.connect("clicked", self._do_sections) self.main_tb.insert(self.sections_tb, -1) # Calculator button self.image = gtk.Image() self.image.set_from_file(datafile_path('calc.png')) self.calc_tb = gtk.ToolButton() self.calc_tb.set_icon_widget(self.image) self.calc_tb.set_tooltip_text('Show calculator') self.calc_tb.connect("clicked", self._do_calc) self.main_tb.insert(self.calc_tb, -1) # File magic button self.magic_tb = gtk.ToolButton(gtk.STOCK_INFO) self.magic_tb.set_tooltip_text('Show file magic') self.magic_tb.connect("clicked", self._do_file_magic) self.main_tb.insert(self.magic_tb, -1) # Separator self.sep = gtk.SeparatorToolItem() self.main_tb.insert(self.sep, -1) import ui.search_widget ui.search_widget.create(self) # Separator self.sep = gtk.SeparatorToolItem() self.main_tb.insert(self.sep, -1) # Cheatsheet button self.cheatsheet_tb = gtk.ToolButton(gtk.STOCK_JUSTIFY_FILL) self.cheatsheet_tb.set_tooltip_text('Show assembler reference sheet') self.cheatsheet_tb.connect("clicked", self.create_cheatsheet_dialog) self.main_tb.insert(self.cheatsheet_tb, -1) # Separator self.sep = gtk.SeparatorToolItem() self.sep.set_expand(True) self.sep.set_draw(False) self.main_tb.insert(self.sep, -1) # Show/hide console console_toolitem = gtk.ToolItem() a = gtk.HBox(False, 1) self.hide = gtk.ToggleButton('Console') i = gtk.Image() i.set_from_stock(gtk.STOCK_GO_DOWN, gtk.ICON_SIZE_MENU) l = gtk.Label('Console') self.hide.set_image(i) self.hide.set_tooltip_text('Show/hide console') self.hide.set_active(True) handler = self.hide.connect('toggled', self._hide_tb_toggled) console_toolitem.add(self.hide) self.main_tb.insert(console_toolitem, -1) # Throbber self.throbber = throbber.Throbber() self.throbber_tb = gtk.ToolItem() self.throbber_tb.add(self.throbber) self.main_tb.insert(self.throbber_tb, -1) self.toolbox.pack_start(self.main_tb, True, True) self.show_all()
def create_buttons(self, option): # Icons self.fcn_pix = gtk.Image() self.fcn_pix.set_from_file(datafile_path("function.png")) self.bb_pix = gtk.Image() self.bb_pix.set_from_file(datafile_path("block.png")) self.imp_pix = gtk.Image() self.imp_pix.set_from_file(datafile_path("import.png")) self.exp_pix = gtk.Image() self.exp_pix.set_from_file(datafile_path("export.png")) # Show/hide toolbar and menu self.hide_tb = gtk.ToggleButton() i = gtk.Image() i.set_from_stock(gtk.STOCK_GO_UP, gtk.ICON_SIZE_MENU) self.hide_tb.set_image(i) self.hide_tb.set_tooltip_text("Toggle visibility of the top toolbar") handler = self.hide_tb.connect("toggled", self._hide_tb_toggled) self.hide_tb.handler = handler self.pack_start(self.hide_tb, False, False, 0) if "bin" in option: # Functions a = gtk.VBox(False, 1) fcntb = gtk.ToggleButton() fcntb.set_active(True) fcntb.set_tooltip_text("List of function entrypoints in the binary") handler = fcntb.connect("toggled", self._on_toggle) fcntb.handler = handler l = gtk.Label("Functions") l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.fcn_pix, False, False, 1) fcntb.add(a) self.pack_start(fcntb, False, False, 0) if option == "full_bin": # Imports imptb = gtk.ToggleButton() imptb.set_tooltip_text("List of imported symbols") handler = imptb.connect("toggled", self._on_toggle) imptb.handler = handler a = gtk.VBox(False, 1) l = gtk.Label("Imports") l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.imp_pix, False, False, 1) imptb.add(a) # Symbols exptb = gtk.ToggleButton() exptb.set_tooltip_text("List of exported symbols") handler = exptb.connect("toggled", self._on_toggle) exptb.handler = handler a = gtk.VBox(False, 1) l = gtk.Label("Symbols") l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.exp_pix, False, False, 1) exptb.add(a) # Relocs sectb = gtk.ToggleButton() sectb.set_tooltip_text("List of relocs in the binary") handler = sectb.connect("toggled", self._on_toggle) sectb.handler = handler a = gtk.VBox(False, 1) l = gtk.Label("Relocs") l.set_angle(90) a.pack_start(l, False, False, 1) a.pack_start(self.bb_pix, False, False, 1) sectb.add(a) self.pack_start(imptb, False, False, 0) self.pack_start(exptb, False, False, 0) self.pack_start(sectb, False, False, 0) self.show_all()