Skip to content

Instantly share code, notes, and snippets.

@hcooper
hcooper / syslog_convert.py
Created October 19, 2012 16:58
syslog priority converter
# Convert encoded syslog values into human-friendly facility and level names
severity_map = {
0: 'emergency', 1: 'alert', 2: 'critical', 3: 'error',
4: 'warning', 5: 'notice', 6: 'informational', 7: 'debug'
}
facility_map = {
0: 'kernel', 1: 'user', 2: 'mail', 3: 'daemon',
4: 'auth', 5: 'syslog', 6: 'lpr', 7: 'news', 8: 'uucp',
@hcooper
hcooper / pound_sslv2_compression.patch
Created October 8, 2012 11:03
Disable SSLv2 and SSL Compression support in Pound.
--- config.c.orig 2012-10-05 14:57:53.000000000 +0100
+++ config.c 2012-10-08 10:29:55.523951240 +0100
@@ -1136,6 +1136,13 @@
SSL_CTX_set_app_data(pc->ctx, res);
SSL_CTX_set_mode(pc->ctx, SSL_MODE_AUTO_RETRY);
SSL_CTX_set_options(pc->ctx, ssl_op_enable);
+
+ /* Disable compression and SSLv2 support
+ * this code isn't very portable as it presumes your OpenSSL version
+ * supports both these options, when many older versions don't. */
@hcooper
hcooper / random-password.php
Created September 19, 2012 20:23
PHP script to generate random passwords via apg
<?php
/* PHP script using apg to generate random passwords
*
* Requires: apg
* Suggested: rng-tools (to keep entropy high)
*
* Stick this in your apache/htaccess to support custom lengths
* via domain.com/12
*
@hcooper
hcooper / xinetd_remove_only_from.sh
Created September 14, 2012 08:48
Remove any access restrictions for xinetd services
## Remove any access restrictions for xinetd services
# Our list of services
SERVICES="nrpe check_mk"
# $RUN determines is we need to do a restart afterwards
RUN=0
for service in $SERVICES; do
@hcooper
hcooper / savenetconfig.sh
Created September 14, 2012 08:42
Saving running network config to sysconfig
#!/bin/bash
# Hack to quickly save the running network config to sysconfig
DEV=eth0
IPDATA=`ip addr show dev $DEV | tr -s " " | grep -m 1 inet | cut -d " " -f 3`
IP=`echo $IPDATA | cut -d "/" -f 1`
NM=`echo $IPDATA | cut -d "/" -f 2`
MAC=`ip addr show dev $DEV | tr -s " " | grep 'link/ether' | cut -d " " -f 3`
@hcooper
hcooper / ciphertest.sh
Created September 6, 2012 11:09
Report what ciphers are support by a given host (using openssl)
#!/usr/bin/env bash
# ciphertest.sh
# Hereward Cooper <[email protected]> - 6th Sept 2012
# Report what ciphers are support by a given host
# Modifed from code found here: http://superuser.com/questions/109213/
# Do we want to pause between each cipher?
DELAY=0
@hcooper
hcooper / proxy.py
Created November 9, 2011 19:36
A simple threaded caching HTTP proxy
#!/usr/bin/python
"""
A simple threaded caching HTTP proxy.
Hereward Cooper <[email protected]>
v0.1
"""
LISTENPORT = 8000
LISTENINT = '127.0.0.1'
@hcooper
hcooper / gist:1267869
Created October 6, 2011 16:30
check_mk tcp check
moved into my main check_mk plugin repo...
@hcooper
hcooper / check_mk_sun_hw_windows.bat
Created October 4, 2011 14:08
check_mk script to query Sun Hardware alerts via IPMI on Windows (2003)
moved into main check_mk plugin repo....
@hcooper
hcooper / mysql_rep.sh
Created June 16, 2011 19:16
A mysql replication plugin for the check_mk nagios system
moved into my main check_mk plugin repo...