Skip to content

Instantly share code, notes, and snippets.

View jvehent's full-sized avatar

Julien Vehent jvehent

View GitHub Profile
@jvehent
jvehent / crazyperl.pl
Created September 18, 2011 16:57
99 bottles of beer
''=~( '(?{' .('`' |'%') .('[' ^'-')
.('`' |'!') .('`' |',') .'"'. '\\$'
.'==' .('[' ^'+') .('`' |'/') .('['
^'+') .'||' .(';' &'=') .(';' &'=')
.';-' .'-'. '\\$' .'=;' .('[' ^'(')
.('[' ^'.') .('`' |'"') .('!' ^'+')
.'_\\{' .'(\\$' .';=('. '\\$=|' ."\|".( '`'^'.'
).(('`')| '/').').' .'\\"'.+( '{'^'['). ('`'|'"') .('`'|'/'
).('['^'/') .('['^'/'). ('`'|',').( '`'|('%')). '\\".\\"'.( '['^('(')).
'\\"'.('['^ '#').'!!--' .'\\$=.\\"' .('{'^'['). ('`'|'/').( '`'|"\&").(
# default foreground color (%N) - -1 is the "default terminal color"
default_color = "-1";
# print timestamp/servertag at the end of line, not at beginning
info_eol = "false";
# these characters are automatically replaced with specified color
# (dark grey by default)
replaces = { "[]=" = "%K$*%n"; };
@jvehent
jvehent / htb_collect.pl
Created November 2, 2011 16:41
rrds::create with unknown list of datasources
# define a list of HTB classes to check
# the order matters, because of the RRD database
my @class_list=(100,200,300,400,999);
[..... truncated .... ]
my $datasources = "";
for my $class (0 .. $#class_list){
$datasources .= "DS:$class_list[$class]:$storage_type:". $updatefreq * 10 .":0:U";
# SSH class: for outgoing connections to
# avoid lag when somebody else is downloading
# however, an SSH connection cannot fill up
# the connection to more than 70%
echo "#---ssh - id 300 - rate 160 kbit ceil 1120 kbit"
/sbin/tc class add dev eth0 parent 1:1 classid 1:300 htb \
rate 160kbit ceil 1120kbit burst 15k prio 3
# SFQ will mix the packets if there are several
@jvehent
jvehent / gist:1629798
Created January 17, 2012 23:40
check-rbl.sh
#!/usr/bin/env bash
DEBUG="$1"
SRV="smtp.example.net smtp2.example.net smtp.example.com"
# RBL list from http://www.anti-abuse.org/multi-rbl-check/
RBL="bl.spamcop.net cbl.abuseat.org b.barracudacentral.org dnsbl.invaluement.com ddnsbl.internetdefensesystems.com dnsbl.sorbs.net http.dnsbl.sorbs.net dul.dnsbl.sorbs.net misc.dnsbl.sorbs.net smtp.dnsbl.sorbs.net socks.dnsbl.sorbs.net spam.dnsbl.sorbs.net web.dnsbl.sorbs.net zombie.dnsbl.sorbs.net dnsbl-1.uceprotect.net dnsbl-2.uceprotect.net dnsbl-3.uceprotect.net pbl.spamhaus.org sbl.spamhaus.org xbl.spamhaus.org zen.spamhaus.org bl.spamcannibal.org psbl.surriel.com ubl.unsubscore.com dnsbl.njabl.org combined.njabl.org rbl.spamlab.com dnsbl.ahbl.org ircbl.ahbl.org dyna.spamrats.com noptr.spamrats.com spam.spamrats.com cbl.anti-spam.org.cn cdl.anti-spam.org.cn dnsbl.inps.de drone.abuse.ch httpbl.abuse.ch dul.ru korea.services.net short.rbl.jp virus.rbl.jp spamrbl.imp.ch wormrbl.imp.ch virbl.bit.nl rbl.suresupport.com dsn.rfc-ignorant.org ips.backscatterer.org sp
@jvehent
jvehent / zipfile.py
Created February 29, 2012 15:55
python zip error
# iterate through the list on messages
for number in message_number[0].split():
# fetch the current message
typ, data = connection.fetch(number, '(RFC822)')
# parse the email
message = email.message_from_string(data[0][1])
# for each attachment
$ grep 'include_recipe "nginx' cookbooks/ -R
cookbooks/python-webserver/recipes/default.rb:include_recipe "nginx"
chef > result = search(:node, "recipes:python-webserver").map {|n| n.fqdn}
=> ["pythonwebserver1.local.vm"]
chef > result = search(:node, "recipes:nginx").map {|n| n.fqdn}
=> []
@jvehent
jvehent / gist:2406497
Created April 17, 2012 14:53
password manager with openssl
# To create a new credential file, use:
echo "credential file created on $(date +%Y%m%d)" |openssl aes-256-ecb -e -a -salt -out credential_file.encrypted
# =======================================
#!/usr/bin/env bash
# --- getpassword.sh
# opens the credential file and display it in the terminal
:/lib/udev/devices# tree -alfpugh
.
├── [crw------- root root 0] ./console
├── [lrwxrwxrwx root root 11] ./core -> /proc/kcore
├── [lrwxrwxrwx root root 13] ./fd -> /proc/self/fd
│   ├── [lrwx------ root root 64] /proc/self/fd/0 -> /dev/pts/0
│   ├── [lrwx------ root root 64] /proc/self/fd/1 -> /dev/pts/0
│   ├── [lrwx------ root root 64] /proc/self/fd/2 -> /dev/pts/0
│   └── [lr-x------ root root 64] /proc/self/fd/3 -> /proc/3611/fd [recursive, not followed]
├── [brw------- root root 0] ./loop0
@jvehent
jvehent / conntrack_parse_webforms.py
Created June 9, 2012 15:06
conntrack_parse_webforms.py
#!/usr/bin/env python
from collections import defaultdict
import sys
import datetime
counters = defaultdict(int)
entries = 0
show_progress = 0
print