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 previaPróxima revisiónAmbos lados, revisión siguiente | ||
enlaces:utilidades_de_red:scapy [2018/11/22 16:34] – cayu | enlaces:utilidades_de_red:scapy [2018/11/22 16:54] – cayu | ||
---|---|---|---|
Línea 4: | Línea 4: | ||
==== Sniffer ==== | ==== Sniffer ==== | ||
<code python> | <code python> | ||
- | sniff(iface=" | + | 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 ==== | ==== Ping ==== |