From 996c67c027a27573e9298b491854cdfbed5d7bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Dudek?= Date: Tue, 21 Feb 2023 16:31:55 +0100 Subject: [PATCH] Fixing remaining issues on missing bands + cleaning the print --- smartjam_rpcclient.py | 20 +++++++++++++++----- utils/eu_arfcn_calc.py | 6 ++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/smartjam_rpcclient.py b/smartjam_rpcclient.py index 5583b9f..ff4390f 100755 --- a/smartjam_rpcclient.py +++ b/smartjam_rpcclient.py @@ -20,6 +20,10 @@ import xmlrpc.client import argparse from utils.eu_arfcn_calc import * +def superprintofdeath(message): + print('\r'+message, end='\r\r\r\r\r\r\r', flush=True) + + if __name__ == "__main__": parser = argparse.ArgumentParser(description='Modmodjam - Software-Defined Radio Jammer') parser.add_argument('-s', '--host', dest='host', default='localhost', @@ -80,8 +84,12 @@ if __name__ == "__main__": cbandwidth = int(val['bandwidth'].replace('MHz','')) try: if ctype == '3G': + if band is None: + band = findband(table_uarfcn, findex) downlink, uplink = uarfcn2freq(int(band), findex, None) elif ctype == '4G': + if band is None: + band = findband(table_earfcn, findex) downlink, uplink = earfcn2freq(int(band), findex, None) elif ctype == '2G': pass @@ -90,19 +98,21 @@ if __name__ == "__main__": cent_freq = downlink if linkjam == 1: cent_freq = uplink - t_freqs[key] = { 'freq' : cent_freq, + t_freqs[key] = { 'freq' : round(cent_freq), 'bandwidth' : cbandwidth } except Exception as e: print (e) while True: try: for key, val in t_freqs.items(): - print ("[+] Jamming cell {cell} central frequency at {freq} MHz with {bandwidth} MHz bandwidth".format(cell=key, freq=val['freq'], bandwidth=val['bandwidth'])) - s.set_var_cent_freq(val['freq']*1000000) - s.set_var_bandwidth(val['bandwidth']*1000000) + 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) time.sleep(delay) - except: + except Exception as e: print('Stopping jammer...') state = False + #print(e) break diff --git a/utils/eu_arfcn_calc.py b/utils/eu_arfcn_calc.py index 157a721..7779339 100755 --- a/utils/eu_arfcn_calc.py +++ b/utils/eu_arfcn_calc.py @@ -426,6 +426,12 @@ table_uarfcn = { # Functions # + +def findband(indextable, dl_frequency): + for i,j in indextable.items(): + if dl_frequency <= j['DL_range'][1] and dl_frequency >= j['DL_range'][0]: + return i + def uarfcn2freq(band, dl_uarfcn=None, ul_uarfcn=None): ''' in(1): int band index,