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.1'
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 23 24 |
# File 'lib/kh2hc.rb', line 15 def self.convert(khfile) hosts = [] data = File.read(khfile) # |<Magic string>|<salt>|<hash> <key algorithm> <public key sig.> data.scan(/^\|1\|([^|]+)\|([^|].+) .+ .+$/).each do |host| # hash:salt hosts << { hash: host[1].from_b64.to_hex, salt: host[0].from_b64.to_hex } end hosts end |
.convert1(khfile) ⇒ String
Convert OpenSSH known_hosts file hashed with HashKnownHosts to a hash file crackable by Hashcat.
29 30 31 32 33 34 35 |
# File 'lib/kh2hc.rb', line 29 def self.convert1(khfile) hc_out = [] convert(khfile).each do |host| hc_out << "#{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.
40 41 42 43 44 45 46 47 |
# File 'lib/kh2hc.rb', line 40 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 |