Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
Addition of a tunable timeout parameter
Chrome browser support for debian/ubuntu systems
verbose output for each stage of the process
  • Loading branch information
bvachha committed May 17, 2018
1 parent 321c8b9 commit e2a7feb
Showing 1 changed file with 42 additions and 17 deletions.
59 changes: 42 additions & 17 deletions BFuzz.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,58 @@
import os
import signal
import subprocess
import sys
from time import sleep


def runWebTest():
dir_path = os.path.dirname(os.path.realpath(__file__))
print("Enter the browser type: \n 1: Chrome \n 2: Firefox")
browserType = input('>>')
if browserType not in [1,2]:
print("Incorrect option!!")
sys.exit(0)
timeout = input(
"Duration the browser process should wait before stopping(>=15 seconds to ensure full load of page):")
checkValidBrowserType(browserType)
for root, folders, fileNames in os.walk("recurve"):
for fileName in fileNames:
if not fileName.endswith('.html'):
continue
if browserType == 1:
processCommand = 'chrome '
elif browserType == 2:
processCommand = ['firefox','--new-instance']
filePath = os.path.join(dir_path,root,fileName)
filePath = "file://"+filePath
print filePath
processCommand.append(filePath)
print processCommand
process = subprocess.Popen(processCommand)
sleep(12)
process.kill()
sleep(3)
processCommand = getBrowserApplication(browserType)
if processCommand is not None:
setupExploit(dir_path, fileName, processCommand, root)
runExploit(processCommand, timeout)
else:
print "Invalid Browser Type"


def runExploit(processCommand, timeout):
print "Executing Command: " + " ".join(processCommand)
process = subprocess.Popen(processCommand)
sleep(timeout)
print "Killing browser process.... bye bye"
process.kill()
sleep(3)


def setupExploit(dir_path, fileName, processCommand, root):
filePath = os.path.join(dir_path, root, fileName)
filePath = "file://" + filePath
print "Testing with exploit:" + filePath
processCommand.append(filePath)


def getBrowserApplication(browserType):
if browserType == 1:
processCommand = ['google-chrome']
elif browserType == 2:
processCommand = ['firefox', '--new-instance']
else:
processCommand = None
return processCommand


def checkValidBrowserType(browserType):
if browserType not in [1, 2]:
print("Incorrect option!!")
sys.exit(0)


if __name__ == '__main__':
Expand Down

0 comments on commit e2a7feb

Please sign in to comment.