This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function ssh-keygen-remove-all() { | |
if [ -n $1 ]; then | |
ssh-keygen -R "$1" >/dev/null 2>&1 && \ | |
echo "Removed complete hostname: $1" | |
simple_host=$(echo $1 | cut -d '.' -f1) | |
if [ -n "$simple_host" ]; then | |
ssh-keygen -R "$simple_host" >/dev/null 2>&1 && \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Handy helper script to generate new SSH keys in a predictable format, | |
# provide the needed ssh_config stanza to use them, and automatically | |
# upload them to the remote server. | |
# | |
# Copyleft 2014 Ian Gallagher <crash@neg9.org> | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <remote_host> [key_type] [key_size]" >&2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Masquerade/redirect incoming TCP connections on all ports (1:65535) to $dst_ip port $dst_port | |
# Call with -f to force update, even if IP cache exists and shows no changes. | |
# Make sure this isn't a CNAME! Otherwise the below dig command won't follow it and return an IP. | |
dst_host="neg9.org" | |
target_ns="google-public-dns-a.google.com" | |
dst_port=22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Select easy to use passphrases based on the diceware list; but not their selection methodology [lazy]. | |
Place the diceware and beale wordlists (GPG signed is fine) in /usr/share/dict before use. | |
* Diceware list: http://world.std.com/~reinhold/diceware.wordlist.asc | |
* Alternative Beale list: http://world.std.com/~reinhold/beale.wordlist.asc | |
* EFF List (Large): https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt | |
* EFF List (Small): https://www.eff.org/files/2016/09/08/eff_short_wordlist_1.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Parse a TripCreator JSON file and emit a KML file. | |
Example: https://widgets.tripcreator.com/gas-stations-prices-iceland-map/tripcreator-gas-prices-iceland.json | |
Taken from the widget on this page: http://luxeadventuretraveler.com/tips-for-driving-icelands-ring-road-winter/ | |
Copyleft 2017 Ian Gallagher <crash@neg9.org> | |
""" | |
import json | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Use to setup numerous various tunnels to SSH servers, useful with ssh config blocks like those below | |
# for each host, with incrementing port numbers for each - then configure FoxyProxy etc to use the unique | |
# port for each host you want to tunnel out of. | |
# | |
# Thanks to tecknicaltom <tecknicaltom@neg9.org> for the initial idea behind tying this all together. | |
# | |
# Host host_alpha | |
# IdentityFile ~/.ssh/id_ecdsa-$USER-host_alpha-<remote_hostname>-<key_gen_year>-<key_gen_month> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ "$PS1" ]; then | |
if [ "$BASH" ]; then | |
shortname=${HOSTNAME%%.*} | |
shortname=${shortname//[aeiou]/} | |
hostname_crc=$(echo $HOSTNAME | tr 'A-Z' 'a-z' | cksum) | |
hostname_crc=${hostname_crc%% *} | |
hostcolor_a=$(( (0x${hostname_crc} + 1) % 2 )) | |
hostcolor_b=$(( 0x${hostname_crc} % 8 + 30 )) | |
PS1="\[\e[33;1m\]\u@\[\e[${hostcolor_a};${hostcolor_b}m\]${shortname}:\[\e[0m\]\w"'\$ ' | |
PS2='\[\e[31;1m\]>\[\e[0m\]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Convert given plist file in-place from binary to XML or XML to binary. | |
file -bI "$1" | grep -q '^application/octet-stream' | |
if [ $? -eq 0 ]; then | |
# Binary plist - convert to XML | |
plutil -convert xml1 "$1" || echo "Failed to convert $1 to XML." >&2; exit 1 | |
echo "Converted to XML: $1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Tiny script to split M3U playlist entries from stdin out to multiple playlists. | |
Handy for iTunes, because it's stupid in how it imports playlists. | |
Copyleft 2011 Ian Gallagher <crash@neg9.org> | |
""" | |
import sys, os | |
def do_stdin(): | |
pls = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String hashPassword(String password, String salt) throws Exception | |
/* | |
* Wrap pbkdf2 method to return password hash as a hex string | |
*/ | |
{ | |
// Bail if password or salt are null/0 length | |
if ((null == password || 0 == password.length()) || (null == salt || 0 == salt.length())) | |
throw new Exception("Failed to create PBKDF2 Hash for password, password or salt can not be empty"); | |
// Result string |