ntlm and lm hashes

This commit is contained in:
thomashaw
2018-11-05 11:44:28 +00:00
committed by ts
parent 508506ed59
commit d2a04f8d43
19 changed files with 173 additions and 5 deletions

View File

@@ -22,6 +22,7 @@ gem 'programr', :git => "http://github.com/robertjwhitney/programr.git"
gem 'process_helper'
gem 'ovirt-engine-sdk'
gem 'duplicate'
gem 'smbhash'
#development only gems go here
group :test, :development do

View File

@@ -84,6 +84,7 @@ GEM
rsync (1.0.9)
rubyzip (1.2.2)
semantic_puppet (1.0.2)
smbhash (1.0.2)
spidr (0.6.0)
nokogiri (~> 1.3)
sshkey (1.9.0)
@@ -121,6 +122,7 @@ DEPENDENCIES
redcarpet
rmagick
rqrcode
smbhash
sshkey
wordlist
yard
@@ -128,4 +130,4 @@ DEPENDENCIES
zipruby
BUNDLED WITH
1.15.4
1.16.1

View File

@@ -5,6 +5,7 @@ require 'digest'
class HashEncoder < StringEncoder
attr_accessor :salt
attr_accessor :return_salts
attr_accessor :salt_position
def initialize
super
@@ -12,6 +13,7 @@ class HashEncoder < StringEncoder
self.strings_to_encode = []
self.salt = []
self.return_salts = false
self.salt_position = %w(before after).sample
end
def hash_function(str)
@@ -21,8 +23,13 @@ class HashEncoder < StringEncoder
self.strings_to_encode.each_with_index do |string, i|
combined_string = string
if self.salt[i]
combined_string += self.salt[i]
if salt_position == 'before'
combined_string = self.salt[i] + combined_string
elsif salt_position == 'after'
combined_string = combined_string + self.salt[i]
end
end
self.outputs << hash_function(combined_string)
@@ -51,8 +58,13 @@ class HashEncoder < StringEncoder
end
def encoding_print_string
'strings_to_encode: ' + self.strings_to_encode.to_s + print_string_padding +
'salt: ' + self.salt.to_s + print_string_padding +
'return_salts: ' + self.return_salts.to_s
print_string = 'strings_to_encode: ' + self.strings_to_encode.to_s + print_string_padding +
'salt: ' + self.salt.to_s
if self.salt.size > 0
print_string += print_string_padding
print_string += "return_salts: #{self.return_salts.to_s} #{print_string_padding}"
print_string += "salt_position: #{self.salt_position.to_s}"
end
print_string
end
end

View File

View File

@@ -0,0 +1,16 @@
#!/usr/bin/ruby
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
class LMEncoder < HashEncoder
def initialize
super
self.module_name = 'LM Hash Encoder'
end
def hash_function(string)
require 'smbhash'
Smbhash.lm_hash(string)
end
end
LMEncoder.new.run

View File

@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<encoder xmlns="http://www.github/cliffe/SecGen/encoder"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.github/cliffe/SecGen/encoder">
<name>MD5 Encoder</name>
<author>Thomas Shaw</author>
<module_license>MIT</module_license>
<description>Generates an MD5 hash for each of the strings.</description>
<type>hash</type>
<type>md5</type>
<platform>linux</platform>
<platform>windows</platform>
<read_fact>strings_to_encode</read_fact>
<read_fact>salt</read_fact>
<read_fact>return_salts</read_fact>
<output_type>string</output_type>
</encoder>

View File

@@ -0,0 +1,17 @@
#!/usr/bin/ruby
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
class MySQLPasswordHashEncoder < HashEncoder
def initialize
super
self.module_name = 'MySQL Password Hash Encoder'
self.strings_to_encode = ['right']
end
def hash_function(string)
require 'digest/sha1'
"*" + Digest::SHA1.hexdigest(Digest::SHA1.digest(string)).upcase
end
end
MySQLPasswordHashEncoder.new.run

View File

@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<encoder xmlns="http://www.github/cliffe/SecGen/encoder"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.github/cliffe/SecGen/encoder">
<name>MySQL Password Hash Encoder</name>
<author>Thomas Shaw</author>
<module_license>MIT</module_license>
<description>Generates a MySQL password hash for each of the strings. '*' + sha1sum(sha1sum(password))</description>
<type>hash</type>
<type>mysql</type>
<type>mysql_password</type>
<platform>linux</platform>
<platform>windows</platform>
<read_fact>strings_to_encode</read_fact>
<read_fact>salt</read_fact>
<read_fact>return_salts</read_fact>
<output_type>string</output_type>
</encoder>

View File

View File

@@ -0,0 +1,16 @@
#!/usr/bin/ruby
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
class NTLMEncoder < HashEncoder
def initialize
super
self.module_name = 'NTLM Hash Encoder'
end
def hash_function(string)
require 'smbhash'
Smbhash.ntlm_hash(string)
end
end
NTLMEncoder.new.run

View File

@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<encoder xmlns="http://www.github/cliffe/SecGen/encoder"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.github/cliffe/SecGen/encoder">
<name>MD5 Encoder</name>
<author>Thomas Shaw</author>
<module_license>MIT</module_license>
<description>Generates an MD5 hash for each of the strings.</description>
<type>hash</type>
<type>md5</type>
<platform>linux</platform>
<platform>windows</platform>
<read_fact>strings_to_encode</read_fact>
<read_fact>salt</read_fact>
<read_fact>return_salts</read_fact>
<output_type>string</output_type>
</encoder>

View File

@@ -0,0 +1,15 @@
#!/usr/bin/ruby
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
class SHA1Encoder < HashEncoder
def initialize
super
self.module_name = 'SHA1 Encoder'
end
def hash_function(string)
Digest::SHA1.hexdigest(string)
end
end
SHA1Encoder.new.run

View File

@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<encoder xmlns="http://www.github/cliffe/SecGen/encoder"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.github/cliffe/SecGen/encoder">
<name>SHA1 Encoder</name>
<author>Thomas Shaw</author>
<module_license>MIT</module_license>
<description>Generates an SHA1 hash for each of the strings.</description>
<type>hash</type>
<type>sha1</type>
<platform>linux</platform>
<platform>windows</platform>
<read_fact>strings_to_encode</read_fact>
<read_fact>salt</read_fact>
<read_fact>return_salts</read_fact>
<output_type>string</output_type>
</encoder>

View File