Skip to content

Instantly share code, notes, and snippets.

@olekstomek
Last active September 28, 2022 10:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olekstomek/0d598b7c8e251d403e18689211f23a78 to your computer and use it in GitHub Desktop.
Save olekstomek/0d598b7c8e251d403e18689211f23a78 to your computer and use it in GitHub Desktop.
skrypt do ustawiania parametrów sygnału w modemie mobilnym 4G
import base64
import hashlib
import requests
import sys
#usage: python3 zte-setband_2.0 B1,B3,B7
router_ip = '192.168.100.1' #change to MF286D IP
password = 'password' #change to MF286D admin password
ltebandlock='0x20080800C5' #don't change this
bdict = {
"B1": 1,
"B3": 4,
"B7": 40,
"B8": 80,
"B20": 80000,
"B28": 8000000,
"B38": 2000000000
}
password_encoded = hashlib.sha256(base64.b64encode(password.encode())).hexdigest().upper()
if len(sys.argv) > 1:
bands=sys.argv[1].split(',')
if len(bands) < 4:
somma=0
for x in bands:
somma=somma+bdict[x]
ltebandlock='0x'+str(somma)
print(ltebandlock)
headers = {'Referer': f'http://{router_ip}/index.html'}
login = requests.post(f'http://{router_ip}/goform/goform_set_cmd_process', data={'goformId': 'LOGIN', 'password': password_encoded}, headers=headers)
if login.json()['result'] == '0':
version = requests.get(f'http://{router_ip}/goform/goform_get_cmd_process', params={'cmd': 'wa_inner_version,cr_version', 'multi_data': '1'}, headers=headers, cookies=login.cookies).json()
version_string = version['wa_inner_version'] + version['cr_version']
version_md5 = hashlib.md5(version_string.encode()).hexdigest()
rd = requests.get(f'http://{router_ip}/goform/goform_get_cmd_process', params={'cmd': 'RD'}, headers=headers, cookies=login.cookies).json()
ad_string = version_md5 + rd['RD']
ad = hashlib.md5(ad_string.encode()).hexdigest()
setlteband = requests.post(f'http://{router_ip}/goform/goform_set_cmd_process', data={'isTest': 'false', 'goformId': 'SET_LTE_BAND_LOCK', 'lte_band_lock': ltebandlock, 'AD': ad}, headers=headers, cookies=login.cookies).json()
print(setlteband['result'])
else:
print(f'Login error: {login.text}')
@olekstomek
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment