Created
May 14, 2018 00:51
-
-
Save ymgve/27b16a20949092ad4bfaacf56041824d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
blocks = [] | |
for i in xrange(1, 9): | |
blocks.append(open("fragment_%d.dat" % i, "rb").read()) | |
for p in itertools.permutations(range(1,9)): | |
data = "" | |
for i in p: | |
data += blocks[i-1] | |
if data[0x5ad-0x5ad:0x5ad-0x5ad+3] != "\x55\x89\xe5": | |
continue | |
if data[0x72e-0x5ad:0x72e-0x5ad+3] != "\x55\x89\xe5": | |
continue | |
if data[0x7a2-0x5ad:0x7a2-0x5ad+3] != "\x55\x89\xe5": | |
continue | |
if p[7] != 4: | |
continue | |
id = "".join(str(x) for x in p) | |
data2 = open("broken", "rb").read() | |
data3 = data2.replace("X" * 0x327, data) | |
assert len(data2) == len(data3) | |
open("badfix" + id, "wb").write(data3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment