Created
May 6, 2018 07:13
-
-
Save xinali/cc4e6b0655d09b773e957cb40da5b50a to your computer and use it in GitHub Desktop.
Handle Payloads
This file contains hidden or 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
#encoding:utf-8 | |
import sys | |
from pwnlib.util.cyclic import cyclic, cyclic_find | |
def usage(): | |
print """ | |
==================================================== | |
[*] python payloads.py s/g arg" | |
example: | |
generate: python payloads.py g 1000 | |
search: python payloads.py s abcd | |
search: python payloads.py s 41414241 | |
==================================================== | |
""" | |
if __name__ == "__main__": | |
if len(sys.argv) < 2: | |
usage() | |
sys.exit(1) | |
op = sys.argv[1] | |
try: | |
if op == 'g': | |
gen_len = sys.argv[2] | |
print cyclic(int(gen_len)) | |
elif op == 's': | |
search_ch = sys.argv[2] | |
if len(sys.argv[2]) > 4: | |
hex_ch = search_ch.decode('hex')[::-1] | |
print hex_ch | |
print cyclic_find(hex_ch) | |
else: | |
print cyclic_find(search_ch) | |
except Exception as ex: | |
print ex | |
usage() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment