mirror of
https://github.com/ysoftdevs/wapifuzz.git
synced 2026-03-18 23:43:58 +01:00
Timeout implementation reworked
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import time
|
import time
|
||||||
|
import threading
|
||||||
import json
|
import json
|
||||||
from http.client import HTTPResponse
|
from http.client import HTTPResponse
|
||||||
from boofuzz import exception
|
from boofuzz import exception
|
||||||
@@ -7,6 +8,12 @@ from fake_socket import get_response_object
|
|||||||
|
|
||||||
|
|
||||||
class PostTestCaseCallback(object):
|
class PostTestCaseCallback(object):
|
||||||
|
timeout_flag: bool = False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_timeout():
|
||||||
|
PostTestCaseCallback.timeout_flag = True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def post_test_callback(target, fuzz_data_logger, session, sock, *args, **kwargs):
|
def post_test_callback(target, fuzz_data_logger, session, sock, *args, **kwargs):
|
||||||
fuzz_data_logger.log_info("Mutation: " + session.fuzz_node.mutant._rendered.decode('utf-8', errors='ignore'))
|
fuzz_data_logger.log_info("Mutation: " + session.fuzz_node.mutant._rendered.decode('utf-8', errors='ignore'))
|
||||||
@@ -15,10 +22,15 @@ class PostTestCaseCallback(object):
|
|||||||
response_timeout = ConfigurationManager.config["response_timeout"]
|
response_timeout = ConfigurationManager.config["response_timeout"]
|
||||||
polling_interval = ConfigurationManager.config["polling_interval"]
|
polling_interval = ConfigurationManager.config["polling_interval"]
|
||||||
|
|
||||||
|
timer = threading.Timer(response_timeout, PostTestCaseCallback.set_timeout)
|
||||||
|
|
||||||
response_string = None
|
response_string = None
|
||||||
for _ in range(0, int(response_timeout / polling_interval)):
|
PostTestCaseCallback.timeout_flag = False
|
||||||
|
timer.start()
|
||||||
|
while not PostTestCaseCallback.timeout_flag:
|
||||||
try:
|
try:
|
||||||
response_string = target.recv()
|
response_string = target.recv()
|
||||||
|
timer.cancel()
|
||||||
break
|
break
|
||||||
except exception.BoofuzzTargetConnectionReset:
|
except exception.BoofuzzTargetConnectionReset:
|
||||||
time.sleep(polling_interval)
|
time.sleep(polling_interval)
|
||||||
|
|||||||
Reference in New Issue
Block a user