Skip to content

Commit

Permalink
Added new flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
b4cktr4ck2 authored Feb 21, 2019
1 parent 77b78fa commit 5923dc9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions shellcode-cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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(' ', '')
Expand Down Expand Up @@ -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

0 comments on commit 5923dc9

Please sign in to comment.