enlaces:utilidades_de_red:scapy
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
enlaces:utilidades_de_red:scapy [2018/11/22 16:54] – cayu | enlaces:utilidades_de_red:scapy [Fecha desconocida] (actual) – borrado - editor externo (Fecha desconocida) 127.0.0.1 | ||
---|---|---|---|
Línea 1: | Línea 1: | ||
- | ====== 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. | + | |
- | ===== 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=" | + | |
- | </ | + |
enlaces/utilidades_de_red/scapy.1542905652.txt.gz · Última modificación: 2018/11/22 16:54 por cayu