Created
September 14, 2016 08:49
-
-
Save Mrmaxmeier/8edec4826e219e24031c1f40896ee9d2 to your computer and use it in GitHub Desktop.
payload_info generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import hashlib | |
from functools import partial | |
def md5sum(filename): | |
with open(filename, mode='rb') as f: | |
d = hashlib.md5() | |
for buf in iter(partial(f.read, 128), b''): | |
d.update(buf) | |
return d.hexdigest() | |
files = [] | |
for root, subdirs, files_in_dir in os.walk(".", topdown=True, followlinks=False): | |
for file in files_in_dir: | |
if file.startswith('.') or file == 'payload_info': continue | |
files.append(os.path.join(root, file)) | |
# write the file count, whether this is a 'full' payload, and finally the files | |
payloadStr = "{}\n1\n".format(len(files)) | |
for file in files: | |
payloadStr += "{} {}\n".format(file.strip("./"), md5sum(file)) | |
print("writing", len(files), "files to payload_info..") | |
with open('payload_info', 'w') as f: | |
f.write(payloadStr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment