#!/usr/bin/env python # # Reading NS1 files - http://www.stumbler.net/ns1files.html # # Rick van der Zwet # import datetime from struct import unpack from collections import defaultdict import logging logger = logging.getLogger(__name__) def parse_ns1(fh): def get_int32(size=1): v = unpack('<' + 'i'*size,fh.read(4*size)) return v[0] if size == 1 else v def get_uint32(size=1): v = unpack('<' + 'I'*size,fh.read(4*size)) return v[0] if size == 1 else v def get_uint64(size=1): v = unpack('<' + 'Q'*size,fh.read(8*size)) return v[0] if size == 1 else v def get_uint8(size=1): v = unpack('<' + 'B'*size,fh.read(1*size)) return v[0] if size == 1 else v def get_filetime(): _FILETIME_null_date = datetime.datetime(1601, 1, 1, 0, 0, 0) ns = unpack(' 100 or signaal < 0: logger.warning("Signal %s is not valid entry for BSSID %s @ %s", point['Signal'], ap['BSSID'], point['Time']) continue meting_pool[key].append(signaal) return (counters, ap_pool, None, meting_pool) if __name__ == '__main__': import sys import pprint pp = pprint.PrettyPrinter(indent=2) pp.pprint(parse_ns1(open(sys.argv[1],'r')))