Sha256: 20536f7268468b962b683a3754da17d3ed526960c8661a6eb3b9ea1afdc7e5d2

Contents?: true

Size: 1.85 KB

Versions: 2

Compression:

Stored size: 1.85 KB

Contents

#!/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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
haiti-hash-3.0.0 bin/john-haiti
haiti-hash-2.1.0 bin/john-haiti