Skip to content

Instantly share code, notes, and snippets.

@Svenito
Created April 25, 2014 14:24
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 Svenito/d28572d6c9a4c1a1b603 to your computer and use it in GitHub Desktop.
Save Svenito/d28572d6c9a4c1a1b603 to your computer and use it in GitHub Desktop.
Egg 0x0e
#!/usr/bin/env python
import base64
import re
import urllib
import codecs
import binascii
def decode(text):
m = re.match("^\[(\d+):(\w+)\](.+)", text)
if not m:
return text
level = m.group(1)
enc = m.group(2)
payload = m.group(3)
print level, enc
if enc == "b64":
result = base64.b64decode(payload)
elif enc == 'b32':
result = base64.b32decode(payload)
elif enc == 'inv':
result = payload.swapcase()
elif enc == 'url':
result = urllib.unquote(payload)
elif enc == 'nop':
result = payload
elif enc == 'r13':
result = codecs.decode(payload, 'rot_13')
elif enc == 'xxx':
result = re.match('xxx(.+)xxx', payload).group(1)
elif enc == 'rev':
result = payload[::-1]
elif enc == 'hex':
result = binascii.unhexlify(payload)
else:
return payload
return decode(result)
if __name__ == "__main__":
fh = open("source.txt")
source = fh.read()
fh.close()
a = decode(source)
print a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment