Added all bash_aliases and functions

This commit is contained in:
Phil 2021-11-06 23:27:56 +00:00
parent 34ea2e9584
commit 191be85744
11 changed files with 283 additions and 0 deletions

View File

@ -0,0 +1,4 @@
# Aliases for 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'

View File

@ -0,0 +1,25 @@
## 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
}

46
Linux/Functions/Git.sh Normal file
View File

@ -0,0 +1,46 @@
## Git Functions
## Git Commit
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
}
## Git Push
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
}
## Git Pull All
## 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
}

View File

@ -0,0 +1,19 @@
## My IP Info
alias myip='MYIP=$(curl -s https://ipecho.net/plain; echo) && curl https://ipinfo.io/"$MYIP" && echo'
## IP infomation
alias ports-in-use='sudo lsof -i -P -n | grep LISTEN'
## 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 \\/.*\"
}
## Wireshark Shortcuts
alias wireshark-pfsense="sudo su -c 'wireshark -k -i <(ssh root@192.168.0.3 -p 2222 tcpdump -i lagg0 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 - )'"

View File

@ -0,0 +1,64 @@
## Terminal Settings
## set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1="\[\033[0;31m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]root\[\033[01;33m\]@\[\033[01;96m\]\h'; else echo '\[\033[0;39m\]\u\[\033[01;33m\]@\[\033[01;96m\]\h'; fi)\[\033[0;31m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;31m\]]\n\[\033[0;31m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]\[\e[01;33m\]\\$\[\e[0m\]"
else
PS1='┌──[\u@\h]─[\w]\n└──╼ \卌\n'
fi
# Set 'man' colors
if [ "$color_prompt" = yes ]; then
man() {
env \
LESS_TERMCAP_mb=$'\e[01;31m' \
LESS_TERMCAP_md=$'\e[01;31m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_so=$'\e[01;44;33m' \
LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_us=$'\e[01;32m' \
man "$@"
}
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\033[0;31m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]root\[\033[01;33m\]@\[\033[01;96m\]\h'; else echo '\[\033[0;39m\]\u\[\033[01;33m\]@\[\033[01;96m\]\h'; fi)\[\033[0;31m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;31m\]]\n\[\033[0;31m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]\[\e[01;33m\]\\$\[\e[0m\]"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi

3
Linux/Functions/amass.sh Normal file
View File

@ -0,0 +1,3 @@
## Amass
## alias for quickly scanning sub-domains with amass
alias amass-subdomain='domain(){ /opt/amass/amass enum -passive -d "$1" >> /opt/amass-scans/"$1".txt; unset -f domain;}; domain'

View File

@ -0,0 +1,4 @@
# 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"
}

View File

@ -0,0 +1,8 @@
# ffmpeg custom aliases
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'
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'
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'

21
Linux/Functions/nmap.sh Normal file
View File

@ -0,0 +1,21 @@
## nmap Functions
# nmap-basic
function nmap-basic() {
if [ -d "./nmap" ];then
sudo nmap -sC -sV -oA ./nmap/$1 $2 -v
else
mkdir ./nmap
sudo nmap -sC -sV -oA ./nmap/$1 $2 -v
fi
}
# nmap-basic
function nmap-allports() {
if [ -d "./nmap" ];then
sudo nmap -p- -oA "./nmap/$1-allports" $2 -v
else
mkdir ./nmap
sudo nmap -p- -oA "./nmap/$1-allports" $2 -v
fi
}

30
Linux/Functions/others.sh Normal file
View File

@ -0,0 +1,30 @@
## Others
## Didn't warrent having their own files
## SAV (Sophos Anti-Virus) 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"
## Hack the Box
alias htb-vpn-starting_point='sudo openvpn ~/htb/vpn/starting_point_NCLtech.ovpn'
alias htb-vpn-lab='sudo openvpn ~/htb/vpn/lab_NCLtech.ovpn'
## Enable aliases to be sudoed
alias sudo='sudo '
## Typo's
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'

59
Linux/Functions/update.sh Normal file
View File

@ -0,0 +1,59 @@
## Update Function
function update() {
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
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
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
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
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
else
echo "No apt or pacman found. I guess you're out of luck"
fi
}