summaryrefslogtreecommitdiffstats
path: root/Src
diff options
context:
space:
mode:
authorTom2012-04-12 17:38:40 +0200
committerTom2012-04-12 17:38:40 +0200
commit7c2974bb74e4db4470559d4784a423c3c6c97638 (patch)
treec7f6af6a39e1f3faa01982599844c9ec955eaccd /Src
parentevaluation windows integrated (diff)
downloadimsi-catcher-detection-7c2974bb74e4db4470559d4784a423c3c6c97638.tar.gz
imsi-catcher-detection-7c2974bb74e4db4470559d4784a423c3c6c97638.tar.xz
imsi-catcher-detection-7c2974bb74e4db4470559d4784a423c3c6c97638.zip
implemented databases save for guis
Diffstat (limited to 'Src')
-rw-r--r--Src/PyCatcher/Databases/sqlitejdbc-v056.jarbin0 -> 2684154 bytes
-rw-r--r--Src/PyCatcher/Databases/test.dbbin0 -> 2048 bytes
-rw-r--r--Src/PyCatcher/Databases/zentus-sqlite-license.txt22
-rw-r--r--Src/PyCatcher/GUI/catcher_main.glade21
-rw-r--r--Src/PyCatcher/src/CellIDDatabase.py96
-rw-r--r--Src/PyCatcher/src/LocalAreaDatabse.py97
-rw-r--r--Src/PyCatcher/src/parstertest.py47
-rw-r--r--Src/PyCatcher/src/pyCatcherModel.py24
-rw-r--r--Src/PyCatcher/src/pyCatcherView.py6
-rw-r--r--Src/PyCatcher/src/settings.py7
10 files changed, 264 insertions, 56 deletions
diff --git a/Src/PyCatcher/Databases/sqlitejdbc-v056.jar b/Src/PyCatcher/Databases/sqlitejdbc-v056.jar
new file mode 100644
index 0000000..f95d90e
--- /dev/null
+++ b/Src/PyCatcher/Databases/sqlitejdbc-v056.jar
Binary files differ
diff --git a/Src/PyCatcher/Databases/test.db b/Src/PyCatcher/Databases/test.db
new file mode 100644
index 0000000..d2ee778
--- /dev/null
+++ b/Src/PyCatcher/Databases/test.db
Binary files differ
diff --git a/Src/PyCatcher/Databases/zentus-sqlite-license.txt b/Src/PyCatcher/Databases/zentus-sqlite-license.txt
new file mode 100644
index 0000000..083ef26
--- /dev/null
+++ b/Src/PyCatcher/Databases/zentus-sqlite-license.txt
@@ -0,0 +1,22 @@
+The ISC/BSD License
+
+All the source files start with this:
+
+/*
+ * Copyright (c) 2007 David Crawshaw
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+All you have to do is leave it there. There are no other restrictions on the source, just don't change that text.
+
+As for any binaries, do as you will. Use and distribute. \ No newline at end of file
diff --git a/Src/PyCatcher/GUI/catcher_main.glade b/Src/PyCatcher/GUI/catcher_main.glade
index 09ed4ec..68241ef 100644
--- a/Src/PyCatcher/GUI/catcher_main.glade
+++ b/Src/PyCatcher/GUI/catcher_main.glade
@@ -22,6 +22,7 @@
<property name="default_width">341</property>
<property name="default_height">256</property>
<property name="has_resize_grip">False</property>
+ <signal name="delete-event" handler="_on_evaluators_window_close_clicked" swapped="no"/>
<child>
<object class="GtkImage" id="evaluation_image">
<property name="visible">True</property>
@@ -490,13 +491,13 @@
</packing>
</child>
<child>
- <object class="GtkToolButton" id="btn_location">
+ <object class="GtkToolButton" id="btn_databases">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
- <property name="label" translatable="yes">Location</property>
+ <property name="label" translatable="yes">Databases</property>
<property name="use_underline">True</property>
- <property name="icon_name">applications-internet</property>
+ <property name="icon_name">network-server</property>
</object>
<packing>
<property name="expand">False</property>
@@ -533,6 +534,20 @@
<property name="homogeneous">True</property>
</packing>
</child>
+ <child>
+ <object class="GtkToolButton" id="btn_user_mode">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="label" translatable="yes">User Mode</property>
+ <property name="use_underline">True</property>
+ <property name="icon_name">applications-internet</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/Src/PyCatcher/src/CellIDDatabase.py b/Src/PyCatcher/src/CellIDDatabase.py
new file mode 100644
index 0000000..2471a5a
--- /dev/null
+++ b/Src/PyCatcher/src/CellIDDatabase.py
@@ -0,0 +1,96 @@
+import re
+import urllib2
+from settings import Open_Cell_ID_Key
+from struct import pack, unpack
+from httplib import HTTP
+
+class Translator:
+ Country = {
+ 'Germany':'262'
+ }
+
+ Provider = {
+ 'T-Mobile':'01',
+ 'Vodafone':'02',
+ 'E-Plus':'03',
+ 'O2':'07'
+ }
+
+ MCC = {
+ 262:'de'
+ }
+
+class CellIDDBStatus:
+ CONFIRMED = 0
+ APPROXIMATED = 1
+ ERROR = 2
+ NOT_LOOKED_UP = 3
+ NOT_IN_DB = 4
+
+class CellIDDatabaseFetcher:
+
+
+ def fetch(self, cid, lac, mcc, mnc):
+ print CID.fetch_id_from_Google(cid,lac,mcc)
+ print CID.fetch_id_from_OpenCellID(cid,lac,mcc,mnc)
+
+
+ def fetch_id_from_OpenCellID(self,cid, lac, mcc, mnc):
+ key_ocid = Open_Cell_ID_Key
+
+ url = 'http://www.opencellid.org/cell/get?key=%s&mnc=%d&mcc=%d&lac=%d&cellid=%d'%(key_ocid, mnc, mcc, lac, cid)
+ response = urllib2.urlopen(url).read()
+
+ status = (re.search(r'stat="(.+)"',response)).group(1)
+
+ if status != 'ok':
+ status = CellIDDBStatus.ERROR
+ return
+
+ match = re.search(r'lat="(\d+\.\d+)".*lon="(\d+\.\d+).*range="(\d+)"',response)
+ latitude,longitude,range = match.group(1),match.group(2),match.group(3)
+
+ if int(range) > 10000:
+ status = CellIDDBStatus.APPROXIMATED
+ else:
+ status = CellIDDBStatus.CONFIRMED
+
+ latitude = float(latitude)
+ longitude = float(longitude)
+
+ if latitude == 0 or longitude == 0:
+ status = CellIDDBStatus.NOT_IN_DB
+
+ return status, latitude, longitude
+
+
+ def fetch_id_from_Google(self, cid, lac, country):
+ device = "Motorola C123"
+ country = Translator.MCC[country]
+ b_string = pack('>hqh2sh13sh5sh3sBiiihiiiiii',
+ 21, 0,
+ len(country), country,
+ len(device), device,
+ len('1.3.1'), "1.3.1",
+ len('Web'), "Web",
+ 27, 0, 0,
+ 3, 0, cid, lac,
+ 0, 0, 0, 0)
+
+ http = HTTP('www.google.com', 80)
+ http.putrequest('POST', '/glm/mmap')
+ http.putheader('Content-Type', 'application/binary')
+ http.putheader('Content-Length', str(len(b_string)))
+ http.endheaders()
+ http.send(b_string)
+ code, msg, headers = http.getreply()
+ try:
+ bytes = http.file.read()
+ (a, b,errorCode, latitude, longitude, c, d, e) = unpack(">hBiiiiih",bytes)
+ latitude = latitude / 1000000.0
+ longitude = longitude / 1000000.0
+ status = CellIDDBStatus.CONFIRMED
+ except:
+ status = CellIDDBStatus.NOT_IN_DB
+
+ return status, latitude, longitude \ No newline at end of file
diff --git a/Src/PyCatcher/src/LocalAreaDatabse.py b/Src/PyCatcher/src/LocalAreaDatabse.py
new file mode 100644
index 0000000..102408a
--- /dev/null
+++ b/Src/PyCatcher/src/LocalAreaDatabse.py
@@ -0,0 +1,97 @@
+import sqlite3
+import os
+from pyCatcherModel import BaseStationInformation
+
+class dummystation:
+
+ def __init__(self):
+ self.arfcn = 0
+ self.bsic = '2,3'
+ self.cell = 2
+ self.country = 'Nirvana'
+ self.lac = 4
+ self.provider = 'T-Schrott'
+ self.rxlev = -70
+
+
+class LocalAreaDatabase:
+
+ def __init__(self):
+ self._connection = None
+ self._cursor = None
+
+ def load_or_create_database(self, path):
+ if self._connection:
+ self._connection.close()
+ self._connection = None
+
+ database_exists = os.path.exists(path)
+ self._connection = sqlite3.connect(path)
+ self._cursor = self._connection.cursor()
+ if not database_exists:
+ print 'file has been created'
+ self._create_base_table()
+ else:
+ print 'connected to existing'
+
+ def _create_base_table(self):
+ sql = '''CREATE TABLE basestations(
+ cellid INTEGER, country TEXT, provider TEXT, arfcn INTEGER, bsic TEXT, lac INTEGER,
+ rxmin INTEGER, rxmax INTEGER, sightings INTEGER
+ )
+ '''
+ self._cursor.execute(sql)
+ self._connection.commit()
+
+ def _insert_station(self, base_station):
+ values = ( base_station.cell,
+ base_station.country,
+ base_station.provider,
+ base_station.arfcn,
+ base_station.bsic,
+ base_station.lac,
+ base_station.rxlev,
+ base_station.rxlev,
+ 1
+ )
+ sql = 'INSERT INTO basestations VALUES (?,?,?,?,?,?,?,?,?)'
+ self._cursor.execute(sql, values)
+ self._connection.commit()
+
+ def _alter_station(self, base_station, old_rmin, old_rmax, old_sightings):
+ if base_station.rxlev < old_rmin:
+ rmin = base_station.rxlev
+ else:
+ rmin = old_rmin
+ if base_station.rxlev > old_rmax:
+ rmax = base_station.rxlev
+ else:
+ rmax = old_rmax
+ sightings = old_sightings + 1
+ values = (rmin,rmax,sightings,base_station.cell)
+ sql = 'UPDATE basestations SET rxmin=?, rxmax=?, sightings=? WHERE cellid=?'
+ self._cursor.execute(sql, values)
+ self._connection.commit()
+
+ def get_station(self, cellID):
+ sql = 'SELECT * FROM basestations WHERE cellid =%d'%cellID
+ self._cursor.execute(sql)
+ try:
+ result = (self._cursor.fetchall())[0]
+ except:
+ result = None
+ return result
+
+ def insert_or_alter_base_stations(self, base_station_list):
+ for station in base_station_list:
+ self.insert_or_alter_base_station(station)
+
+ def insert_or_alter_base_station(self, base_station):
+ lookupresult = self.get_station(base_station.cell)
+ if lookupresult:
+ self._alter_station(station,lookupresult[6],lookupresult[7],lookupresult[8])
+ else:
+ self._insert_station(base_station)
+
+ def __del__(self):
+ self._connection.close() \ No newline at end of file
diff --git a/Src/PyCatcher/src/parstertest.py b/Src/PyCatcher/src/parstertest.py
deleted file mode 100644
index c824b36..0000000
--- a/Src/PyCatcher/src/parstertest.py
+++ /dev/null
@@ -1,47 +0,0 @@
-def si_to_bin(si):
- system_information = si.split(' ')
- neighbours = system_information[3:19]
- bin_representation = ''
- for value in neighbours:
- bin_representation += str(bin(int(value, 16))[2:].zfill(8))
- return bin_representation
-
-def parse_bit_mask(si, offset):
- bin_representation = si_to_bin(si)
- neighbours = []
- for x in xrange(1,125):
- index = 0-x
- bit = bin_representation[index]
- if bit == '1':
- neighbours.append(abs(index) + offset)
- return neighbours
-
-
-def parse_900(si):
- neighbours = parse_bit_mask(si, 0)
- print neighbours
-
-def parse_1800(si,siter,sibis):
- pass
-
-def parse_900_ext(si):
- pass
-
-
-
-system_information_1 = '59 06 1A 0B B9 3B 30 00 00 00 00 00 00 00 00 00 00 00 00 80 9D 00 00'
-system_information_2 = '59 06 1a 00 00 00 00 02 10 00 00 00 00 00 48 20 95 00 00 08 a5 00 00'
-system_information_3 = '59 06 1a 00 00 00 0b 90 08 00 00 00 01 14 08 00 11 00 00 88 a5 00 00'
-system_information_4 = '59 06 1a 00 00 00 0b 90 08 00 00 00 01 14 08 00 11 00 00 88 a5 00 00'
-
-parse_900(system_information_2)
-
-
-
-
-
-
-
-
-
-
diff --git a/Src/PyCatcher/src/pyCatcherModel.py b/Src/PyCatcher/src/pyCatcherModel.py
index bf4be14..112646b 100644
--- a/Src/PyCatcher/src/pyCatcherModel.py
+++ b/Src/PyCatcher/src/pyCatcherModel.py
@@ -1,6 +1,12 @@
import datetime
import gtk
import math
+from CellIDDatabase import CellIDDBStatus
+
+class LocationProvider:
+ GOOGLE = 0
+ OPENCELLID = 1
+ NONE = 2
class BaseStationInformation:
@@ -21,6 +27,9 @@ class BaseStationInformation:
self.evaluation_report = {}
self.evaluation = 'NYE'
self.evaluation_by = 'NYE'
+ self.latitude = 0
+ self.longitude = 0
+ self.locationprovider = LocationProvider.NONE
def get_list_model(self):
return self.provider, str(self.arfcn), str(self.rxlev), self.evaluation, self.discovery_time
@@ -59,6 +68,11 @@ class BaseStationInformation:
pass
def create_report(self):
+ #TODO: remove this after scans with new data model are available
+ self.locationprovider = 'NONE'
+ self.longitude = 0
+ self.latitude = 0
+
report_params = '''------- Base Station Parameters -----------
Country: %s
Provider: %s
@@ -68,8 +82,11 @@ BSIC: %s
LAC: %s
Cell ID: %s
Neighbours: %s
+Latitude: %s
+Longitude: %s
+Location Provider: %s
Evaluation: %s\n
-'''%(self.country,self.provider, self.arfcn, self.rxlev, self.bsic, self.lac, self.cell, ', '.join(map(str,self.get_neighbour_arfcn())),self.evaluation)
+'''%(self.country,self.provider, self.arfcn, self.rxlev, self.bsic, self.lac, self.cell, ', '.join(map(str,self.get_neighbour_arfcn())),self.latitude,self.longitude,self.locationprovider,self.evaluation)
report_rules ='------- Rule Results -----------\n'
for key in self.rules_report.keys():
@@ -125,6 +142,8 @@ class BaseStationInformationList:
for item in filtered_list:
store.append(item.get_list_model())
+ def _get_unfiltered_list(self):
+ return self._base_station_list
def _get_filtered_list(self, band_filter, filters):
filtered_list = []
@@ -160,4 +179,5 @@ class BaseStationInformationList:
station.rules_report = rule_results.copy()
station.evaluation, station.evaluation_report = evaluator.evaluate(rule_results)
station.evaluation_by = evaluator.identifier
- \ No newline at end of file
+
+
diff --git a/Src/PyCatcher/src/pyCatcherView.py b/Src/PyCatcher/src/pyCatcherView.py
index 6cb33a4..e39a247 100644
--- a/Src/PyCatcher/src/pyCatcherView.py
+++ b/Src/PyCatcher/src/pyCatcherView.py
@@ -161,7 +161,11 @@ class PyCatcherGUI:
def _on_evaluators_clicked(self, widget):
self._evaluators_window.show()
-
+
+ def _on_evaluators_window_close_clicked(self, window, event):
+ window.hide()
+ return True
+
def _on_rules_clicked(self, widget):
self._rules_window.show()
diff --git a/Src/PyCatcher/src/settings.py b/Src/PyCatcher/src/settings.py
index 9d94054..8f5c002 100644
--- a/Src/PyCatcher/src/settings.py
+++ b/Src/PyCatcher/src/settings.py
@@ -44,11 +44,12 @@ ARFCN_mapping = {
LAC_threshold = 0.5
-BSIC_database = ''
+#Database Configuration ----------------------------------------------------------------------------------------
+
+Open_Cell_ID_Key = 'd7a5bc3f21b44d4bf93d1ec2b3f83dc4'
+Open_Cell_ID_Local = ''
-Cell_ID_database = ''
-Home_database = ''
#Evaluator Configuration ---------------------------------------------------------------------------------------