Notebook
!git clone https://github.com/choller/simply-buggy !(cd simply-buggy && make)
!cat simply-buggy/simple-crash.cpp!cat simply-buggy/simple-crash.fuzzmanagerconf
!simply-buggy/simple-crash
import subprocesscmd = ["simply-buggy/simple-crash"]result = subprocess.run(cmd, stderr=subprocess.PIPE) stderr = result.stderr.decode().splitlines() crashed = False for line in stderr: if "ERROR: AddressSanitizer" in line: crashed = True break if crashed: print("Yay, we crashed!") else: print("Move along, nothing to see...")
import subprocessfrom Collector.Collector import Collectorfrom FTB.ProgramConfiguration import ProgramConfigurationfrom FTB.Signatures.CrashInfo import CrashInfo
collector = Collector() cmd = ["simply-buggy/simple-crash"] result = subprocess.run(cmd, stderr=subprocess.PIPE) stderr = result.stderr.decode().splitlines() crashed = False for line in stderr: if "ERROR: AddressSanitizer" in line: crashed = True break if crashed: print("Yay, we crashed, processing...") # This reads the simple-crash.fuzzmanagerconf file configuration = ProgramConfiguration.fromBinary(cmd[0]) # This reads and parses our ASan trace into a more generic format, # returning us a generic "CrashInfo" object that we can inspect # and/or submit to the server. crashInfo = CrashInfo.fromRawCrashData([], stderr, configuration) # Submit the crash collector.submit(crashInfo) print("Crash submitted!") else: print("Move along, nothing to see...")
!cat simply-buggy/out-of-bounds.cpp
import os import random import subprocess import tempfile import sysfrom Collector.Collector import Collectorfrom FTB.ProgramConfiguration import ProgramConfigurationfrom FTB.Signatures.CrashInfo import CrashInfo# Instantiate the collector instance, this will be our entry point # for talking to the server.collector = Collector() cmd = ["simply-buggy/out-of-bounds"] crash_count = 0 for itnum in range(0,100): rand_len = random.randint(1, 1024) rand_data = bytearray(os.urandom(rand_len)) (fd, current_file) = tempfile.mkstemp(prefix="fuzztest") os.write(fd, rand_data) os.close(fd) current_cmd = [] current_cmd.extend(cmd) current_cmd.append(current_file) result = subprocess.run(current_cmd, stderr=subprocess.PIPE) stderr = result.stderr.decode().splitlines() crashed = False for line in stderr: if "ERROR: AddressSanitizer" in line: crashed = True break if crashed: sys.stdout.write("C") # This reads the simple-crash.fuzzmanagerconf file configuration = ProgramConfiguration.fromBinary(cmd[0]) # This reads and parses our ASan trace into a more generic format, # returning us a generic "CrashInfo" object that we can inspect # and/or submit to the server. crashInfo = CrashInfo.fromRawCrashData([], stderr, configuration) # Submit the crash collector.submit(crashInfo, testCase = current_file) crash_count += 1 else: sys.stdout.write(".") os.remove(current_file) print("") print("Done, submitted %s crashes." % crash_count)
!cat simply-buggy/maze.cpp
!(cd simply-buggy && make clean && make coverage)
!git clone https://github.com/choller/simply-buggy $HOME/simply-buggy-server !python3 $HOME/FuzzManager/server/manage.py setup_repository simply-buggy GITSourceCodeProvider $HOME/simply-buggy-server
import random import subprocessrandom.seed(0) cmd = ["simply-buggy/maze"] constants = [3735928559, 1111638594]; for itnum in range(0,1000): current_cmd = [] current_cmd.extend(cmd) for _ in range(0,4): if random.randint(0, 9) < 3: current_cmd.append(str(constants[random.randint(0, len(constants) - 1)])) else: current_cmd.append(str(random.randint(-2147483647, 2147483647))) result = subprocess.run(current_cmd, stderr=subprocess.PIPE) stderr = result.stderr.decode().splitlines() crashed = False if stderr and "secret" in stderr[0]: print(stderr[0]) for line in stderr: if "ERROR: AddressSanitizer" in line: crashed = True break if crashed: print("Found the bug!") break print("Done!")
!grcov simply-buggy/ -t coveralls+ --commit-sha $(cd simply-buggy && git rev-parse HEAD) --token NONE -p `pwd`/simply-buggy/ > coverage.json !python3 -mCovReporter --repository simply-buggy --description "Test1" --submit coverage.json
import random import subprocessrandom.seed(0) cmd = ["simply-buggy/maze"] constants = [3735928559, 1111638594, 3405695742]; # Added the missing constant here for itnum in range(0,1000): current_cmd = [] current_cmd.extend(cmd) for _ in range(0,4): if random.randint(0, 9) < 3: current_cmd.append(str(constants[random.randint(0, len(constants) - 1)])) else: current_cmd.append(str(random.randint(-2147483647, 2147483647))) result = subprocess.run(current_cmd, stderr=subprocess.PIPE) stderr = result.stderr.decode().splitlines() crashed = False if stderr: print(stderr[0]) for line in stderr: if "ERROR: AddressSanitizer" in line: crashed = True break if crashed: print("Found the bug!") break print("Done!")