-
Notifications
You must be signed in to change notification settings - Fork 7
/
95M730c.py
162 lines (143 loc) · 7.41 KB
/
95M730c.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# coding: latin-1
"""
Name: 95M730C
ID:000-000-000
version: Pren
About: This program shows you IMSI , TMSI, LAC, CI of cellphones around you.
Disclaimer:-
This program was made to understand how GSM network works. Understanding the vulnerability regarding attacks to provide awarness
We are not responsible for any illegal activity !
About:-
Author: Humayun Ali Khan
Created on : 20/04/2022
website: https://theeyeofcyber.github.io/
Github: https://github.com/TheEyeOfCyber
"""
import pyshark
from optparse import OptionParser
import os, sys
import datetime
class Imsi730C:
sql_conn = None
imsi = ""
tmsi = ""
mcc = ""
mnc = ""
lac = ""
ci = ""
id_ = 0
live_db = {}
def sql_db(self):
import sqlite3
self.sql_conn = sqlite3.connect(options.save)
self.sql_conn.execute('CREATE TABLE IF NOT EXISTS imsi_data(id INTEGER PRIMARY KEY, imsi TEXT, tmsi TEXT, mcc INTEGER, mnc INTEGER, lac INTEGER, ci INTEGER, date_time timestamp)')
def save_data(self):
date_time = datetime.datetime.now()
self.sql_conn.execute('INSERT INTO imsi_data(imsi, tmsi, mcc, mnc, lac, ci, date_time) VALUES ( ?, ?, ?, ?, ?, ?, ?)',(self.imsi, self.tmsi, self.mcc, self.mnc, self.lac, self.ci, date_time))
self.sql_conn.commit()
def get_data(self):
self.cur = self.sql_conn.cursor()
self.cur.execute('SELECT * FROM imsi_data WHERE imsi=' + self.imsi)
self.data = self.cur.fetchall()
def update_data(self, id_, tmsi):
self.sql_conn.execute('UPDATE imsi_data SET tmsi = ?, date_time = ? WHERE id= ?',(tmsi, id_, datetime.datetime.now()))
self.sql_conn.commit()
def filter_imsi(self):
if options.save:
self.sql_db()
self.get_data()
data = self.data
if data:
data = self.data[0]
if(self.imsi != data[1]):
self.save_data()
else:
if (self.tmsi != data[2]) & (self.tmsi != ''): #Check if tmsi is different than update in file db
self.update_data(data[0],self.tmsi)
else:
self.save_data()
if self.imsi in self.live_db:
if self.live_db[self.imsi]['tmsi'] != self.tmsi: #Check if tmsi is different than update in live db
self.live_db[self.imsi]['tmsi'] = self.tmsi
else:
self.id_ += 1
self.live_db[self.imsi] = {"id" : self.id_,"tmsi" : self.tmsi, "mcc" : self.mcc, "mnc" : self.mnc}
self.output()
def get_imsi(self, capture):
for packet in capture:
layer = packet.highest_layer
if layer == "GSM_A.CCCH":
if packet[4].layer_name == 'gsm_a.ccch':
gsm_a_ccch = packet[4]
if hasattr(gsm_a_ccch, "gsm_a_bssmap_cell_ci"):
self.ci = int(gsm_a_ccch.gsm_a_bssmap_cell_ci, 16)
self.lac = int(gsm_a_ccch.gsm_a_lac, 16)
elif hasattr(gsm_a_ccch, 'e212.imsi'):
self.imsi = gsm_a_ccch.e212_imsi #[-11:-1]
self.mcc = gsm_a_ccch.e212_mcc
self.mnc = gsm_a_ccch.e212_mnc
if hasattr(gsm_a_ccch,'gsm_a_rr_tmsi_ptmsi'):
self.tmsi = gsm_a_ccch.gsm_a_rr_tmsi_ptmsi
elif hasattr(gsm_a_ccch,'gsm_a_tmsi'):
self.tmsi = gsm_a_ccch.gsm_a_tmsi
else:
self.tmsi = ''
if options.imsi == '':
self.filter_imsi()
elif options.imsi == self.imsi:
self.filter_imsi()
elif packet[6].layer_name == 'gsm_a.ccch':
gsm_a_ccch = packet[6]
if hasattr(gsm_a_ccch, "gsm_a_bssmap_cell_ci"):
self.ci = int(gsm_a_ccch.gsm_a_bssmap_cell_ci, 16)
self.lac = int(gsm_a_ccch.gsm_a_lac, 16)
def header(self):
os.system('clear')
title = '''
__..--""""""""""""""--..__
__..--"" ""--..__
' `-.
_.-------._ `-.
/ \ _.--._ `-.
/ /\ \ .-' `-. `-.
/ / \_________/\ / .--...--. \ `
/`-' .--. .--. / .--.___.--. \
\_ | __ |_| __ | / | __ :_: __ | \
|\ `.__.'-`.__.' / . `.___/ \___.'. \
|_\___/ / \\_| / | - | \
/ | `. | / . \ .-. / . \
\__|__.' / | . \ `-' / . |
__\__________/__ \ . /`.__.'\ . /
_..--" \ / \ / "-._ \_____/ \_____/
\ | | / `. .' __ __ `.
\| |/ `./ \
o o | _.---._ _.---._ |
/ \ | / \ / \ |
| o o | | | \/ \ |
________________________________________________________
| "... That the whole time we're there, we'll probably |
| be exposed to HUNDREDS OF TIMES the normal residual |
| <>Fallout<> levels we're accustomed to!" |
|_____________________________________________________jro|
☠️ 丨爪丂丨 匚卂ㄒ匚卄乇尺 ☠️'''
print ("\033[0;31;48m" + title)
print ("................................................................................")
print("\033[0;37;48m ID \033[0;31;48m; \033[0;37;48m IMSI \033[0;31;48m; \033[0;37;48mTMSI \033[0;31;48m; \033[0;37;48mMCC \033[0;31;48m; \033[0;37;48mMNC \033[0;31;48m; \033[0;37;48m LAC \033[0;31;48m; \033[0;37;48m CI\033[0;31;48m ;")
print ("\033[0;31;48m................................................................................")
def output(self):
print("\033[0;37;48m {:3s}\033[0;31;48m; \033[0;37;48m {:16s} \033[0;31;48m; \033[0;37;48m {:12s}\033[0;31;48m; \033[0;37;48m\033[0;37;48m {:5s} \033[0;31;48m;\033[0;37;48m {:4s}\033[0;31;48m; \033[0;37;48m {:5} \033[0;31;48m; \033[0;37;48m {:6} \033[0;31;48m;".format(str(self.live_db[self.imsi]["id"]), self.imsi, self.live_db[self.imsi]["tmsi"], self.mcc, self.mnc, self.lac, self.ci))
print ("\033[0;31;48m................................................................................")
if __name__ == "__main__":
parser = OptionParser(usage="%prog: [options]")
parser.add_option("-i", "--iface", dest="iface", default="lo", help="Interface (default : lo)")
parser.add_option("-p", "--port", dest="port", default="4729", type="int", help="Port (default : 4729)")
parser.add_option("-m", "--imsi", dest="imsi", default="", type="string", help='IMSI to track (default : None, Example: 123456789101112)')
parser.add_option("-s", "--save", dest="save", default=None, type="string", help="Save all imsi numbers to sqlite file. (default : None)")
(options, args) = parser.parse_args()
try:
Imsi730C = Imsi730C()
Imsi730C.header()
capture = pyshark.LiveCapture(interface=options.iface, bpf_filter="port {} and not icmp and udp".format(options.port))
Imsi730C.get_imsi(capture)
except:
print ("Stop sniffing")