diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2019-01-21 17:00:35 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2019-01-21 17:00:35 +0100 |
commit | 44b32c31eb575ec20b8bb2f0b1642c78d556cb91 (patch) | |
tree | 1e74e148cd4d8540c11a363d624b854e36536fda | |
parent | 8c15ce9fd2c753fc21b5f71c8ab81fd145180f7f (diff) |
fuzzer.py: build pt icmp pkt
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rwxr-xr-x | test/fuzzer.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/test/fuzzer.py b/test/fuzzer.py index 3778952..766122c 100755 --- a/test/fuzzer.py +++ b/test/fuzzer.py @@ -254,22 +254,25 @@ class PingQuery(asyncore.dispatcher): def handle_close(self): self.close() +def build_pt_pkt(ip, port, state, ack, seq, rsv, data): + if type(ip) is int: + dst_ip = ip + elif type(ip) is str: + dst_ip = struct.unpack('<L', socket.inet_aton(ip))[0] + else: + raise Exception('ip is not of type str|int') + dst_port = int(port) + return struct.pack('!IIIIIIHH', + 0xdeadc0de, dst_ip, dst_port, state, ack, len(data), + seq, rsv) + data if __name__ == '__main__': # Testing while True: - pt_pkt = struct.pack('!IIIIIIHHs', - 0xdeadc0de, # magic - random.randint(0, UINT_MAX), # ip - random.randint(0, UINT_MAX), # port - random.randint(0, 4), # state - random.randint(0, UINT_MAX), # ack - random.randint(0, UINT_MAX), # length - random.randint(0, USHORT_MAX), # seq - random.randint(0, USHORT_MAX), # rsv - '2222' # data.. - ) + pt_pkt = build_pt_pkt('127.0.0.1', '22', 1, 2, + random.randint(0, USHORT_MAX), + random.randint(0, USHORT_MAX), 'blah') verbose_ping('127.0.0.1', pt_pkt, 1, 1) random.seed(time.clock()) |