Module: Kh2hc
- Defined in:
- lib/kh2hc.rb,
lib/kh2hc/cli.rb,
lib/kh2hc/version.rb
Overview
known_hosts to Hashcat
Defined Under Namespace
Modules: CLI
Constant Summary collapse
- VERSION =
Version of Kh2hc library and app
'0.0.2'
Class Method Summary collapse
-
.convert(khfile) ⇒ Array<Hash>
Convert OpenSSH known_hosts file hashed with HashKnownHosts to an array of hashes crackable by Hashcat.
-
.convert1(khfile) ⇒ String
Convert OpenSSH known_hosts file hashed with HashKnownHosts to a hash file crackable by Hashcat.
-
.hashed?(khfile) ⇒ Boolean
Check if OpenSSH known_hosts is hashed with HashKnownHosts option or not.
Class Method Details
.convert(khfile) ⇒ Array<Hash>
Convert OpenSSH known_hosts file hashed with HashKnownHosts to an array of hashes crackable by Hashcat.
15 16 17 18 19 20 21 22 |
# File 'lib/kh2hc.rb', line 15 def self.convert(khfile) data = File.read(khfile) # |<Magic string>|<salt>|<hash> <key algorithm> <public key sig.> data.scan(/^\|1\|([^|]+)\|([^|].+) .+ .+$/).map do |host| # hash:salt { hash: host[1].from_b64.to_hex, salt: host[0].from_b64.to_hex } end end |
.convert1(khfile) ⇒ String
Convert OpenSSH known_hosts file hashed with HashKnownHosts to a hash file crackable by Hashcat.
27 28 29 30 31 32 |
# File 'lib/kh2hc.rb', line 27 def self.convert1(khfile) hc_out = convert(khfile).map do |host| "#{host[:hash]}:#{host[:salt]}" end hc_out.join("\n") end |
.hashed?(khfile) ⇒ Boolean
Check if OpenSSH known_hosts is hashed with HashKnownHosts option or not.
37 38 39 40 41 42 43 44 |
# File 'lib/kh2hc.rb', line 37 def self.hashed?(khfile) File.open(khfile) do |f| return f.read(3) == '|1|' end # Resources friendly version of: # data = File.read(khfile) # /\A\|1\|/.match?(data) end |