Adds / tweaks a bunch of scripts

master
Jonathan Hodgson 9 months ago
parent 887f479d1f
commit 285165913d
  1. 2
      bin/.bin/albumDuration
  2. 15
      bin/.bin/compiler
  3. 2
      bin/.bin/dmenu/password-manager
  4. 3
      bin/.bin/dmenu/rofi-shutdown
  5. 2
      bin/.bin/i3/fadeLockScreen
  6. 9
      bin/.bin/jqi
  7. 3
      bin/.bin/linkhandler
  8. 12
      bin/.bin/opout
  9. 2
      bin/.bin/screenlayouts/docked-laptop-left.sh
  10. 10
      bin/.bin/screenshot
  11. 67
      bin/.bin/sshportforward
  12. 2
      bin/.bin/webtest/analyse-headers
  13. 11
      shells/shared/aliases

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
shopt -s nullglob shopt -s nullglob
let playlist_duration_ms=0 let playlist_duration_ms=0
for song_file in *.{mp3,ogg,m4a,flac,wav}; do for song_file in */*.{mp3,ogg,m4a,flac,wav}; do
playlist_duration_ms=$(expr $playlist_duration_ms + $(mediainfo --Inform="Audio;%Duration%" "$song_file")) playlist_duration_ms=$(expr $playlist_duration_ms + $(mediainfo --Inform="Audio;%Duration%" "$song_file"))
done done
shopt -u nullglob shopt -u nullglob

@ -12,18 +12,17 @@
# config.h files: (For suckless utils) recompiles and installs program. # config.h files: (For suckless utils) recompiles and installs program.
# all others: run `sent` to show a presentation # all others: run `sent` to show a presentation
echo "$1" file="$(readlink -f "$1")"
file=$(readlink -f "$1") dir="$(dirname "$file")"
dir=$(dirname "$file")
base="${file%.*}" base="${file%.*}"
shebang=$(sed -n 1p "$file") shebang="$(sed -n 1p "$file")"
cd "$dir" || exit cd "$dir" || exit
textype() { \ textype() { \
command="pdflatex" command="latexmk -pdf"
( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex" ( sed 5q "$file" | grep -i -q 'xelatex' ) && command="latexmk -pdfxe"
$command --output-directory="$dir" "$file" $command -output-directory="$dir" "$file"
#grep -i addbibresource "$file" >/dev/null && #grep -i addbibresource "$file" >/dev/null &&
#biber --input-directory "$dir" "$base" && #biber --input-directory "$dir" "$base" &&
#$command --output-directory="$dir" "$base" && #$command --output-directory="$dir" "$base" &&
@ -60,7 +59,7 @@ case "$file" in
*\.c) cc "$file" -o "$base" && "$base" ;; *\.c) cc "$file" -o "$base" && "$base" ;;
*\.py) python "$file" ;; *\.py) python "$file" ;;
*\.js) cat "$file" | minify --js > "${base}.min.js" ;; *\.js) cat "$file" | minify --js > "${base}.min.js" ;;
*\.less) lessc --clean-css "$file" "${base}.min.css" ;; *\.less) lessc --clean-css -x "$file" "${base}.min.css" ;;
#*\.less) lessc "$file" "${base}.css" ;; #*\.less) lessc "$file" "${base}.css" ;;
#*\.go) go run "$file" ;; #*\.go) go run "$file" ;;
#*) shebangtest ;; #*) shebangtest ;;

@ -31,7 +31,7 @@ function type_password(){
# Then revert back to colemak # Then revert back to colemak
setxkbmap -layout gb,gb -variant "colemak," -option grp:shifts_toggle setxkbmap -layout gb,gb -variant "colemak," -option grp:shifts_toggle
xset r rate 200 70 xset r rate 200 70
xinput --list | grep -Ei 'ErgoDox EZ\s+id' | grep -oE 'id=[0-9]+' | cut -d'=' -f2 | xargs -r setxkbmap -layout gb -device xinput --list | grep -Ei 'ErgoDox EZ Glow\s+id' | grep -oE 'id=[0-9]+' | cut -d'=' -f2 | xargs -r setxkbmap -layout gb -device
} }
function copy_password(){ function copy_password(){
local password="$1" local password="$1"

@ -33,8 +33,7 @@ hostname="$(hostname)"
if isPhone; then if isPhone; then
selection="$(echo -e "$shutdown\n$reboot\n$lock\n$logout" | selectcommand)" selection="$(echo -e "$shutdown\n$reboot\n$lock\n$logout" | selectcommand)"
else else
notify-send "Not phone" selection="$(echo -e "$lock\n$shutdown\n$reboot\n$logout\n$suspend" | selectcommand)"
selection="$(echo -e "$shutdown\n$reboot\n$lock\n$logout\n$suspend" | selectcommand)"
fi fi
sleep .2 sleep .2

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
rm /tmp/screen.png rm /tmp/screen.png
scrot -z /tmp/screen.png maim /tmp/screen.png
convert /tmp/screen.png -scale 10% -scale 1000% /tmp/screen.png convert /tmp/screen.png -scale 10% -scale 1000% /tmp/screen.png
if [[ -f $HOME/.config/screen-lock.png ]] if [[ -f $HOME/.config/screen-lock.png ]]

@ -1,9 +0,0 @@
#!/usr/bin/env bash
stdin="$(cat -)"
escaped="$(echo "$stdin" | sed 's/"/\\"/g')"
query="$(echo "" | fzf --preview-window=up:99% --print-query \
--preview "echo \"$escaped\" | jq -C {q}" | head -n 1)"
echo "$stdin" | jq "$query"

@ -18,6 +18,9 @@ case "$url" in
sxiv "$tmp" sxiv "$tmp"
rm "$tmp" rm "$tmp"
;; ;;
*.mp3|*.wma)
mpv "$url"
;;
*"//xkcd.com/"*) xkcd "$url"; exit 0 ;; *"//xkcd.com/"*) xkcd "$url"; exit 0 ;;
"mailto:"*) neomutt "$url"; exit 0 ;; "mailto:"*) neomutt "$url"; exit 0 ;;
*) $browser "$url"; exit 0 ;; *) $browser "$url"; exit 0 ;;

@ -2,11 +2,19 @@
# opout: "open output": A general handler for opening a file's intended output. # opout: "open output": A general handler for opening a file's intended output.
# I find this useful especially running from vim. # I find this useful especially running from vim.
name="$1"
basename="${1%.*}" basename="${1%.*}"
case "$1" in case "$name" in
/tmp/neomutt*|*.tex|*.latex|*.md|*.rmd|*.ms|*.me|*.mom) setsid "$READER" "$basename".pdf >/dev/null 2>&1 & ;; /tmp/neomutt*|*.tex|*.latex|*.md|*.rmd|*.ms|*.me|*.mom)
if [ -f "$name".pdf ]; then
setsid "$READER" "$name".pdf >/dev/null 2>&1 &
elif [ -f "$basename".pdf ]; then
setsid "$READER" "$basename".pdf >/dev/null 2>&1 &
fi
;;
*.html) setsid "surf" "$basename".html >/dev/null 2>&1 & ;; *.html) setsid "surf" "$basename".html >/dev/null 2>&1 & ;;
*.sent) setsid sent "$1" >/dev/null 2>&1 & ;; *.sent) setsid sent "$1" >/dev/null 2>&1 & ;;
*.scad) setsid openscad $1 & ;;
*.jpg|*.jpeg|*.png|*.gif) setsid sxiv "$1" > /dev/null 2>&1 & ;; *.jpg|*.jpeg|*.png|*.gif) setsid sxiv "$1" > /dev/null 2>&1 & ;;
esac esac

@ -7,7 +7,7 @@ externalScreen="$(xrandr | grep -Eo '^.* connected' | grep -v "$laptopScreen" |
externalResolution="$(xrandr | grep -A 1 "^$externalScreen" | sed -n 2p | awk '{print $1}')" externalResolution="$(xrandr | grep -A 1 "^$externalScreen" | sed -n 2p | awk '{print $1}')"
pkill compton pkill compton
echo xrandr --output "$laptopScreen" --primary --mode "$laptopResolution" --pos 0x0 --rotate normal --output "$externalScreen" --mode "$externalResolution" --pos "${laptopResolution%x*}x0" --rotate normal xrandr --output "$laptopScreen" --primary --mode "$laptopResolution" --pos 0x0 --rotate normal --output "$externalScreen" --mode "$externalResolution" --pos "${laptopResolution%x*}x0" --rotate normal
/usr/bin/compton --config "$HOME/.config/picom/picom.conf" & disown /usr/bin/compton --config "$HOME/.config/picom/picom.conf" & disown
# xrandr --output "$laptopScreen" --primary --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-2 --mode 1920x1080 --pos 1920x0 --rotate normal # xrandr --output "$laptopScreen" --primary --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-2 --mode 1920x1080 --pos 1920x0 --rotate normal

@ -47,6 +47,16 @@ case "$1" in
maim -s -c 0.41,0.62,0.42,0.2 -l -u "$file" maim -s -c 0.41,0.62,0.42,0.2 -l -u "$file"
fi fi
;; ;;
"monitor")
if [ -n "$WAYLAND_DISPLAY" ]; then
notify-send "No idea"
else
mousex="$(xdotool getmouselocation | awk -F "[: ]" '{print $2}')"
mousey="$(xdotool getmouselocation | awk -F "[: ]" '{print $4}')"
monitors="$(xrandr | grep -o '[0-9]*x[0-9]*[+-][0-9]*[+-][0-9]*')"
fi
;;
*) *)
if [ -n "$WAYLAND_DISPLAY" ]; then if [ -n "$WAYLAND_DISPLAY" ]; then
grim "$file" grim "$file"

@ -0,0 +1,67 @@
#!/usr/bin/env bash
choice(){
local prompt=${1:-"Please make a selection"}
local choices="$(cat)"
local x=1
local selection
echo "$choices" | while read line; do
echo "$x: $line" | column -t -s $'\t' > /dev/tty
x=$((x+1))
done
echo -n "$prompt " > /dev/tty
read selection < /dev/tty
echo "$choices" | sed -n "$selection p" | cut -d $'\t' -f 1
}
print_help(){
echo "$0 This helps with generating ssh tunnels"
echo " -h||--help show this help"
exit 0
}
dryrun="false"
while [[ $1 = -?* ]]; do
case $1 in
-h|--help) print_help >&2 ;;
*) echo "Unknown option $1"; print_help >&2 ;;
esac
shift
done
forwardtype="$(
(
echo -e "local\tAccess on local machine something that is accessible on remote"
echo -e "remote\tAccess on remote machine something that is accessible on local"
echo -e "dynamic\tSimilar to local but creates a socks proxy"
) | choice "Forward Type:" )"
case "$forwardtype" in
"local")
echo "How would you access the resource if on the remote machine?"
echo "e.g. localhost:8834 if nessus is hosted on the remote machine"
echo -n "> "
read remote < /dev/tty
echo "Which local port would you like to listen on?"
echo -n "> "
read localport < /dev/tty
echo "ssh -L ${localport}:${remote} <server>"
;;
"remote")
echo "How would you access the resource if on the local machine?"
echo "e.g. internal-intranet:443 if there was an internal resource you wanted to get access to"
echo -n "> "
read localresource < /dev/tty
echo "Which remote port would you like to listen on the remote server (that you're sshing into)?"
echo -n "> "
read remoteport < /dev/tty
echo "ssh -R ${remoteport}:${localresource} <server>"
;;
"dynamic")
echo "Which local port would you like to listen on?"
echo -n "> "
read localport < /dev/tty
echo "ssh -D ${localport} <server>"
;;
esac

@ -414,6 +414,8 @@ attacks (XSS).\n\n"
while read source; do while read source; do
sourcemessage='' sourcemessage=''
case "$source" in case "$source" in
"'none'")
;;
"'self'") "'self'")
sourcemessage+="This is normally fine \ sourcemessage+="This is normally fine \
although care should be taken if the site being tested has upload functionality" although care should be taken if the site being tested has upload functionality"

@ -133,6 +133,10 @@ type -p cpg > /dev/null && alias cp="cpg --progress-bar"
# If enum4linux-ng is available, use that instead # If enum4linux-ng is available, use that instead
type -p enum4linux-ng > /dev/null && alias enum4linux="enum4linux-ng" type -p enum4linux-ng > /dev/null && alias enum4linux="enum4linux-ng"
# msfdb-blackarch works better than msfdb
type -p msfdb-blackarch > /dev/null && alias msfdb="msfdb-blackarch"
################### ###################
# Git Shortcuts # # Git Shortcuts #
################### ###################
@ -180,7 +184,7 @@ alias r="fzf-remind"
# Start postgres for msfconsole # Start postgres for msfconsole
# In time, use docker instead # In time, use docker instead
alias msfconsole="( systemctl status --no-pager postgresql.service > /dev/null || (echo \"Statring postgres\"; sudo systemctl start postgresql.service) ); ( pass show system/metasploit/database.yaml > database.yaml; sudo msfconsole -y database.yaml; rm database.yaml )" #alias msfconsole="( systemctl status --no-pager postgresql.service > /dev/null || (echo \"Statring postgres\"; sudo systemctl start postgresql.service) ); ( pass show system/metasploit/database.yaml > database.yaml; sudo msfconsole -y database.yaml; rm database.yaml )"
alias ss="tail -n +2 /usr/share/exploitdb/files_exploits.csv | awk -F ',' '{print \$2 \"\t\" \$3 \"\t(\" \$1 \")\"}' | fzf --preview-window=up --preview='echo {} | cut -d\" \" -f1 | xargs echo \"/usr/share/exploitdb/\" | tr -d \" \" | xargs bat --color=always' | cut -d' ' -f3 | tr -d \"()\" | xargs searchsploit -m" alias ss="tail -n +2 /usr/share/exploitdb/files_exploits.csv | awk -F ',' '{print \$2 \"\t\" \$3 \"\t(\" \$1 \")\"}' | fzf --preview-window=up --preview='echo {} | cut -d\" \" -f1 | xargs echo \"/usr/share/exploitdb/\" | tr -d \" \" | xargs bat --color=always' | cut -d' ' -f3 | tr -d \"()\" | xargs searchsploit -m"
@ -209,8 +213,6 @@ if [ -f "$HOME/GitRepos/openssl-weak/openssl-1.0.2-chacha/apps/openssl" ]; then
alias weakopenssl="$HOME/GitRepos/openssl-weak/openssl-1.0.2-chacha/apps/openssl" alias weakopenssl="$HOME/GitRepos/openssl-weak/openssl-1.0.2-chacha/apps/openssl"
alias testssl="testssl --openssl=\"$HOME/GitRepos/openssl-weak/openssl-1.0.2-chacha/apps/openssl\"" alias testssl="testssl --openssl=\"$HOME/GitRepos/openssl-weak/openssl-1.0.2-chacha/apps/openssl\""
alias verifySSL="verifySSL --openssl \"$HOME/GitRepos/openssl-weak/openssl-1.0.2-chacha/apps/openssl\"" alias verifySSL="verifySSL --openssl \"$HOME/GitRepos/openssl-weak/openssl-1.0.2-chacha/apps/openssl\""
else
alias testssl="docker run --rm -ti -v \$PWD:/data drwetter/testssl.sh"
fi fi
@ -222,7 +224,7 @@ fi
# Keyboard - reset # Keyboard - reset
# Sometimes, if I turn the screens off, the keyboard resets itself to defaults. Not sure why but this will put my keyboard back to how I like it # Sometimes, if I turn the screens off, the keyboard resets itself to defaults. Not sure why but this will put my keyboard back to how I like it
#alias kb="xmodmap ~/.Xmodmap; xset r rate 200 70; xcape" #alias kb="xmodmap ~/.Xmodmap; xset r rate 200 70; xcape"
alias keys="setxkbmap -layout gb -variant colemak -option shift:both_capslock -option compose:ralt; xset r rate 200 70; xinput --list | grep -Ei 'ErgoDox EZ\s+id' | grep -oE 'id=[0-9]+' | cut -d'=' -f2 | xargs -r setxkbmap -layout gb -device" alias keys="setxkbmap -layout gb -variant colemak -option shift:both_capslock -option compose:ralt; xset r rate 200 70; xinput --list | grep -Ei 'ErgoDox EZ Glow\s+id' | grep -oE 'id=[0-9]+' | cut -d'=' -f2 | xargs -r setxkbmap -layout gb -device"
alias colemak="setxkbmap -layout gb,gb -variant \"colemak,\" -option grp:shifts_toggle" alias colemak="setxkbmap -layout gb,gb -variant \"colemak,\" -option grp:shifts_toggle"
alias qwerty="setxkbmap -layout gb" alias qwerty="setxkbmap -layout gb"
@ -296,6 +298,7 @@ if type grc > /dev/null 2>&1; then
done done
fi fi
alias stripAnsi='sed -E '"'"'s/\x1B\[[0-9;]*[JKmsu]//g'"'"

Loading…
Cancel
Save