From 9bfa449c9998c94b9fde3bc0e0dcc7bd6e97566d Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 11 May 2012 17:12:48 +0200 Subject: finished experiments seciton apart from tables where data is needed and appendix --- Src/PyCatcher/src/pyCatcherController.py | 8 ++- Src/PyCatcher/src/pyCatcherView.py | 2 + Src/PyCatcher/src/rules.py | 85 +++++++++++++++++++++++++++++--- Src/PyCatcher/src/settings.py | 29 ++++++----- 4 files changed, 102 insertions(+), 22 deletions(-) (limited to 'Src') diff --git a/Src/PyCatcher/src/pyCatcherController.py b/Src/PyCatcher/src/pyCatcherController.py index 6ff6394..f964583 100644 --- a/Src/PyCatcher/src/pyCatcherController.py +++ b/Src/PyCatcher/src/pyCatcherController.py @@ -7,7 +7,7 @@ from pyCatcherView import PyCatcherGUI from filters import ARFCNFilter,ProviderFilter from evaluators import EvaluatorSelect, BayesEvaluator, ConservativeEvaluator, WeightedEvaluator from rules import ProviderRule, ARFCNMappingRule, CountryMappingRule, LACMappingRule, UniqueCellIDRule, \ - LACMedianRule, NeighbourhoodStructureRule, PureNeighbourhoodRule, FullyDiscoveredNeighbourhoodsRule, RuleResult, CellIDDatabaseRule, LocationAreaDatabaseRule + LACMedianRule, NeighbourhoodStructureRule, PureNeighbourhoodRule, FullyDiscoveredNeighbourhoodsRule, RuleResult, CellIDDatabaseRule, LocationAreaDatabaseRule, RxChangeRule, LACChangeRule import pickle from localAreaDatabse import LocalAreaDatabase from cellIDDatabase import CellIDDatabase, CellIDDBStatus, CIDDatabases @@ -59,11 +59,15 @@ class PyCatcherController: self.location_area_database_rule = LocationAreaDatabaseRule() self.location_area_database_rule.is_active = False self.location_area_database_rule.location_database_object = self._local_area_database + self.lac_change_rule = LACChangeRule() + self.lac_change_rule.is_active = True + self.rx_change_rule = RxChangeRule() + self.rx_change_rule.is_active = True self._rules = [self.provider_rule, self.country_mapping_rule, self.arfcn_mapping_rule, self.lac_mapping_rule, self.unique_cell_id_rule, self.lac_median_rule, self.neighbourhood_structure_rule, self.pure_neighbourhood_rule, self.full_discovered_neighbourhoods_rule, self.cell_id_db_rule, - self.location_area_database_rule] + self.location_area_database_rule, self.lac_change_rule, self.rx_change_rule] self.use_google = False self.use_open_cell_id = False diff --git a/Src/PyCatcher/src/pyCatcherView.py b/Src/PyCatcher/src/pyCatcherView.py index 68400a7..3c3c961 100644 --- a/Src/PyCatcher/src/pyCatcherView.py +++ b/Src/PyCatcher/src/pyCatcherView.py @@ -107,6 +107,8 @@ class PyCatcherGUI: self._catcher_controller.full_discovered_neighbourhoods_rule.is_active = self._builder.get_object('cb_neighbours_discovered').get_active() self._catcher_controller.cell_id_db_rule.is_active = self._builder.get_object('cb_cell_id_database').get_active() self._catcher_controller.location_area_database_rule.is_active = self._builder.get_object('cb_local_area_database').get_active() + self._catcher_controller.lac_change_rule.is_active = self._builder.get_object('cb_lac_change') + self._catcher_controller.rx_change_rule.is_active = self._builder.get_object('cb_rx_change') self._catcher_controller.trigger_evaluation() def _update_evaluators(self): diff --git a/Src/PyCatcher/src/rules.py b/Src/PyCatcher/src/rules.py index 143739c..4a5efd4 100644 --- a/Src/PyCatcher/src/rules.py +++ b/Src/PyCatcher/src/rules.py @@ -1,4 +1,5 @@ -from settings import Provider_list, Provider_Country_list, LAC_mapping, ARFCN_mapping, LAC_threshold, RX_threshold +from settings import Provider_list, Provider_Country_list, LAC_mapping, ARFCN_mapping, LAC_threshold, DB_RX_threshold, \ + CH_RX_threshold from cellIDDatabase import CellIDDBStatus import math @@ -62,8 +63,10 @@ class ARFCNMappingRule (Rule): for station in base_station_list: if station.arfcn == arfcn: if station.provider in ARFCN_mapping: - if ARFCN_mapping[station.provider][0] < station.arfcn < ARFCN_mapping[station.provider][1]: - result = RuleResult.OK + for lower,upper in ARFCN_mapping[station.provider]: + if lower < station.arfcn < upper: + result = RuleResult.OK + break return result class LACMappingRule (Rule): @@ -75,8 +78,10 @@ class LACMappingRule (Rule): for station in base_station_list: if station.arfcn == arfcn: if station.provider in LAC_mapping: - if LAC_mapping[station.provider][0] < station.lac < LAC_mapping[station.provider][1]: - result = RuleResult.OK + for lac in LAC_mapping[station.provider]: + if station.lac == lac: + result = RuleResult.OK + break return result class UniqueCellIDRule (Rule): @@ -202,8 +207,8 @@ class LocationAreaDatabaseRule(Rule): return RuleResult.CRITICAL rxmin = result[6] rxmax = result[7] - rxmin_thresh = rxmin - math.fabs(rxmin * RX_threshold) - rxmax_thresh = rxmax + math.fabs(rxmax * RX_threshold) + rxmin_thresh = rxmin - math.fabs(rxmin * DB_RX_threshold) + rxmax_thresh = rxmax + math.fabs(rxmax * DB_RX_threshold) if rxmin_thresh <= float(item.rxlev) <= rxmax_thresh: return RuleResult.OK else: @@ -221,3 +226,69 @@ class CellIDDatabaseRule (Rule): return RuleResult.OK else: return RuleResult.CRITICAL + +#TODO: remove debug crap +class LACChangeRule (Rule): + identifier = 'LAC Change Rule' + + def __init__(self): + self._old_lac = {} + + def check(self, arfcn, base_station_list): + for item in base_station_list: + if item.arfcn == arfcn: + if self._old_lac.has_key(arfcn): + lac, old_scanned = self._old_lac[arfcn] + if item.times_scanned > 1: + if item.times_scanned > old_scanned: + #print 'evaluating lac change on %d(%d): old lac %d / new lac %d'%(item.times_scanned,arfcn, lac, item.lac) + if item.lac == lac: + self._old_lac[arfcn] = item.lac, item.times_scanned + #print ' return ok' + return RuleResult.OK + else: + self._old_lac[arfcn] = item.lac, item.times_scanned + #print ' return critical' + return RuleResult.CRITICAL + else: + return RuleResult.IGNORE + else: + return RuleResult.IGNORE + else: + self._old_lac[arfcn] = item.lac, item.times_scanned + return RuleResult.IGNORE + + +#TODO: remove debug crap +class RxChangeRule (Rule): + identifier = 'rx Change Rule' + + def __init__(self): + self._old_rx = {} + + def check(self, arfcn, base_station_list): + for item in base_station_list: + if item.arfcn == arfcn: + if self._old_rx.has_key(arfcn): + rx, old_scanned = self._old_rx[arfcn] + if item.times_scanned > 1: + if item.times_scanned > old_scanned: + #print 'evaluating rx change on %d(%d): old rx %d / new rx %d'%(item.times_scanned,arfcn, rx, item.rxlev) + lower_bound = rx - math.fabs(rx * CH_RX_threshold) + upper_bound = rx + math.fabs(rx * CH_RX_threshold) + #print ' thresholds: %d/%d'%(lower_bound, upper_bound) + if lower_bound <= item.rxlev <= upper_bound: + self._old_rx[arfcn] = item.rxlev, item.times_scanned + #print ' return ok' + return RuleResult.OK + else: + self._old_rx[arfcn] = item.rxlev, item.times_scanned + #print ' return critical ' + return RuleResult.CRITICAL + else: + return RuleResult.IGNORE + else: + return RuleResult.IGNORE + else: + self._old_rx[arfcn] = item.rxlev, item.times_scanned + return RuleResult.IGNORE diff --git a/Src/PyCatcher/src/settings.py b/Src/PyCatcher/src/settings.py index 11084dc..831fac6 100644 --- a/Src/PyCatcher/src/settings.py +++ b/Src/PyCatcher/src/settings.py @@ -1,6 +1,6 @@ #Core Configuration ------------------------------------------------------------------------------------------ -PyCatcher_settings = {'debug' : False, +PyCatcher_settings = {'debug' : True, } Device_settings = { 'mobile_device' : '/dev/ttyUSB0', @@ -13,7 +13,8 @@ Osmocon_lib = '/home/tom/imsi-catcher-detection/Src/osmolib/src' Commands = {'osmocon_command' : [Osmocon_lib + '/host/osmocon/osmocon', '-p', Device_settings['mobile_device'], '-m', Device_settings['xor_type'], - Osmocon_lib + '/target/firmware/board/' + Device_settings['firmware'] + '/layer1.compalram.bin'], + Osmocon_lib + '/target/firmware/board/' + Device_settings['firmware'] + + '/layer1.compalram.bin'], 'scan_command' : [Osmocon_lib + '/host/layer23/src/misc/catcher'], } @@ -30,24 +31,26 @@ Provider_Country_list = { } LAC_mapping = { - 'DB Systel GSM-R': [0,999999], - 'T-Mobile' : [21000,22000], - 'O2' : [0,99999], - 'Vodafone' : [0,100000], - 'E-Plus' : [0,100000] + 'DB Systel GSM-R': [0], + 'T-Mobile' : [21014,21015], + 'O2' : [50945], + 'Vodafone' : [793], + 'E-Plus' : [138,588] } ARFCN_mapping = { - 'DB Systel GSM-R': [0,9999], - 'T-Mobile' : [0,9999], - 'O2' : [0,9999], - 'Vodafone' : [0,9999], - 'E-Plus' : [0,9999] + 'DB Systel GSM-R': [(0,1)], + 'T-Mobile' : [(13,39),(81, 102),(122,124),(587,611)], + 'O2' : [(0,0),(1000,1023),(637,723)], + 'Vodafone' : [(1,12),(50,80),(103,121),(725,751)], + 'E-Plus' : [(975,999),(777,863)] } LAC_threshold = 0 -RX_threshold = 0.05 +DB_RX_threshold = 0.05 + +CH_RX_threshold = 0.02 #Database Configuration ---------------------------------------------------------------------------------------- -- cgit v1.2.3-55-g7522