Skip to content

Instantly share code, notes, and snippets.

@nguyenl95
Last active July 12, 2019 03:43
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 nguyenl95/9deacab5ceb98da1d8539aa1b552ce03 to your computer and use it in GitHub Desktop.
Save nguyenl95/9deacab5ceb98da1d8539aa1b552ce03 to your computer and use it in GitHub Desktop.
#!/usr/bin/python2
import binascii
import hashlib
drv='/dev/sdb'
mode='rb+'
# pwd default is 'admin'
sector_size=512
magic_string=r"%@#$*&^!**$#&@^%%@#$*&^!**$#&@^%"
magic_number=55
with open(drv, mode) as disk:
with open('raw0.bin') as raw0:
disk.seek(0)
disk.write(raw0.read())
with open('raw1.bin') as raw1:
disk.seek(sector_size*8199)
disk.write(raw1.read())
with open('raw2.bin') as raw2:
for i in range(1, 59):
disk.seek(63+i*262144)
disk.write(raw2.read())
for x in xrange(11, 16):
disk.seek(x*sector_size)
disk.write(magic_string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment