summaryrefslogtreecommitdiffstats
path: root/Src/PyCatcher/src/pyCatcherModel.py
diff options
context:
space:
mode:
authorTom2012-01-11 13:59:54 +0100
committerTom2012-01-11 13:59:54 +0100
commitc547df2720a876aef9dc7a8faa8f00fc0678e59f (patch)
tree9f52529e77f117a79d09dafc49c19733cf7f15c6 /Src/PyCatcher/src/pyCatcherModel.py
parentcleanup (diff)
downloadimsi-catcher-detection-c547df2720a876aef9dc7a8faa8f00fc0678e59f.tar.gz
imsi-catcher-detection-c547df2720a876aef9dc7a8faa8f00fc0678e59f.tar.xz
imsi-catcher-detection-c547df2720a876aef9dc7a8faa8f00fc0678e59f.zip
moved mercurial to git, using git now as main cvs
Diffstat (limited to 'Src/PyCatcher/src/pyCatcherModel.py')
-rw-r--r--Src/PyCatcher/src/pyCatcherModel.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/Src/PyCatcher/src/pyCatcherModel.py b/Src/PyCatcher/src/pyCatcherModel.py
new file mode 100644
index 0000000..a857760
--- /dev/null
+++ b/Src/PyCatcher/src/pyCatcherModel.py
@@ -0,0 +1,83 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+ self.found = False
+
+ def get_list_model(self):
+ return (self.provider, str(self.arfcn), str(self.rxlev), self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: implement this for bis/tar sysinfo
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ '''
+ >>> for i, bit in enumerate(reversed(a)):
+... if bit == '1':
+... print i
+ '''
+
+ for x in xrange(1,125):
+ index = 0-x
+ bit = bin_representation[index]
+ if bit == '1':
+ neighbour_arfcn.append(abs(index))
+ return neighbour_arfcn
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self, filters=None, found_filter=None):
+ preamble = r'digraph bsnetwork { '
+ postamble = r'}'
+ code = ''
+ filtered_list = self._base_station_list
+
+ if found_filter == None:
+ print_neighbours = True
+ else:
+ print_neighbours = not found_filter.is_active
+
+ if filters != None:
+ for filter in filters:
+ if filter.is_active:
+ filtered_list = filter.execute(filtered_list)
+
+ for station in filtered_list:
+ code += str(station.arfcn) + r' [color=red]; '
+ if(print_neighbours):
+ for neighbour in station.get_neighbour_arfcn():
+ code += str(station.arfcn) + r' -> ' + str(neighbour) + r'; '
+ #TODO: make printing the source a fixed option
+ #print preamble + code + postamble
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file