2018-07-27 08:16:41 -07:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
2021-06-01 03:25:36 -07:00
# <sebastien.dudek(<@T>)penthertz.com> wrote this file. As long as you retain this notice you
2018-07-27 08:16:41 -07:00
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return FlUxIuS ;)
2023-02-21 06:50:31 -08:00
#
# We would like to thank our contributors for maintening this code:
# - @h0rac Grzegorz Wypych from PWNsec.pl
2018-07-27 08:16:41 -07:00
# ----------------------------------------------------------------------------
from __future__ import print_function
import time
import json
import random
2021-06-01 03:25:36 -07:00
import xmlrpc . client
2018-07-27 08:16:41 -07:00
import argparse
from utils . eu_arfcn_calc import *
2023-02-21 07:31:55 -08:00
def superprintofdeath ( message ) :
print ( ' \r ' + message , end = ' \r \r \r \r \r \r \r ' , flush = True )
2018-07-27 08:16:41 -07:00
if __name__ == " __main__ " :
parser = argparse . ArgumentParser ( description = ' Modmodjam - Software-Defined Radio Jammer ' )
parser . add_argument ( ' -s ' , ' --host ' , dest = ' host ' , default = ' localhost ' ,
help = ' hostname to send RPC commands (default: " localhost " ) ' )
parser . add_argument ( ' -p ' , ' --port ' , dest = ' port ' , default = 8888 ,
help = ' RPC server port (e.g: 8888 by default) ' )
parser . add_argument ( ' -f ' , ' --file ' , dest = ' filepath ' , required = True ,
help = ' Modmobmap json file ' )
parser . add_argument ( ' -d ' , ' --delay ' , dest = ' delay ' , default = 2 ,
help = ' Delay between each frequency to jam in sec (default: 2) ' )
parser . add_argument ( ' -b ' , ' --bandwidth ' , dest = ' bandwidth ' , default = None ,
help = ' Define a static bandwidth. Will also influence the sample rate. By default it will use the bandwidth of the JSON file ' )
parser . add_argument ( ' -l ' , ' --linkjam ' , dest = ' linkjam ' , default = 0 ,
help = ' Link to jam: " 0 " for downlink and " 1 " for uplink (default: " 0 " ) ' )
parser . add_argument ( ' -w ' , ' --filterplm ' , dest = ' filterplmn ' , default = None ,
help = ' PLMN to filter. Example: 2082-1 (separated with commas) ' )
t_freqs = { }
args = parser . parse_args ( )
host = args . host
port = int ( args . port )
linkjam = int ( args . linkjam )
filepath = args . filepath
delay = int ( args . delay )
filterplmn = args . filterplmn
bandwidth = args . bandwidth
2021-06-01 03:25:36 -07:00
s = xmlrpc . client . ServerProxy ( " http:// %s : %s " % ( host , port ) )
2018-07-27 08:16:41 -07:00
with open ( filepath ) as f :
modmobdata = json . load ( f )
plmns = [ ]
if filterplmn is not None :
plmns = args . filterplmn . split ( ' , ' )
for key , val in modmobdata . items ( ) :
plmn = val [ ' PLMN ' ]
if plmn in plmns or filterplmn is None :
band = None
ctype = None
findex = None
downlink = None
uplink = None
cbandwidth = 10 # MHz
if ' RX ' in val :
findex = val [ ' RX ' ]
elif ' eARFCN ' in val :
findex = val [ ' eARFCN ' ]
if ' band ' in val :
band = val [ ' band ' ]
if ' type ' in val :
ctype = val [ ' type ' ]
if bandwidth is not None :
cbandwidth = bandwidth
else :
if ' bandwidth ' in val :
cbandwidth = int ( val [ ' bandwidth ' ] . replace ( ' MHz ' , ' ' ) )
try :
if ctype == ' 3G ' :
2023-02-21 07:31:55 -08:00
if band is None :
band = findband ( table_uarfcn , findex )
2023-02-21 06:50:31 -08:00
downlink , uplink = uarfcn2freq ( int ( band ) , findex , None )
2018-07-27 08:16:41 -07:00
elif ctype == ' 4G ' :
2023-02-21 07:31:55 -08:00
if band is None :
band = findband ( table_earfcn , findex )
2023-02-21 06:50:31 -08:00
downlink , uplink = earfcn2freq ( int ( band ) , findex , None )
2018-07-27 08:16:41 -07:00
elif ctype == ' 2G ' :
pass
# not implemented for our purposes
if downlink is not None and uplink is not None :
cent_freq = downlink
if linkjam == 1 :
cent_freq = uplink
2023-02-21 07:31:55 -08:00
t_freqs [ key ] = { ' freq ' : round ( cent_freq ) ,
2018-07-27 08:16:41 -07:00
' bandwidth ' : cbandwidth }
except Exception as e :
print ( e )
while True :
2023-02-21 06:50:31 -08:00
try :
for key , val in t_freqs . items ( ) :
2023-02-21 07:31:55 -08:00
message = " [+] Jamming cell {cell} central frequency at {freq} MHz with {bandwidth} MHz bandwidth " . format ( cell = key , freq = val [ ' freq ' ] , bandwidth = val [ ' bandwidth ' ] )
superprintofdeath ( message )
s . set_var_cent_freq ( val [ ' freq ' ] * 1e6 )
s . set_var_bandwidth ( val [ ' bandwidth ' ] * 1e6 )
2023-02-21 06:50:31 -08:00
time . sleep ( delay )
2023-02-21 07:31:55 -08:00
except Exception as e :
2023-02-21 06:50:31 -08:00
print ( ' Stopping jammer... ' )
state = False
2023-02-21 07:31:55 -08:00
#print(e)
2023-02-21 06:50:31 -08:00
break