#!/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] -- ... hashcat-haiti -h | --help hashcat-haiti --version #{Paint['Parameters:', '#00FFFF']} 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[''] args[''] = $stdin.read.chomp if args[''] == '-' ext = args['--extended'] ? '-e' : '' system("hashcat -m $(haiti-fzf hc #{ext} #{args['']}) #{args[''].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