.dotfiles/.aliases
2025-06-08 21:30:21 +01:00

526 lines
18 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
## DOWNLOADED FROM https://git.ncltech.co.uk/phil/.dotfiles
# My Alias
# Custom ffmpeg shortcuts
# mp4 to mp3
alias mp4-mp3-folder='for vid in *.mp4; do ffmpeg -i "$vid" -f mp3 -ab 320000 "${vid%.mp4}.mp3"; done'
alias mp4-mp3='mp4mp3(){ ffmpeg -i "$1" -f mp3 -ab 320000 "${1%.mp4}.mp3"; unset -f mp4mp3;}; mp4mp3'
# mkv to mp4
alias mkv-mp4-folder='for vid in *.mkv; do ffmpeg -i "$vid" -vcodec copy -acodec copy "${vid%.mkv}.mp4"; done'
alias mkv-mp4='mkvmp4(){ ffmpeg -i "$1" "${1%.mkv}.mp4"; unset -f mkvmp4;}; mkvmp4'
# mkv to mp3
alias mkv-mp3-folder='for vid in *.mkv; do ffmpeg -i "$vid" -vn -c:a libmp3lame -y "${vid%.mkv}.mp3"; done'
alias mkv-mp3='mkvmp3(){ ffmpeg -i "$1" -vn -c:a libmp3lame -y "${1%.mkv}.mp3"; unset -f mkvmp3;}; mkvmp3'
# flac to mp3
alias flac-mp3='flacmp3(){ ffmpeg -i "$1" -ab 320k -map_metadata 0 -id3v2_version 3 "${1%.flac}.mp3"; unset -f flacmp3;}; flacmp3'
alias flac-mp3-folder='for flac in *.flac; do ffmpeg -i "$flac" -ab 320k -map_metadata 0 -id3v2_version 3 "${flac%.flac}.mp3"; done'
# webm to mp3
alias webm-mp3='webmmp3(){ ffmpeg -i "$1" -vn -ab 128k -ar 44100 -y "${1%.webm}.mp3"; unset -f webmmp3;}; webmmp3'
alias webm-mp3-folder='for webm in *.webm; do ffmpeg -i "$webm" -ab 320k -map_metadata 0 -id3v2_version 3 "${webm%.webm}.mp3"; done'
# avi to mp4
alias avi-mp4-folder='for vid in *.avi; do ffmpeg -i "$vid" -c:v copy -c:a copy -y "${vid%.avi}.mp4"; done'
alias avi-mp4='avimp4(){ ffmpeg -i "$1" -c:v copy -c:a copy -y "${1%.avi}.mp4"; unset -f avimp4;}; avimp4'
# When you get bored
alias telnet-starwars='telnet towel.blinkenlights.nl'
alias nethack-online='ssh nethack@nethack.alt.org ; clear'
alias tron-online='ssh sshtron.zachlatta.com ; clear'
# My IP Info
alias myip='curl -s https://ipv4.am.i.mullvad.net/json | jq'
alias ports-in-use='sudo lsof -i -P -n | grep LISTEN'
# Typo
alias whosi='whois'
alias gti='git'
alias dc='cd'
# Custom
alias untar='tar xvf'
alias nano='vim'
alias nanoo='/usr/bin/nano'
alias svim='sudo vim'
alias del='shred -f -n 30 -z -u -v'
alias del-quick='shred -f -n 3 -z -u -v'
#amass
alias amass-subdomain='domain(){ /opt/amass/amass enum -passive -d "$1" -r 1.1.1.1 9.9.9.9 8.8.8.8 >> /opt/amass-scans/"$1".txt; unset -f domain;}; domain'
#SAV Command
alias sav-start='sudo service sav-protect start'
alias sav-stop='sudo service sav-protect stop'
# wget Shortcuts
alias get-nordserverlist="wget https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip"
alias get-wp6="wget https://git.ncltech.co.uk/Phil/hak5_WiFi_Pineapple_NANO_Tools/raw/commit/b97f2cdae7d0df34f659f199b5a71e448f2f79d5/wp6.sh"
# Hack the Box
alias htb-vpn-starting_point='sudo openvpn ~/CTF/HTB/vpn/starting_point_NCLtech.ovpn'
alias htb-vpn-lab-vip1='sudo openvpn ~/CTF/HTB/vpn/lab_NCLtech-EU-VIP1.ovpn'
alias htb-vpn-lab-vip2='sudo openvpn ~/CTF/HTB/vpn/lab_NCLtech-EU-VIP2.ovpn'
alias htb-folder='cd ~/git/CTF/HTB/'
# TryHackMe
alias thm-vpn='sudo openvpn ~/CTF/THM/vpn/NCLtech.ovpn'
alias thm-network-wreath='sudo openvpn ~/CTF/THM/vpn/NCLtech-wreath.ovpn'
alias thm-folder='cd ~/git/CTF/THM'
# Enable aliases to be sudoed
alias sudo='sudo '
# View HTTP traffic
function sniff() {
sudo ngrep -d $(ip route | grep '^default' | awk '{print $5}') -t '^(GET|POST) ' 'tcp and port 80'
}
function httpdump() {
sudo tcpdump -i $(ip route | grep '^default' | awk '{print $5}') -n -s 0 -w - | grep -a -o -E \"Host\\: .*|GET \\/.*\"
}
# Start-msfconsole
function mfsconsole-start(){
if [ -d "/opt/sophos-av" ];then
sudo service sav-protect stop >> /dev/null
msfconsole
else
msfconsole
fi
}
# nmap-basic
function nmap-initial() {
if [ -d "./nmap" ];then
sudo nmap -sC -sV -oA ./nmap/initial $1 -v
else
mkdir ./nmap
sudo nmap -sC -sV -oA ./nmap/initial $1 -v
fi
}
# nmap-basic
function nmap-allports() {
if [ -d "./nmap" ];then
sudo nmap -sC -p- -oA "./nmap/$1-allports" $1 -v
else
mkdir ./nmap
sudo nmap -sC -p- -oA "./nmap/$1-allports" $1 -v
fi
}
# Wireshark Shortcuts
alias wireshark-router1-p.ncltech.uk="sudo su -c 'wireshark -k -i <(ssh root@192.168.120.1 -p 2222 tcpdump -i lagg0 -U -w - )'"
alias wireshark-router2-p.ncltech.uk="sudo su -c 'wireshark -k -i <(ssh root@192.168.120.2 -p 2222 tcpdump -i lagg0 -U -w - )'"
alias wireshark-router-guest-p.ncltech.uk="sudo su -c 'wireshark -k -i <(ssh root@100.64.4.1 -p 2222 tcpdump -i wan host not 192.168.120.27 -U -w - )'"
alias wireshark-pfsense-lab="sudo su -c 'wireshark -k -i <(ssh root@10.74.85.11 -p 2222 tcpdump -i xn0 host not 192.168.120.27 -U -w - )'"
# Git Functions
function gpm() {
if [ "$(grep -c '\[branch "master"\]' .git/config )" -gt 0 ]; then
git push origin master
elif [ "$(grep -c '\[branch "main"\]' .git/config )" -gt 0 ]; then
git push origin main
else
echo "fatal: not a git repository (or any of the parent directories): .git"
fi
}
function gac() {
if [ -d ".git" ]; then
echo "Log Message: "
read logmessage
git add --all && git commit --allow-empty-message -m "$logmessage"
else
echo "No .git Folder found in Directory. Are you in the Correct Folder?"
fi
}
# Pull all Git repos in this dir
function pullall() {
for dir in * ; do
# Execute in subshell
(
cd "$dir" || exit 1
# If it's a git directory, then update it
if test -d .git; then
# Check if its Master or Main
if [ "$(grep -c -i ""master"" .git/config )" -gt 0 ]; then
echo "$dir is a Git repo. Pulling master branch..." && git checkout master && git pull && echo ""
elif [ "$(grep -c -i ""main"" .git/config )" -gt 0 ]; then
echo "$dir is a Git repo. Pulling main branch..." && git checkout main && git pull && echo ""
fi
else
echo "$dir is not a Git repo." && echo ""
fi
)
done
}
# Pull Dotfiles inside ~/.dotfiles/
function pulldots() {
# Check if folders are there and if its Master or Main
if grep -q -i "master" ~/.dotfiles/.git/config; then
CURRENTDIR=$(pwd)
echo "dotfiles Found, Pulling master branch..."
cd ~/.dotfiles/
git checkout master
git pull
cd "$CURRENTDIR"
echo ""
elif grep -q -i "main" ~/.dotfiles/.git/config; then
CURRENTDIR=$(pwd)
echo "dotfiles Found, Pulling main branch..."
cd ~/.dotfiles/
git checkout main
git pull
cd "$CURRENTDIR"
echo ""
else
echo "I can't seem to file any dotfiles folders" && echo ""
fi
}
## UPDATE FUNCTIONS
## Update Snaps
function update_snap() {
sudo -v
# if command -v snap >/dev/null; then
# echo "Updating Snaps..."
# sudo snap refresh
if [[ -f "/usr/bin/snapctl" ]];then
echo "Updating Snaps..."
sudo snap refresh
else
echo "No Snap Found"
fi
}
## Update Flatpak
function update_flatpak() {
sudo -v
if [[ -f "/usr/bin/flatpak" ]];then
echo "Updating Flatpaks..."
sudo flatpak update
else
echo "No Flatpak Found"
fi
}
## Updates packages for all Linux Distros
function update_linux() {
sudo -v
## Parrot OS
if [ "$(grep -c "parrot" /etc/os-release)" -gt 0 ]; then
echo "Updating Apt Packages..."
if [ -d "/opt/sophos-av" ];then
sudo service sav-protect stop >> /dev/null
sudo parrot-upgrade -y && sudo apt full-upgrade -y
sudo service sav-protect start >> /dev/null
else
sudo parrot-upgrade -y && sudo apt full-upgrade -y
fi
##Kali
elif [ "$(grep -c "kali" /etc/os-release)" -gt 0 ]; then
echo "Updating Apt Packages..."
if [ -d "/opt/sophos-av" ];then
sudo service sav-protect stop >> /dev/null
sudo apt update && sudo apt --autoremove full-upgrade -y
sudo service sav-protect start >> /dev/null
else
sudo apt update && sudo apt --autoremove full-upgrade -y
fi
## Debian
elif [ "$(grep -c "debian" /etc/os-release)" -gt 0 ]; then
echo "Updating Apt Packages..."
if [ -d "/opt/sophos-av" ];then
sudo service sav-protect stop >> /dev/null
sudo apt clean && sudo apt update && sudo apt full-upgrade -y
sudo service sav-protect start >> /dev/null
else
sudo apt clean && sudo apt update && sudo apt full-upgrade -y
fi
##Arch
elif [ "$(grep -c "arch" /etc/os-release)" -gt 0 ]; then
echo "Updating Pacman Packages"
if [ -d "/opt/sophos-av" ];then
sudo service sav-protect stop >> /dev/null
sudo pacman -Syy -y $$ && sudo -v && sudo pacman -Syu -y && sudo pacman --noconfirm -R $(pacman -Qdtq)
sudo service sav-protect start >> /dev/null
else
pacmanorphan=$(sudo pacman -Qdt)
sudo pacman -Syy -y && sudo -v && sudo pacman -Syu -y && sudo pacman --noconfirm -R $(pacman -Qdtq)
fi
## Fedora
elif [ "$(grep -c "fedora" /etc/os-release)" -gt 0 ]; then
echo "Updating DNF Packages"
if [ -d "/opt/sophos-av" ];then
sudo service sav-protect stop >> /dev/null
sudo dnf update -y && sudo dnf autoremove -y
sudo service sav-protect start >> /dev/null
else
sudo dnf update -y && sudo dnf autoremove -y
fi
else
echo "No apt or pacman found. I guess you're out of luck"
fi
}
## Update All package managers
function update() {
## Update Snaps
update_snap
## Update Flatpaks
update_flatpak
## Update Linux
update_linux
}
# Decrypt pfSence backup configs # pfdecrypt 'File-in' 'File-out' 'Password'
pfdecrypt() {
cat "$1" | sed -e '1d' -e '$d' | base64 -d | openssl enc -d -aes-256-cbc -md md5 -out "$2" -k "$3"
}
# Extract Function
extract() {
if [ ! -f "$1" ];
then
printf '"%s" is not a valid file.' "$1"
exit 1
fi
case $1 in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;;
*.deb) ar x "$1" ;;
*.tar.xz) tar xf "$1" ;;
*) printf 'cannot extract "%s" with extract()' "$1" ;;
esac
}
# Disable ipv6
function ipv6-disable() {
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
}
# Enable ipv6
function ipv6-enable() {
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
}
# Start CyberChef
alias cyberchef="open /opt/cyberchef/cyberchef.sh"
# Local IP lookup
alias ips="ip a | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'"
alias eth0="ip a s eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'"
alias eth1="ip a s eth1 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'"
alias wlan0="ip a s wlan0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'"
alias wlan1="ip a s wlan1 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'"
alias tun0="ip a s tun0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'"
alias tun1="ip a s tun1 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'"
# Sublist3r
alias sublist3r="python3 /opt/Sublist3r/sublist3r.py"
# Get PentestMonkey Reverse php Shell
alias phpshell='wget https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php -O "shell.php"'
# Start reverse_shell_generator
alias reverse-shell-gen-start='docker start a2f132aa528a; open http://localhost:3321'
alias reverse-shell-gen-stop='docker stop a2f132aa528a'
# WG quick gen
alias wg-gen="wg genkey | sudo tee ~/wg/"$1"-priv | wg pubkey | sudo tee ~/wg/"$1"-pub"
# Wireguard - TheHomeTunnel
alias thehometunnel-up="sudo wg-quick up TheHomeTunnel"
alias thehometunnel-down="sudo wg-quick down TheHomeTunnel"
# Wireguard - C2-Gateway1
alias c2-gateway1-up="sudo wg-quick up C2-Gateway1"
alias c2-gateway1-down="sudo wg-quick down C2-Gateway1"
# windirstat shortcut for ncdu
alias windirstat="ncdu"
#What OS
alias os='cat /etc/os-release'
## My Domains Expiry dates - Add list of domains to ~/.domains/domains.txt
function my-domains()
{
lines=$(cat ~/.domains/domains.txt);for domain in $lines; do echo "$(whois $domain | grep -i 'Expiry date:')" - $domain; done
}
## Change Default Shell
alias shell="cat /etc/shells"
alias set-shell-bash="chsh -s /usr/bin/bash"
alias set-shell-zsh="chsh -s /usr/bin/zsh"
alias set-shell-tmux="chsh -s /usr/bin/tmux"
## Get Costco Fuel Price
function costco-fuel-price {
## Get website data with curl
costco_gateshead_site=$(curl -s https://www.costco.co.uk/store-finder/Gateshead)
## Grep text from website for different fuel
costco_diesel=$(echo $costco_gateshead_site | grep -oP '"gas-title">Premium Diesel</span></br> <span class="gas-price">\K.*' | grep -oE '^.{5}')
costco_premium_unleaded=$(echo $costco_gateshead_site | grep -oP '"gas-title">Premium Unleaded Petrol</span></br> <span class="gas-price">\K.*' | grep -oE '^.{5}')
costco_unleaded=$(echo $costco_gateshead_site | grep -oP '"gas-title">Unleaded Petrol</span></br> <span class="gas-price">\K.*' | grep -oE '^.{5}')
## Print fuel prices
echo "Premium Diesel - $costco_diesel p"
echo "Premium Unleaded - $costco_premium_unleaded p"
echo "Unleaded - $costco_unleaded p"
}
## Curl Dump1090 data from scanner
alias fr24feed="curl --http0.9 192.168.10.21:30003 --output -"
fr24feed-dump1090() {
# Start dump1090-mutability in the background
dump1090-mutability --net --net-only --net-bi-port 30004 --interactive &
DUMP1090_PID=$!
# Start the nc pipe in the background
nc 192.168.10.21 30005 | nc 127.0.0.1 30004 &
NC_PID=$!
# Define a cleanup function
cleanup() {
echo "Stopping processes..."
kill $DUMP1090_PID $NC_PID 2>/dev/null
wait $DUMP1090_PID $NC_PID 2>/dev/null
echo "Exited."
}
# Trap Ctrl+C (SIGINT) and call cleanup
trap cleanup SIGINT
# Wait for both background processes
wait $DUMP1090_PID
wait $NC_PID
}
## Subnet Table
function subnet-table() {
echo " --------------------------------------------------------------------------"
echo "| Bit Length | Max Hosts | Subnet Mask | Binary Mask | Mask Length |"
echo "--------------------------------------------------------------------------"
echo "| 0 | 1 | 255.255.255.255 | 11111111 | 32 |"
echo "| 0 | 2 | 255.255.255.254 | 11111110 | 31 |"
echo "| 0 | 4 | 255.255.255.252 | 11111100 | 30 |"
echo "| 0 | 8 | 255.255.255.248 | 11111000 | 29 |"
echo "| 0 | 16 | 255.255.255.240 | 11110000 | 28 |"
echo "| 0 | 32 | 255.255.255.224 | 11100000 | 27 |"
echo "| 0 | 64 | 255.255.255.192 | 11000000 | 26 |"
echo "| 0 | 128 | 255.255.255.128 | 10000000 | 25 |"
echo "| 0 | 256 | 255.255.255.0 | 11111111 | 24 |"
echo "| 0 | 512 | 255.255.254.0 | 11111110 | 23 |"
echo "| 0 | 1024 | 255.255.252.0 | 11111100 | 22 |"
echo "| 0 | 2048 | 255.255.248.0 | 11111000 | 21 |"
echo "| 0 | 4096 | 255.255.240.0 | 11110000 | 20 |"
echo "| 0 | 8192 | 255.255.224.0 | 11100000 | 19 |"
echo "| 0 | 16384 | 255.255.192.0 | 11000000 | 18 |"
echo "| 0 | 32768 | 255.255.128.0 | 10000000 | 17 |"
echo "| 0 | 65536 | 255.255.0.0 | 11111111 | 16 |"
echo "| 0 | 131072 | 255.255.0.0 | 11111110 | 15 |"
echo "| 0 | 262144 | 255.254.0.0 | 11111100 | 14 |"
echo "| 0 | 524288 | 255.252.0.0 | 11111000 | 13 |"
echo "| 0 | 1048576 | 255.240.0.0 | 11110000 | 12 |"
echo "| 0 | 2097152 | 255.224.0.0 | 11100000 | 11 |"
echo "| 0 | 4194304 | 255.192.0.0 | 11000000 | 10 |"
echo "| 0 | 8388608 | 255.128.0.0 | 10000000 | 9 |"
echo "| 0 | 16777216| 255.0.0.0 | 11111111 | 8 |"
echo "--------------------------------------------------------------------------"
}
## Check AbuseIPdb
abuseip_check() {
ip="$1"
abuseipdb_api_key="$HOME/.api/.abuseipdb_api_key"
if [ ! -f "$abuseipdb_api_key" ]; then
echo "API key file not found at $abuseipdb_api_key"
return 1
fi
api_key=$(cat "$abuseipdb_api_key")
if [ -z "$ip" ]; then
echo "Usage: abuseip_check <IP_ADDRESS>"
return 1
fi
curl --silent -G https://api.abuseipdb.com/api/v2/check \
--data-urlencode "ipAddress=$ip" \
-d maxAgeInDays=90 \
-d verbose \
-H "Key: $api_key" \
-H "Accept: application/json" | jq
}
## Pi Temp
alias temp="vcgencmd measure_temp"
## Lookup IP
alias iplookup='iplookup-get(){ curl "ip.nclte.ch/json?ip=$1"; unset -f iplookup-get; }; iplookup-get'
## Make random dir
alias mkdir-random='mkdir $(cat /dev/urandom | tr -dc "a-zA-Z0-9" | fold -w 50 | head -n 1) && echo "Directory created: $(cat /dev/urandom | tr -dc "a-zA-Z0-9" | fold -w 50 | head -n 1)"'
#function rofi-file-browser(){
#rofi -dmenu -p "Select File Manager" -i -no-fixed-num-lines <<< "File Browser"
#if [ $? -eq 0 ]; then
# mate-terminal ranger
#fi
#}
## Display all commands in this Alias file
#GO
alias go=/usr/local/go/bin/go
alias my-alias="cat ~/.aliases | grep -oP 'alias\s\K[^=]+' | sort -n"