Skip to content

Instantly share code, notes, and snippets.

View pichuang's full-sized avatar

Phil Huang pichuang

View GitHub Profile
@pichuang
pichuang / Pingall_flood.py
Created March 13, 2014 18:08
Pingall_flood
#!/usr/bin/env python
import httplib
import json
class StaticFlowPusher(object):
def __init__(self, server):
self.server = server
def get(self, data):
@pichuang
pichuang / set_netflow
Last active August 29, 2015 14:00
set netflow config
#!/bin/bash
BRIDGE_NAME=
COLLECTOR_IP=
COLLECTOR_PORT=
TIMEOUT=10
ovs-vsctl -- set Bridge ${BRIDGE_NAME} netflow=@nf \
-- --id=@nf create NetFlow target=\"${COLLECTOR_IP}:${COLLECTOR_PORT}\" active-timeout=${TIMEOUT}
@pichuang
pichuang / set_sflow
Created April 26, 2014 21:52
set ovs-sflow config
#/bin/bash
COLLECTOR_IP=
COLLECTOR_PORT=
AGENT=
HEADER=128
SAMPLING=512
POLLING=10
BRIDGE_NAME=
sudo ovs-vsctl -- --id=@sflow create sflow agent=${AGENT} \
@pichuang
pichuang / netsec2014_project2.py
Last active August 29, 2015 14:01
netsec2014 Project 2
#!/usr/bin/python
"""
Follow http://danmcinerney.org/http-post-analyzer-in-python/
Enviroment: python2.x and scapy
Goal: Use scapy to sniffer tcp 80 port
"""
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
@pichuang
pichuang / CustomTopo.py
Created June 9, 2014 01:43
Programming Assignment 2: Using Mininet and Mininet Python API
#!/usr/bin/env python
'''
Coursera:
- Software Defined Networking (SDN) course
-- Programming Assignment 2
Professor: Nick Feamster
Teaching Assistant: Arpit Gupta, Muhammad Shahbaz
'''
@pichuang
pichuang / oom_killer_score.sh
Created June 10, 2014 13:44
Display oom_killer all process oom_score
#!/bin/bash
for proc in $(find /proc -maxdepth 1 -regex '/proc/[0-9]+'); do
printf "%2d %5d %s\n" \
"$(cat $proc/oom_score)" \
"$(basename $proc)" \
"$(cat $proc/cmdline | tr '\0' ' ' | head -c 50)"
done 2>/dev/null | sort -nr | head -n 10
@pichuang
pichuang / Support_auto_mysql_secure_installation.patch
Last active August 29, 2015 14:02
auto_mysql_secure_installation.patch
# Maintainer: Roan Huang <pichuang@cs.nctu.edu.tw>
Automating mysql_secure_installation
In this patch, MySQL default password is "ARCHLNMP"
default password is NOT safe to your system, Please use
/usr/bin/mysqladmin -u root -p'ARCHLNMP' password 'YOUR_NEW_PASSWORD'
@pichuang
pichuang / auto_ssh_agent
Created June 12, 2014 14:06
Auto load ssh_key
#Auto load ssh_key & ssh-agent
#Add ~/.bashrc
if [ -z "$SSH_AUTH_SOCK" ] ; then
eval `ssh-agent -s` > /dev/null 2>&1
ls ~/.ssh/ |grep -vE '(.pub|authorized_keys|known_hosts)'| xargs -i ssh-add ~/.ssh/{} > /dev/null 2>&1
fi
@pichuang
pichuang / python_switch
Created June 29, 2014 00:54
python2 python3 switch for archlinux or others
#!/bin/bash
VERSION=$1
if [ "python2" == "$VERSION" ] || [ "python3" == "$VERSION" ]
then
cd /usr/bin/
ln -sfn $VERSION python
echo "switch to $VERSION"
else
@pichuang
pichuang / openwrt-add-libatomic.patch
Created July 1, 2014 08:48
OpenWrt Support libatomic patch
#Signed-off-by: Tobias Steinicke <tobias.steinicke at inet.tu-berlin.de>
#https://lists.openwrt.org/pipermail/openwrt-devel/2014-March/024286.html
--- a/package/libs/toolchain/Makefile 2014-07-01 16:33:40.734903000 +0800
+++ b/package/libs/toolchain/Makefile 2014-07-01 15:02:10.730903000 +0800
@@ -52,6 +52,31 @@
endmenu
endef
+define Package/libatomic