Improvements to hashcat completion
The main args completion no longer uses a bash while loop for splitting up the arguments making it much faster. I have also removed the use of FZF for looking up modes. This has been moved into the overidepartialcompletion file in includes.
This commit is contained in:
		
							parent
							
								
									02b9b6e51e
								
							
						
					
					
						commit
						69206d46a4
					
				
					 2 changed files with 11 additions and 17 deletions
				
			
		|  | @ -15,23 +15,11 @@ trim(){ | |||
| } | ||||
| 
 | ||||
| _args(){ | ||||
| 	hashcat --help | sed -n '/Options/,/Hash modes/p' | tail -n +5 | head -n -2 | while read line; do | ||||
| 		op="$(echo "$line" | cut -d"|" -f1 | trim)" | ||||
| 		description="$(echo "$line" | cut -d"|" -f3 | trim)" | ||||
| 		ty="$(echo "$line" | cut -d"|" -f2 | trim)" | ||||
| 		echo "$op" | sed 's/,/\n/' | trim | awk "{print \$1 \":$description:$ty\"}" | ||||
| 	done | ||||
| 	hashcat --help | sed -n '/Options/,/Hash modes/p' | tail -n +5 | head -n -2 | awk -F '|' '{sub(/[ \t]+$/, "", $1); sub(/[ \t]+$/, "", $3); print $1  ":" $3 ":" $2}' | awk -F ':' '{ if ($1 ~ ",") { first=$1; second=$1; sub(/,.*/,"",first); sub(/.*,/,"",second); print first ":" $2 ":" $3 "\n" second ":" $2 ":" $3 } else {print $0} }' | trim | ||||
| } | ||||
| 
 | ||||
| _hashes(){ | ||||
| 	if $(type fzf > /dev/null); then | ||||
| 		# If fzf if available, use it for hash completion | ||||
| 
 | ||||
| 		hashcat --example-hashes | grep -E '(mode|Example\.Hash\.\.|Name|^$)' | awk -F ': ' '{print $NF}' | sed 's/Hash mode #//' | awk -v RS="\n\n" -F="\t" '{gsub("\n","\t",$0);print $0}' | fzf -d "\t" --header="Mode Type" --with-nth='1,2' --preview='echo {3}' --preview-window=up:1 --height=40% | cut -d'	' -f1 | ||||
| 	else | ||||
| 		hashcat --example-hashes | awk -v RS="\n\n" -F "\t" '{gsub("\n","\t",$0); print $1 ":" $2 }' | sed 's/MODE: //; s/TYPE: //' | ||||
| 	fi | ||||
| 	return 0 | ||||
| 		hashcat --example-hashes | grep -E '(mode|Name|^$)' | awk -F ': ' '{print $NF}' | sed 's/Hash mode #//' | awk -v RS="\n\n" -F="\t" '{gsub("\n",":",$0);print $0}' | ||||
| } | ||||
| 
 | ||||
| _basic_section(){ | ||||
|  | @ -66,9 +54,8 @@ best_guess(){ | |||
| 
 | ||||
| case "$previousArg" in | ||||
| 	-m|--hash-type) | ||||
| 		# hashes=("${(f)$(_hashes)}") | ||||
| 		# _describe "Hashes" hashes ;; | ||||
| 		compadd -- "$(_hashes)" ;; | ||||
| 		hashes=("${(f)$(_hashes)}") | ||||
| 		_describe "Hashes" hashes ;; | ||||
| 	-a|--attack-mode) | ||||
| 		ops=("${(f)$(_basic_section "Attack Modes")}") | ||||
| 		_describe "Modes" ops ;; | ||||
|  |  | |||
|  | @ -53,6 +53,13 @@ overidecomplete(){ | |||
| 				esac ;; | ||||
| 			ytaudio) | ||||
| 				toadd="\"$(cat "$HOME/Music/youtube-playlists" | fzf -d '	' --with-nth=2 --preview='echo {1}' --preview-window=up:1 | cut -d'	' -f1)\""; ret=0 ;; | ||||
| 			hashcat) | ||||
| 				case "$lastWord" in | ||||
| 					-m|--hash-type) toadd="$( hashcat --example-hashes | grep -E '(mode|Example\.Hash\.\.|Name|^$)' | awk -F ': ' '{print $NF}' | sed 's/Hash mode #//' | awk -v RS="\n\n" -F="\t" '{gsub("\n","\t",$0);print $0}' | fzf -d "\t" --header="Mode Type" --with-nth='1,2' --preview='echo {3}' --preview-window=up:1 --height=40% | cut -d'	' -f1)" | ||||
| 						ret=0 | ||||
| 						;; | ||||
| 				esac | ||||
| 				;; | ||||
| 
 | ||||
| 		esac | ||||
| 	fi | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue