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

adding send ether program

parents
No related branches found
No related tags found
No related merge requests found
import sys
import argparse
from scapy.all import sendp, sendpfast, Ether, IP, RandIP, RandMAC, TCP
def macsender(iface):
smac_rand = str(RandMAC('00:*:*:*:*:*'))
print(smac_rand)
dmac_rand = str(RandMAC('*:*:*:*:*:*'))
old = int(dmac_rand[1], 16)
new = old | 0x1
if old != new:
dmac_rand = "{0}{1:x}{2}".format(smac_rand[0], new, smac_rand[2:])
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')))/
TCP(sport=None, dport=None, flags='R',
options=[('Timestamp', (0, 0))]))
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")
args = parser.parse_args()
try:
macsender(iface = args.iface)
except ValueError as e:
print("ERROR: {0}".format(e))
return 1
return 0
if __name__ == '__main__':
exit(main())
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment