├── README.md ├── address ├── kismetclient ├── __init__.py ├── __init__.pyc ├── client.py ├── client.pyc ├── exceptions.py ├── exceptions.pyc ├── handlers.py ├── handlers.pyc ├── utils.py └── utils.pyc └── third-eye.py /README.md: -------------------------------------------------------------------------------- 1 | # Third-Eye 2 | Third-Eye is people finder. If target people ( actually target device ) is your nearest Third-Eye will alert you. 3 | 4 | Third-Eye working with kismetclient. 5 | Please visit for more: https://github.com/PaulMcMillan/kismetclient 6 | 7 | # Dependencies 8 | - espeak 9 | 10 | Installation: 11 | ```sh 12 | $ git clone https://github.com/canack/Third-Eye.git 13 | $ cd Third-Eye 14 | $ chmod +x third-eye.py 15 | ``` 16 | 17 | Usage: 18 | ```sh 19 | $ ./third-eye.py -i INTERFACE 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /address: -------------------------------------------------------------------------------- 1 | # First column MAC address, second and after columns target's name or anything for sound feedback. 2 | 00:11:22:33:44:55 John 3 | 03:03:03:02:02:02 Isabella 4 | 04:11:49:11:11:11 Boss 5 | ff:55:a5:22:22:22 My lover 6 | -------------------------------------------------------------------------------- /kismetclient/__init__.py: -------------------------------------------------------------------------------- 1 | from kismetclient.client import Client 2 | -------------------------------------------------------------------------------- /kismetclient/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/canack/Third-Eye/8ece6bef58cdc8e89523524bfc9e8a71a866d8fb/kismetclient/__init__.pyc -------------------------------------------------------------------------------- /kismetclient/client.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import re 3 | import logging 4 | 5 | from kismetclient import handlers 6 | from kismetclient.utils import get_csv_args 7 | from kismetclient.utils import get_pos_args 8 | 9 | log = logging.getLogger(__name__) 10 | 11 | 12 | class Command(object): 13 | # assign at the class level, so these are unique. 14 | # FIXME race condition. 15 | command_id = 0 16 | 17 | def __init__(self, command, *opts): 18 | Command.command_id += 1 19 | self.command_id = Command.command_id 20 | self.command = command 21 | 22 | def wrap(opt): 23 | if ' ' in opt: 24 | return '\x01%s\x01' 25 | else: 26 | return opt 27 | self.opts = map(wrap, opts) 28 | 29 | def __str__(self): 30 | return '!%d %s %s' % (self.command_id, 31 | self.command, 32 | ' '.join(self.opts)) 33 | 34 | 35 | class Response(object): 36 | protocol = '' 37 | fields = [] 38 | 39 | def __init__(self, res): 40 | if not res.startswith('*'): 41 | raise ValueError('Attempted to create a Response object ' 42 | 'from string which did not start with "*"') 43 | self.protocol, _, tail = res[1:].partition(':') 44 | fields = re.findall(' \x01(.*?)\x01| ([^ ]+)', tail) 45 | # only one of the regex fields will match; the other will be empty 46 | self.fields = [''.join(f) for f in fields] 47 | 48 | def __str__(self): 49 | return '*%s: %s' % (self.protocol, str(self.fields)) 50 | 51 | 52 | class Client(object): 53 | def __init__(self, address=('localhost', 2501)): 54 | self.handlers = {} 55 | self.protocols = {} 56 | self.in_progress = {} 57 | self.register_handler('KISMET', 58 | handlers.kismet, 59 | send_enable=False) 60 | self.register_handler('PROTOCOLS', 61 | handlers.protocols, 62 | send_enable=False) 63 | self.register_handler('CAPABILITY', 64 | handlers.capability, 65 | send_enable=False) 66 | self.register_handler('ACK', 67 | handlers.ack, 68 | send_enable=False) 69 | self.register_handler('ERROR', 70 | handlers.error, 71 | send_enable=False) 72 | # Open a socket to the kismet server with line-based buffering 73 | self.file = socket.create_connection(address).makefile('w', 1) 74 | 75 | # Bootstrap the server protocols 76 | self.listen() # Kismet startup line 77 | self.listen() # Protocols line triggers capabilities requests 78 | while len(self.in_progress) > 0: 79 | self.listen() 80 | # Protocols done populating 81 | 82 | def register_handler(self, protocol, handler, send_enable=True): 83 | """ Register a protocol handler, and (optionally) send enable 84 | sentence. 85 | """ 86 | self.handlers[protocol] = handler 87 | if send_enable: 88 | fields = get_csv_args(handler) 89 | if not fields: 90 | fields = '*' 91 | self.cmd('ENABLE', protocol, fields) 92 | 93 | def cmd(self, command, *opts): 94 | cmd = Command(command, *opts) 95 | log.debug(cmd) 96 | self.in_progress[str(cmd.command_id)] = cmd 97 | self.file.write(str(cmd) + '\n') 98 | 99 | def listen(self): 100 | line = self.file.readline().rstrip('\n') 101 | r = Response(line) 102 | log.debug(r) 103 | handler = self.handlers.get(r.protocol) 104 | if handler: 105 | fields = r.fields 106 | if get_pos_args(handler): 107 | # just the named parameters in handler 108 | return handler(self, *fields) 109 | else: 110 | # all parameters in default order 111 | field_names = self.protocols.get(r.protocol, []) 112 | # If the protocol fields aren't known at all, we don't 113 | # handle the message. 114 | if field_names: 115 | named_fields = dict(zip(field_names, fields)) 116 | return handler(self, **named_fields) 117 | -------------------------------------------------------------------------------- /kismetclient/client.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/canack/Third-Eye/8ece6bef58cdc8e89523524bfc9e8a71a866d8fb/kismetclient/client.pyc -------------------------------------------------------------------------------- /kismetclient/exceptions.py: -------------------------------------------------------------------------------- 1 | class ServerError(Exception): 2 | """ Exception raised for errors captured from the Kismet Server. """ 3 | 4 | def __init__(self, cmd, text): 5 | self.cmd = cmd 6 | self.text = text 7 | 8 | def __str__(self): 9 | return 'ID: %d CMD: "%s" ERROR: "%s"' % (self.cmd.command_id, 10 | self.cmd.command, 11 | self.text) 12 | -------------------------------------------------------------------------------- /kismetclient/exceptions.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/canack/Third-Eye/8ece6bef58cdc8e89523524bfc9e8a71a866d8fb/kismetclient/exceptions.pyc -------------------------------------------------------------------------------- /kismetclient/handlers.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from kismetclient.utils import csv 4 | from kismetclient.exceptions import ServerError 5 | 6 | log = logging.getLogger(__name__) 7 | 8 | 9 | def kismet(client, version, starttime, servername, dumpfiles, uid): 10 | """ Handle server startup string. """ 11 | log.info('Server: ' + 12 | ' '.join([version, starttime, servername, dumpfiles, uid])) 13 | 14 | 15 | def capability(client, CAPABILITY, capabilities): 16 | """ Register a server's default protocol capabilities. """ 17 | client.protocols[CAPABILITY] = csv(capabilities) 18 | 19 | 20 | def protocols(client, protocols): 21 | """ Enumerate protocol capabilities so they can be registered. """ 22 | for protocol in csv(protocols): 23 | client.cmd('CAPABILITY', protocol) 24 | 25 | 26 | def ack(client, cmdid, text): 27 | """ Handle ack messages in response to commands. """ 28 | # Simply remove from the in_progress queue 29 | client.in_progress.pop(cmdid) 30 | 31 | 32 | def error(client, cmdid, text): 33 | """ Handle error messages in response to commands. """ 34 | cmd = client.in_progress.pop(cmdid) 35 | raise ServerError(cmd, text) 36 | 37 | 38 | def print_fields(client, **fields): 39 | """ A generic handler which prints all the fields. """ 40 | for k, v in fields.items(): 41 | print '%s: %s' % (k, v) 42 | print '-' * 80 43 | -------------------------------------------------------------------------------- /kismetclient/handlers.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/canack/Third-Eye/8ece6bef58cdc8e89523524bfc9e8a71a866d8fb/kismetclient/handlers.pyc -------------------------------------------------------------------------------- /kismetclient/utils.py: -------------------------------------------------------------------------------- 1 | import inspect 2 | 3 | 4 | def csv(val): 5 | if isinstance(val, basestring): 6 | return val.split(',') 7 | elif hasattr(val, '__iter__'): 8 | return ','.join(map(str, val)) 9 | else: 10 | raise TypeError('Must supply a comma separated string or an iterable') 11 | 12 | 13 | def get_pos_args(func): 14 | """ Return the names of a function's positional args. """ 15 | return inspect.getargspec(func).args[1:] 16 | 17 | 18 | def get_csv_args(func): 19 | """ Return a csv string of a function's positional args. """ 20 | return csv(get_pos_args(func)) 21 | -------------------------------------------------------------------------------- /kismetclient/utils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/canack/Third-Eye/8ece6bef58cdc8e89523524bfc9e8a71a866d8fb/kismetclient/utils.pyc -------------------------------------------------------------------------------- /third-eye.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import argparse 4 | import os 5 | 6 | from kismetclient import Client as KismetClient 7 | from kismetclient import handlers 8 | 9 | ##### ARGPARSE AREA BEGIN ##### 10 | parser = argparse.ArgumentParser( 11 | description='''Third-Eye is people finder. 12 | If target people ( actually target device ) is your nearest Third-Eye will alert you.''' 13 | ) 14 | 15 | #parser.add_argument('-t', help='Target MAC address', required=True) 16 | parser.add_argument('-i', help='Interface for use', required=True) 17 | 18 | args = parser.parse_args() 19 | 20 | INTERFACE = args.i 21 | #TARGET = args.t.upper() 22 | ##### ARGPARSE AREA END ##### 23 | 24 | 25 | ##### COLOR AREA BEGIN ##### 26 | 27 | RED = "\033[31m" 28 | BLUE = "\033[34m" 29 | GREEN = "\033[32m" 30 | WHITE = "\033[0m" 31 | 32 | ##### COLOR AREA END ##### 33 | 34 | address = ('127.0.0.1', 2501) 35 | 36 | k = KismetClient(address) 37 | k.register_handler('TRACKINFO', handlers.print_fields) 38 | 39 | import time 40 | 41 | log_file = open('logs','a+') 42 | 43 | TARGETS = open("address").readlines() 44 | target_list = {} 45 | 46 | for i in TARGETS: 47 | if not i.startwith("#"): 48 | target_list[i.strip("\n").split(' ')[0]] = " ".join(i.strip().split()[1:]) 49 | 50 | 51 | def handle_ssid(client, bssid, channel, signal_dbm): 52 | signal = str(signal_dbm.strip('-')[0]) 53 | for target_mac, target_name in target_list.iteritems(): 54 | target_mac = target_mac.upper() 55 | if target_mac == bssid: 56 | today_time = '( ' + time.strftime("%d/%m/%Y - %H:%M:%S") + ' )' 57 | os.popen("espeak '" + target_name + " " + signal + "' -p 12 -s 160 ") 58 | print BLUE + target_mac, target_name, '[ Signal lv:',signal, '] ' + today_time + WHITE 59 | log_file.write(target_mac + ' ' + target_name + ' [ Signal lv: ' + signal + ' ] Time: '+ today_time + "\n") 60 | log_file.flush() 61 | break 62 | 63 | 64 | k.register_handler('CLIENT', handle_ssid) 65 | 66 | while True: 67 | k.listen() 68 | 69 | 70 | 71 | 72 | 73 | 74 | --------------------------------------------------------------------------------