Makes hashcat mode completion automatic on tab after -m

master
Jonathan Hodgson 5 years ago
parent 187872ab6a
commit 433b39942b
  1. 17
      shells/zsh/oh-my-zsh-custom/fzf.zsh

@ -52,7 +52,6 @@ if [ -e /usr/share/fzf/key-bindings.zsh ]; then
local comp=$(echo $1 | cut -d':' -f1) local comp=$(echo $1 | cut -d':' -f1)
local prompt=$(echo $1 | cut -d':' -f2) local prompt=$(echo $1 | cut -d':' -f2)
local currentProject=$(project current --path) local currentProject=$(project current --path)
export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --reverse --height 40%"
find "$HOME/.local/share/snippets/" -name \*.func | while read line; do find "$HOME/.local/share/snippets/" -name \*.func | while read line; do
source "$line" source "$line"
done done
@ -81,9 +80,6 @@ if [ -e /usr/share/fzf/key-bindings.zsh ]; then
snip) snip)
snippets snippets
;; ;;
hcm)
hashcat --example-hashes | awk -v RS="\n\n" -F "\t" '{gsub("\n","\t",$0); print $1 "\t" $2 "\t" $3}' | sed 's/MODE: //; s/TYPE: //' | fzf -d "\t" --header="Mode Type" --with-nth='1,2' --preview='echo {3}' --preview-window=up:1 | cut -d' ' -f1
;;
network-interface|int) network-interface|int)
ip -o link show | cut -d' ' -f2- | sed -E 's/[^:]+(UP|DOWN).*/\1/' | tr ':' ' ' | fzf --preview="interface=\$(echo {} | cut -f1 -d' ');ip address show \$interface" | cut -d' ' -f1 ip -o link show | cut -d' ' -f2- | sed -E 's/[^:]+(UP|DOWN).*/\1/' | tr ':' ' ' | fzf --preview="interface=\$(echo {} | cut -f1 -d' ');ip address show \$interface" | cut -d' ' -f1
;; ;;
@ -131,6 +127,7 @@ jhswap(){
# I want my tab complete to be based on "current" word I am typing sometimes, before the command # I want my tab complete to be based on "current" word I am typing sometimes, before the command
custom_tabcomplete(){ custom_tabcomplete(){
local tokens cmd prefix trigger tail fzf matches lbuf d_cmds local tokens cmd prefix trigger tail fzf matches lbuf d_cmds
export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --reverse --height 40%"
setopt localoptions noshwordsplit noksh_arrays noposixbuiltins setopt localoptions noshwordsplit noksh_arrays noposixbuiltins
if [ -n "$RBUFFER" ]; then if [ -n "$RBUFFER" ]; then
@ -141,7 +138,6 @@ jhswap(){
fi fi
# http://zsh.sourceforge.net/FAQ/zshfaq03.html # http://zsh.sourceforge.net/FAQ/zshfaq03.html
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
tokens=(${(z)LBUFFER}) tokens=(${(z)LBUFFER})
@ -150,7 +146,16 @@ jhswap(){
return return
fi fi
cmd=${tokens[1]} cmd=${tokens[1]}
tail=${LBUFFER:$(( ${#LBUFFER} - ${#trigger} ))} if [[ "$cmd" == "hydra" && "${tokens[-1]}" == "-m" ]]; then
mode=$(hashcat --example-hashes | awk -v RS="\n\n" -F "\t" '{gsub("\n","\t",$0); print $1 "\t" $2 "\t" $3}' | sed 's/MODE: //; s/TYPE: //' | fzf -d "\t" --header="Mode Type" --with-nth='1,2' --preview='echo {3}' --preview-window=up:1 | cut -d' ' -f1)
if [[ "${LBUFFER[-1]}" != " " ]]; then
LBUFFER="${LBUFFER} "
fi
LBUFFER="${LBUFFER}${mode}"
zle reset-prompt
return $ret
return 0
fi
#local newLBuffer="${tokens:1:${#tokens[@]}-1}" #local newLBuffer="${tokens:1:${#tokens[@]}-1}"
local newLBuffer local newLBuffer
for i in $(seq 1 $((${#tokens[@]} - 1)) ); do for i in $(seq 1 $((${#tokens[@]} - 1)) ); do

Loading…
Cancel
Save