Skip to content

Instantly share code, notes, and snippets.

@nguyenl95
Forked from kkirsche/base64-to-hex.py
Created November 13, 2019 11:10
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 nguyenl95/5497cc94da7f37b620f6be81a1a366f8 to your computer and use it in GitHub Desktop.
Save nguyenl95/5497cc94da7f37b620f6be81a1a366f8 to your computer and use it in GitHub Desktop.
Decode base64 and convert to hex format, like shellcode
#!/usr/bin/env python
from base64 import b64decode
from urllib import unquote
base64_strs = ['xU5LNJhXeo9B6o4Ri%2FxFHodARXWqgtNufNrYzqG05nGOLNboDgJtkw%3D%3D',
'%2BjAd73J7RAZgLxAUkIG5l0cMPLQEBAtZRMP3WdXr1%2BMYdrg2cZKaow%3D%3D']
for bstr in base64_strs:
unquoted_bstr = unquote(bstr)
data = b64decode(unquoted_bstr)
bl = []
for char in data:
mm = int(char.encode('hex'), 16)
bl.append(hex(mm))
print(' '.join(bl))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment