Show your aliases!

hi,

i use some aliases and wan’t to know what’s your bunch of aliases you use or i miss.

thats my in /root/.bashhrc:

alias p_auto="touch /root/.pwnagotchi-auto && systemctl restart pwnagotchi"
alias p_restart="systemctl restart pwnagotchi"
alias p_stop="systemctl stop pwnagotchi"
alias p_status="systemctl status pwnagotchi"
alias p_log="tail -f /var/log/pwnagotchi.log"
alias p_mail_list="pwngrid -inbox"
alias p_mail_get="pwngrid -inbox -id "
alias p_version="echo -n \"installed version: \";python3 -c \"print(__import__('pwnagotchi').version)\";echo -n \"   local revision: \";git --git-dir=/usr/local/src/pwnagotchi/.git rev-parse --short HEAD;echo -n \"  remote revision: \";git ls-remote https://github.com/evilsocket/pwnagotchi.git HEAD | awk '{print substr(\$0,0,7)}'"
alias p_update="olddir=\$(pwd);systemctl stop pwnagotchi ; cd /usr/local/src/pwnagotchi/ ; git pull ; pip3 install . ; cd \$olddir"
alias p_fix_firmware="apt-get update && apt-get install --reinstall firmware-brcm80211=20190114-2"
alias p_get_0byte_hanshake_files="echo \" >> add '-delete' for delete :)\" ; find /root/handshakes/ -size 0 -type f"

so lets show your aliases!

  • edit 20200116: add “p_fix_firmware” to reinstall older wifi-firmware on broken monitor-mode after “apt upgrade” on raspiZeroW
4 Likes

One-liner for backup of the sd cards
export BAK_DEV="yourGotchi"; dd bs=2M if=/dev/sdb status=progress | pv -petra | gzip > /mnt/data/gotchi_${BAK_DEV}/${BAK_DEV}_$(date +%y%m%d).img.gz

log and temp

alias temperature='echo -e "thermal_zone0: \e[1m$(echo $(cat /sys/class/thermal/thermal_zone0/temp) / 1000 | bc)\e[0m°C"'
alias pwnlog='tail -f -n200 /var/log/pwngrid-peer.log /var/log/pwnagotchi.log | sed --unbuffered "s/,[[:digit:]]\{3\}\]//g" | cut -d " " -f 2-

service management (simple wrapper basically)

pwnstate() {
    services_pwnagotchi=(pwnagotchi pwngrid-peer bettercap)
    services_extra=(gpsd chrony)
    services=("${services_pwnagotchi[@]}" "${services_extra[@]}")

    if [[ $1 == "restart" ]]; then
        systemctl restart ${services_pwnagotchi[@]}
    elif [[ $1 == "stop" ]]; then
        systemctl stop ${services_pwnagotchi[@]}
    fi

    if [[ $1 == "erestart" ]]; then
        systemctl restart ${services_extra[@]}
    elif [[ $1 == "estop" ]]; then
        systemctl stop ${services_extra[@]}
    fi

    declare -A states=()
    for service in "${services[@]}"; do
        if $(systemctl is-active --quiet ${service}.service); then
            # states[$service]="\e[92mrunning\e[0m"
            states[$service]="\e[92m${service}\e[0m"
        else
            # states[$service]="\e[91mstopped\e[0m"
            states[$service]="\e[91m${service}\e[0m"
        fi
    done

    unset states_pwnagotchi
    unset states_extra
    for service in "${services[@]}"; do
        if [[ ${services_pwnagotchi[*]} =~ $service ]]; then
            states_pwnagotchi="$states_pwnagotchi ${states[$service]}"
        elif [[ ${services_extra[*]} =~ $service ]]; then
            states_extra="$states_extra ${states[$service]}"
        fi
    done

    tabs 2
    echo
    echo -e "\t\e[1m$(hostname)\e[0m\t\t\e[1m$(echo $(cat /sys/class/thermal/thermal_zone0/temp) / 1000 | bc)°C\e[0m, \e[1m$(uptime --pretty)\e[0m\n"

    echo -e " pwnagotchi:\t${states_pwnagotchi}"
    echo -e "     extras:\t${states_extra}"
    echo
}
2 Likes
alias ll="ls -l --color=auto"
alias ip="ip -c"
alias rm="rm -I"

Old thread, but just added a new one, and remembered this thread.

The first of these may be obviated by some recent fixes to the gps plugin, but I was noticing a bunch of files with empty coords created when my gps didn’t have a fix yet so I run this occasionally.

cleangpsfiles() {
        for file in $(ls /root/handshakes/*.gps.json); do
                if [ $(jq '.Latitude == 0' $file) == "true" ]; then
                        rm -f $file;
                fi
        done
}

Also found myself constantly cutting & pasting coordinates from the command line when I wanted more detail on an ssid location than available in the webgpsmap plugin basemap, so I added the following.

  gmap() {
        jq -r '"https://www.google.com/maps/search/?api=1&query=\(.Latitude)+\(.Longitude)"' $1
     }

Now just gmap <ssid>.gps.json will give me a google maps url w/ a pin at the coords.

Will have to install jq for either of these to work, but IMHO jq is damn near a requirement if you’re dealing with json in bash.

1 Like