def OnBtnExportStemmedWordsButton(self, event): db = SqliteDatabase(Globals.TextCatFileName) if not db.OpenConnection(): return CommonFunctions.ShowErrorMessage(self, 'This is not yet implemented!', False) return dlg = wx.FileDialog(self, "Save Stemmed Words List", ".", "", "*.csv", wx.SAVE) try: if dlg.ShowModal() == wx.ID_OK: fileName = dlg.GetPath() busy = wx.BusyInfo( "It might take some time depending on the word feature size..." ) wx.Yield() fout = open(fileName, 'w') query = "select stemmedwords.word, sum(bagofstemmedwords.frequency) as total from stemmedwords left join bagofstemmedwords on stemmedwords.id = bagofstemmedwords.wordid " query += " group by bagofstemmedwords.wordid order by total desc;" #print 'before' rows = db.FetchAllRows(query) #rint 'after' i = 1 for row in rows: #print row #if i == 0: #try: fout.write(row[0]) fout.write(" (%d)" % row[1]) #fout.write(row[1]) #i += 1 #except Exception, value: # print "Error: writing word: ", value #else: #try: fout.write(", ,") #fout.write(row[0]) #fout.write(" - %d"%row[1]) #fout.write(row[1]) i += 1 if i == 4: i = 0 fout.write("\n") db.CloseConnection() fout.close() except Exception, value: db.CloseConnection() fout.close() CommonFunctions.ShowErrorMessage( self, "Failed to Export Word List. No Indexing has been done! Error: %s" % value)
def OnBtnOKButton(self, event): msg = "" imagePath = self.txtImagePath.GetValue().strip() if not imagePath: msg = "Please select dd image file path!" elif not self.listDriveNames: msg = "Please add at least one destination device drive to write image to." elif not os.path.exists(imagePath): msg = "Please enter a valid image file path!" if msg <> "": CommonFunctions.ShowErrorMessage(self, msg, True) return try: import dlgDDToDiskParallelProgress ddDialog = dlgDDToDiskParallelProgress.create( self, imagePath, self.listDriveNames) ddDialog.ShowModal() finally: self.Destroy()
def OnBtnOKButton(self, event): msg = "" if not self.choiceSourceType.GetStringSelection() == "Logical Drive": msg = "Please select Logical Drive which is the only supported source evidence type for now!" elif not self.listImageNames: msg = "Please add at least one destination image file path to the list." if msg <> "": CommonFunctions.ShowErrorMessage(self, msg, True) return driveName = self.choiceSource.GetStringSelection() self.rootDrive = r'\\.\%s:' % driveName[:driveName.find(':')] try: import dlgDDParallelProgress """ PhysicalDrive = 0 LogicalDrive = 1 DiskDrive = 2 ImageFile = 3 FolderContents = 4 """ ddDialog = dlgDDParallelProgress.create( self, self.rootDrive, self.listImageNames, Constants.LogicalDrive, self.chkVerifyImages.GetValue()) #scanMAC.StartScan(dir) ddDialog.ShowModal() #self.Close() finally: self.Destroy()
def OnBtnSaveReportButton(self, event): self.startTime = time.time() dlg = wx.FileDialog(self, "Save Known Files Report", ".", "", "*.csv", wx.SAVE) try: if dlg.ShowModal() == wx.ID_OK: db = SqliteDatabase(Globals.FileSystemName) if not db.OpenConnection(): return busy = wx.BusyInfo("It might take a while...") wx.Yield() query = "select DirPath||'%s'||Name, MD5 from %s where KnownFile = 1;" % ( os.path.sep, Globals.CurrentEvidenceID) fileName = dlg.GetPath() fout = open(fileName, 'wb') fout.write('Report Generated on: %s\n' % (time.ctime())) rows = db.FetchAllRows(query) fout.write('There are %d total known files.\n\n' % (len(rows))) delimeter = ";" if self.radComma.GetValue(): delimeter = "," for row in rows: fout.write("%s%s%s\n" % (unicode(row[0]), delimeter, unicode(row[1]))) db.CloseConnection() fout.close() self.elapsedTime = CommonFunctions.ConvertSecondsToYearDayHourMinSec( time.time() - self.startTime) msg = "Done generating report! (%s)" % (self.elapsedTime) CommonFunctions.ShowErrorMessage(self, msg, error=False) except Exception, value: CommonFunctions.ShowErrorMessage( self, "Failed to Save Known Files Report! Error: %s" % value)
def OnBtnExportSearchResultsButton(self, event): db = SqliteDatabase(Globals.KeywordsFileName) if not db.OpenConnection(): return dlg = wx.DirDialog(self, message="Empty Directory to Save Search Results") #try: if dlg.ShowModal() == wx.ID_OK: dirPath = dlg.GetPath() if os.listdir(dirPath): CommonFunctions.ShowErrorMessage(self, "Selected directory is not empty! Please select an empty directory!") else: busy = wx.BusyInfo("It may take some time depending on the total number of kewywords...") wx.Yield() fout = open(os.path.join(dirPath, "SearchResultsSummary.txt"), 'wb') fout.write("%s%s%s%s\n"%("Keyword".ljust(20, " "), "File Path".ljust(200, " "), "Case Sens.".rjust(12, " "), "Case Insens.".rjust(12, " "))) fout.write("%s%s%s%s\n"%("=".ljust(20, "="), "=".ljust(200, "="), "=".rjust(12, "="), "=".rjust(12, "="))) for word in Globals.Keywords: keywordPath = os.path.join(dirPath, word) if not os.path.isdir(keywordPath): os.mkdir(keywordPath) fout.write(word.ljust(20, " ")) query = "select FileName, " + word + "_CS," + word + "_CI from " + Constants.KeywordsFrequencyTable query += " where " + word + "_CI > 0 or " + word + "_CS > 0;" rows = db.FetchAllRows(query) i = 0 for row in rows: try: if i> 0: fout.write(" ".ljust(20, " ")) i += 1 srcFilePath = PlatformMethods.Decode(row[0]) #.replace("\\\\", "\\") fileName = os.path.basename(row[0]) dstFilePath = PlatformMethods.Decode(os.path.join(keywordPath, fileName)) fout.write(srcFilePath.ljust(200, " ")) fout.write(PlatformMethods.Encode(row[1]).rjust(12, " ")) fout.write(PlatformMethods.Encode(row[2]).rjust(12, " ")) shutil.copyfile(srcFilePath, dstFilePath) shutil.copystat(srcFilePath, dstFilePath) except Exception, value: print 'Error occured while exporting: Error: ', value fout.write("\n") fout.write("\n") fout.write("%s\n"%("*".ljust(250, "*"))) db.CloseConnection() fout.close()
def OnBtnExportWordFeaturesButton(self, event): db = SqliteDatabase(Globals.TextCatFileName) if not db.OpenConnection(): return dlg = wx.FileDialog(self, "Save Words List", ".", "", "*.csv", wx.SAVE) try: if dlg.ShowModal() == wx.ID_OK: fileName = dlg.GetPath() busy = wx.BusyInfo( "It might take some time depending on the total number of unique words..." ) wx.Yield() fout = open(fileName, 'wb') #query = "select ID, `Word` from " + Constants.TextCatWordsTable + " order by `ID`; " query = "select words.word, count(WordLocation.WordID) as total from words left join WordLocation on words.rowid = wordlocation.wordid " query += "group by wordlocation.wordid order by total desc;" #print 'before' rows = db.FetchAllRows(query) #rint 'after' i = 1 for row in rows: #print row #if i == 0: #try: fout.write(PlatformMethods.Encode(row[0])) fout.write(" (%d)" % row[1]) #fout.write(row[1]) #i += 1 #except Exception, value: # print "Error: writing word: ", value #else: #try: fout.write(", ,") #fout.write(row[0]) #fout.write(" - %d"%row[1]) #fout.write(row[1]) i += 1 if i == 4: i = 0 fout.write("\n") #except Exception, value: # print "Error: writing word: ", value db.CloseConnection() fout.close() except Exception, value: db.CloseConnection() fout.close() CommonFunctions.ShowErrorMessage( self, "Failed to Export Word List. Error: %s" % value)
def OnBtnAddDestinationButton(self, event): imagePath = self.txtImagePath.GetValue().strip() if not imagePath: msg = "Please select dd image file path first!" CommonFunctions.ShowErrorMessage(self, msg, True) return if not os.path.exists(imagePath): CommonFunctions.ShowErrorMessage( self, "Please enter a valid image file path!", True) return st = os.stat(imagePath) imageSize = st[ST_SIZE] dlg = wx.DirDialog(self) try: if dlg.ShowModal() == wx.ID_OK: driveName = dlg.GetPath() driveName = driveName[:driveName.find(':') + 1] #print driveName try: rfin = Win32RawIO.Win32RAWIO(r'\\.\%s' % driveName, 'r') if imageSize > rfin.size: CommonFunctions.ShowErrorMessage( self, "Warning! Image file size bigger than the disk size!!", False) rfin.close() self.listDriveNames.append(r'\\.\%s' % driveName) self.lstDestinations.Append([driveName]) except Exception, msg: CommonFunctions.ShowErrorMessage(self, str(msg), True) finally: dlg.Destroy() event.Skip()
def CheckInputError(self): errMsg = "" if not self.txtKeywordsFile.GetValue(): errMsg = "Please Enter or Browse to Keywords File Path!" elif not self.txtOutputPath.GetValue(): errMsg = "Please Enter or Browse Path to Output Report!" if errMsg: CommonFunctions.ShowErrorMessage(self, errMsg) return True else: return False
def SearchDocuments(self, searchWords): if self.SearchDocumentsMenu.FindItem(searchWords) < 0: id = wx.NewId() self.SearchDocumentsMenu.Append(id, searchWords) self.Bind(wx.EVT_MENU, self.OnSearchDocumentsMenu, id=id) #print searchWords DocPaths =[] totalResults = 0 try: DocPaths, totalResults = self.search.GetRankedDocuments(searchWords) except Exception, msg: CommonFunctions.ShowErrorMessage(self, 'No Indexing has been performed!', error=True)
def OnBtnOKButton(self, event): msg = self.CheckSettingsInput() if msg: dlg = wx.MessageDialog(self, msg, 'Error', wx.OK | wx.ICON_ERROR) try: dlg.ShowModal() finally: dlg.Destroy() return busy = wx.BusyInfo("Please wait! Processing emails data...") wx.Yield() self.CentralID = self.txtCentralID.GetValue().strip().lower() if not Globals.EmailsDict.has_key(self.CentralID): if not self.EmailRE.search(self.CentralID): self.CentralID = EmailUtilities.LookupEmailID(self.CentralID).lower() if not Globals.EmailsDict.has_key(self.CentralID): CommonFunctions.ShowErrorMessage(self, "Central ID: %s is not found in database!"%self.CentralID) return emails = self.txtEmails.GetValue() self.GroupEmailsDict = {} if len(emails) > 0: mailsList = emails.split(",") for emailID in mailsList: if not self.EmailRE.search(emailID): email = EmailUtilities.LookupEmailID(emailID.strip()).lower() self.GroupEmailsDict[email] = {} else: self.GroupEmailsDict[emailID.strip().lower()] = {} if Globals.CentralID != self.CentralID or self.GroupEmailsDict != Globals.GroupEmailsDict: Globals.GroupEmailsDict = self.GroupEmailsDict Globals.CentralID = self.CentralID Globals.OrderedEmailDict = {} EmailUtilities.OrderEmailsToCentralEmail(self.CentralID, Globals.EmailsDict, Globals.OrderedEmailDict, Globals.GroupEmailsDict) map = EmailMapWindow.WindowHolder(Globals.frmGlobalMainForm, Globals.OrderedEmailDict, self.CentralID) map.Show(True) self.Close()
def CheckSettingsError(self): #Globals.TextCatDirList = [] #self.treeDirCheckView.UpdateCheckedList(Globals.TextCatDirList) #Globals.TextCatCategoryList = [] self.treeCategoryCheckView.UpdateCheckedList( Globals.AttachmentsCheckedMimes) errMsg = "" """ if len(Globals.Keywords) == 0: errMsg = "Please import keywords from a text file before start searching.\n File must have one keyword per line." """ #if len(self.txtAddressBookPath.GetValue()) == 0: # errMsg = "Please enter or browse to the directory path where address book is present." if len(self.txtEmailsPath.GetValue()) == 0: errMsg = "Please enter or browse to the directory path where email files are present." CommonFunctions.ShowErrorMessage(self, errMsg, True) return False else: return True
def OnBtnOKButton(self, event): self.startTime = time.time() busy = wx.BusyInfo( "Extracting Emails and Attachments and generating reports...It might take some time; just relax!" ) wx.Yield() """ import keyextract keyextract.msg_Folder_Path = self.txtMessageFolderPath.GetValue() keyextract.result_Dir_Path = self.txtResultFolderPath.GetValue() keyextract.file_Name = self.txtKeywordsFile.GetValue() keyextract.DoIt() """ db = SqliteDatabase(Globals.EmailsFileName) if not db.OpenConnection(): return keywordsFile = self.txtKeywordsFile.GetValue() outPutPath = self.txtResultFolderPath.GetValue() if not outPutPath: outPutPath = "." self.ReportOutputPath = os.path.join(outPutPath, "KeywordsReport") self.MessageOutputPath = os.path.join(self.ReportOutputPath, "Messages") #self.HTMLOutputPath = os.path.join(self.ReportOutputPath, "HTML") if not keywordsFile: return keywordsList = self.ReadKeywords(keywordsFile) for keyword in keywordsList: self.searchBitMap(db, keyword.strip()) self.elapsedTime = CommonFunctions.ConvertSecondsToYearDayHourMinSec( time.time() - self.startTime) msg = "Done generating report! (%s)" % (self.elapsedTime) CommonFunctions.ShowErrorMessage(self, msg, error=False) self.Close()