-
Notifications
You must be signed in to change notification settings - Fork 2
/
docx.py
30 lines (24 loc) · 805 Bytes
/
docx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from os import path
import os
import argparse
import zipfile
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--file", "-f", type=str, required=True)
args = parser.parse_args()
try:
if path.exists(args.file):
os.rename(args.file, 'temp.zip')
orgf = args.file
with zipfile.ZipFile('temp.zip', 'r') as zip_ref:
zip_ref.extractall("temp")
tokenfile = os.path.join(os.getcwd(), ".\\temp\\word\\footer2.xml")
print(tokenfile)
with open(tokenfile) as f:
if "canary" in f.read():
print("Canarytoken detected")
os.rename("temp.zip", orgf)
except OSError:
print("error")
if __name__ == "__main__":
main()