def _handleCrash(self, corpusData, fuzzerPos): print("Detected Crash at " + fuzzerPos) self.iterStats["crashCount"] += 1 crashData = CrashData(self.config, corpusData, fuzzerPos) self.serverManager.getCrashInformation(crashData) crashData.writeToFile() self.serverManager.restart()
def test_writeread(self): config = self._getConfig() testutils.prepareFs(config) # get some example corpus corpusData = self._getCorpusData(config) # assume this corpus crashed the server crashData = CrashData(config, corpusData) crashData.setCrashInformation(asanOutput="meh") # write it crashData.writeToFile() # try to read it again crashData2 = CrashData(config, filename=crashData.filename) crashData2.readFromFile() # test an example of each layer self.assertEqual( crashData.asanOutput, crashData2.asanOutput) self.assertEqual( crashData.corpusData.filename, crashData2.corpusData.filename) self.assertEqual( crashData.corpusData.networkData.messages[0]['data'], crashData2.corpusData.networkData.messages[0]['data'], )
def setRawData(self, rawData): self.crashData = CrashData(self.config) self.crashData.setRawData(rawData['crashData']) self.filename = rawData['filename'] self.faultaddress = rawData['faultaddress'] self.backtrace = rawData['backtrace'] self.cause = rawData['cause'] self.analyzerOutput = rawData['analyzerOutput'] self.analyzerType = rawData['analyzerType'] self.processStdout = rawData['processStdout']
def getNetworkData(self, filepath): data = self._readPickleFile(filepath) if 'networkData' in data: corpusData = CorpusData(self.config) corpusData.setRawData(data) return corpusData.networkData if 'corpusData' in data: crashData = CrashData(self.config) crashData.setRawData(data) return crashData.corpusData.networkData if 'crashData' in data: verifyData = VerifyData(self.config) verifyData.setRawData(data) return verifyData.crashData.corpusData.networkData return None
def _handleCrash(self, honggCorpusData, fuzzerPosition): # check if core exists if self.config['handle_corefiles']: n = 0 while n < 4: corepath = os.path.join(self.config['target_dir'], 'core') if os.path.isfile(corepath): break time.sleep(0.1) n += 1 print('Found crash!') crashData = CrashData(self.config, honggCorpusData, fuzzerPosition) crashData.writeToFile() if self.config['tweetcrash']: msg = "Found crash in " + self.config['name'] msg += "" self.twitterInterface.tweet(msg)
def _getCrashData(self, config): corpusData = self._getCorpusData(config) crashData = CrashData(config, corpusData) return crashData
def _getCrashData(self, config): corpusData = self._getCorpusData(config) crashData = CrashData(config, corpusData, '-') crashData.setCrashInformation(asanOutput="meh") return crashData
class VerifyData(object): def __init__(self, config, crashData=None, filename=None, faultaddress=0, backtrace=None, cause=None, analyzerOutput=None, analyzerType=None): self.config = config self.crashData = crashData if analyzerType is not None: self.analyzerType = analyzerType else: self.analyzerType = '' if filename is not None: self.filename = filename elif crashData is not None: self.filename = utils.filenameWithoutExtension(crashData.filename) self.filename += "." + self.analyzerType self.filename += '.verified' else: self.filename = None self.faultaddress = faultaddress self.backtrace = backtrace self.cause = cause self.analyzerOutput = analyzerOutput self.processStdout = None def getRawData(self): verifyDataRaw = { 'filename': self.filename, 'faultaddress': self.faultaddress, 'backtrace': self.backtrace, 'cause': self.cause, 'analyzerOutput': self.analyzerOutput, 'analyzerType': self.analyzerType, 'processStdout': self.processStdout, 'crashData': self.crashData.getRawData(), } return verifyDataRaw def setRawData(self, rawData): self.crashData = CrashData(self.config) self.crashData.setRawData(rawData['crashData']) self.filename = rawData['filename'] self.faultaddress = rawData['faultaddress'] self.backtrace = rawData['backtrace'] self.cause = rawData['cause'] self.analyzerOutput = rawData['analyzerOutput'] self.analyzerType = rawData['analyzerType'] self.processStdout = rawData['processStdout'] def writeToFile(self): data = self.getRawData() filepath = os.path.join(self.config["verified_dir"], self.filename) with open(filepath, 'w') as f: pickle.dump(data, f) def readFromFile(self): filepath = os.path.join(self.config["verified_dir"], self.filename) with open(filepath, 'r') as f: rawData = pickle.load(f) self.setRawData(rawData) def __str__(self): d = "" d += "VerifyCrashData: " + "Faultaddress: " + str(self.faultAddress) if self.backtrace: d += " Has_Backtrace" else: d += " NO_Backtrace" if self.cause: d += " Has_Cause" else: d += " NO_Cause" if self.analyzerOutput: d += " Has_AnalyzerOutput" else: d += " NO_AnalyzerOutput" d += "\n" return d