예제 #1
0
def pre_fuzz():
    # 防止浏览器进程不结束导致Vectors生成失败
    config.TerminateProc()
    # 生成每次Fuzz使用的Vectors样本
    if generateVectors() is False:
        config.logging_exception('G', "Generate vectors is failed.")
        return
    # 遍历所有Vectors样本
    vector_i = 0
    config.MOR_LAST_COMPLETE_VECOTR = -1
    while vector_i < config.MOR_PRE_VECTORS_NUM:
        config.TerminateProc()
        # 浏览器打开样本Vectors
        if config.LoadBrowserProc(vector_i) is False:
            config.logging_exception('L', "Open Browser process is failed.")
            break
        # 开启Monitor监控线程
        t_m = threading.Thread(target=monitor.Watch)
        t_m.setDaemon(True)
        t_m.start()
        t_m.join(config.MOR_FUZZING_TIMEOUT)  # seconds
        timeout = False
        while t_m.is_alive():  # 线程超时
            config.MOR_MONITOR_RUNNING = False
            timeout = True
            time.sleep(1)
        if timeout is True:
            # 保证了某个网页超时能继续运行后面的样本
            config.MOR_LAST_COMPLETE_VECOTR += 1
        # 跳到下一个需要执行的Vector序号
        vector_i = config.MOR_LAST_COMPLETE_VECOTR + 1
예제 #2
0
파일: morph.py 프로젝트: cherry-wb/morph
def pre_fuzz():
    # 防止浏览器进程不结束导致Vectors生成失败
    config.TerminateProc()
    # 生成每次Fuzz使用的Vectors样本
    if generateVectors() is False:
        config.logging_exception('G', "Generate vectors is failed.")
        return
    # 遍历所有Vectors样本
    vector_i = 0
    config.MOR_LAST_COMPLETE_VECOTR = -1
    while vector_i < config.MOR_PRE_VECTORS_NUM:
        config.TerminateProc()
        # 浏览器打开样本Vectors
        if config.LoadBrowserProc(vector_i) is False:
            config.logging_exception('L', "Open Browser process is failed.")
            break
        # 开启Monitor监控线程
        t_m = threading.Thread(target=monitor.Watch)
        t_m.setDaemon(True)
        t_m.start()
        t_m.join(config.MOR_FUZZING_TIMEOUT)  # seconds
        timeout = False
        while t_m.is_alive(): # 线程超时
            config.MOR_MONITOR_RUNNING = False
            timeout = True
            time.sleep(1)
        if timeout is True:
            # 保证了某个网页超时能继续运行后面的样本
            config.MOR_LAST_COMPLETE_VECOTR += 1
        # 跳到下一个需要执行的Vector序号
        vector_i = config.MOR_LAST_COMPLETE_VECOTR + 1
예제 #3
0
 for name, value in opts:
     if name in ('-b', '--browser'):
         browser = value
     elif name in ('-f', '--fuzzer'):
         fuzzer = value
     elif name in ('-d', '--debugger'):
         debugger = value
     else:
         config.morph_usage()
         sys.exit()
 # 2.若参数中没有Debugger则设置为默认的
 dbg_keys = list(config.MOR_DEBUGGERS[config.MOR_SYSTEM].keys())
 browser_keys = list(config.MOR_BROWSERS[config.MOR_SYSTEM].keys())
 if len(dbg_keys) <= 0 or len(browser_keys) <= 0:
     config.morph_signals()
     config.logging_exception(
         'C', "MOR_BROWSER or MOR_DEBUGGER is not found in config.py.")
     sys.exit()
 if len(debugger) <= 0:
     for dbg_i in dbg_keys:
         if config.MOR_DEBUGGERS[
                 config.MOR_SYSTEM][dbg_i]['property'] == "default":
             debugger = dbg_i
             break
 # 3.判断运行参数是否合理
 fuzzer_path = os.path.join(config.MOR_FUZZERS_FOLDER, fuzzer)
 fuzzer_exist = os.path.exists(fuzzer_path)
 if browser not in browser_keys or debugger not in dbg_keys or len(
         fuzzer) <= 0 or fuzzer_exist is False:
     config.morph_usage()
     sys.exit()
 # 4.运行Fuzz主进程
예제 #4
0
파일: morph.py 프로젝트: cherry-wb/morph
 for name, value in opts:
     if name in ('-b', '--browser'):
         browser = value
     elif name in ('-f', '--fuzzer'):
         fuzzer = value
     elif name in ('-d', '--debugger'):
         debugger = value
     else:
         config.morph_usage()
         sys.exit()
 # 2.若参数中没有Debugger则设置为默认的
 dbg_keys = list(config.MOR_DEBUGGERS[config.MOR_SYSTEM].keys())
 browser_keys = list(config.MOR_BROWSERS[config.MOR_SYSTEM].keys())
 if len(dbg_keys) <= 0 or len(browser_keys) <= 0:
     config.morph_signals()
     config.logging_exception('C', "MOR_BROWSER or MOR_DEBUGGER is not found in config.py.")
     sys.exit()
 if len(debugger) <= 0:
     for dbg_i in dbg_keys:
         if config.MOR_DEBUGGERS[config.MOR_SYSTEM][dbg_i]['property'] == "default":
             debugger = dbg_i
             break
 # 3.判断运行参数是否合理
 fuzzer_path = os.path.join(config.MOR_FUZZERS_FOLDER, fuzzer)
 fuzzer_exist = os.path.exists(fuzzer_path)
 if browser not in browser_keys or debugger not in dbg_keys or len(fuzzer) <= 0 or fuzzer_exist is False :
     config.morph_usage()
     sys.exit()
 # 4.运行Fuzz主进程
 config.MOR_BROWSER_NICK = browser
 config.MOR_FUZZER_NICK = fuzzer