Skip to content

Instantly share code, notes, and snippets.

@ryancdotorg
Created March 19, 2023 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryancdotorg/bb41536d19b4e26883352802f170892a to your computer and use it in GitHub Desktop.
Save ryancdotorg/bb41536d19b4e26883352802f170892a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
in_file = sys.argv[1]
lower = in_file.lower()
if 'eap1300ext' in lower or 'eap1300' not in lower:
raise ValueError('This does not look like an EAP1300 firmware file name.')
out_file = in_file.replace('eap1300', 'eap1300ext').replace('EAP1300', 'EAP1300EXT')
with open(in_file, 'rb') as f:
in_header = f.read(256)
vendor_and_product = in_header[4:12]
model_len = in_header[0x87]
data_start = 0x88+model_len
model = in_header[0x88:data_start]
if model != b'EAP1300_A' or vendor_and_product != b'\0\0\1\1\0\0\0\x9d':
raise ValueError('Header data does not look like it is for an EAP1300')
out_header = in_header[0:0x87] + \
b'\x0cEAP1300EXT_A' + \
in_header[data_start:]
with open(out_file, 'wb') as o:
o.write(out_header)
while True:
block = f.read1()
if not block: break
o.write(block)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment