Skip to content

Commit

Permalink
Added PoC
Browse files Browse the repository at this point in the history
  • Loading branch information
lflare committed Dec 24, 2021
1 parent a3b271f commit 2b7509c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions rewrite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#! /usr/bin/env python3
##
import os
import sys

BLOCKSIZE = 128 * 1000


def rewrite_file(path):
# Get size of file
size = os.path.getsize(path)

# Iterate through file
with open(path, "rb+") as file:
# Iterate through steps of block size
for i in range(0, size, BLOCKSIZE):
# Seek to offset and read
file.seek(i)
a, b = file.read(2)

# Seek back to offset and write
file.seek(i)
file.write(bytes([a, b]))


def main():
rewrite_file(sys.argv[1])


if __name__ == "__main__":
main()

0 comments on commit 2b7509c

Please sign in to comment.