Skip to content

Commit

Permalink
add fzf binaries
Browse files Browse the repository at this point in the history
fix #168
  • Loading branch information
noraj committed Nov 6, 2023
1 parent 003a9a6 commit b967a52
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 0 deletions.
57 changes: 57 additions & 0 deletions bin/haiti-fzf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# Ruby internal
# Project internal
require 'haiti'
# External
require 'docopt'
require 'paint'

doc = <<~DOCOPT
#{Paint['HAITI (HAsh IdenTifIer)', '#FF69B4']} v#{Paint[HashIdentifier::VERSION, :bold]}
#{Paint['Usage:', '#00FFFF']}
haiti-fzf hc [options] <hash>
haiti-fzf jtr [options] <hash>
haiti-fzf -h | --help
haiti-fzf --version
#{Paint['Commands:', '#00FFFF']}
hc Select a Hashcat reference with fzf from one of the matching hash types
jtr Select a John the Ripper reference with fzf from one of the matching hash types
#{Paint['Parameters:', '#00FFFF']}
<hash> Hash string to identify, read from STDIN if equal to "-"
#{Paint['Options:', '#00FFFF']}
-e, --extended List all possible hash algorithms including ones using salt
--debug Display arguments
-h, --help Show this screen
--version Show version
#{Paint['Examples:', '#00FFFF']}
haiti-fzf hc -e d41d8cd98f00b204e9800998ecf8427e
haiti-fzf jtr d41d8cd98f00b204e9800998ecf8427e
#{Paint['Project:', '#00FFFF']}
#{Paint['author', :underline]} (https://pwn.by/noraj / https://twitter.com/noraj_rawsec)
#{Paint['source', :underline]} (https://github.com/noraj/haiti)
#{Paint['documentation', :underline]} (https://noraj.github.io/haiti)
DOCOPT

begin
args = Docopt.docopt(doc, version: HashIdentifier::VERSION)
puts args if args['--debug']
# use case 1, using the tool
if args['<hash>']
args['<hash>'] = $stdin.read.chomp if args['<hash>'] == '-'
ext = args['--extended'] ? '-e' : ''
system("haiti-parsable hc #{ext} #{args['<hash>']} | fzf | cut -d '|' -f 2") if args['hc']
system("haiti-parsable jtr #{ext} #{args['<hash>']} | fzf | cut -d '|' -f 2") if args['jtr']
end
# use case 2, help: already handled by docopt
# use case 3, version: already handled by docopt
rescue Docopt::Exit => e
puts e.message
end
69 changes: 69 additions & 0 deletions bin/haiti-parsable
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# Ruby internal
# Project internal
require 'haiti'
# External
require 'docopt'
require 'paint'

doc = <<~DOCOPT
#{Paint['HAITI (HAsh IdenTifIer)', '#FF69B4']} v#{Paint[HashIdentifier::VERSION, :bold]}
#{Paint['Usage:', '#00FFFF']}
haiti-parsable hc [options] <hash>
haiti-parsable jtr [options] <hash>
haiti-parsable -h | --help
haiti-parsable --version
#{Paint['Commands:', '#00FFFF']}
hc Display hash types matching that have a Hashcat reference
jtr Display hash types matching that have a John the Ripper reference
#{Paint['Parameters:', '#00FFFF']}
<hash> Hash string to identify, read from STDIN if equal to "-"
#{Paint['Options:', '#00FFFF']}
-e, --extended List all possible hash algorithms including ones using salt
--debug Display arguments
-h, --help Show this screen
--version Show version
#{Paint['Examples:', '#00FFFF']}
haiti-parsable hc -e d41d8cd98f00b204e9800998ecf8427e
haiti-parsable jtr d41d8cd98f00b204e9800998ecf8427e
#{Paint['Project:', '#00FFFF']}
#{Paint['author', :underline]} (https://pwn.by/noraj / https://twitter.com/noraj_rawsec)
#{Paint['source', :underline]} (https://github.com/noraj/haiti)
#{Paint['documentation', :underline]} (https://noraj.github.io/haiti)
DOCOPT

def manage_options(args, types)
types.each do |type|
next if type.extended && !args['--extended']

puts "#{type.name} |#{type.hashcat}" if args['hc'] && !type.hashcat.nil?
puts "#{type.name} |#{type.john}" if args['jtr'] && !type.john.nil?
end
end

begin
args = Docopt.docopt(doc, version: HashIdentifier::VERSION)
puts args if args['--debug']
# use case 1, using the tool
if args['<hash>']
args['<hash>'] = $stdin.read.chomp if args['<hash>'] == '-'
hi = HashIdentifier.new(args['<hash>'])
if hi.type.empty?
puts 'Unknown hash type'
exit(0)
end
manage_options(args, hi.type)
end
# use case 2, help: already handled by docopt
# use case 3, version: already handled by docopt
rescue Docopt::Exit => e
puts e.message
end
53 changes: 53 additions & 0 deletions bin/hashcat-haiti
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# Ruby internal
# Project internal
require 'haiti'
# External
require 'docopt'
require 'paint'

