SHARE
TWEET

Python Sniffer - Part 1

yeahhub Jul 1st, 2018 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from scapy.all import *
  2. import re
  3.  
  4. conf.iface="wlan0"
  5. def sniffData(pkt):
  6.     if pkt.haslayer( Raw ):   # Check for the Data layer
  7.         header = pkt.getlayer( Raw ).load    # Get the sent data
  8.         if header.startswith('GET'):     # Make sure it's a request
  9.             if '/search?' in header:
  10.                 q = re.search(r'q=(.*)\w', header)
  11.                 if q:
  12.                     src = pkt.getlayer(IP).src
  13.                     query = q.group().split(' ')[0].lstrip('q=')
  14.                     print "%s searched for %s" % (src, query)
  15. sniff(prn=sniffData)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top