Skip to content
Snippets Groups Projects
Commit c3aea3d9 authored by Mickaël Hoerdt's avatar Mickaël Hoerdt
Browse files

allow to send multiple paquets in one command

parent 527ef6ec
No related branches found
No related tags found
No related merge requests found
sendether.py 100644 → 100755
......@@ -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)))/
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment