From f05313a1bb6edea664ed4e3accfe0540d2834160 Mon Sep 17 00:00:00 2001 From: Oros Date: Sat, 18 Apr 2020 16:53:57 +0200 Subject: [PATCH] fix #92 #93 bug --- simple_IMSI-catcher.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/simple_IMSI-catcher.py b/simple_IMSI-catcher.py index 4e2d3d0..e29ac88 100644 --- a/simple_IMSI-catcher.py +++ b/simple_IMSI-catcher.py @@ -42,6 +42,9 @@ class tracker: brand="" operator="" + # in minutes + purgeTimer = 10 # default 10 min + show_all_tmsi = False mcc_codes = None sqlcon = None @@ -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