Skip to content

Instantly share code, notes, and snippets.

@Mrmaxmeier
Created September 14, 2016 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mrmaxmeier/8edec4826e219e24031c1f40896ee9d2 to your computer and use it in GitHub Desktop.
Save Mrmaxmeier/8edec4826e219e24031c1f40896ee9d2 to your computer and use it in GitHub Desktop.
payload_info generator
#!/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