#!/bin/bash
alias cp="cp -vi"
alias sless='less -S -R'
alias dockerstatus="docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock moncho/dry"
alias dockerip="docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'"
alias dritn='docker run -i -t --rm '
alias drit='docker run -i -t --rm --network=none'
alias dritpwn='docker run -i -t --rm -v "$(mktemp -d):/output" -v "$(pwd)":/data:ro'
alias dritpwnrw='docker run -i -t --rm -v "$(mktemp -d):/output" -v "$(pwd)":/data:rw'
alias dritpw='docker run -i -t --rm --network=none -v "$(mktemp -d):/output" -v "$(pwd)":/data:ro'
alias dritpwrw='docker run -i -t --rm --network=none -v "$(mktemp -d):/output" -v "$(pwd)":/data:rw'
alias kali='docker run --rm -it -v ${workdir-`pwd`}:/root/workdir kalilinux/kali-rolling'
alias lazydocker="docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock -v /opt/lazydocker:/.config/jesseduffield/lazydocker lazyteam/lazydocker"
alias mv="mv -vi"
alias ntfsmount='sudo mount -o ro,show_sys_files,streams_interface=windows'
alias powershell='docker run --rm -it -v ${workdir-`pwd`}:/data mcr.microsoft.com/powershell pwsh'
alias ppxml="xmllin --format -"
alias ppxml="xmlstarlet format --indent-tab"
alias pwsh=powershell
alias remnux_crits_start='sudo docker run --rm --name critsy -it -v ${workdir-`pwd`}:/home/nonroot/workdir -p 8443:8443 remnux/crits'
alias remnux_crits_stop="sudo docker stop critsy"
alias remnux_jsdetox_start="sudo docker run --rm --name jsdetoxy --rm -p 3000:3000 remnux/jsdetox"
alias remnux_jsdetox_stop="sudo docker stop jsdetoxy"
alias remnux_mastiff='sudo docker run --rm -it -v ${workdir-`pwd`}:/home/nonroot/workdir remnux/mastiff'
alias remnux_msf='docker run --rm -it -p 443:443 -v ~/.msf4:/root/.msf4 -v /tmp/msf:/tmp/data remnux/metasploit'
alias remnux_pescanner='docker run --rm -it --dns=192.168.130.1 -v ${workdir-`pwd`}:/home/nonroot/workdir remnux/pescanner bash'
alias remnux_rekall='docker run --rm -it -p 8000:8000 --dns=192.168.130.1 -v ${workdir-`pwd`}:/home/nonroot/files remnux/rekall bash'
alias remnux_thug='sudo docker run --rm -it --dns=192.168.130.1 -v /var/log/docker/thug_logs:/home/thug/logs remnux/thug ./thug.py -F '
alias remnux_viper='docker run --rm -it --dns=192.168.130.1 -v ${workdir-`pwd`}:/home/nonroot/workdir remnux/viper bash'
alias remnux_vol='docker run --rm -it -v ${workdir-`pwd`}:/home/nonroot/memdumps remnux/volatility bash'
alias locate='locate -i -A'
alias mc='source /usr/lib/mc/mc-wrapper.sh'
alias evtvd='vd -f csv --skip 5'
alias rot13='tr "abcdefghijklmnopqrstuvwxyz" "nopqrstuvwxyzabcdefghijklm"'
alias uniq2='awk '"'"'{a[$0]++; if (a[$0]==1) print $0 }'"'"
alias pip='pip3'
alias python='python3'
function bindiff() { cmp -l "${1}" "${2}" | gawk '{printf "%s,%02X,%02X\n",$1,strtonum(0$2),strtonum(0$3) }' ; }
function avscan(){ av="${1:-kaspersky}" ; if [ "${av}" == "update" ] ; then ( docker pull tabledevil/kaspersky ; docker pull tabledevil/sep ; docker pull tabledevil/clamav) ; elif [[ $# -eq 2 ]] ; then dritpw "tabledevil/${av}" "${2}" ; else dritpw "tabledevil/${av}" scan ; fi ;  }
function dockerfa() {  [[ $# -eq 0 ]] && wpd=$(readlink -f . ) || wpd=$(readlink -f "${1}");  docker run -it --rm -v "${wpd}":/data tabledevil/file-analysis;}
function docker_killall() { docker rm $(docker stop $(docker ps -a -q --filter ancestor="${1}" --format="{{.ID}}")) ; }
function dockertags() {     tags=`wget -q https://registry.hub.docker.com/v1/repositories/${1}/tags -O -  | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n'  | awk -F: '{print $3}'`;     if [ -n "$2" ] ; then          tags=` echo "${tags}" | grep "$2" `;     fi ;     echo "${tags}" ;     }
alias pip='pip3'
alias python='python3'
alias usbb="usbguard list-devices -b"
alias usba="usbguard allow-device"
alias searchpackage="apt-cache search '' | sort | cut --delimiter ' ' --fields 1 | fzf --multi --cycle --reverse --preview 'apt-cache show {1}' | xargs -r sudo apt install -y"
if (hash exa 2>/dev/null) ; then
  alias ll='exa -l --git --icons --group-directories-first'
  alias ll='exa -l --icons --group-directories-first'
  alias lt='exa -lT --level 2 --git --git-ignore --group-directories-first'
  alias lt='exa -lT --level 2 --git-ignore --group-directories-first'
fi
if (hash bat 2>/dev/null) ; then
  export MANPAGER="sh -c 'col -bx | bat -l man -p'"
fi
function unsetproxy() { unset $(env | grep -Pio '^https?_proxy' | xargs) ; }
hash fdfind 2>/dev/null && alias fd=fdfind
alias dissect="dritpw tabledevil/dissect"
function nsrt() {     local col=$1;     shift;     awk -v c="$col" '{print $c, $0}' "$@" | sort -k1,1 -n | cut -d' ' -f2-; }
