diff --git a/shellcode-cleaner.py b/shellcode-cleaner.py index 43ae84e..496a274 100644 --- a/shellcode-cleaner.py +++ b/shellcode-cleaner.py @@ -8,7 +8,9 @@ parser.add_argument('-q', action='store_true', help="strip quotation marks (\"\") AND single quotes") parser.add_argument('-x', action='store_true', help="strip (\\x) characters") parser.add_argument('-s', action='store_true', help="strip semicolons (;)") -parser.add_argument('--addhex', action='store_true', help="prepend \"\\x\" to each of the hex bytes. EXPERIMENTAL.") +parser.add_argument('--addhex', action='store_true', help="prepend \"\\x\" to each of the hex bytes.") +parser.add_argument('--unicode', action='store_true', help="prepend a \"%%u\" to each of the hex bytes.") +parser.add_argument('-p', action='store_true', help="prepend a percent \"%%\" to each of the hex bytes. EXPERIMENTAL.") args = parser.parse_args() print "Shellcode (Press Enter then Control+D to submit):" dirty_shellcode = sys.stdin.read() @@ -18,7 +20,9 @@ "q": args.q, "x": args.x, "s": args.s, - "addhex": args.addhex + "addhex": args.addhex, + "unicode": args.unicode, + "p": args.p } #Clean up spacing first clean_shellcode = dirty_shellcode.replace(' ', '') @@ -46,7 +50,17 @@ clean_shellcode = '\\x' + clean_shellcode #Finally, we remove a trailing "\x" that gets added to our stirng. #re.sub(r'\\x$', '', repr(clean_shellcode)) - + elif key == 'unicode' : + clean_shellcode = clean_shellcode.replace('\n', '') + clean_shellcode = '%u'.join([clean_shellcode[i:i+2] for i in range(0, len(clean_shellcode), 2)]) + #For some reason, first hex byte isn't given a "\x" with this method. This will fix that. + clean_shellcode = '%u' + clean_shellcode + elif key == 'p' : + clean_shellcode = clean_shellcode.replace('\n', '') + clean_shellcode = '%'.join([clean_shellcode[i:i+2] for i in range(0, len(clean_shellcode), 2)]) + #For some reason, first hex byte isn't given a "\x" with this method. This will fix that. + clean_shellcode = '%' + clean_shellcode + if default_flag == True: clean_shellcode = dirty_shellcode.replace('\n', '').replace('\r', '').replace('"', '').replace('\\x', '').replace(';', '').replace(' ', '') print clean_shellcode