diff --git a/sendether.py b/sendether.py old mode 100644 new mode 100755 index 85aaf2d8e20a1dbb8432ebcbefe97b29ea68a9a4..e5792fcaeba89d2d3b3b8e5b433ce84f5a6c204f --- a/sendether.py +++ b/sendether.py @@ -4,7 +4,8 @@ import sys import argparse from scapy.all import sendp, sendpfast, Ether, IP, RandIP, RandMAC, ICMP -def macsender(iface): + +def get_etheraddrs(): smac_rand = str(RandMAC('00:*:*:*:*:*')) print(smac_rand) dmac_rand = str(RandMAC('*:*:*:*:*:*')) @@ -12,21 +13,26 @@ def macsender(iface): new = old | 0x1 if old != new: dmac_rand = "{0}{1:x}{2}".format(smac_rand[0], new, smac_rand[2:]) + return smac_rand,dmac_rand + +def macsender(iface,count=1): pkts=[] - pkts.append(Ether(src=smac_rand, dst=str(RandMAC(dmac_rand)))/ - IP(src=str(RandIP('0.0.0.0/0')), dst=str(RandIP('0.0.0.0/0')))/ - ICMP()) + for i in range(count): + ether_src, ether_dst=get_etheraddrs() + pkts.append(Ether(src=ether_src, dst=str(RandMAC(ether_dst)))/ + IP(src=str(RandIP('0.0.0.0/0')), dst=str(RandIP('0.0.0.0/0')))/ + ICMP()) - print(pkts) sendp(pkts, iface=iface, loop=False, verbose=True) def main(): parser = argparse.ArgumentParser(description="Random MAC sender tool") parser.add_argument('-i', '--iface', help="Output interface name") + parser.add_argument('-c', '--count', type=int, default=1, help="Number of packets to send") args = parser.parse_args() try: - macsender(iface = args.iface) + macsender(iface = args.iface, count=args.count) except ValueError as e: print("ERROR: {0}".format(e)) return 1