fork(1) download
  1. import types
  2. def function():
  3. # Get bools
  4. none=None;N,o,n,e=`none`
  5. false=none>none;F,a,l,s,e=`false`
  6. true=not false;T,r,u,e=`true`
  7.  
  8. # Get chars from the string '__builtins__'
  9. # Without exec ... in ... I only managed to get the chars
  10. # aefilnorstuFLNT0123456789{}[](),:."'\-+ - which was
  11. # *just* not enough to do what we need
  12. env = {}
  13. exec `none` in env
  14. _,_,b,u,i,l,t,i,n,s,_,_=[x for x in env][false]
  15.  
  16. n0=+false;n1=+true;n2=n1+n1 # 0,1,2
  17. s,e,t,lp,lb,c0,com,sp,c1,rb,rp=`{n0,n1}` # set([0, 1])
  18. qu,dqu,bsl,qu,c0,bsl,qu,dqu,qu=````n0```` # '"\'0\'"'
  19.  
  20. m1=n0-n1;half=n2**m1;c0,dot,c5=`half` # 0.5 = 2**(-1)
  21. n4f=n2/half;big=n4f**n4f**n4f
  22. inf=big*big;i,n,f=`inf` # inf = float infinity
  23.  
  24. env = {}
  25. # [a for a in[''.title]], using list comp to assign since we don't have =
  26. code = lb+a+sp+f+o+r+sp+a+sp+i+n+lb+qu+qu+dot+t+i+t+l+e+rb+rb
  27. exec code in env
  28.  
  29. title=env[a]
  30. # <built-in method title of str object at 0x...>
  31. # Length of address might depend on your system - modify underscores as necessary
  32. try:
  33. (lt,b,u,i,l,t,mi,i,n,sp,m,e,t,h,o,d,sp,t,i,t,l,e,sp,o,f,sp,s,t,r,sp,o,b,j,e,c,t
  34. ,sp,a,t,sp,c0,x,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,gt) = `title`
  35. except:
  36. (lt,b,u,i,l,t,mi,i,n,sp,m,e,t,h,o,d,sp,t,i,t,l,e,sp,o,f,sp,s,t,r,sp,o,b,j,e,c,t
  37. ,sp,a,t,sp,c0,x,__,__,__,__,__,__,__,__,gt) = `title`
  38.  
  39. env = {}
  40. # [b for b in[[a for a in().__class__.__bases__[0].__subclasses__()if'catc'in a.__name__][0]()._module.__builtins__]]
  41. code = lb+b+sp+f+o+r+sp+b+sp+i+n+lb+lb+a+sp+f+o+r+sp+a+sp+i+n+lp+rp+dot+_+_+c+l+a+s+s+_
  42. code += _+dot+_+_+b+a+s+e+s+_+_+lb+c0+rb+dot+_+_+s+u+b+c+l+a+s+s+e+s+_+_+lp+rp+i+f+qu
  43. code += c+a+t+c+qu+i+n+sp+a+dot+_+_+n+a+m+e+_+_+rb+lb+c0+rb+lp+rp+dot+_+m+o+d+u+l+e
  44. code += dot+_+_+b+u+i+l+t+i+n+s+_+_+rb+rb
  45. exec code in env
  46.  
  47. __builtins__ = env[b]
  48. # Grab g from range
  49. range=[x for x in __builtins__ if r+a+n<x<r+a+o][n0];r,a,n,g,e=range
  50.  
  51. # Now we can use __builtins__ in exec
  52. env = {_+_+b+u+i+l+t+i+n+s+_+_: __builtins__}
  53.  
  54. # [chr(c)for c in range(97,123)]
  55. c1,c2,c3,c7,c9=`n1`,`n2`,`n2+n1`,`n2+n2+n2+n1`,`n2+n2+n2+n2+n1`
  56. code = lb+a+sp+f+o+r+sp+a+sp+i+n+lb+qu+qu+dot+j+o+i+n+lp+c+h+r+lp+c+rp+f+o+r+sp+c
  57. code += sp+i+n+sp+r+a+n+g+e+lp+c9+c7+com+c1+c2+c3+rp+rp+rb+rb
  58. exec code in env
  59. a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z = env[a]
  60.  
  61. # exec raw_input() - do whatever we want now
  62. code = e+x+e+c+sp+r+a+w+_+i+n+p+u+t+lp+rp
  63. exec code in env
  64.  
  65. pass
  66.  
  67. c = function.__code__
  68. code = types.CodeType(0,
  69. c.co_nlocals,
  70. c.co_stacksize,
  71. c.co_flags,
  72. c.co_code,
  73. (None,)*len(c.co_consts),
  74. (),
  75. (),
  76. "filename",
  77. "funcname",
  78. 1,
  79. "")
  80.  
  81. func = types.FunctionType(code, {})
  82. func()
Success #stdin #stdout 0.01s 9016KB
stdin
print "Flag captured!"; n = 59; print all(n%d > 0 for d in range(2, n))
stdout
Flag captured!
True