Script code itself

#!/usr/bin/env python import zlib import sys import re import binascii if(len(sys.argv) < 2 or sys.argv[1] == "-h"): print("usage: python DecompNewDell.py <biosupdate.exe>") exit() f = open(sys.argv[1], "rb") string = f.read() pat = re.compile(r'.{4}\xAA\xEE\xAA\x76\x1B\xEC\xBB\x20\xF1\xE6\x51.{1}\x78\x9C') match = pat.search(string) (start_match, end_match) = match.span() compessed_len = string[start_match:start_match+4] compessed_len = binascii.b2a_hex(compessed_len[::-1]) compessed_len = long(compessed_len, 16) f.seek(start_match+16) string = f.read(compessed_len) o = zlib.decompress(string) f2 = open(sys.argv[1] + "_decompressed.hdr", "wb") f2.write(o) f.close() f2.close() print("Decompressed data written to %s_decompressed.hdr" % sys.argv[1]) 

I execute from the command line (the file is located next to the script, namely on the desktop and it is .exe ) and as a result it sounds an alarm on the line match = pat.search(string) enter image description here

  • one
    text information is better to attach as text: a) easier to read; b) can be copied; c) the search works. You can correct the question text by clicking below to edit the question text - aleksandr barakin

1 answer 1

If you work with binary data, then the pattern must be set in bytes

 pat = re.compile(rb'.{4}\xAA\xEE\xAA\x76\x1B\xEC\xBB\x20\xF1\xE6\x51.{1}\x78\x9C')