Code cleanups

This commit is contained in:
Kkevsterrr 2019-12-13 07:25:19 -05:00
parent 350d7f7a53
commit 1bf737abb3
4 changed files with 6 additions and 28 deletions

View File

@ -13,9 +13,3 @@ class DuplicateAction(Action):
"""
logger.debug(" - Duplicating given packet %s" % str(packet))
return packet, packet.copy()
def mutate(self, environment_id=None):
"""
Swaps its left and right child
"""
self.left, self.right = self.right, self.left

View File

@ -196,22 +196,3 @@ class FragmentAction(Action):
self.correct_order = False
return True
def mutate(self, environment_id=None):
"""
Mutates the fragment action - it either chooses a new segment offset,
switches the packet order, and/or changes whether it segments or fragments.
"""
self.correct_order = self.get_rand_order()
self.segment = random.choice([True, True, True, False])
if self.segment:
if random.random() < 0.5:
self.fragsize = int(random.uniform(1, 60))
else:
self.fragsize = -1
else:
if random.random() < 0.2:
self.fragsize = int(random.uniform(1, 50))
else:
self.fragsize = -1
return self

View File

@ -780,8 +780,6 @@ class DNSLayer(Layer):
if packet.haslayer("IP"):
del packet["IP"].chksum
del packet["IP"].len
if packet.haslayer("TCP"):
del packet["TCP"].chksum
if packet.haslayer("UDP"):
del packet["UDP"].chksum
del packet["UDP"].len

View File

@ -139,7 +139,6 @@ def test_parse_parameters():
actions.tamper.TamperAction().parse("not:enough", logger)
def test_corrupt():
"""
Tests the tamper 'corrupt' primitive.
@ -240,6 +239,12 @@ def test_decompress():
# Confirm tamper didn't corrupt anything else in the IP header
assert confirm_unchanged(packet, original, IP, [])
packet = actions.packet.Packet(IP(dst="8.8.8.8")/TCP(dport=53)/DNS(qd=DNSQR(qname="maps.google.com")))
original = packet.copy()
tamper.tamper(packet, logger)
assert bytes(packet) == bytes(original)
def test_corrupt_chksum():
"""