Skip to content

Commit

Permalink
fix #92 #93 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Oros42 committed Apr 18, 2020
1 parent e73a1eb commit f05313a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions simple_IMSI-catcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class tracker:
brand=""
operator=""

# in minutes
purgeTimer = 10 # default 10 min

show_all_tmsi = False
mcc_codes = None
sqlcon = None
Expand Down Expand Up @@ -257,11 +260,15 @@ def imsi_seen(self, imsi, arfcn):
self.imsi_purge_old()
def imsi_purge_old(self):
now = datetime.datetime.utcnow().replace(microsecond=0)
maxage = datetime.timedelta(minutes=10)
maxage = datetime.timedelta(minutes=self.purgeTimer)
limit = now - maxage
for imsi in self.imsistate.keys():
if limit > self.imsistate[imsi]["lastseen"]:
del self.imsistate[imsi]
remove = [imsi for imsi in self.imsistate if limit > self.imsistate[imsi]["lastseen"]]
for k in remove: del self.imsistate[k]
#keys = self.imsistate.keys()
#for imsi in keys:
# if limit > self.imsistate[imsi]["lastseen"]:
# del self.imsistate[imsi]
# keys = self.imsistate.keys()

class gsmtap_hdr(ctypes.BigEndianStructure):
_pack_ = 1
Expand Down

0 comments on commit f05313a

Please sign in to comment.