enlaces:utilidades_de_red:scapy
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anteriorRevisión previa | |||
| enlaces:utilidades_de_red:scapy [2018/11/26 16:29] – 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=" | ||
| - | </ | ||
| - | ==== Ejemplos de 0x90 ==== | ||
| - | Ejemplos de [[https:// | ||
| - | Sniffing on eth0: | ||
| - | <code python> | ||
| - | sniff(iface=" | ||
| - | sniff(iface=" | ||
| - | </ | ||
| - | Formated sniff output | ||
| - | <code python> | ||
| - | sniff(prn=lambda x: | ||
| - | </ | ||
| - | | ||
| - | Traceroute: | ||
| - | <code python> | ||
| - | traceroute([" | ||
| - | result, unans=_ | ||
| - | result.show() | ||
| - | # save output | ||
| - | result.graph(type=" | ||
| - | result.graph(target="> | ||
| - | </ | ||
| - | Port scanner: | ||
| - | <code python> | ||
| - | res,unans = sr( IP(dst=" | ||
| - | res.nsummary( lfilter=lambda (s,r): (r.haslayer(TCP) and (r.getlayer(TCP).flags & 2)) ) | ||
| - | </ | ||
| - | |||
| - | ===== Referencias ===== | ||
| - | https:// | ||
enlaces/utilidades_de_red/scapy.1543249747.txt.gz · Última modificación: 2018/11/26 16:29 por cayu
