#!/usr/bin/env python import random, traceback, logging, socket, struct logging.getLogger("scapy.runtime").setLevel(logging.ERROR) import scapy.all import binascii def fuzz(packet): rand_chr = chr(random.choice(range(256))) replacement = random.choice(range(len(packet))) packet = packet[:replacement] + str(rand_chr) + packet[replacement+1:] return packet def packet_generate(): layers = [] for name in dir(scapy.all): #Skip the base packet and a genergic packet which can describe anything if name in ['Packet', 'ASN1_Packet', 'ISAKMP_payload_ID']: continue item = getattr(scapy.all, name) try: if issubclass(item, scapy.all.Packet): layers.append(item) except TypeError: pass while True: layer = random.choice(layers) packet = scapy.all.fuzz(scapy.all.IP(dst='127.0.0.1')/layer()) yield packet if __name__ == "__main__": for x in packet_generate(): try: x = str(x) while random.random() > 0.50: x = fuzz(x) print x print except KeyboardInterrupt: break except (ValueError, TypeError, AttributeError, socket.error, struct.error, IndexError): pass except Exception, e: print type(e) traceback.print_exc()