Skip to content

Instantly share code, notes, and snippets.

@tomoconnor
tomoconnor / munin.conf
Created February 6, 2011 22:33
Example munin.conf
# The next three variables specifies where the location of the RRD
# databases, the HTML output, and the logs, severally. They all
# must be writable by the user running munin-cron.
dbdir /var/lib/munin
htmldir /var/www/munin
logdir /var/log/munin
rundir /var/run/munin
# Where to look for the HTML templates
tmpldir /etc/munin/templates
@tomoconnor
tomoconnor / munin-node.conf
Created February 6, 2011 22:45
Example Munin-node conf
#
# Example config-file for munin-node
#
log_level 4
log_file /var/log/munin/munin-node.log
pid_file /var/run/munin/munin-node.pid
background 1
setseid 1
@tomoconnor
tomoconnor / tmp_files
Created February 6, 2011 23:17
Very simple example munin plugin
#!/usr/bin/env python
import os
from munin import MuninPlugin
class TmpFileCount(MuninPlugin):
title = "Number of Files in /tmp"
args = "--base 1000 -l 0"
vlabel = "files"
scaled = False
@tomoconnor
tomoconnor / dhcp-event
Created April 20, 2011 17:09
Thingy for updating powerdns backend when stuff changes
#!/usr/bin/env python
import MySQLdb
import os, sys
import pprint
pp = pprint.PrettyPrinter()
mysql_host = "localhost"
mysql_user = "dbusername"
mysql_pass = "dbpassword"
@tomoconnor
tomoconnor / dhcpd.conf
Created April 20, 2011 17:11
snippet to show usage of dhcp-event (don't forget to set apparmor to allowing (complain) mode)
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.200;
option broadcast-address 192.168.0.255;
option routers 192.168.0.1;
on commit {
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
log(concat("Commit: IP: ", ClientIP, " Mac: ", ClientMac, "Hostname: ", host-decl-name));
execute("/usr/local/bin/dhcp-event", "commit", ClientIP, ClientMac, host-decl-name);
}
@tomoconnor
tomoconnor / gist:966745
Created May 11, 2011 16:00
Rewrite Rule to disallow non-cookie authed users
RewriteEngine On
RewriteCond %{HTTP_COOKIE} !^PHPSESSID [NC]
RewriteRule .*/? http://example.org/not-authorized [R]
@tomoconnor
tomoconnor / clientcertificate.sh
Created May 30, 2011 19:32
Create A Client Certificate
#!/bin/bash
# How To Create a client certificate
#As Root
cd /etc/ssl/myca
echo "Enter your username/tag!"
read USERNAME
echo "creating a CSR"
openssl req -config openssl.my.cnf -new -nodes -keyout private/${USERNAME}.key -out csr/${USERNAME}.csr -days 365
echo "Sign the CSR, get a Certificate"
@tomoconnor
tomoconnor / webserver.ssl.vhost.conf
Created May 30, 2011 20:14
Apache Config for SSL x509 Authentication
SSLEngine On
## path to the server signed certificate
SSLCertificateFile /etc/ssl/myca/certs/webserver.crt
## path to the server key
SSLCertificateKeyFile /etc/ssl/myca/private/webserver.key
## path to Root CA signed certificate
SSLCACertificateFile /etc/ssl/myca/certs/myca.crt
root@holborn:~# apt-get install openssl
...
root@holborn:/etc/ssl# ls
certs openssl.cnf private
...
root@holborn:/etc/ssl# mkdir myca
root@holborn:/etc/ssl# cd myca
root@holborn:/etc/ssl/myca# mkdir private certs newcerts crl
@tomoconnor
tomoconnor / password_analysis.py
Created June 19, 2011 23:33
Password Analyser
#!/usr/bin/env python
#
# Fecking ugly thing I wrote to parse lulzsec's password releases
# and display some fairly anonymous data.
# Usage: password_analysis.py <filename to process>
# App expects Email | Password
# Easily modified to fit a file format.
import re
import operator