Skip to content

Instantly share code, notes, and snippets.

View kd7lxl's full-sized avatar

Tom Hayward kd7lxl

  • Infoblox
  • Tacoma, WA
View GitHub Profile
@kd7lxl
kd7lxl / hexdiff.sh
Created September 12, 2016 20:12
Compares two binary files
#!/bin/sh
A=`mktemp`
B=`mktemp`
hexdump -C "$1" > $A
hexdump -C "$2" > $B
diff -U 0 --label "$1" --label "$2" $A $B | less
rm $A $B
@kd7lxl
kd7lxl / generate_email_robot.py
Created January 11, 2017 00:49
Generate A records for a network for the AMPR DNS robot
#!/usr/bin/env python
#
# Usage: ./generate_email_robot.py NETWORK
#
# Setup:
# virtualenv env
# source env/bin/activate
# pip install ipaddr
#
# Example:
@kd7lxl
kd7lxl / telnet_auth.py
Created March 25, 2017 00:20
Simple telnet credential harvester
# usage: twistd -ny telnet_auth.py
from twisted.conch.telnet import TelnetTransport, AuthenticatingTelnetProtocol
from twisted.internet.protocol import ServerFactory
from twisted.application.internet import TCPServer
from twisted.application.service import Application
log = open('creds.log', 'a')
class TelnetHoneypot(AuthenticatingTelnetProtocol):
@kd7lxl
kd7lxl / install_hp_tools.yml
Created April 24, 2017 21:09
Ansible playbook to install HP server management tools
---
- name: Install HP management tools
hosts: hp
become: yes
tasks:
- name: Install pexpect for Ansible expect
apt:
name: python-pexpect
@kd7lxl
kd7lxl / diff_routes.sh
Created August 3, 2017 17:32
Detect a change in the route table
#!/bin/bash
PREVTABLE=/tmp/routes
NEWTABLE=$(mktemp)
ip r > "$NEWTABLE"
if [ -f "$PREVTABLE" ]; then
diff -u "$PREVTABLE" "$NEWTABLE"
fi
mv "$NEWTABLE" "$PREVTABLE"
@kd7lxl
kd7lxl / genkmz.sh
Last active November 11, 2021 00:07
Runs signalserver and converts the output to a kmz file
#!/bin/bash
while read line
do
echo $line
if [[ $line == Writing* ]]
then
while IFS='"' read -ra writingline
do
filename=${writingline[1]%.*}
done <<< $line
@kd7lxl
kd7lxl / ant_to_azel.py
Last active July 23, 2021 18:28
Converts Radio Mobile .ant antenna pattern files to SPLAT! .az/.el format
#!/usr/bin/env python
import sys
from os.path import splitext
def db_to_norm(db):
return 10**(db/10.)
antfilename = sys.argv[1]
@kd7lxl
kd7lxl / fqdn_sort.py
Created August 22, 2018 15:10
Sorts a list of hostnames by their domain
#!/usr/bin/env python
import fileinput
print "".join(sorted(fileinput.input(), key=lambda fqdn: fqdn.lower().split('.')[::-1])),
@kd7lxl
kd7lxl / find_invalid_elbs.py
Created October 25, 2018 15:56
Lists AWS ELBs with no valid endpoints
import boto.ec2.elb
def get_elbs_with_no_valid_instances(elb):
"""Finds ELBs with zero instances or where all instances are no longer in service."""
for lb in elb.get_all_load_balancers():
instances = lb.get_instance_health()
if len(instances) == 0:
yield lb
continue
@kd7lxl
kd7lxl / librenms.py
Created December 19, 2018 05:27
Ansible dynamic inventory from LibreNMS
#!/usr/bin/env python
import json
import urllib2
librenms = json.loads(
urllib2.urlopen(urllib2.Request(
'https://librenms.hamwan.org/api/v0/devices',
headers={'X-Auth-Token': ''},