def setDialog(self, dialog, cpacket, badchars, fdlist, xpacket): #self.fdlist = fdlist self.xpacketlist = xpacket #sendstring=dialog.get_widget('sendstring') #sendstring.set_text(self.sendstring) hboxpreparexpacket = dialog.get_widget("hbox4") #hboxpreparefd = dialog.get_widget("hbox5") preparexpacket = gtk.combo_box_new_text() hboxpreparexpacket.pack_start(preparexpacket, expand=True, padding=0) #preparefd = gtk.combo_box_new_text() #hboxpreparefd.pack_start(preparefd,expand=True, padding=0) preparexpacket.show() #preparefd.show() #basic edition == silent sockets if len(self.xpacketlist) == 0: preparexpacket.append_text(N_('No Buffer to send yet')) else: preparexpacket.append_text(N_('Select Buffer to send')) for a in self.xpacketlist: preparexpacket.append_text(str(self.xpacketlist.index(a) + 1)) try: preparexpacket.set_active(int(self.boxargs['preparexpacket'])) except: preparexpacket.set_active(0) preparexpacket.connect('changed', self.changedp)
def Show(self): if self.xpacket2send == None and self.sendstring == None: return N_("send(Nothing to send)") elif self.xpacket2send: return N_("send(Buffer %s)") % self.xpacket2send else: return N_("send(%s)") % self.sendstring
def setDialog(self, dialog, xpacket, badchars, arch): # The self.xpacketlist is set on the setEssential function hboxpreparexpacket = dialog.get_widget("hbox4") preparexpacket = gtk.combo_box_new_text() hboxpreparexpacket.pack_start(preparexpacket, expand=True, padding=0) preparexpacket.show() if len(self.xpacketlist) == 0: preparexpacket.append_text(N_('No Buffer to send yet')) else: preparexpacket.append_text(N_('Select Buffer to send')) for a in self.xpacketlist: preparexpacket.append_text(str(self.xpacketlist.index(a) + 1)) try: preparexpacket.set_active(int(self.boxargs['preparexpacket'])) except: preparexpacket.set_active(0) preparexpacket.connect('changed', self.changedp) string = dialog.get_widget('checkbadchar') string.set_text(self.string) inttype = dialog.get_widget('inttype') inttype.set_active(self.inttype)
def Show(self): if self.topad < 0: self.topad=0 if self.buffer != None: try: return "PAD Buffer %s TO: %d BYTES\nPad Size: %s bytes" % (self.bufdic[self.buffer], int(self.padbytes),self.topad) except: return N_("Select buffer to pad") else: return N_("Select buffer to pad")
def humanize_seconds(elapsed_seconds, use_hours = True, use_days = True): """ Turns a number of seconds into to a human readable string, example 125 seconds is: '2 minutes and 5 seconds'. @param elapsed_seconds: number of seconds you want to humanize @param use_hours: wether or not to render the hours(if hours > 0) @param use_days: wether or not to render the days(if days > 0) """ MIN_FRACTION = 60 HOUR_FRACTION = 60 * MIN_FRACTION DAY_FRACTION = 24 * HOUR_FRACTION text = [] duration = elapsed_seconds if duration == 0: return _("0 seconds") days = duration / DAYS_FRACTION if use_days and days > 0: text.append(N_("%d day", "%d days", days) % days) duration %= DAY_FRACTION hours = duration / HOUR_FRACTION if use_hours and hours > 0: text.append(N_("%d hour", "%d hours", hours) % hours) duration %= HOUR_FRACTION minutes = duration / MIN_FRACTION if minutes > 0: text.append(N_("%d minute", "%d minutes", minutes) % minutes) duration %= MIN_FRACTION seconds = duration % 60 if seconds > 0: text.append(N_("%d second", "%d seconds", seconds) % seconds) if len(text) > 2: # To translators: this joins 3 or more time fractions return _(", ").join(text[:-1]) + _(" and ") + text[-1] else: # To translators: this joins 2 or 1 time fractions return _(" and ").join(text)
class Toolobject(VisualToolbar): NAME = "addxpacket" GLADE_DIALOG = "dialog.glade2" filexpm = "addxpacket.ico" button_label = N_("Add Buffer") button_tooltip = N_("Add a Buffer") button_private_tooltip = "Private" button_signal = None color = "green" size = 20 def __init__(self): VisualToolbar.__init__(self) def setSize(self, size): self.size = size def Help(self): return N_("Add a exploit buffer to your data.")
class Toolobject(VisualToolbar): NAME = "calculator" GLADE_DIALOG = "dialog.glade2" filexpm = "calculator.ico" button_label = N_("Calculator") button_tooltip = N_("Show a useful calculator") button_private_tooltip = "Private" button_signal = None color = "green" size = 20 def __init__(self): VisualToolbar.__init__(self) def setSize(self, size): self.size = size def Help(self): return N_("Shows a useful calculator")
class Toolobject(VisualToolbar): NAME = "clearpacket" GLADE_DIALOG = "dialog.glade2" filexpm = "clearpacket.ico" button_label = N_("Clear the exploit packet") button_tooltip = N_("Clear the exploit packet") button_private_tooltip = "Private" button_signal = None color = "green" size = 20 def __init__(self): VisualToolbar.__init__(self) def setSize(self, size): self.size = size def Help(self): return N_("Removes all buffers from the exploit packet")
def start (self): if len (self.errors) == 0: e = operations.FinishedEvent (self, operations.SUCCESSFUL) for l in self.listeners: l.on_finished (e) return filenames = [] for e in self.errors: filenames.append (urlutil.basename(e.hints['location'])) del self.__errors title = N_( "Unsupported file type", "Unsupported file types", len(filenames) ) msg = N_( "The following file was not added:", "The following files were not added:", len(filenames) ) gtkutil.list_dialog( title, _("If you're having problems opening certain files make sure you " "have the GStreamer plugins needed to decode them."), list_title=msg, parent=self.parent, items=filenames, stock = gtk.STOCK_DIALOG_ERROR, buttons =(gtk.STOCK_CLOSE, gtk.RESPONSE_OK), ) e = operations.FinishedEvent (self, operations.SUCCESSFUL) for l in self.listeners: l.on_finished (e)
def setDialog(self,widget,xpacket,badchars,arch): padbytes=widget.get_widget('padbytes') padbytes.set_value(float(self.padbytes)) hboxprepareobjs = widget.get_widget("vbox1") #if the setdialog is called from a loaded object prepareobjs = gtk.combo_box_new_text() hboxprepareobjs.pack_start(prepareobjs,expand=True, padding=0) prepareobjs.show() prepareobjs.append_text(N_('Buffer to pad?')) i=0 for a in self.xpacketlist: if i==self.xpacketlist.index(xpacket): pass else: self.bufdic[N_("Buffer %s") %str(self.xpacketlist.index(a)+1)]= "%s" %str(self.xpacketlist.index(a)+1) prepareobjs.append_text(N_("Buffer %s") %str(self.xpacketlist.index(a)+1)) prepareobjs.connect('changed', self.changeobjs,widget) i=i+1 try: pos = self.index except: pos=0 prepareobjs.set_active(int(pos))
def preparedialog(self, widget, xpacketlist, fdlist): self.fdlist = fdlist self.xpacketlist = xpacketlist sendstring = widget.get_widget('sendstring') sendstring.set_text(self.sendstring) hboxpreparexpacket = widget.get_widget("hbox4") hboxpreparefd = widget.get_widget("hbox5") preparexpacket = gtk.combo_box_new_text() hboxpreparexpacket.pack_start(preparexpacket, expand=True, padding=0) preparefd = gtk.combo_box_new_text() hboxpreparefd.pack_start(preparefd, expand=True, padding=0) preparexpacket.show() #basic edition == silent sockets #preparefd.show() if len(xpacketlist) == 0: preparexpacket.append_text(N_('No Buffer to send yet')) else: preparexpacket.append_text(N_('Select Buffer to send')) preparexpacket.append_text(PLAINSTRING) for a in xpacketlist: preparexpacket.append_text(str(xpacketlist.index(a) + 1)) if len(fdlist) == 0: preparefd.append_text('No FD to use yet') else: preparefd.append_text('Select FD to use') for a in fdlist: preparefd.append_text(str(fdlist.index(a) + 1)) preparexpacket.set_active(0) preparefd.set_active(0) preparexpacket.connect('changed', self.changedp, sendstring) preparefd.connect('changed', self.changedf)
class Toolobject(VisualToolbar): NAME = "RunExploit" GLADE_DIALOG = "dialog.glade2" filexpm = "runexploit.ico" button_label = N_("RunExploit") button_tooltip = N_("Run this exploit") button_private_tooltip = "Private" button_signal = None color = "green" size = 20 def __init__(self): VisualToolbar.__init__(self) def setSize(self, size): self.size =size def Help(self): return N_("Run Exploit: Executes your exploit. Requires you to set the hostname and\n\ port number of the target, and fill in the callback information for the payload.")
class Toolobject(VisualToolbar): NAME = "addzcpacket" GLADE_DIALOG = "dialog.glade2" filexpm = "addzcpacket.ico" button_label = "Add cPacket" button_tooltip = N_("Add a cPacket") button_private_tooltip = "Private" button_signal = None color = "green" size = 20 def __init__(self): VisualToolbar.__init__(self) def setSize(self, size): self.size = size def Help(self): return "addzcpacket: Add a Program Flow to your framework, Adding extra program\n\
def Help(self): return N_( "Set Comments: this fills in the exploit documentation header and CANVAS\n\ exploit properties which are required to run your exploit from CANVAS.")
def Help(self): return N_("Removes all buffers from the exploit packet")
def Show(self): #if self.xpacket2send == None and self.sendstring == None: # return N_("send(Nothing to send)") if self.xpacket2send: return N_("Block Buffer %s") % self.xpacket2send
class Toolobject(VisualToolbar): NAME = "AddBlockBuffer" INDEXED = "COMMONTCP" GLADE_DIALOG = "dialog.glade2" filexpm = "addblockbuffer.ico" button_label = N_("Add Block Buffer") button_tooltip = N_("Add a Block Buffer to Spike") button_private_tooltip = "Private" button_signal = None color = "yellow" size = 20 boxargs = {} xpacket2send = None cfd = None fdlist = [] objectcomments = None xpacketlist = [] buf = [] NumberofXp = 1 sendstring = "" def __init__(self): VisualToolbar.__init__(self) def setSize(self, size): self.size = size def setArg(self, args): if args.has_key('preparexpacket'): self.xpacket2send = args['preparexpacket'] #if args.has_key('preparefd'): # self.cfd = args['preparefd'] #if args.has_key('sendstring'): # self.sendstring= args['sendstring'] def Show(self): #if self.xpacket2send == None and self.sendstring == None: # return N_("send(Nothing to send)") if self.xpacket2send: return N_("Block Buffer %s") % self.xpacket2send def Help(self): return "Once you created a socket with CONNECT object you are able to send and receive data on it.\n\ The send dialog allows you to choose which data to send: this can be either a string or a previously \n\ created buffer.\n\ e.g. if we're exploiting a SMTPD which has an overflow in the handling of the RCPT command \n\ you would add three send objects:\n\ 1. \"HELO localhost\\n\"\n\ 2. \"MAIL FROM: [email protected]\\n\"\n\ 3. \"RCPT TO: \" + exploit buffer" def setDialog(self, dialog, cpacket, badchars, fdlist, xpacket): #self.fdlist = fdlist self.xpacketlist = xpacket #sendstring=dialog.get_widget('sendstring') #sendstring.set_text(self.sendstring) hboxpreparexpacket = dialog.get_widget("hbox4") #hboxpreparefd = dialog.get_widget("hbox5") preparexpacket = gtk.combo_box_new_text() hboxpreparexpacket.pack_start(preparexpacket, expand=True, padding=0) #preparefd = gtk.combo_box_new_text() #hboxpreparefd.pack_start(preparefd,expand=True, padding=0) preparexpacket.show() #preparefd.show() #basic edition == silent sockets if len(self.xpacketlist) == 0: preparexpacket.append_text(N_('No Buffer to send yet')) else: preparexpacket.append_text(N_('Select Buffer to send')) for a in self.xpacketlist: preparexpacket.append_text(str(self.xpacketlist.index(a) + 1)) try: preparexpacket.set_active(int(self.boxargs['preparexpacket'])) except: preparexpacket.set_active(0) preparexpacket.connect('changed', self.changedp) def preparedialog(self, widget, xpacketlist, fdlist): #self.fdlist=fdlist self.xpacketlist = xpacketlist #sendstring=widget.get_widget('sendstring') #sendstring.set_text(self.sendstring) hboxpreparexpacket = widget.get_widget("hbox4") #hboxpreparefd = widget.get_widget("hbox5") preparexpacket = gtk.combo_box_new_text() hboxpreparexpacket.pack_start(preparexpacket, expand=True, padding=0) #preparefd = gtk.combo_box_new_text() #hboxpreparefd.pack_start(preparefd,expand=True, padding=0) preparexpacket.show() #basic edition == silent sockets #preparefd.show() if len(xpacketlist) == 0: preparexpacket.append_text(N_('No Buffer to send yet')) else: preparexpacket.append_text(N_('Select Buffer to send')) for a in xpacketlist: preparexpacket.append_text(str(xpacketlist.index(a) + 1)) #if len(fdlist) == 0: # preparefd.append_text('No FD to use yet') #else: # preparefd.append_text('Select FD to use') #for a in fdlist: # preparefd.append_text(str(fdlist.index(a) + 1)) preparexpacket.set_active(0) #preparefd.set_active(0) preparexpacket.connect('changed', self.changedp) #preparefd.connect('changed', self.changedf) def changedp(self, combobox): model = combobox.get_model() index = combobox.get_active() #if index != 1: # sendstring.set_sensitive(False) #else: # sendstring.set_sensitive(True) self.boxargs['preparexpacket'] = model[index][0] self.setArg(self.boxargs) return def createPython(self, paddingfromrow): multiplier = str(paddingfromrow + 1) padding = " " * int(multiplier) #rbuf=r'self.log("sending buffer of length %s..." % str(len(xpacket' if paddingfromrow > 0: self.buf = [] self.buf.append(padding + "spk.s_block_start('Buffer_%s')" % self.xpacket2send) self.buf.append(padding + "xpacket%sbuf=self.createxPacket%s(spk)" % (self.xpacket2send, self.xpacket2send)) self.buf.append(padding + "spk.s_block_end('Buffer_%s')" % self.xpacket2send) #self.buf.append(padding+rbuf+'%sbuf)))' %self.xpacket2send) #self.buf.append(padding+'FD_%s.send(xpacket%sbuf)'% (self.cfd,self.xpacket2send)) #in this basic edition we will manage sockets silently #self.buf.append(padding+'FD_1.sendall(xpacket%sbuf)'% self.xpacket2send) else: self.buf = [] self.buf.append("spk.s_block_start('Buffer_%s')" % self.xpacket2send) self.buf.append("xpacket%sbuf=self.createxPacket%s(spk)" % (self.xpacket2send, self.xpacket2send)) self.buf.append("spk.s_block_end('Buffer_%s')" % self.xpacket2send) #self.buf.append(rbuf+'%sbuf)))' %self.xpacket2send) #self.buf.append('self.log("Sending: %%s"%%repr(xpacket%sbuf))'%self.xpacket2send) #in this basic edition we will manage sockets silently return self.buf def save(self): savedic = {} if self.xpacket2send: savedic['xpacket2send'] = self.xpacket2send #savedic['cfd']=self.cfd if self.objectcomments: savedic['comment'] = self.objectcomments.replace("\n", "\\n") return savedic def load(self, args): if args.has_key('comment'): tmp = args['comment'] self.objectcomments = tmp.replace("\\n", "\n") if args.has_key('xpacket2send'): self.xpacket2send = args['xpacket2send']
def Help(self): return N_("Shows a useful calculator")
def Help(self): return N_("Add a exploit buffer to your data.")
#! /usr/bin/env python #Proprietary CANVAS source code - use only under the license agreement #specified in LICENSE.txt in your CANVAS distribution #Copyright Immunity, Inc, 2002 #http://www.immunityinc.com/CANVAS/ for more information import sys import gtk sys.path.append(".") sys.path.append("../") sys.path.append("../../") from toolbar import VisualToolbar from gettext import gettext as N_ PLAINSTRING = N_("Just send a string") class Toolobject(VisualToolbar): NAME = "send" INDEXED = "COMMONTCP" GLADE_DIALOG = "dialog.glade2" filexpm = "send.ico" button_label = N_("Add send()") button_tooltip = N_("Add send() to connection packet") button_private_tooltip = "Private" button_signal = None color = "cyan" size = 20 boxargs = {}
def choice_dialog(primary_text, secondary_text, parent=None, \ allow_cancel=True, **kwargs): """ @param items: the items you want to choose from @param list_title: the title of the list. Optional. @param allow_cancel: If the user can cancel/close the dialog. @param min_select: The minimum number of elements to be selected. @param max_select: The maximum number of elements to be selected. -1 Means no limit. @param dialog_callback: This is a callback function that is going to be called when the dialog is created. The argument is the dialog object. @param one_item_text: when specified and if the number of `items` is one this text will be the primary text. This string must contain a '%s' which will be replaced by the item value. Optional. """ if "run" in kwargs: del kwargs["run"] choices = len(kwargs["items"]) min_select = kwargs.get("min_select", 1) max_select = kwargs.get("max_select", -1) # Make sure the arguments are correct assert choices > 0 assert (max_select == -1) ^ (min_select <= max_select <= choices) assert 0 <= min_select <= choices buttons = (kwargs.get("ok_button", gtk.STOCK_OK), gtk.RESPONSE_OK) if allow_cancel: buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) + buttons else: # TODO: make closing the window impossible pass if min_select == 0: txt = N_("Don't select it", "Don't select any items", choices) txt = kwargs.get("skip_button", txt) buttons = (txt, gtk.RESPONSE_CLOSE) + buttons for strategy in _STRATEGIES: if strategy.accepts(choices, min_select, max_select): break assert strategy.accepts(choices, min_select, max_select) if choices == 1: if "one_item_text" in kwargs: primary_text = kwargs["one_item_text"] % kwargs["items"][0] data = strategy.before(kwargs) if data is not None: primary_text = data dlg = hig_alert(primary_text, secondary_text, parent=parent, run=False, buttons=buttons, **kwargs) kwargs.get("dialog_callback", lambda foo: None)(dlg) response = dlg.run() if response != gtk.RESPONSE_OK: dlg.destroy() return (), response items = strategy.get_items(dlg) dlg.destroy() return items, response
def save_changes(files, last_save=None, parent=None, **kwargs): """ Shows up a Save changes dialog to a certain list of documents and returns a tuple with two values, the first is a list of files that are to be saved the second is the value of the response, which can be one of: - gtk.RESPONSE_OK - the user wants to save - gtk.RESPONSE_CANCEL - the user canceled the dialog - gtk.RESPONSE_CLOSE - the user wants to close without saving - gtk.RESPONSE_DELETE_EVENT - the user closed the window So if you want to check if the user canceled just check if the response is equal to gtk.RESPONSE_CANCEL or gtk.RESPONSE_DELETE_EVENT When the `elapsed_time` argument is not `None` it should be a list of the elapsed time since each was modified. It must be in the same order of the `files` argument. This function also accepts every argument that a hig_alert function accepts, which means it accepts `title`, etc. Note that this function overrides the `run` argument and sets it to True, because it's not possible for a user to know which files were saved since the dialog changes is structure depending on the arguments. Simple usage example:: files_to_save, response = save_changes(["foo.bar"]) @param files: a list of filenames to be saved @param last_save: when you only want to save one file you can optionally send the date of when the user saved the file most recently. @type last_save: datetime.datetime @param parent: the window that will be parent of this window. @param primary_text: optional, see hig_alert. @param secondary_text: optional, see hig_alert. @param one_item_text: optional, see choice_alert. @param list_title: optional, see choice_alert. @param kwargs: the remaining keyword arguments are the same as used on the function hig_alert. @return: a tuple with a list of entries the user chose to save and a gtk.RESPONSE_* from the dialog """ primary_text = N_( "There is %d file with unsaved changes. " "Save changes before closing?", "There are %d files with unsaved " "changes. Save changes before closing?", len(files)) primary_text %= len(files) primary_text = kwargs.get("primary_text", primary_text) secondary_text = _("If you don't save, all your changes will be " "permanently lost.") secondary_text = kwargs.get("secondary_text", secondary_text) one_item_text = _("Save the changes to <i>%s</i> before closing?") one_item_text = kwargs.get("one_item_text", one_item_text) list_title = _("Select the files you want to save:") list_title = kwargs.get("list_title", list_title) if len(files) == 1 and last_save is not None: updater = _TimeUpdater(last_save) secondary_text = updater.get_text() kwargs["dialog_callback"] = updater.set_dialog indexes, response = choice_dialog(primary_text, secondary_text, min_select=0, max_select=-1, skip_button=_("Close without saving"), ok_button=gtk.STOCK_SAVE, list_title=list_title, items=files, one_item_text=one_item_text, **kwargs) return map(files.__getitem__, indexes), response
class Toolobject(VisualToolbar): NAME = "setComments" GLADE_DIALOG = "dialog.glade2" filexpm = "comments.ico" button_label = N_("Set Comments") button_tooltip = N_("Set exploit documentation") button_private_tooltip = "Private" button_signal = None setflag = 0 def __init__(self): VisualToolbar.__init__(self) def setSize(self, size): pass def Help(self): return N_( "Set Comments: this fills in the exploit documentation header and CANVAS\n\ exploit properties which are required to run your exploit from CANVAS.") def setArg(self, args): self.setflag = 1 if args.has_key('sploitcomments'): self.sploitcomments = args['sploitcomments'] else: self.sploitcomments = "" if args.has_key('description'): self.description = args['description'] else: self.description = "" if args.has_key('proptype') and args["proptype"] != "": self.proptype = args['proptype'] else: self.proptype = "Exploit" if args.has_key('repeatability'): self.repeatability = args['repeatability'] else: self.repeatability = "" if args.has_key('propversion') and args["propversion"] != "": self.propversion = args['propversion'] else: self.propversion = "Windows" if args.has_key('references'): self.references = args['references'] else: self.references = "" if args.has_key('propsite') and args["propsite"] != "": self.propsite = args['propsite'] else: self.propsite = "Remote" if args.has_key('datepublic'): self.datepublic = args['datepublic'] else: self.datepublic = "" if args.has_key('name'): self.name = args['name'] else: self.name = "" if args.has_key('version'): self.version = args['version'] else: self.version = "" def setDialog(self, dialog, args): if self.setflag == 1: sploitcomments = dialog.get_widget('sploitcomments') scommentbuffer = gtk.TextBuffer() scommentbuffer.set_text(self.sploitcomments) sploitcomments.set_buffer(scommentbuffer) description = dialog.get_widget('description') description.set_text(self.description) proptype = dialog.get_widget('proptype') proptype.set_text(self.proptype) repeatability = dialog.get_widget('repeatability') repeatability.set_text(self.repeatability) propversion = dialog.get_widget('propversion') propversion.set_text(self.propversion) references = dialog.get_widget('references') references.set_text(self.references) propsite = dialog.get_widget('propsite') propsite.set_text(self.propsite) datepublic = dialog.get_widget('datepublic') datepublic.set_text(self.datepublic) name = dialog.get_widget('name') name.set_text(self.name) version = dialog.get_widget('version') version.set_text(self.version) else: sploitcomments = dialog.get_widget('sploitcomments') scommentbuffer = gtk.TextBuffer() scommentbuffer.set_text(args['sploitcomments']) sploitcomments.set_buffer(scommentbuffer) description = dialog.get_widget('description') description.set_text(args['description']) proptype = dialog.get_widget('proptype') proptype.set_text(args['proptype']) repeatability = dialog.get_widget('repeatability') repeatability.set_text(args['repeatability']) propversion = dialog.get_widget('propversion') propversion.set_text(args['propversion']) references = dialog.get_widget('references') references.set_text(args['references']) propsite = dialog.get_widget('propsite') propsite.set_text(args['propsite']) datepublic = dialog.get_widget('datepublic') datepublic.set_text(args['datepublic']) name = dialog.get_widget('name') name.set_text(args['name']) version = dialog.get_widget('version') version.set_text(args['version']) def Show(self): pass def preparedialog(self, widget, platlist, xpacket): pass def createPython(self): return ""
def Help(self): return N_("Run Exploit: Executes your exploit. Requires you to set the hostname and\n\ port number of the target, and fill in the callback information for the payload.")