Exemplo n.º 1
0
class SaveMacs(object):
    def __init__(self):
        self.db = MacDumpDB()

    def start(self, iface):
        ml = MacListener(iface)
        ml.start(self.cb)

    def cb(self, p):
        self.db.store_mac(p["timestamp"], p["src"], p["signal"])
Exemplo n.º 2
0
def main():
    db = MacDumpDB()
    c = db.create_cursor()
    c.execute('select mac, max(signal) sig, GROUP_CONCAT(ts) ts_list from seen group by mac order by min(ts) ASC')

    macs = []
    for o in c:
        mac, sig, ts_list_str = o
        ts_list = [int(float(x)) for x in ts_list_str.split(',')]
        ts_list = sorted(ts_list)
        
        hours_active = []
        for ts in ts_list:
            dt = datetime.datetime.fromtimestamp(ts)
            dt_str = dt.strftime('%Y-%m-%d %H:00:00')
            if dt_str not in hours_active:
                hours_active.append(dt_str)
        
        macs.append({'mac': mac, 'max_sig': sig, 'ts': ts_list, 'minutes_active': len(ts_list), 'hours_active': hours_active})
        
    macs = sorted(macs, key=lambda x: len(x['hours_active']), reverse=True)
    
    for mac in macs[:100]:
        print '%s - %s' % (mac['mac'], ' '.join([x.split(' ')[1] for x in mac['hours_active']]))
Exemplo n.º 3
0
 def __init__(self):
     self.db = MacDumpDB()