Skip to content

Commit

Permalink
Fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
purwowd committed Aug 4, 2020
1 parent 93603f8 commit 47f5b0a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
5 changes: 0 additions & 5 deletions .env

This file was deleted.

5 changes: 5 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# MySQL Config
MYSQL_HOST=
MYSQL_USER=
MYSQL_PASSWORD=
MYSQL_DB=
34 changes: 17 additions & 17 deletions simple_IMSI-catcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,9 @@
import ctypes
import json
from optparse import OptionParser
from decouple import config
import datetime
import io
import socket
import MySQLdb as mdb

con = mdb.connect(
config("MYSQL_HOST"),
config("MYSQL_USER"),
config("MYSQL_PASSWORD"),
config("MYSQL_DB")
)
cur = con.cursor()

imsitracker = None

Expand Down Expand Up @@ -170,11 +160,23 @@ def textfile(self, filename):
self.textfile = filename

def mysql_file(self):
self.db = con.cursor()
if self.db:
print("mysql connection is success :)")
global con
global cur
import os.path
if os.path.isfile('.env'):
import MySQLdb as mdb
from decouple import config
con = mdb.connect(config("MYSQL_HOST"), config("MYSQL_USER"), config("MYSQL_PASSWORD"), config("MYSQL_DB"))
cur = con.cursor()
# Check MySQL connection
if cur:
print("mysql connection is success :)")
else:
print("mysql connection is failed!")
exit()
else:
print("mysql connection is failed!")
print("create file .env first")
exit()

def output(self, cpt, tmsi1, tmsi2, imsi, imsicountry, imsibrand, imsioperator, mcc, mnc, lac, cell, now, packet=None):
print("{:7s} ; {:10s} ; {:10s} ; {:17s} ; {:12s} ; {:10s} ; {:21s} ; {:4s} ; {:5s} ; {:6s} ; {:6s} ; {:s}".format(str(cpt), tmsi1, tmsi2, imsi, imsicountry, imsibrand, imsioperator, str(mcc), str(mnc), str(lac), str(cell), now.isoformat()))
Expand Down Expand Up @@ -212,13 +214,11 @@ def pfields(self, cpt, tmsi1, tmsi2, imsi, mcc, mnc, lac, cell, packet=None):
tmsi1 = None
if tmsi2 == "":
tmsi2 = None

# Example query
query = ("INSERT INTO `imsi` (`tmsi1`, `tmsi2`, `imsi`,`mcc`, `mnc`, `lac`, `cell_id`, `stamp`, `deviceid`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)")
arg = (tmsi1, tmsi2, imsi, mcc, mnc, lac, cell, now, "rtl")
cur.execute(query, arg)
con.commit()
else:
print("Failed! check your db connection")

def header(self):
print("{:7s} ; {:10s} ; {:10s} ; {:17s} ; {:12s} ; {:10s} ; {:21s} ; {:4s} ; {:5s} ; {:6s} ; {:6s} ; {:s}".format("Nb IMSI", "TMSI-1", "TMSI-2", "IMSI", "country", "brand", "operator", "MCC", "MNC", "LAC", "CellId", "Timestamp"))
Expand Down

0 comments on commit 47f5b0a

Please sign in to comment.