Skip to content

Instantly share code, notes, and snippets.

@evandhoffman
evandhoffman / parse-secure.pl
Created November 17, 2011 05:24
Parse /var/log/secure for hacking attempts and insert into a SQL DB
#!/usr/bin/perl
#########################################################################
# Parse /var/log/secure for attacks and log the attacks to a database.
# 11/16/2011
# [email protected]
#########################################################################
use strict;
use warnings;
@evandhoffman
evandhoffman / ls.txt
Created October 28, 2011 02:42
Chmod question
[evan@evan-fedora Windows7]$ ls -Flrt
total 18784080
drwxr-xr-x. 3 evan evan 4096 Feb 5 2011 caches/
-rw-------. 1 evan evan 9769058304 Feb 14 2011 Windows 7.vmdk
-rw-r-----. 1 evan evan 28011 Feb 14 2011 Windows 7-Snapshot1.vmsn
-rw-r--r--. 1 evan evan 1641 Feb 14 2011 Windows 7.vmxf
-rw-r--r--. 1 evan evan 303512 Jul 8 15:57 vmware-2.log
-rw-r--r--. 1 evan evan 706853 Jul 8 19:07 vmware-1.log
-rw-r--r--. 1 evan evan 313609 Sep 9 17:28 vmware-0.log
-rw-r-----. 1 evan evan 9464053760 Sep 9 17:41 Windows 7-000001.vmdk
@evandhoffman
evandhoffman / Results.rdf
Created October 27, 2011 19:30
Results.rdf for RT 3.8 that includes Ticket # in the <item> title
%# BEGIN BPS TAGGED BLOCK {{{
%#
%# COPYRIGHT:
%#
%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
%# <[email protected]>
%#
%# (Except where explicitly superseded by other copyright notices)
%#
%#
@evandhoffman
evandhoffman / dateparse-822.pl
Created October 27, 2011 17:45
Parse a date in RT format into RFC822
#!/usr/bin/perl
use DateTime;
my $date = '2009-02-13 15:43:14';
print "Original: $date\n";
print "Converted: ";
@evandhoffman
evandhoffman / changeadpasswd.pl
Created October 6, 2011 19:39
Change Active Directory password from a web browser.
#!/usr/bin/perl
#
# Evan Hoffman ([email protected])
# 13 January, 2010
#
# Base functionality from: http://search.cpan.org/~gbarr/perl-ldap/lib/Net/LDAP/FAQ.pod#..._in_MS_Active_Directory_?
print "Content-Type: text/html\n\n";
use Net::LDAP;
@evandhoffman
evandhoffman / gen-zonefile.pl
Created September 23, 2011 21:57
Converts a spreadsheet of hostname->IP/hostname->hostnames to multiple zone files.
#!/usr/bin/perl
my %domains = ();
while(<>) {
chomp;
my @a = split(/\t/);
my ($host, $dom, $points_to,$unused,$crap) = map { s/^([\W\s]+)(.+)/$2/g ; $_; } @a;
#next if $unused;
@evandhoffman
evandhoffman / evan-ses-send-email.pl
Created August 2, 2011 18:05
Amazon's ses-send-email.pl vs mine.
# Read message body from STDIN, replacing illegal headers with X-headers.
my @legal_headers = qw( Accept-Language Bcc Cc Comments Content-Type Content-Transfer-Encoding Content-ID Content-Description Content-Disposition Content-Language Date DKIM-Signature DomainKey-Signature From In-Reply-To Keywords List-Archive List-Help List-Id List-Owner List-Post List-Subscribe List-Unsubscribe Message-Id MIME-Version Received References Reply-To Return-Path Sender Subject Thread-Index Thread-Topic To User-Agent );
my %legal_headers;
@legal_headers{@legal_headers} = (1) x @legal_headers;
sub read_message {
my $in_header = 1;
my $in_body = 0;
@evandhoffman
evandhoffman / san-backup.sh
Created July 12, 2011 21:32
Postgres/Compellent snapsho backup
#!/bin/bash
# Compellent CLI config
WAL_ARCHIVE_DIR=/mnt/isilon/wal-archive/
TIMESTAMP_FILE="$WAL_ARCHIVE_DIR/`date +%s`.lock"
JAVA=/usr/bin/java
CML_JAR=CompCU.jar
@evandhoffman
evandhoffman / aws-header-filter.pl
Created July 6, 2011 20:58
aws-header-filter.pl
#!/usr/bin/perl
use strict;
use warnings;
my @legal_headers = qw( Accept-Language Bcc Cc Comments Content-Type Content-Transfer-Encoding Content-ID Content-Description Content-Disposition Content-Language Date DKIM-Signature DomainKey-Signature From In-Reply-To Keywords List-Archive List-Help List-Id List-Owner List-Post List-Subscribe List-Unsubscribe Message-Id MIME-Version Received References Reply-To Return-Path Sender Subject Thread-Index Thread-Topic To User-Agent );
my %legal_headers;
@legal_headers{@legal_headers} = (1) x @legal_headers;
@evandhoffman
evandhoffman / profile.sh
Created June 23, 2011 20:50
Mac .profile for non-retarded terminal behavior
#!/bin/bash
PS1='[\d \t \u@\h \# \W]\$ '
function settitle () {
export PREV_COMMAND=${@}
export CURR_CMD=${PREV_COMMAND}
echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~} : ${CURR_CMD}\007"
}