mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 10:18:21 -05:00
Merge pull request #44 from angeloc/connected_delay
research/fragattack: implement --pre-test-delay
This commit is contained in:
commit
baa1c9357f
@ -132,7 +132,7 @@ def prepare_tests(opt):
|
||||
else: return None
|
||||
|
||||
# If requested, override delay and inc_pn parameters in the test.
|
||||
test.set_general_options(opt.delay, opt.inc_pn)
|
||||
test.set_general_options(opt.delay, opt.inc_pn, opt.pre_test_delay)
|
||||
|
||||
# If requested, override the ptype
|
||||
if opt.ptype != None:
|
||||
@ -215,6 +215,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument('--no-qos', default=False, action='store_true', help="Don't send QoS data frames (experimental - may break some tests).")
|
||||
parser.add_argument('--freebsd-cache', default=False, action='store_true', help="Sent EAP(OL) frames as (malformed) broadcast EAPOL/A-MSDUs.")
|
||||
parser.add_argument('--connected-delay', type=float, default=1, help="Second to wait after AfterAuth before triggering Connected event")
|
||||
parser.add_argument('--pre-test-delay', type=int, default=0, help="Delay before launching the test")
|
||||
parser.add_argument('--to-self', default=False, action='store_true', help="Send ARP/DHCP/ICMP with same src and dst MAC address.")
|
||||
parser.add_argument('--no-drivercheck', default=False, action='store_true', help="Don't check if patched drivers are being used.")
|
||||
parser.add_argument('--stay-up', default=False, action='store_true', help="Don't quit when test has finished.")
|
||||
|
@ -202,6 +202,7 @@ class Test(metaclass=abc.ABCMeta):
|
||||
def __init__(self, actions=None):
|
||||
self.actions = actions if actions != None else []
|
||||
self.generated = False
|
||||
self.pre_delay = None
|
||||
self.delay = None
|
||||
self.inc_pn = None
|
||||
self.check_fn = None
|
||||
@ -260,7 +261,7 @@ class Test(metaclass=abc.ABCMeta):
|
||||
|
||||
def generate(self, station):
|
||||
self.prepare(station)
|
||||
self.enforce_delay()
|
||||
self.enforce_delays()
|
||||
self.enforce_inc_pn()
|
||||
|
||||
def check(self, p):
|
||||
@ -268,17 +269,24 @@ class Test(metaclass=abc.ABCMeta):
|
||||
return False
|
||||
return self.check_fn(p)
|
||||
|
||||
def set_general_options(self, delay=None, inc_pn=None):
|
||||
def set_general_options(self, delay=None, inc_pn=None, pre_delay=None):
|
||||
self.pre_delay = pre_delay
|
||||
self.delay = delay
|
||||
self.inc_pn = inc_pn
|
||||
|
||||
def enforce_delay(self):
|
||||
if self.delay == None or self.delay <= 0:
|
||||
return
|
||||
def enforce_delays(self):
|
||||
inject_frags = self.get_actions(Action.Inject)
|
||||
|
||||
# Add a delay between injected fragments if requested
|
||||
for frag in self.get_actions(Action.Inject)[1:]:
|
||||
frag.delay = self.delay
|
||||
# Add a delay before executing the first Inject action. This means a delay is added after
|
||||
# possibly getting an IP via DHCP but before injecting the first test fragment/frame.
|
||||
if self.pre_delay is not None and self.pre_delay > 0:
|
||||
assert len(inject_frags) > 0
|
||||
inject_frags[0].delay = self.pre_delay
|
||||
|
||||
# Add a delay between every next injected fragments if requested
|
||||
if self.delay is not None and self.delay > 0:
|
||||
for frag in inject_frags[1:]:
|
||||
frag.delay = self.delay
|
||||
|
||||
def enforce_inc_pn(self):
|
||||
if self.inc_pn == None:
|
||||
|
Loading…
Reference in New Issue
Block a user