Skip to content

Instantly share code, notes, and snippets.

@zhuzhuor
Created July 17, 2012 23:34
Show Gist options
  • Save zhuzhuor/3132921 to your computer and use it in GitHub Desktop.
Save zhuzhuor/3132921 to your computer and use it in GitHub Desktop.
An obfuscated RC4 keystream generator, made for AppFog OpenStack Birthday Contest
#!/usr/bin/env python
__copyright__ = "Copyright (C) 2012 Bo Zhu http://zhuzhu.org"
def ARC4(OOO4):
"""A fully functional RC4 keystream generator"""
O400,O4O0,O40O,O4OO=range(0400),0000,0000,0000
for OO04 in range(0400):O4O0=(O4O0+O400[OO04]+OOO4[OO04%len(OOO4)])%0400;O400[O4O0],O400[OO04]=O400[OO04],O400[O4O0]
while-1:O40O=(O40O+0001)%0400;O4OO=(O4OO+O400[O40O])%0400;O400[O40O],O400[O4OO]=O400[O4OO],O400[O40O];yield O400[(O400[O40O]+O400[O4OO])%0400]
from flask import Flask, make_response
application = app = Flask('wsgi')
@app.route('/')
def index():
g = ARC4([0004])
d = (0xa9, 0x46, 0x44, 0x7f, 0x06, 0x24, 0xed, 0xae,
0xbb, 0x1f, 0xe0, 0x99, 0x37, 0x1f, 0x84, 0x69,
0x46, 0xe9, 0xb9, 0xbe, 0xe7, 0x28, 0x06, 0x05)
text = ''.join(chr(g.next() ^ i) for i in d)
resp = make_response(text)
resp.headers['Content-Type'] = 'text/plain'
return resp
@app.route('/src')
def source():
with open('wsgi.py') as f:
text = f.read()
resp = make_response(text)
resp.headers['Content-Type'] = 'text/plain'
return resp
if __name__ == '__main__':
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment