2024-01-28 19:38:36 +01:00
|
|
|
# /usr/bin/env python3
|
|
|
|
"""
|
|
|
|
Escaner de red ARP
|
|
|
|
"""
|
|
|
|
|
|
|
|
import scapy.all as scapy
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
|
|
|
|
def get_arguments():
|
2024-01-28 20:53:14 +01:00
|
|
|
"""
|
|
|
|
Obtiene los argumentos de la línea de comandos
|
|
|
|
"""
|
2024-01-28 19:38:36 +01:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Escaner de red ARP')
|
|
|
|
parser.add_argument(
|
|
|
|
'-t', '--target',
|
|
|
|
required=True, dest='target',
|
|
|
|
help='Host / IP range. ex: 192.168.1.1 or 192.168.1.0/24'
|
|
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
return args.target
|
|
|
|
|
|
|
|
|
|
|
|
def scan(ip):
|
2024-01-28 20:53:14 +01:00
|
|
|
"""
|
|
|
|
Escanea la red en busca de hosts
|
|
|
|
"""
|
2024-01-28 19:38:36 +01:00
|
|
|
|
|
|
|
arp_packet = scapy.ARP(pdst=ip)
|
|
|
|
broadcast_packet = scapy.Ether(dst='ff:ff:ff:ff:ff:ff')
|
|
|
|
arp_packet = broadcast_packet/arp_packet # / es un operador de composición
|
|
|
|
|
|
|
|
answered, unanswered = scapy.srp(arp_packet, timeout=1, verbose=False)
|
|
|
|
|
|
|
|
response = answered.summary()
|
|
|
|
|
|
|
|
if response:
|
|
|
|
print(response)
|
|
|
|
|
|
|
|
def main():
|
2024-01-28 20:53:14 +01:00
|
|
|
"""
|
|
|
|
Función principal
|
|
|
|
"""
|
2024-01-28 19:38:36 +01:00
|
|
|
|
|
|
|
target = get_arguments()
|
|
|
|
scan(target)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|