Skip to content

Instantly share code, notes, and snippets.

@tchn
tchn / gist:1285093
Last active September 27, 2015 14:37
py func code snippet
def select_entry(seq, question):
for entry in seq:
print '%d) %s' % ((1 + seq.index(entry)), entry)
return input(question) - 1
def remove_duplicate(seq):
seen = set()
seen_add = seen.add
return [x for x in seq if x not in seen and not seen_add(x)]
@tchn
tchn / ipfw
Created December 8, 2011 11:27
ipfw
MBP OSX 10.5 (en0: WAN, en1:WiFi <- iPhone4のデフォゲさま)
Thinkpad x200s (wlan1: APさま、dnsmasqさま
iPhone4 (WiFi)
コマンド @MBP
# sysctl -w net.inet.ip.forwarding=1
# natd -interface en0
# ipfw -f flush
# ipfw add divert natd all from any to any via en0
# ipfw add 99 forward 127.0.0.1,8080 tcp from any to any 80 in
@tchn
tchn / list_private_apps.sh
Created June 12, 2012 14:15
shell script to tell if an android application is publicly available on googleplay
#!/bin/sh -e
set -o nounset
PLAY_URL="https://play.google.com/store/apps/details?id="
ret="private_app_list.txt"
if ! [ $# -eq 1 ]; then
echo "Error: appname not provided!";
exit
fi
@tchn
tchn / p12topem
Created January 13, 2013 03:14
generate PEM (1) client cert (2) ca cert (3) private key file from PKCS12 client cert, to be used by wget and other commandline http client.
#!/bin/sh
yourp12="$1"
clcert="${yourp12}-clcert.pem"
cacert="${yourp12}-cacert.pem"
keyfile="${yourp12}-key.pem"
echo -n "Type passphrase: "
read -s passwd
@tchn
tchn / runburp.sh
Last active December 12, 2015 02:08
#!/bin/bash
# Usage: burpsuite [ extension_in_full_path [xtension [...] ]
set -o nounset
set -x
showusage() {
echo "Usage: runburp.sh [ extension_in_full_path [...] ]"
}
burpdir="/opt/lib/burp";
@tchn
tchn / pull.sh
Last active December 12, 2015 02:39
[android] private-app-keeper adb-pull apks not on the goolgle-play
#!/bin/bash
#
# 1. package list -> list private apps
# 2. private app list -> private app path list
# 3. pull all
# Usage: $0 <destdir>
set -o nounset
set -x
@tchn
tchn / Web-Sorrow_v.1.5.0_basic-auth.patch
Last active December 14, 2015 22:19
patch for We-Sorrow to support basic auth request
diff -rupN Wsorrow.orig/Wsorrow.pl Wsorrow/Wsorrow.pl
--- Wsorrow.orig/Wsorrow.pl 2013-02-15 16:41:18.000000000 +0900
+++ Wsorrow/Wsorrow.pl 2013-03-14 01:41:48.240744685 +0900
@@ -27,6 +27,7 @@ BEGIN { # it seems to load faster. plus
use LWP::ConnCache;
use HTTP::Request;
use HTTP::Response;
+ use MIME::Base64;
use Getopt::Long qw( GetOptions );
use Socket qw( inet_aton );
@tchn
tchn / gist:5316472
Last active December 15, 2015 20:09
Taglist.vim を Objective-C 対応させる
$ git clone https://github.com/pebble8888/ctags-objc-ja
$ cd ctags-objc-ja
$ autoconf
$ ./configure
$ make
$ cp ctags /opt/bin
$ sudo update-alternatives --install /usr/bin/ctags ctags /opt/bin/ctags 1065
$ cp $VIMRUNTIME/filetype.vim ~/.vim
@tchn
tchn / gist:5353528
Created April 10, 2013 10:31
bitcasa for linux のページの perl
https://www.bitcasa.com/download-linux
perl -e '$h="5261776264206775722076617376617667722065726663626166766879642";
$h=~y/48/cf/;$_=pack("H*","${h}e0a");@a=split//,"/-35753=?=357"x2;
s.([a-zA-Z]).ord$1<97?uc($1^$a[ord($1)-65]):lc($1^$a[ord($1)-97]).ge;print'
は、
#!/bin/env python
import binascii
@tchn
tchn / m2crypt.py
Created May 8, 2013 13:35
A python m2crypto usage example, simply encrypt/decrypting AES-128/ECB
#!/bin/env python
# m2crypt.py <mode> <key> <data>
import M2Crypto
import binascii
import sys
mode = sys.argv[1]
key = sys.argv[2]
data = sys.argv[3]