Skip to content

Instantly share code, notes, and snippets.

View craSH's full-sized avatar

Ian Gallagher craSH

View GitHub Profile
#!/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 && \
@craSH
craSH / natstrings.py
Last active August 29, 2015 14:19
Like strings(1) but only return stuff that is probably english (or whatever locale you set)
#!/usr/bin/env python
"""
Like strings(1) but only return stuff that is probably English (or whatever locale you set)
TODO:
* Add a parameter to ignore punctuation as token counts towards the threshold.
e.g. "Foo." vs "Foo........" would both return true.
* Add conditional for not counting digit only results if alphanumeric=True in is_natlang()
* Unicode support - currently it doesn't work with unicode, quite bad for non-english input
@craSH
craSH / diceware.py
Last active April 28, 2017 17:44
Select easy to use passphrases based on the diceware list; but not their selection methodology [lazy]
#!/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
@craSH
craSH / keybase.md
Last active August 29, 2015 14:02
I have updated my PGP key, and am updating my keybase proof.

Keybase proof

I hereby claim:

  • I am crash on github.
  • I am crash (https://keybase.io/crash) on keybase.
  • I have a public key whose fingerprint is F887 3E31 2041 DF5E A3E6 2D3F AFD0 1F0B 7F26 52C4

To claim this, I am signing this object:

@craSH
craSH / ssh-mkkey
Last active March 2, 2020 21:13
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.
#!/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 <[email protected]>
if [ -z "$1" ]; then
echo "Usage: $0 <remote_host> [key_type] [key_size]" >&2
###########################################################
# This srcipt will simply produce expressions to be #
# used with config.py #
# - Disclaimer - I'm not responsible for how you use this #
# this was created for personal usage and for educational #
# purposes #
# CopyLeft Jason Tsang Mui Chung ([email protected]) #
###########################################################
brute_list = raw_input("Enter the string you would like to generate a expression for:")
length = len(brute_list)
@craSH
craSH / pkcs12_dictionary_attack.py
Created April 16, 2014 00:42
Quick single-threaded script to perform a dictionary attack on a PKCS12/PFX password encrypted certificate bundle
#!/usr/bin/env python
"""
Copyleft 2014 Ian Gallagher <[email protected]>
"""
import sys, os
import OpenSSL
def p12_load(p12_path, passwd):
# open PKCS12/PFX file, using password.
p12 = OpenSSL.crypto.load_pkcs12(file(p12_path, 'rb').read(), passwd)
@craSH
craSH / plflip
Created November 22, 2013 21:31
Convert given plist file in-place from binary to XML or XML/JSON to binary.
#!/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"
@craSH
craSH / iptables-sol.sh
Last active September 4, 2018 18:23
Masquerade/redirect incoming TCP connections on all ports (1:65535) to $dst_ip port $dst_port.Great for creating a proxy/jump box that lets you SSH to your server, in cases when you're on strange/(poorly) restrictive networks and need to tunnel out.
#!/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
@craSH
craSH / Password.java
Last active June 12, 2024 05:13
A simple example Java class to safely generate and verify bcrypt password hashes for use in authentication systems.
/**
* Author: Ian Gallagher <[email protected]>
*
* This code utilizes jBCrypt, which you need installed to use.
* jBCrypt: http://www.mindrot.org/projects/jBCrypt/
*/
public class Password {
// Define the BCrypt workload to use when generating password hashes. 10-31 is a valid value.
private static int workload = 12;