doc = <<~DOCOPT
#{Paint['HAITI (HAsh IdenTifIer)', '#FF69B4']} v#{Paint[HashIdentifier::VERSION, :bold]}
#{Paint['Usage:', '#00FFFF']}
hashcat-haiti [options] <hash> -- <hashcat_options>...
hashcat-haiti -h | --help
hashcat-haiti --version
#{Paint['Parameters:', '#00FFFF']}
<hash> Hash string to identify, read from STDIN if equal to "-"
#{Paint['Options:', '#00FFFF']}
-e, --extended List all possible hash algorithms including ones using salt
--debug Display arguments
-h, --help Show this screen
--version Show version
#{Paint['Examples:', '#00FFFF']}
hashcat-haiti -e d41d8cd98f00b204e9800998ecf8427e -- hashes.txt /usr/share/wordlists/passwords/rockyou.txt -r /usr/share/doc/hashcat/rules/best64.rule
hashcat-haiti d41d8cd98f00b204e9800998ecf8427e -- hashes.txt -a 3
head -1 /tmp/hash.txt | hashcat-haiti - -- /tmp/hash.txt
hashcat-haiti -e d41d8cd98f00b204e9800998ecf8427e -- hashes.txt --show
#{Paint['Project:', '#00FFFF']}
#{Paint['author', :underline]} (https://pwn.by/noraj / https://twitter.com/noraj_rawsec)
#{Paint['source', :underline]} (https://github.com/noraj/haiti)
#{Paint['documentation', :underline]} (https://noraj.github.io/haiti)
DOCOPT

begin
args = Docopt.docopt(doc, version: HashIdentifier::VERSION)
puts args if args['--debug']
# use case 1, using the tool
if args['<hash>']
args['<hash>'] = $stdin.read.chomp if args['<hash>'] == '-'
ext = args['--extended'] ? '-e' : ''
system("hashcat -m $(haiti-fzf hc #{ext} #{args['<hash>']}) #{args['<hashcat_options>'].join(' ')}")
end
# use case 2, help: already handled by docopt
# use case 3, version: already handled by docopt
rescue Docopt::Exit => e
puts e.message
end
53 changes: 53 additions & 0 deletions bin/john-haiti
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# Ruby internal
# Project internal
require 'haiti'
# External
require 'docopt'
require 'paint'

doc = <<~DOCOPT
#{Paint['HAITI (HAsh IdenTifIer)', '#FF69B4']} v#{Paint[HashIdentifier::VERSION, :bold]}
#{Paint['Usage:', '#00FFFF']}
john-haiti [options] <hash> -- <john_options>...
john-haiti -h | --help
john-haiti --version
#{Paint['Parameters:', '#00FFFF']}
<hash> Hash string to identify, read from STDIN if equal to "-"
#{Paint['Options:', '#00FFFF']}
-e, --extended List all possible hash algorithms including ones using salt
--debug Display arguments
-h, --help Show this screen
--version Show version
#{Paint['Examples:', '#00FFFF']}
john-haiti -e d41d8cd98f00b204e9800998ecf8427e -- hashes.txt --wordlist=/usr/share/wordlists/passwords/rockyou.txt
john-haiti 1f474c6dadb3cb2370f6cb88d4576ede0db9ff43 -- hashes.txt --rules=NT --fork=3
head -1 /tmp/hash.txt | john-haiti - -- /tmp/hash.txt
john-haiti -e d41d8cd98f00b204e9800998ecf8427e -- hashes.txt --show
#{Paint['Project:', '#00FFFF']}
#{Paint['author', :underline]} (https://pwn.by/noraj / https://twitter.com/noraj_rawsec)
#{Paint['source', :underline]} (https://github.com/noraj/haiti)
#{Paint['documentation', :underline]} (https://noraj.github.io/haiti)
DOCOPT

begin
args = Docopt.docopt(doc, version: HashIdentifier::VERSION)
puts args if args['--debug']
# use case 1, using the tool
if args['<hash>']
args['<hash>'] = $stdin.read.chomp if args['<hash>'] == '-'
ext = args['--extended'] ? '-e' : ''
system("john --format=$(haiti-fzf jtr #{ext} #{args['<hash>']}) #{args['<john_options>'].join(' ')}")
end
# use case 2, help: already handled by docopt
# use case 3, version: already handled by docopt
rescue Docopt::Exit => e
puts e.message
end
11 changes: 11 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
## [unreleased]

## [2.1.0]

- **Additions**:
- 4 new binaries
- `hashcat-haiti`: wrapper for Hashcat where you can select the mode using haiti and fzf
- `john-haiti`: wrapper for John the Ripper where you can select the format using haiti and fzf
- `haiti-fzf`: select a Hashcat or John the Ripper reference with fzf from one of the matching hash types
- mostly useful for `hashcat-haiti` and `john-haiti` or building another binary or alias that will make use of haiti with fzf input
- `haiti-parsable`: display hash types matching that have a Hashcat reference in an easily parsable format
- mostly useful for `haiti-fzf` or building another binary or alias

## [2.0.0]

- **Breaking changes**:
Expand Down

0 comments on commit b967a52

Please sign in to comment.