Skip to content

Instantly share code, notes, and snippets.

@thedroidgeek
Last active August 26, 2025 14:48
Show Gist options
  • Save thedroidgeek/80c379aa43b71015d71da130f85a435a to your computer and use it in GitHub Desktop.
Save thedroidgeek/80c379aa43b71015d71da130f85a435a to your computer and use it in GitHub Desktop.
Nokia/Alcatel-Lucent router backup configuration tool
#!/usr/bin/env python3
#
# Nokia/Alcatel-Lucent router backup configuration tool
#
# Features:
# - Unpack/repack .cfg files generated from the backup and restore functionnality
# in order to modify the full router configuration
# - Decrypt/encrypt the passwords/secret values present in the configuration
#
# Blog post: https://0x41.cf/reversing/2019/10/08/unlocking-nokia-g240wa.html
#
# Released under the MIT License (http://opensource.org/licenses/MIT)
# Copyright (c) Sami Alaoui Kendil (thedroidgeek)
#
import sys
import zlib
import struct
import base64
import binascii
import datetime
big_endian = True
encrypted_cfg = False
def u32(val):
return struct.unpack('>I' if big_endian else '<I', val)[0]
def p32(val):
return struct.pack('>I' if big_endian else '<I', val)
def checkendian(cfg):
if (cfg[0:4] == b'\x00\x12\x31\x23'):
return True
elif (cfg[0:4] == b'\x23\x31\x12\x00'):
return False
else:
return None
class RouterCrypto:
def __init__(self):
from Crypto.Cipher import AES
# key and IV for AES
key = '3D A3 73 D7 DC 82 2E 2A 47 0D EC 37 89 6E 80 D7 2C 49 B3 16 29 DD C9 97 35 4B 84 03 91 77 9E A4'
iv = 'D0 E6 DC CD A7 4A 00 DF 76 0F C0 85 11 CB 05 EA'
# create AES-128-CBC cipher
self.cipher = AES.new(bytes(bytearray.fromhex(key)), AES.MODE_CBC, bytes(bytearray.fromhex(iv)))
def decrypt(self, data):
output = self.cipher.decrypt(data)
# remove PKCS#7 padding
return output[:-ord(output[-1:])]
def encrypt(self, data):
# add PKCS#7 padding for 128-bit AES
pad_num = (16 - (len(data) % 16))
data += chr(pad_num).encode() * pad_num
return self.cipher.encrypt(data)
#
# unpack xml from cfg
#
if (len(sys.argv) == 3 and sys.argv[1] == '-u'):
# line feed
print('')
# read the cfg file
cf = open(sys.argv[2], 'rb')
cfg_data = cf.read()
# check cfg file magic (0x123123) and determine endianness
big_endian = checkendian(cfg_data)
if big_endian == None:
# check if config is encrypted
decrypted = None
try:
# decrypt and check validity
decrypted = RouterCrypto().decrypt(cfg_data)
big_endian = checkendian(decrypted)
except ValueError:
pass
# if decryption failed, or still invalid, bail out
if big_endian == None:
print('invalid cfg file/magic :(\n')
exit()
# set decrypted cfg buffer and encryption flag
print('-> encrypted cfg detected')
cfg_data = decrypted
encrypted_cfg = True
# log endianness
if big_endian:
print('-> big endian CPU detected')
else:
print('-> little endian CPU detected')
# get fw_magic (unknown, could be fw version/compile time, hw serial number, etc.)
fw_magic = u32(cfg_data[0x10:0x14])
print('-> fw_magic = ' + hex(fw_magic))
# get the size of the compressed data
data_size = u32(cfg_data[4:8])
# get the compressed data
compressed = cfg_data[0x14 : 0x14 + data_size]
# get the checksum of the compressed data
checksum = u32(cfg_data[8:12])
# verify the checksum
if (binascii.crc32(compressed) & 0xFFFFFFFF != checksum):
print('\nCRC32 checksum failed :(\n')
exit()
# unpack the config
xml_data = zlib.decompress(compressed)
# output the xml file
out_filename = 'config-%s.xml' % datetime.datetime.now().strftime('%d%m%Y-%H%M%S')
of = open(out_filename, 'wb')
of.write(xml_data)
print('\nunpacked as: ' + out_filename)
print('\n# repack with:')
print('%s %s %s %s\n' % (sys.argv[0], ('-pb' if big_endian else '-pl') + ('e' if encrypted_cfg else ''), out_filename, hex(fw_magic)))
cf.close()
of.close()
#
# generate cfg from xml
#
elif (len(sys.argv) == 4 and (sys.argv[1][:3] == '-pb' or sys.argv[1][:3] == '-pl')):
fw_magic = 0
try:
# parse hex string
fw_magic = int(sys.argv[3], 16)
# 32-bit check
p32(fw_magic)
except:
print('\ninvalid magic value specified (32-bit hex)\n')
exit()
big_endian = sys.argv[1][:3] == '-pb'
encrypted_cfg = sys.argv[1][3:] == 'e'
out_filename = 'config-%s.cfg' % datetime.datetime.now().strftime('%d%m%Y-%H%M%S')
# read the xml file
xf = open(sys.argv[2], 'rb')
xml_data = xf.read()
xf.close()
# compress using default zlib compression
compressed = zlib.compress(xml_data)
## construct the header ##
# magic
cfg_data = p32(0x123123)
# size of compressed data
cfg_data += p32(len(compressed))
# crc32 checksum
cfg_data += p32(binascii.crc32(compressed) & 0xFFFFFFFF)
# size of xml file
cfg_data += p32(len(xml_data) + 1)
# fw_magic
cfg_data += p32(fw_magic)
# add the compressed xml
cfg_data += compressed
# encrypt if necessary
if encrypted_cfg:
cfg_data = RouterCrypto().encrypt(cfg_data)
# write the cfg file
of = open(out_filename, 'wb')
of.write(cfg_data)
of.close()
print('\npacked as: ' + out_filename + '\n')
#
# decrypt/encrypt secret value
#
elif (len(sys.argv) == 3 and (sys.argv[1] == '-d' or sys.argv[1] == '-e')):
decrypt_mode = sys.argv[1] == '-d'
if decrypt_mode:
# base64 decode + AES decrypt
print('\ndecrypted: ' + RouterCrypto().decrypt(base64.b64decode(sys.argv[2])).decode('UTF-8') + '\n')
else:
# AES encrypt + base64 encode
print('\nencrypted: ' + base64.b64encode(RouterCrypto().encrypt(sys.argv[2].encode())).decode('UTF-8') + '\n')
else:
print('\n#\n# Nokia/Alcatel-Lucent router backup configuration tool\n#\n')
print('# unpack (cfg to xml)\n')
print(sys.argv[0] + ' -u config.cfg\n')
print('# pack (xml to cfg)\n')
print(sys.argv[0] + ' -pb config.xml 0x13377331 # big endian, no encryption, fw_magic = 0x13377331')
print(sys.argv[0] + ' -pl config.xml 0x13377331 # little endian, ...')
print(sys.argv[0] + ' -pbe config.xml 0x13377331 # big endian, with encryption, ...')
print(sys.argv[0] + ' -ple config.xml 0x13377331 # ...\n')
print('# decrypt/encrypt secret values within xml (ealgo="ab")\n')
print(sys.argv[0] + ' -d OYdLWUVDdKQTPaCIeTqniA==')
print(sys.argv[0] + ' -e admin\n')
@achiragaming
Copy link

