Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. img_path = 'C:/mbr12.img'
  2. file_com = 'C:/GAME_COM.com'
  3. start_pos = 0
  4. end_pos = 10
  5. with open(img_path, 'rb') as file:
  6.     with open(file_com, 'rb') as wfile:
  7.         text = wfile.read()
  8.         print(len(text))
  9.         ftext = file.read()
  10.         print(len(ftext))
  11.         empty = b'\00' * 13824
  12.         for k in range(start_pos, end_pos):
  13.             n = str(k)
  14.             name = b'\00\01' + b'programm' + bytes(n, encoding="ascii")
  15.             print(name)
  16.             ftext = ftext[:4096 + 32*k] + name + ftext[4096 + 32*k + len(name):]
  17.         for j in range(start_pos, end_pos):
  18.             ftext = ftext[:4608 + 13824 * j] + empty + ftext[4608 + len(empty) + 13824 * j:]
  19.             ftext = ftext[:4608 + 13824 * j] + text + ftext[4608 + len(text) + 13824 * j:]
  20.         print(len(ftext))
  21. with open(img_path, 'wb') as file:
  22.     file.write(ftext)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement