Skip to content

Instantly share code, notes, and snippets.

View Sanghyun-Hong's full-sized avatar

Sanghyun Hong Sanghyun-Hong

View GitHub Profile
@Sanghyun-Hong
Sanghyun-Hong / iptables.sh
Created July 8, 2016 15:43 — forked from thomasfr/iptables.sh
iptable rules to allow outgoing DNS lookups, outgoing icmp (ping) requests, outgoing connections to configured package servers, outgoing connections to all ips on port 22, all incoming connections to port 22, 80 and 443 and everything on localhost
#!/bin/bash
IPT="/sbin/iptables"
# Server IP
SERVER_IP="$(ip addr show eth0 | grep 'inet ' | cut -f2 | awk '{ print $2}')"
# Your DNS servers you use: cat /etc/resolv.conf
DNS_SERVER="8.8.4.4 8.8.8.8"
# Allow connections to this package servers
#!/bin/bash
#
# Flush iptables
#
iptables -F
#
# Allow SSH, HTTP, HTTPS
#
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
#!/bin/sh
#toriptables.sh
# I learned this from https://wiki.torproject.org/noreply/TheOnionRouter/TransparentProxy
#Reject all ICMP packets because they have no owner which creates a leak
iptables -A OUTPUT -p icmp -j REJECT
#All traffic for the user root will go through tor
iptables -t nat -A OUTPUT ! -o lo -p tcp -m owner --uid-owner root -m tcp -j REDIRECT --to-ports 9040
iptables -t nat -A OUTPUT ! -o lo -p udp -m owner --uid-owner root -m udp --dport 53 -j REDIRECT --to-ports 53
#!/bin/sh
# Réinitialise les règles
iptables -t filter -F
iptables -t filter -X
# Bloque tout le trafic
iptables -t filter -P INPUT DROP
iptables -t filter -P FORWARD DROP
iptables -t filter -P OUTPUT DROP
#!/bin/sh
IF=eth0
iptables -F
iptables -t nat -F
iptables -X
iptables -Z
# drop all packets by default
#!/usr/bin/env python
# SLLabs.com vif hotplug script
# Copyright (C) 2013 SLLabs.com <support@sllabs.com>
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
# Written in 2013 for Kamilion@SLLabs.com by ircs://irc.ospnet.org/#sllabs residents
# "If you have an apple and I have an apple and we exchange these apples
# then you and I will still each have one apple.
@Sanghyun-Hong
Sanghyun-Hong / vif-bridge.sh
Created July 17, 2016 21:34 — forked from mmoya/vif-bridge.sh
vif-bridge with ebtables
#!/bin/bash
#============================================================================
# ${XEN_SCRIPT_DIR}/vif-bridge
#
# Script for configuring a vif in bridged mode.
# The hotplugging system will call this script if it is specified either in
# the device configuration given to Xend, or the default Xend configuration
# in ${XEN_CONFIG_DIR}/xend-config.sxp. If the script is specified in
# neither of those places, then this script is the default.
#

Testing of Xen vPMU filter options.

Three tests are executed on a simple program (noploop, which runs NOP in a loop). The first two show Linux "perf stat" summaries, and the third tests specific counters: the IPC ones, an architectural one, and a few extras. Which of these will work depends on the filter mode.

I'll begin by showing off and on, the current modes, and then the new modes: ipc and arch.

vpmu=off (default)

root@lgud-bgregg:~> xl dmesg | grep vpmu
#!/usr/bin/sh
#
# intelcpi - measure CPI and utilization on Intel processors.
#
# USAGE: intelcpi [interval]
# eg,
# intelcpi 0.1 # for 0.1 second intervals
#
# CPI shows how memory intensive CPU workloads are.
#
/*
* memprofiletest
*
* USAGE: ./memprofiletest size_kb
*
* eg, ./memprofiletest 10240 # make larger than LLC cache for misses
*/
#include <stdio.h>
#include <stdlib.h>