achiragaming commented Dec 17, 2024

hey so i got a nokia g-240w-f router from a isp and i disconnected the router from them and so currently its not use for me so what i was trying to do is trying to make it a access point for my main router the problem is i cant change the gateway ip and such i dont know why the isp disabled those is there a way that i can reflash the firmware and if so where do i find a firmware also my gpon dashboard does not have a update firmware option on the maintance tab
maintance tab
here is the lan tab
lan tab
i managed it to disable the dhcp by removing the disable tag from the inspect menu so currently dhcp is not there but i tried to do the same on the IPv4 Address and it gives me error lan ip as a alert

@Lukasd1298
Copy link

Hi,

Does this work for the 5G14-B device as well? I would like to export the settings, but I can't access them. I believe the ISP has blocked it. I can only overwrite the firmware.

image
image

@theSoberSobber
Copy link

hey so i got a nokia g-240w-f router from a isp and i disconnected the router from them and so currently its not use for me so what i was trying to do is trying to make it a access point for my main router the problem is i cant change the gateway ip and such i dont know why the isp disabled those is there a way that i can reflash the firmware and if so where do i find a firmware also my gpon dashboard does not have a update firmware option on the maintance tab maintance tab here is the lan tab lan tab i managed it to disable the dhcp by removing the disable tag from the inspect menu so currently dhcp is not there but i tried to do the same on the IPv4 Address and it gives me error lan ip as a alert

Hey I have the same router and my DHCP is enabled by default and the setting to turn it off is greyed out, neither am I able to allocate any static IPs, please help.

@achiragaming
Copy link

what i did was use the inspect menu and remove the disabled tag and save and it works for the disableing the dhcp and the nat but not the subnets and other things

@theSoberSobber
Copy link

@achiragaming hey man, thanks for the reply! I did the same and removed disabled from save button and the DHCP checkbox, but after clicking on save it says "The normal user is not allowed to do this!)". Maybe they patched it to needing superuser auth?

@enineboyuna06
Copy link

enineboyuna06 commented Jan 7, 2025

https://drive.google.com/file/d/1iXzdb1HwwtGxB5JYywYvdZRQDtlRcGmX/view TRCL firmware G-2426G-A FE49226IJJJ09

I need shell password2

'; /bin/sh; #
LA(ImvZx%8
SUGAR2A041

Does not work unable to dump config it's fully locked uart access requires password can anyone help me?

Successfully extracted the firmware into folders but don't know where to look at.

@sudosufatima
Copy link

try this- nE7jA%5m

@enineboyuna06
Copy link

enineboyuna06 commented Jan 9, 2025

try this- nE7jA%5m

20250109_22h21m34s_grim

It says password invalid.

TRCL preconfiguration: https://raw.githubusercontent.com/tolgagazii/tolga/refs/heads/main/preconfiguration_global_TRCL.xml

@ken5100
Copy link

ken5100 commented Jan 12, 2025

hello, i have a nokia G140W-F
software ver. 3FE47150IJJL04(1.2204.504)

whenever i try running the python script to unpack my config file it giving me this error please help me

ERROR:
PS C:\Users\kenka\OneDrive\Desktop\nokia new\80c379aa43b71015d71da130f85a435a-fc00533292eb1233b391de06481099ca69fe92a0>python nokia-router-cfg-tool.py -u config.cfg

-> big endian CPU detected
-> fw_magic = 0xffffffff
Traceback (most recent call last):
File "C:\Users\kenka\OneDrive\Desktop\nokia new\80c379aa43b71015d71da130f85a435a-fc00533292eb1233b391de06481099ca69fe92a0\nokia-router-cfg-tool.py", line 137, in
xml_data = zlib.decompress(compressed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
zlib.error: Error -3 while decompressing data: incorrect header check
PS C:\Users\kenka\OneDrive\Desktop\nokia new\80c379aa43b71015d71da130f85a435a-fc00533292eb1233b391de06481099ca69fe92a0>

@LysanderAlcander
Copy link

hello, i have a nokia G140W-F software ver. 3FE47150IJJL04(1.2204.504)

whenever i try running the python script to unpack my config file it giving me this error please help me

ERROR: PS C:\Users\kenka\OneDrive\Desktop\nokia new\80c379aa43b71015d71da130f85a435a-fc00533292eb1233b391de06481099ca69fe92a0>python nokia-router-cfg-tool.py -u config.cfg

-> big endian CPU detected -> fw_magic = 0xffffffff Traceback (most recent call last): File "C:\Users\kenka\OneDrive\Desktop\nokia new\80c379aa43b71015d71da130f85a435a-fc00533292eb1233b391de06481099ca69fe92a0\nokia-router-cfg-tool.py", line 137, in xml_data = zlib.decompress(compressed) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ zlib.error: Error -3 while decompressing data: incorrect header check PS C:\Users\kenka\OneDrive\Desktop\nokia new\80c379aa43b71015d71da130f85a435a-fc00533292eb1233b391de06481099ca69fe92a0>

I'm getting the exact same error, did you have any luck finding a fix for it?

@SamuelGaona
Copy link

hello, i have a nokia G140W-F software ver. 3FE47150IJJL04(1.2204.504)
whenever i try running the python script to unpack my config file it giving me this error please help me
ERROR: PS C:\Users\kenka\OneDrive\Desktop\nokia new\80c379aa43b71015d71da130f85a435a-fc00533292eb1233b391de06481099ca69fe92a0>python nokia-router-cfg-tool.py -u config.cfg
-> big endian CPU detected -> fw_magic = 0xffffffff Traceback (most recent call last): File "C:\Users\kenka\OneDrive\Desktop\nokia new\80c379aa43b71015d71da130f85a435a-fc00533292eb1233b391de06481099ca69fe92a0\nokia-router-cfg-tool.py", line 137, in xml_data = zlib.decompress(compressed) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ zlib.error: Error -3 while decompressing data: incorrect header check PS C:\Users\kenka\OneDrive\Desktop\nokia new\80c379aa43b71015d71da130f85a435a-fc00533292eb1233b391de06481099ca69fe92a0>

I'm getting the exact same error, did you have any luck finding a fix for it?

I'm stuck here too.

@pyroMx001
Copy link

Sin título

someone who can help me?

@mistressAlisi
Copy link

Hi there!
I have a Nokia G1425 from Telemex (Mexican ISP):
Chipset: MTK7528
Hardware: 3FE77771BEAA
Software: 3FE49568IJLJ07(1.2402.307)
Made in Nov 1, 2024.
This one does not let me decode, I get the dreaded:
-> little endian CPU detected
-> fw_magic = 0xfffffffe
Traceback (most recent call last):
File "/home/alisi/Downloads/nokia.py", line 137, in
xml_data = zlib.decompress(compressed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
zlib.error: Error -3 while decompressing data: incorrect header check

I understand this is a decoding problem (I use Python and these libraries myself!) - The question here is, is there anything I can do to help the project/community to get this version of the firmware cracked?

I am more than willing to share my config.cfg with someone if needed; the credentials are non-relevant outside Telmex's network anyway:
https://drive.google.com/file/d/1NEp0mSZUdCpTH5w9QxykT00Mxmmgn1aj/view?usp=sharing

Thanks in advance!
-Alisi

@mistressAlisi
Copy link

Sin título

someone who can help me?

Try using Base64 decode on those strings :)
the ones inside the XML objects, the v="" variables.

@krausar791
Copy link

can we extract username and password from nokia config file?

@alexceltare2
Copy link

alexceltare2 commented Apr 3, 2025

PSA: You need pycryptodome library installed from pip for this script to work! Remove any previously installed crypto libraries.

@enineboyuna06
Copy link

Do anyone has a full flash dump of G-2426G-A?

@NimdaR00t
Copy link

Hello, do anyone has an idea about Orange fiberbox ? ALCL code
when you request for a configuration backup, a .fiberbox file extension is downloaded not a .cfg

@ckfu37186
Copy link

ckfu37186 commented Jul 16, 2025 via email

@Heaven-Is-Myth-Nepal-Is-Real
Copy link

@ckfu37186
Copy link

ckfu37186 commented Jul 16, 2025 via email

@NimdaR00t
Copy link

kindly email me justsad[at]gmail.c0m

@NimdaR00t
Copy link

Can you share the file and model number of your router

On Wed, 16 Jul 2025 at 3:51 AM NimdaR00t @.> wrote: @.* commented on this gist. ------------------------------ Hello, do anyone has an idea about Orange fiberbox ? ALCL code when you request for a configuration backup, a .fiberbox file extension is downloaded not a .cfg — Reply to this email directly, view it on GitHub https://gist.github.com/thedroidgeek/80c379aa43b71015d71da130f85a435a#gistcomment-5677556 or unsubscribe https://github.com/notifications/unsubscribe-auth/BIN23NPBEZUOVEXRI3M6VDT3IV3NRBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVA4TQNZVGAZTENNHORZGSZ3HMVZKMY3SMVQXIZI . You are receiving this email because you commented on the thread. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

kindly email me justsad[at]gmail.com

@ckfu37186
Copy link

ckfu37186 commented Jul 16, 2025 via email

@Padke9
Copy link

Padke9 commented Aug 12, 2025

Nokia Windows decrypt tool
https://drive.google.com/file/d/1rbXrwxtVOGvXmg4usAOj_VvgvDL91srC/view?usp=sharing

<X_CT-COM_TeleComAccount. n="ctcAccount" t="staticObject">


<DebugDyPass. n="DyPass" t="staticObject">

<X_Authentication. n="Authentication" t="staticObject">

<X_ASB_COM_NormalUserHelpInfo ml="128" rw="RW" t="string" v=""></X_ASB_COM_NormalUserHelpInfo>
<Account. n="Account" t="staticObject">




X_ALU-COM_SwMgnt. n="SwMgnt" t="staticObject">
<X_ALU-COM_Enable rw="RW" t="boolean" v="true"></X_ALU-COM_Enable>
<X_ALU-COM_Polling_URL ml="1024" rw="RW" t="string" v="https://swupd.wifi.nokia.com"></X_ALU-COM_Polling_URL>
<X_ALU-COM_Polling_Time ml="128" rw="RW" t="string" v="0 2 * * *"></X_ALU-COM_Polling_Time>
<X_ALU-COM_Client_Auth_Key ml="1024" rw="RW" t="string" v="slEksSx4015s9j6K3rvN78QeCGiq4q187AAbZmED"></X_ALU-COM_Client_Auth_Key>

if any one could decrypt That would be the password for these users

ONTUSER:$1$2TKiGGwh$6ulkF8D9DsL0RIBK1cgYQ
AdminGPON:$1$M.jBzxHe$jMtIpXxwMTeOg/1JPE6pP0
AdminGPON:$1$J4VA3VCi$y2c4Byu0m5PZ79eRDjHnr0
ONTUSER:$1$.7SbDVPl$lvlevMX.wgvaFyxwN5Ij8/

Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,F659D1CBA9992077

aQuaeZEU2UwTDiuvQeFU2xuZG80PO0LKFSDGM5ehGlOyHopOFHCVCyIZ4AE7oYdv
fT2abi6f060gWP/+E6+knsaTdKwgzVCec+75+7/DCIQD9cWRD2XzxKlu8lMTay4a
dY/U1NN1ufjCV2eDnv7sfoimB+zzcMO7/oCKGCKvVHib9cb4vvfY4ujstxkWXz7+
T7Tcqpm6cLHxMjzqnJcgDmP+fd5RYDr3JhESPJB54ll5oBSFoFt1jNAWAgV5rGba
zvQJVMQ06MZk2vqS653Qyi+pMdUv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W3oBE+RJhad1nF0rNWtKsLFBtbBz2HzqBJRKTeJ0oUukwzYnVCc5Ps6
L+oPNPh1w61fl3tgd5eW172nWYr1cHW+GVT6xyqWDcPAPxjFmk1/Gin9dVu/3W8q
iONdPUWXcubLb53MnGcT77z2JLRpeeDXybqyjb8wCxo8+m1iHPDGz2i0fxB2vH2o
l2+jKYvevb5gZztfvASuMBKJQY9gEURwdJv5HjBb0E4pcz1o9MleCA==
-----END RSA PR-

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