Commit 73cbb70c authored by Mateus Goto's avatar Mateus Goto

[ADDED] IPfinder - getAllip

parent 5a75ec61
import random
import socket
class NHR9400:
def __init__(self, name):
self.__id = random.randrange(100, 300, 2)
self.__name = name
def start(void):
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.timeout(1)
\ No newline at end of file
import socket
from threading import local
from scapy.all import ARP, Ether, srp
class IPFinder:
#uses socket and scapy to scan the entire local network and returns all the IPs adresses of the devices connects in this networok
def getAllIp():
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.connect(("10.255.255.255",1))
local_ip = s.getsockname()[0]
local_ip = local_ip[:-1] + "/24"
print(local_ip)
print(type(local_ip))
arp = ARP(pdst=local_ip)
ether = Ether(dst="ff:ff:ff:ff:ff:ff")
packet = ether/arp
result = srp(packet, timeout=1, verbose=0)[0]
clients = []
for sent, received in result:
clients.append({"ip": received.psrc})
for client in clients:
print(client['ip'])
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment