Add fw.py
This commit is contained in:
commit
dbd29ee83a
58
fw.py
Normal file
58
fw.py
Normal file
@ -0,0 +1,58 @@
|
||||
import sys, binascii
|
||||
from datetime import datetime
|
||||
|
||||
with open(sys.argv[1], 'rb') as f:
|
||||
data = f.read()
|
||||
|
||||
data_hex = data.hex()
|
||||
date = data_hex[0x18*2:0x18*2+10] # BCD encoded
|
||||
try:
|
||||
date_dt = datetime.strptime(date, '%M%H%d%m%y')
|
||||
date_str = date_dt.strftime("%Y-%m-%d %H:%M")
|
||||
except ValueError:
|
||||
date_str = date
|
||||
|
||||
console_type = {
|
||||
'ff': 'Nintendo DS',
|
||||
'20': 'Nintendo DS Lite',
|
||||
'43': 'iQue DS',
|
||||
'63': 'iQue DS Lite',
|
||||
'35': 'Nintendo DS Lite (Korea)',
|
||||
'00': 'IS-NITRO-EMULATOR / Nintendo DS (Prototype)',
|
||||
'01': 'Nintendo Zone Box',
|
||||
'a0': 'IS-NITRO-EMULATOR (USG)'
|
||||
}
|
||||
console = data_hex[0x1D*2:0x1D*2+2]
|
||||
try:
|
||||
console_t = console_type[console]
|
||||
except KeyError:
|
||||
console_t = 'Unknown'
|
||||
|
||||
print(f'Build timestamp: {date_str}')
|
||||
print(f'Console: {console_t}')
|
||||
|
||||
with open('cleaned.bin', 'wb') as f:
|
||||
f.write(data[:0x2A])
|
||||
f.write(binascii.unhexlify('FF'*0x1D6))
|
||||
f.write(data[0x200:-0x600])
|
||||
f.write(binascii.unhexlify('00'*0x400))
|
||||
user_settings = '05' + '00'*0x6F
|
||||
for i in range(2):
|
||||
if console == '35': # lite korean
|
||||
usr_set = user_settings + f'0{i}00454F' + '0101AF00' + 'FF'*0x86 + 'BC25'
|
||||
elif console == '63': # lite ique
|
||||
usr_set = user_settings + f'0{i}00454F' + '01017E00' + '00'*0x86 + '5494'
|
||||
elif console == '43': # phat ique
|
||||
usr_set = user_settings + f'0{i}00454F' + '01017E00' + 'FF'*0x86 + 'E510'
|
||||
else:
|
||||
usr_set = user_settings + f'0{i}00454F' + 'FF'*0x8C
|
||||
f.write(binascii.unhexlify(usr_set))
|
||||
|
||||
print("Cleaned Wi-Fi calibration, Wi-Fi access points, user settings in cleaned.bin")
|
||||
|
||||
with open('WifiCalibration.bin', 'wb') as f:
|
||||
f.write(data[0x2A:0x200])
|
||||
with open('WifiAccessPoints.bin', 'wb') as f:
|
||||
f.write(data[-0x600:-0x200])
|
||||
with open('UserSettings.bin', 'wb') as f:
|
||||
f.write(data[-0x200:])
|
||||
Loading…
Reference in New Issue
Block a user