mirror of
https://github.com/autistic-symposium/sec-pentesting-toolkit.git
synced 2025-04-27 19:16:08 -04:00
31 lines
821 B
Python
31 lines
821 B
Python
#!/usr/bin/env python
|
|
|
|
__author__ = "bt3"
|
|
|
|
''' A simple sniffer '''
|
|
|
|
'''
|
|
DOCUMENTATION:
|
|
# sniffer that dissects and dumps the packets out
|
|
# filter allows to specify a BPF, wireshark style to packets,
|
|
# for example, to sniff all HTTP packets you use a BPF filter of tcp
|
|
# and port 80
|
|
# iface parameter tells the sniffer which network interface to sniff on
|
|
# prn parameter specifies a callback function to every packet that matches the filter
|
|
# and it will receive packet as its single parameter
|
|
# count specifies how many packets you want to sniff (blank: infinite)
|
|
sniff(filter'', iface='any', prn=function, count=N)
|
|
'''
|
|
|
|
|
|
from scapy.all import *
|
|
|
|
# our packet callback
|
|
def packet_callback(packet):
|
|
print packet.show()
|
|
|
|
# fire up the sniffer on all interfaces, with no filtering
|
|
sniff(prn=packet_callback, count=1)
|
|
|
|
|