Skip to content

Commit

Permalink
common algorithms are sorted first
Browse files Browse the repository at this point in the history
fix #26
  • Loading branch information
noraj committed Apr 27, 2021
1 parent d974afd commit f13abab
Show file tree
Hide file tree
Showing 17 changed files with 158 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
haiti-hash (1.1.0)
haiti-hash (1.1.1)
docopt (~> 0.6)
paint (~> 2.2)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ A CLI tool (and library) to identify the hash type of a given hash.

## Features

- 340+ hash types detected
- 360+ hash types detected
- Modern algorithms supported (SHA3, Keccak, Blake2, etc.)
- Hashcat and John the Ripper references
- CLI tool & library
Expand Down
29 changes: 29 additions & 0 deletions data/commons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
"MD5",
"SHA-1",
"SHA-256",
"SHA-512",
"bcrypt",
"NTLM",
"NetNTLMv2",
"NetNTLMv1-VANILLA / NetNTLMv1+ESS",
"BLAKE2-512",
"SHA3-224",
"SHA3-256",
"SHA3-512",
"Keccak-256",
"Keccak-512",
"CRC-32B",
"CRC-32",
"CRC-16",
"CRC-64",
"GOST R 34.11-94",
"Apache MD5",
"MD5(APR)",
"md5apr1",
"Domain Cached Credentials",
"Domain Cached Credentials 2",
"LM",
"RIPEMD-160",
"scrypt"
]
11 changes: 11 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
## [Unreleased]

## [1.1.1]

- code:
- common algorithms are sorted first
- add some BLAKE2 length variants
- add some Kerberos variants
- add some cryptocurrency wallets (bitcoin, ethereum, monero)
- add Android Backup
- add WinZip
- add iTunes backup

## [1.1.0]

- code:
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A CLI tool (and library) to identify the hash type of a given hash.

## Features

- 340+ hash types detected
- 360+ hash types detected
- Modern algorithms supported (SHA3, Keccak, Blake2, etc.)
- Hashcat and John the Ripper references
- CLI tool & library
Expand Down
100 changes: 86 additions & 14 deletions docs/yard/HashIdentifier.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ <h2>
</dt>
<dd><pre class="code"><span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid___dir__'>__dir__</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>../data/prototypes.json</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span></pre></dd>

<dt id="COMMONS-constant" class="">COMMONS =

</dt>
<dd><pre class="code"><span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid___dir__'>__dir__</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>../data/commons.json</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span></pre></dd>

</dl>


Expand Down Expand Up @@ -274,6 +279,30 @@ <h2>
<p>A new instance of hash identifier.</p>
</div></span>

</li>


<li class="private ">
<span class="summary_signature">

<a href="#sort_commons-instance_method" title="#sort_commons (instance method)">#<strong>sort_commons</strong> &#x21d2; Object </a>



</span>



<span class="note title private">private</span>





<span class="summary_desc"><div class='inline'>
<p>Sort common hash types first.</p>
</div></span>

</li>


Expand Down Expand Up @@ -335,17 +364,19 @@ <h3 class="signature first" id="initialize-instance_method">
<pre class="lines">


26
27
28
29</pre>
29
30
31</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/haiti.rb', line 26</span>
<pre class="code"><span class="info file"># File 'lib/haiti.rb', line 27</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
<span class='ivar'>@hash</span> <span class='op'>=</span> <span class='id identifier rubyid_hash'>hash</span>
<span class='ivar'>@type</span> <span class='op'>=</span> <span class='id identifier rubyid_identify'>identify</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
<span class='id identifier rubyid_sort_commons'>sort_commons</span>
<span class='kw'>end</span></pre>
</td>
</tr>
Expand Down Expand Up @@ -411,12 +442,12 @@ <h3 class="signature first" id="hash-instance_method">
<pre class="lines">


18
19
20</pre>
20
21</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/haiti.rb', line 18</span>
<pre class="code"><span class="info file"># File 'lib/haiti.rb', line 19</span>

<span class='kw'>def</span> <span class='id identifier rubyid_hash'>hash</span>
<span class='ivar'>@hash</span>
Expand Down Expand Up @@ -472,12 +503,12 @@ <h3 class="signature " id="type-instance_method">
<pre class="lines">


22
23
24</pre>
24
25</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/haiti.rb', line 22</span>
<pre class="code"><span class="info file"># File 'lib/haiti.rb', line 23</span>

<span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span>
<span class='ivar'>@type</span>
Expand Down Expand Up @@ -558,8 +589,6 @@ <h3 class="signature first" id="identify-instance_method">
<pre class="lines">


37
38
39
40
41
Expand All @@ -569,10 +598,12 @@ <h3 class="signature first" id="identify-instance_method">
45
46
47
48</pre>
48
49
50</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/haiti.rb', line 37</span>
<pre class="code"><span class="info file"># File 'lib/haiti.rb', line 39</span>

<span class='kw'>def</span> <span class='id identifier rubyid_identify'>identify</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
Expand All @@ -589,14 +620,55 @@ <h3 class="signature first" id="identify-instance_method">
</td>
</tr>
</table>
</div>

<div class="method_details ">
<h3 class="signature " id="sort_commons-instance_method">

#<strong>sort_commons</strong> &#x21d2; <tt>Object</tt> <span class="extras">(private)</span>





</h3><div class="docstring">
<div class="discussion">

<p>Sort common hash types first</p>


</div>
</div>
<div class="tags">


</div><table class="source_code">
<tr>
<td>
<pre class="lines">


53
54
55</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/haiti.rb', line 53</span>

