def OnSavs(self, event=None): wildcard = "xml files (*.xml)|*.xml |sqlite files (*.db)|*.db" title="Save File" dialog=wx.FileDialog(self.frame, title, style=wx.SAVE|wx.OVERWRITE_PROMPT, wildcard=wildcard) result = dialog.ShowModal() path = dialog.GetPath() if result==wx.ID_OK: try: if path.find('.xml') != -1: filetype='xml' elif path.find('.db') != -1: filetype='db' else: wx.MessageBox("Format not supported","Info") return if os.path.exists(path): os.remove(path) if filetype=='xml': self.OnDumpXML(path) elif filetype=='db': self.OnDumpDB(path) except: pass dialog.Destroy()
def OnOpen(self,event): title="Select file" wildcard = "xml files (*.xml)|*.xml |sqlite files (*.db)|*.db" dlg = wx.FileDialog(self.frame, title, style = wx.OPEN, wildcard=wildcard) result = dlg.ShowModal() path = dlg.GetPath() if result==wx.ID_OK: if path.find('.xml') != -1: filetype='xml' elif path.find('.XML') != -1: filetype='xml' elif path.find('.db') != -1: filetype='db' if filetype=='xml': try: if os.path.exists(path): fd = open(path, 'rb') data=fd.read() if data != "" or data is not None: #self.frame.lc_sources.DeleteAllItems() self.frame.cb_exploit.Clear() self.frame.cb_targets.Clear() self.frame.cb_proxy.Clear() self.frame.cb_single.SetValue(0) self.frame.cb_mass.SetValue(0) self.frame.cb_glob.SetValue(0) self.frame.tc_url.Clear() l=xmlparser.XmlToDict(path) self.OnInsertRows(l) fd.close() except Exception, e : print e elif filetype=='db': try: db=gsqlite.Gomozdblite('', '') if path is not None and path != '': db.Connectdb(path) data, dump=db.Selectdb() dump=dump[0] db.Closedb() for i in range(len(data)): self.frame.lc_sources.InsertStringItem(i, str(data[i][0])) self.frame.lc_sources.SetStringItem(i, 1, str(data[i][1])) self.frame.lc_sources.SetStringItem(i, 2, str(data[i][2])) self.frame.lc_sources.SetStringItem(i, 3, str(data[i][3])) self.frame.lc_sources.SetStringItem(i, 4, str(data[i][4])) self.frame.cb_exploit.SetValue(str(dump[3])) self.frame.cb_targets.SetValue(str(dump[0])) self.frame.cb_proxy.SetValue(str(dump[2])) self.frame.cb_single.SetValue(0) self.frame.cb_mass.SetValue(0) self.frame.cb_glob.SetValue(0) self.frame.tc_url.SetValue(str(dump[1])) except Exception, msg: wx.MessageBox(str(msg),"Info")