Skip to content

Instantly share code, notes, and snippets.

@bitfolk
bitfolk / check_poodle.sh
Last active August 29, 2015 14:07
Horrible shell hack to check for enabled SSLv3 on port 443 of a CIDR mask
#!/bin/sh
# Horrible shell hack to check for enabled SSLv3 on port 443 of a CIDR mask.
#
# This is pretty slow because it does them in series. Sticking a '&' on the end
# of the for loop (so "done &" instead of "done") will execute openssl against
# every IP:443 at once. If there's too many to do at once then I suggest
# lashing something up with GNU parallel.
#
# Note also that nmap itself can check for SSLv3 with something like:
#!/usr/bin/env python
"""
Quick demo of evdev to snoop on mouse button events.
Full docs at: https://pythonhosted.org/evdev/
To get anything out of this you'll probably need to run it as root.
"""
@bitfolk
bitfolk / fix-disk-timeouts
Created November 8, 2013 17:08
Use something like this on boot to check that all your SCSI devices either support Error Recovery Control at 7 seconds, or else have a large enough SCSI layer timeout to prevent them being kicked from a RAID array on bad sector reads.
#!/bin/sh
for disk in `find /sys/block -maxdepth 1 -name 'sd*' | xargs -n 1 basename`
do
smartctl -q errorsonly -l scterc,70,70 /dev/${disk}
if test $? -eq 4
then
echo "/dev/${disk} doesn't support scterc, setting timeout to 180s /o\\"
echo 180 > /sys/block/${disk}/device/timeout
@bitfolk
bitfolk / reap-dead-tracks.pl
Created October 6, 2013 16:54
Here's a thing to check your Banshee library for files that are no longer present. It tells you which ones it will remove first and asks you if you want to. It's only removing the database entry.
#!/usr/bin/perl
use warnings;
use strict;
use DBI;
use URI::Escape;
use Term::UI;
use Term::ReadLine;
@bitfolk
bitfolk / find_open_resolvers.pl
Created January 9, 2013 11:08
Quick bit of perl code to scan an IP range for open DNS resolvers. I use it to check for misconfigured customer resolvers on my network, so that I can hopefully open a ticket with the customer before they get used as a DDoS multiplier.
#!/usr/bin/perl
use warnings;
use strict;
use Net::IP;
use Net::DNS;
use IO::Select;
use Getopt::Long;
use Pod::Usage;
@bitfolk
bitfolk / check_rev_dns_exists.pl
Created December 12, 2012 12:20
Check that reverse DNS exists for every one of a big list of IPv4 and IPv6 addresses.
#!/usr/bin/perl
use strict;
use warnings;
use Net::IP qw(:PROC);
use Net::DNS;
use Getopt::Long;
use Pod::Usage;
@bitfolk
bitfolk / v6_cidr_to_reverse.pl
Created November 29, 2012 07:11
Convert an IPv6 CIDR format address to its corresponding reverse zone
#!/usr/bin/perl
use strict;
use warnings;
foreach my $cidr (qw(2001:ba8:1f1:f004::/64 4:2::/32 2001:ba8:1f1:400::/56)) {
print "$cidr reverses to ", v6_cidr_to_reverse($cidr), "\n";
}
sub v6_cidr_to_reverse