def scan():
        from scapy.all import srp, Ether, ARP, conf
        import socket

        conf.verb = 0
        ans, uans = srp(Ether(dst="FF:FF:FF:FF:FF:FF") /
                        ARP(pdst=VMSettings.ip_range),
                        timeout=2,
                        iface=VMSettings.interface_to_scan,
                        inter=0.1)

        collection = VMRecordCollection()

        for snd, rcv in ans:
            hostIP = rcv.sprintf("%ARP.psrc%")
            hostMAC = rcv.sprintf("%Ether.src%")
            try:
                host = socket.gethostbyaddr(hostIP)
            except:
                host = ('unknown', [], [hostIP])
                pass
            new_rec = VMRecord(hostIP, hostMAC, host[0])
            collection.append(new_rec)

        return collection
示例#2
0
 def collection1():
     collection = VMRecordCollection()
     collection.append(
         VMRecord("192.168.0.1", "00:00:00:c0:00:08", "Host 1"))
     collection.append(
         VMRecord("192.168.0.2", "00:00:00:f7:9d:df", "Host 1"))
     collection.append(
         VMRecord("192.168.0.254", "00:00:00:ff:76:17", "Host 1"))
     collection.append(
         VMRecord("192.168.0.184", "00:00:00:ff:76:17", "Host 1"))
     return collection
示例#3
0
    def load_collection():
        if not DBLayer.is_connected():
            return 0

        collection = VMRecordCollection()
        try:
            c = DBLayer.connection.cursor()
            res = c.execute("select ip, mac, name from vms_current")
            for item in res:
                item = VMRecord(item[0], item[1], item[2])
                collection.append(item)
        except Exception as ex:
            ArpDump.printout(
                "DBCurrent.load_collection: unable to load collection")
        return collection
示例#4
0
    def read_from_bytes(barray):
        collection = VMRecordCollection()
        try:
            arp_lines = barray.decode("utf-8").split("\n")
            i = 0
            for line in arp_lines:
                if i > 1:
                    if len(line) > 0:
                        new_vm = ArpScanArp.parse_arp_line(line)
                        collection.append(new_vm)
                    else:
                        break
                i += 1
        except Exception as ex:
            ArpDump.printout("unable to perform file read")

        return collection
示例#5
0
 def collection5():
     collection = VMRecordCollection()
     collection.append(
         VMRecord("192.168.0.1", "00:00:00:e0:00:08", "Host 3"))
     collection.append(
         VMRecord("192.168.0.2", "00:00:00:f7:9d:df", "Host 2"))
     return collection
示例#6
0
 def empty_collection():
     collection = VMRecordCollection()
     return collection