Skip to content

Instantly share code, notes, and snippets.

View wcarhart's full-sized avatar
🦉
Hoot hoot

Will Carhart wcarhart

🦉
Hoot hoot
View GitHub Profile
@wcarhart
wcarhart / remove_file.sh
Last active February 9, 2020 00:42
Completely remove a file from Git history
# Completely remove a file from git history
# Remove file from all commits
# $path_to_file supports wildcards: path/to/directory/*
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch $path_to_file" HEAD
# Prune branch
git reflog expire --expire=now --all && git gc --prune=now --aggressive
# Rewrite history in remote
@wcarhart
wcarhart / bash_metaprogramming.sh
Created April 21, 2020 03:20
Bash metaprogramming
#!/bin/bash
# list all custom BASH functions
lsf() {
if [[ ! -d ~/.bash_functions ]] ; then
if [[ ! -f ~/.bashrc ]] ; then
echo "lsf: err: no such directory ~/.bash_functions, no such file ~/.bashrc"
return 1
fi
@wcarhart
wcarhart / knock.sh
Last active January 13, 2021 19:06
Setup and use port knocking
#!/bin/bash
# test port knocking using nmap
for port in 7151 10888 8899 ; do nmap -Pn --host_timeout 201 --max-retries 0 -p $port ipaddress ; done && ssh root@ipaddress
# test port knocking using knock
sudo apt-get update
sudo apt-get install knockd
knock ipaddress 7151 10888 8899 && ssh root@ipaddress
@wcarhart
wcarhart / links.txt
Last active January 24, 2024 23:07
Interesting software links