#!/usr/bin/python import sys import os if len(sys.argv) < 2: sys.exit("Target file not specified") f = open(sys.argv[1],"r+b") f.seek(0,os.SEEK_END) marker = "avcC"+chr(1) mlen = len(marker) sys.stdout.write("Searching"); found = 0 while found==0: if(f.tell()%50000==0): sys.stdout.write(".") sys.stdout.flush() f.seek(-mlen-1,os.SEEK_CUR) s=f.read(mlen) if s==marker: found=1 elif f.tell()==mlen: f.close() sys.exit("\nCould not find file marker") f.seek(2,os.SEEK_CUR) f.write(chr(0x1F)) print "\nFile successfully patched" f.close()