Skip to content

Instantly share code, notes, and snippets.

@dmiedema
dmiedema / NotAGoodFileName.md
Created January 2, 2014 19:59
Modifications i had to make to fail2ban to have it ban failed imap dovecot logins on Debian

I was having issues with fail2ban not catching invalid dovecot login attempts because for whatever reason invalid login attempts we're going into the mail.log. So, here is what I changed to get it to work.

In /var/log/auth.log the failed dovecot login attempts look like

Jan 2 19:41:14 shittie auth: pam_unix(dovecot:auth): authentication failure; logname= uid=0 euid=0 tty=dovecot ruser=derp rhost=10.0.0.1

Awesome, failed attempt. However, the dovecot filter in fail2ban (v0.8.6) for dovecot wasn't catching failed attempts even when I switched it to look at /var/log/auth.log instead of /var/log/mail.log.

so, all I did was open up /etc/fail2ban/filter.d/dovecot.conf and replace the failregex line with

@dmiedema
dmiedema / DMMacroManifest
Last active December 29, 2015 23:59
Objective C Macro-Manifest I want to keep around
#define DM_rgba(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define DM_rgb(r,g,b) DM_rgba(r, g, b, 1.0f)
#define DM_isIPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define DM_isIPhone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define DM_isIPhone5 ([[UIScreen mainScreen] bounds].size.height == 568)
@dmiedema
dmiedema / Podfile
Last active December 26, 2015 00:09
Saving my Podfile structure for adding the Acknowledgements.plist generated by cocoa pods into my Settings.bundle, soon to be part of my default app template.
platform :ios '7.0'
# Put pods here...
# Automatically put the acknowledgements in the Settings.bundle
post_install do | installer |
require 'fileutils'
FileUtils.cp_r('Pods/Pods-acknowledgements.plist', File.basename(Dir.getwd) << '/Settings.bundle/Acknowledgements.plist', : remove_destination => true)
end
@dmiedema
dmiedema / authlog.py
Last active December 23, 2015 05:59
Searches auth.log for failed logins and adds them to hosts.deny. Probably a terrible way to do it, and it's potentially a massive failure. But i'm sick of fail2ban not banning
#!/usr/bin/env python
authlog=open('/var/log/auth.log','r')
lines = []
for line in authlog:
lines.append(line)
authlog.close()
@dmiedema
dmiedema / parser
Created March 31, 2013 01:23
PHP fixed size file parser. Designed to take a huge file and break it down into a bunch of smaller ones
<?php
$file = fopen($argv[1], "r");
$output = $argv[2];
$count= 0;
if ($file) {
while(!feof($file)) {
$buffer = fgets($file, 10240);
@dmiedema
dmiedema / bashwrapper.sh
Created March 23, 2013 21:06
A python script to parse the IP assignment/allotment list from Arin ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest as well as a bash wrapper designed to wrap the python script enabling different options. It creates a lot of unnecessary lines that could be combined when determining the subnet type. I haven't fixed that yet so in its curr…
#!/bin/bash
# Set up some default values in case options aren't specified.
DEFAULTDOWNLOADFILE="arin-current-ip-download.txt"
DEFAULTOUTPUTFILE="formatted-ips.txt"
DEFAULTDOWNLOADURL="ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest"
DEFAULTOUTPUTFILETYPE="txt" # this doesn't do anything yet, but this flag could determine other scripts to be called if warranted.
VERBOSE=0
cmd(){ echo `basename $0`; }
# usage. Self explanitory I feel. Just shows you how to use the script.