Class: HashIdentifier
- Inherits:
-
Object
- Object
- HashIdentifier
- Includes:
- Version
- Defined in:
- lib/haiti.rb,
lib/haiti/hash.rb
Overview
The global Hash Identifier class
Defined Under Namespace
Classes: Chf
Constant Summary collapse
- PROTOTYPES =
JSON.parse(File.read(File.join(__dir__, '../data/prototypes.json')))
- COMMONS =
JSON.parse(File.read(File.join(__dir__, '../data/commons.json')))
Constants included from Version
Instance Attribute Summary collapse
-
#hash ⇒ String
readonly
The hash (as provided).
-
#type ⇒ Array<Chf>
readonly
List of Chf objects, representing the identified hashes.
Class Method Summary collapse
-
.list ⇒ Array<String>
List names of all hash types available.
-
.object_list ⇒ Array<Chf>
List all hash types available as <Chf> object.
-
.samples(input) ⇒ Array<String>
Find hash samples for a given hash type (by name or hashcat/john the ripper reference).
Instance Method Summary collapse
-
#initialize(hash) ⇒ HashIdentifier
constructor
A new instance of hash identifier.
Constructor Details
#initialize(hash) ⇒ HashIdentifier
A new instance of hash identifier
27 28 29 30 31 |
# File 'lib/haiti.rb', line 27 def initialize(hash) @hash = hash @type = identify(hash) sort_commons end |
Instance Attribute Details
#hash ⇒ String (readonly)
Returns the hash (as provided).
19 20 21 |
# File 'lib/haiti.rb', line 19 def hash @hash end |
Class Method Details
.list ⇒ Array<String>
List names of all hash types available
59 60 61 |
# File 'lib/haiti.rb', line 59 def list (PROTOTYPES.flat_map { |d| d['modes'].map { |m| m['name'] } }).sort { |a, b| a.downcase <=> b.downcase }.uniq end |
.object_list ⇒ Array<Chf>
List all hash types available as <Chf> object
65 66 67 68 69 70 71 |
# File 'lib/haiti.rb', line 65 def object_list (PROTOTYPES.flat_map do |d| d['modes'].map do |m| Chf.new(m) end end).sort { |a, b| a.name.downcase <=> b.name.downcase }.uniq end |
.samples(input) ⇒ Array<String>
Find hash samples for a given hash type (by name or hashcat/john the ripper reference)
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/haiti.rb', line 40 def samples(input) samples = [] PROTOTYPES.each do |prototype| prototype['modes'].each do |mode| if [mode['name'].downcase, mode['hashcat'].to_s, mode['john'].nil? ? mode['john'] : mode['john'].downcase].include?(input.to_s.downcase) samples << Chf.new(mode).samples end end end samples.delete(nil) samples.flatten.uniq end |