<span class='kw'>def</span> <span class='id identifier rubyid_sort_commons'>sort_commons</span>
<span class='ivar'>@type</span><span class='period'>.</span><span class='id identifier rubyid_sort_by!'>sort_by!</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_e'>e</span><span class='op'>|</span> <span class='const'><span class='object_link'><a href="#COMMONS-constant" title="HashIdentifier::COMMONS (constant)">COMMONS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='int'>0</span> <span class='op'>:</span> <span class='int'>1</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>

</div>

</div>

<div id="footer">
Generated on Mon Apr 26 16:12:14 2021 by
Generated on Tue Apr 27 10:07:42 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-3.0.1).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/yard/HashIdentifier/Chf.html
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ <h3 class="signature " id="name-instance_method">
</div>

<div id="footer">
Generated on Mon Apr 26 16:12:14 2021 by
Generated on Tue Apr 27 10:07:42 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-3.0.1).
</div>
Expand Down
4 changes: 2 additions & 2 deletions docs/yard/Version.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ <h2>
<dt id="VERSION-constant" class="">VERSION =

</dt>
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>1.1.0</span><span class='tstring_end'>&#39;</span></span></pre></dd>
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>1.1.1</span><span class='tstring_end'>&#39;</span></span></pre></dd>

</dl>

Expand All @@ -116,7 +116,7 @@ <h2>
</div>

<div id="footer">
Generated on Mon Apr 26 16:12:14 2021 by
Generated on Tue Apr 27 10:07:42 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-3.0.1).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/yard/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ <h2>Namespace Listing A-Z</h2>
</div>

<div id="footer">
Generated on Mon Apr 26 16:12:14 2021 by
Generated on Tue Apr 27 10:07:42 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-3.0.1).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/yard/file.LICENSE.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<div id="content"><div id='filecontents'>The MIT License (MIT)<br/><br/>Copyright (c) 2020-2020 Alexandre ZANNI<br/>Copyright (c) 2019-2020 Alexandre ZANNI at Orange Cyberdefense<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the &quot;Software&quot;), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in<br/>all copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>THE SOFTWARE.</div></div>

<div id="footer">
Generated on Mon Apr 26 16:12:14 2021 by
Generated on Tue Apr 27 10:07:42 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-3.0.1).
</div>
Expand Down
4 changes: 2 additions & 2 deletions docs/yard/file.README.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ <h2 id="what-is-it">What is it?</h2>
<h2 id="features">Features</h2>

<ul>
<li>270+ hash types detected</li>
<li>360+ hash types detected</li>
<li>Modern algorithms supported (SHA3, Keccak, Blake2, etc.) </li>
<li>Hashcat and John the Ripper references</li>
<li>CLI tool &amp; library</li>
Expand Down Expand Up @@ -119,7 +119,7 @@ <h2 id="author">Author</h2>
</div></div>

<div id="footer">
Generated on Mon Apr 26 16:12:14 2021 by
Generated on Tue Apr 27 10:07:42 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-3.0.1).
</div>
Expand Down
4 changes: 2 additions & 2 deletions docs/yard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ <h2 id="what-is-it">What is it?</h2>
<h2 id="features">Features</h2>

<ul>
<li>270+ hash types detected</li>
<li>360+ hash types detected</li>
<li>Modern algorithms supported (SHA3, Keccak, Blake2, etc.) </li>
<li>Hashcat and John the Ripper references</li>
<li>CLI tool &amp; library</li>
Expand Down Expand Up @@ -119,7 +119,7 @@ <h2 id="author">Author</h2>
</div></div>

<div id="footer">
Generated on Mon Apr 26 16:12:14 2021 by
Generated on Tue Apr 27 10:07:42 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-3.0.1).
</div>
Expand Down
8 changes: 8 additions & 0 deletions docs/yard/method_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ <h1 id="full_list_header">Method List</h1>


<li class="odd ">
<div class="item">
<span class='object_link'><a href="HashIdentifier.html#sort_commons-instance_method" title="HashIdentifier#sort_commons (method)">#sort_commons</a></span>
<small>HashIdentifier</small>
</div>
</li>


<li class="even ">
<div class="item">
<span class='object_link'><a href="HashIdentifier.html#type-instance_method" title="HashIdentifier#type (method)">#type</a></span>
<small>HashIdentifier</small>
Expand Down
2 changes: 1 addition & 1 deletion docs/yard/top-level-namespace.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h2>Defined Under Namespace</h2>
</div>

<div id="footer">
Generated on Mon Apr 26 16:12:14 2021 by
Generated on Tue Apr 27 10:07:42 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-3.0.1).
</div>
Expand Down
7 changes: 7 additions & 0 deletions lib/haiti.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class HashIdentifier
# Constants
include Version
PROTOTYPES = JSON.parse(File.read(File.join(__dir__, '../data/prototypes.json')))
COMMONS = JSON.parse(File.read(File.join(__dir__, '../data/commons.json')))

# @return [String] the hash (as provided)
# @example
Expand All @@ -26,6 +27,7 @@ class HashIdentifier
def initialize(hash)
@hash = hash
@type = identify(hash)
sort_commons
end

private
Expand All @@ -46,4 +48,9 @@ def identify(hash)
end
return res
end

# Sort common hash types first
def sort_commons
@type.sort_by! { |e| COMMONS.include?(e.name) ? 0 : 1 }
end
end
2 changes: 1 addition & 1 deletion lib/haiti/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Version
VERSION = '1.1.0'
VERSION = '1.1.1'
end
Loading

0 comments on commit f13abab

Please sign in to comment.