mirror of
https://github.com/cliffe/SecGen.git
synced 2026-02-21 11:18:06 +00:00
Hash encoders and example scenarios
This commit is contained in:
58
lib/objects/local_hash_encoder.rb
Normal file
58
lib/objects/local_hash_encoder.rb
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/ruby
|
||||
require_relative 'local_string_encoder.rb'
|
||||
require 'digest'
|
||||
|
||||
class HashEncoder < StringEncoder
|
||||
attr_accessor :salt
|
||||
attr_accessor :return_salts
|
||||
|
||||
def initialize
|
||||
super
|
||||
self.module_name = 'Hash Encoder'
|
||||
self.strings_to_encode = []
|
||||
self.salt = []
|
||||
self.return_salts = false
|
||||
end
|
||||
|
||||
def hash_function(str)
|
||||
end
|
||||
|
||||
def encode_all
|
||||
self.strings_to_encode.each_with_index do |string, i|
|
||||
|
||||
combined_string = string
|
||||
if self.salt[i]
|
||||
combined_string += self.salt[i]
|
||||
end
|
||||
|
||||
self.outputs << hash_function(combined_string)
|
||||
end
|
||||
|
||||
if self.return_salts
|
||||
self.outputs += self.salt
|
||||
end
|
||||
end
|
||||
|
||||
def process_options(opt, arg)
|
||||
super
|
||||
if opt == '--salt'
|
||||
self.salt << arg;
|
||||
end
|
||||
|
||||
if opt == '--return_salts'
|
||||
self.return_salts = (arg.to_s.downcase == 'true');
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def get_options_array
|
||||
super + [['--salt', GetoptLong::OPTIONAL_ARGUMENT],
|
||||
['--return_salts', GetoptLong::OPTIONAL_ARGUMENT]]
|
||||
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
|
||||
end
|
||||
end
|
||||
0
modules/encoders/hash/md5/manifests/.no_puppet
Normal file
0
modules/encoders/hash/md5/manifests/.no_puppet
Normal file
0
modules/encoders/hash/md5/md5.pp
Normal file
0
modules/encoders/hash/md5/md5.pp
Normal file
15
modules/encoders/hash/md5/secgen_local/local.rb
Normal file
15
modules/encoders/hash/md5/secgen_local/local.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/ruby
|
||||
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
|
||||
|
||||
class MD5Encoder < HashEncoder
|
||||
def initialize
|
||||
super
|
||||
self.module_name = 'MD5 Encoder'
|
||||
end
|
||||
|
||||
def hash_function(string)
|
||||
Digest::MD5.hexdigest(string)
|
||||
end
|
||||
end
|
||||
|
||||
MD5Encoder.new.run
|
||||
22
modules/encoders/hash/md5/secgen_metadata.xml
Normal file
22
modules/encoders/hash/md5/secgen_metadata.xml
Normal 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>
|
||||
0
modules/encoders/hash/rmd160/manifests/.no_puppet
Normal file
0
modules/encoders/hash/rmd160/manifests/.no_puppet
Normal file
0
modules/encoders/hash/rmd160/rmd160.pp
Normal file
0
modules/encoders/hash/rmd160/rmd160.pp
Normal file
15
modules/encoders/hash/rmd160/secgen_local/local.rb
Normal file
15
modules/encoders/hash/rmd160/secgen_local/local.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/ruby
|
||||
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
|
||||
|
||||
class RMD160Encoder < HashEncoder
|
||||
def initialize
|
||||
super
|
||||
self.module_name = 'RMD160 Encoder'
|
||||
end
|
||||
|
||||
def hash_function(string)
|
||||
Digest::RMD160.hexdigest(string)
|
||||
end
|
||||
end
|
||||
|
||||
RMD160Encoder.new.run
|
||||
22
modules/encoders/hash/rmd160/secgen_metadata.xml
Normal file
22
modules/encoders/hash/rmd160/secgen_metadata.xml
Normal 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>RMD160 Encoder</name>
|
||||
<author>Thomas Shaw</author>
|
||||
<module_license>MIT</module_license>
|
||||
<description>Generates an RMD160 hash for each of the strings.</description>
|
||||
|
||||
<type>hash</type>
|
||||
<type>rmd160</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>
|
||||
0
modules/encoders/hash/sha1/manifests/.no_puppet
Normal file
0
modules/encoders/hash/sha1/manifests/.no_puppet
Normal file
15
modules/encoders/hash/sha1/secgen_local/local.rb
Normal file
15
modules/encoders/hash/sha1/secgen_local/local.rb
Normal 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
|
||||
22
modules/encoders/hash/sha1/secgen_metadata.xml
Normal file
22
modules/encoders/hash/sha1/secgen_metadata.xml
Normal 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>
|
||||
0
modules/encoders/hash/sha1/sha1.pp
Normal file
0
modules/encoders/hash/sha1/sha1.pp
Normal file
0
modules/encoders/hash/sha256/manifests/.no_puppet
Normal file
0
modules/encoders/hash/sha256/manifests/.no_puppet
Normal file
15
modules/encoders/hash/sha256/secgen_local/local.rb
Normal file
15
modules/encoders/hash/sha256/secgen_local/local.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/ruby
|
||||
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
|
||||
|
||||
class SHA256Encoder < HashEncoder
|
||||
def initialize
|
||||
super
|
||||
self.module_name = 'SHA256 Encoder'
|
||||
end
|
||||
|
||||
def hash_function(string)
|
||||
Digest::SHA256.hexdigest(string)
|
||||
end
|
||||
end
|
||||
|
||||
SHA256Encoder.new.run
|
||||
22
modules/encoders/hash/sha256/secgen_metadata.xml
Normal file
22
modules/encoders/hash/sha256/secgen_metadata.xml
Normal 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>SHA256 Encoder</name>
|
||||
<author>Thomas Shaw</author>
|
||||
<module_license>MIT</module_license>
|
||||
<description>Generates an SHA256 hash for each of the strings.</description>
|
||||
|
||||
<type>hash</type>
|
||||
<type>sha256</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>
|
||||
0
modules/encoders/hash/sha256/sha256.pp
Normal file
0
modules/encoders/hash/sha256/sha256.pp
Normal file
0
modules/encoders/hash/sha384/manifests/.no_puppet
Normal file
0
modules/encoders/hash/sha384/manifests/.no_puppet
Normal file
15
modules/encoders/hash/sha384/secgen_local/local.rb
Normal file
15
modules/encoders/hash/sha384/secgen_local/local.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/ruby
|
||||
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
|
||||
|
||||
class SHA256Encoder < HashEncoder
|
||||
def initialize
|
||||
super
|
||||
self.module_name = 'SHA256 Encoder'
|
||||
end
|
||||
|
||||
def hash_function(string)
|
||||
Digest::SHA256.hexdigest(string)
|
||||
end
|
||||
end
|
||||
|
||||
SHA256Encoder.new.run
|
||||
22
modules/encoders/hash/sha384/secgen_metadata.xml
Normal file
22
modules/encoders/hash/sha384/secgen_metadata.xml
Normal 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>SHA384 Encoder</name>
|
||||
<author>Thomas Shaw</author>
|
||||
<module_license>MIT</module_license>
|
||||
<description>Generates an SHA384 hash for each of the strings.</description>
|
||||
|
||||
<type>hash</type>
|
||||
<type>sha384</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>
|
||||
0
modules/encoders/hash/sha384/sha384.pp
Normal file
0
modules/encoders/hash/sha384/sha384.pp
Normal file
0
modules/encoders/hash/sha512/manifests/.no_puppet
Normal file
0
modules/encoders/hash/sha512/manifests/.no_puppet
Normal file
15
modules/encoders/hash/sha512/secgen_local/local.rb
Normal file
15
modules/encoders/hash/sha512/secgen_local/local.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/ruby
|
||||
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
|
||||
|
||||
class SHA384Encoder < HashEncoder
|
||||
def initialize
|
||||
super
|
||||
self.module_name = 'SHA384 Encoder'
|
||||
end
|
||||
|
||||
def hash_function(string)
|
||||
Digest::SHA384.hexdigest(string)
|
||||
end
|
||||
end
|
||||
|
||||
SHA384Encoder.new.run
|
||||
22
modules/encoders/hash/sha512/secgen_metadata.xml
Normal file
22
modules/encoders/hash/sha512/secgen_metadata.xml
Normal 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>SHA512 Encoder</name>
|
||||
<author>Thomas Shaw</author>
|
||||
<module_license>MIT</module_license>
|
||||
<description>Generates an SHA512 hash for each of the strings.</description>
|
||||
|
||||
<type>hash</type>
|
||||
<type>sha512</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>
|
||||
0
modules/encoders/hash/sha512/sha512.pp
Normal file
0
modules/encoders/hash/sha512/sha512.pp
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/ruby
|
||||
require_relative '../../../../../lib/objects/local_string_generator.rb'
|
||||
|
||||
class NumberGenerator < StringGenerator
|
||||
attr_accessor :minimum
|
||||
attr_accessor :maximum
|
||||
|
||||
def initialize
|
||||
super
|
||||
self.module_name = 'Random NumberGenerator'
|
||||
self.minimum = 0
|
||||
self.maximum = 10
|
||||
end
|
||||
|
||||
def generate
|
||||
self.outputs << rand(self.minimum .. self.maximum).to_s
|
||||
end
|
||||
|
||||
def process_options(opt, arg)
|
||||
super
|
||||
if opt == '--minimum'
|
||||
self.minimum = arg.to_i;
|
||||
end
|
||||
|
||||
if opt == '--maximum'
|
||||
self.maximum = arg.to_i;
|
||||
end
|
||||
end
|
||||
|
||||
def get_options_array
|
||||
super + [['--minimum', GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--maximum', GetoptLong::REQUIRED_ARGUMENT]]
|
||||
end
|
||||
|
||||
def encoding_print_string
|
||||
'minimum: ' + self.minimum.to_s + print_string_padding +
|
||||
'maximum: ' + self.maximum.to_s
|
||||
end
|
||||
end
|
||||
|
||||
NumberGenerator.new.run
|
||||
30
modules/generators/random/random_number/secgen_metadata.xml
Normal file
30
modules/generators/random/random_number/secgen_metadata.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<generator xmlns="http://www.github/cliffe/SecGen/generator"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.github/cliffe/SecGen/generator">
|
||||
<name>Random Number Generator</name>
|
||||
<author>Thomas Shaw</author>
|
||||
<module_license>MIT</module_license>
|
||||
<description>Random number generator.</description>
|
||||
|
||||
<type>random_number_generator</type>
|
||||
<type>number_generator</type>
|
||||
<type>number</type>
|
||||
<type>local_calculation</type>
|
||||
<platform>linux</platform>
|
||||
<platform>windows</platform>
|
||||
|
||||
<read_fact>minimum</read_fact>
|
||||
<read_fact>maximum</read_fact>
|
||||
|
||||
<default_input into="minimum">
|
||||
<value>0</value>
|
||||
</default_input>
|
||||
|
||||
<default_input into="maximum">
|
||||
<value>1000000</value>
|
||||
</default_input>
|
||||
|
||||
<output_type>number</output_type>
|
||||
</generator>
|
||||
119
scenarios/examples/ctf_challenge_examples/hash_challenges.xml
Normal file
119
scenarios/examples/ctf_challenge_examples/hash_challenges.xml
Normal file
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<scenario xmlns="http://www.github/cliffe/SecGen/scenario"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.github/cliffe/SecGen/scenario">
|
||||
|
||||
<!-- Hash challenges.
|
||||
# TODO : Create a wrapper module so that accounts use the below as passwords in /etc/passwd and /etc/shadow
|
||||
-->
|
||||
|
||||
<system>
|
||||
<system_name>challenge_server</system_name>
|
||||
<base platform="linux" type="server"/>
|
||||
|
||||
<input into="challenges">
|
||||
<!--Unsalted dictionary word - rainbow lookup-->
|
||||
<encoder type="hash">
|
||||
<input into="strings_to_encode">
|
||||
<generator type="random_word_generator"/>
|
||||
</input>
|
||||
</encoder>
|
||||
|
||||
<!--Unsalted password - rainbow lookup-->
|
||||
<encoder type="hash">
|
||||
<input into="strings_to_encode">
|
||||
<generator type="password_generator"/>
|
||||
</input>
|
||||
</encoder>
|
||||
|
||||
<!--Dictionary word - dictionary salt - salt provided-->
|
||||
<encoder type="hash">
|
||||
<input into="strings_to_encode">
|
||||
<generator type="random_word_generator"/>
|
||||
</input>
|
||||
<input into="salt">
|
||||
<generator type="random_word_generator"/>
|
||||
</input>
|
||||
<input into="return_salts">
|
||||
<value>true</value>
|
||||
</input>
|
||||
</encoder>
|
||||
|
||||
<!--Dictionary word - dictionary salt - salt not provided-->
|
||||
<encoder type="hash">
|
||||
<input into="strings_to_encode">
|
||||
<generator type="random_word_generator"/>
|
||||
</input>
|
||||
<input into="salt">
|
||||
<generator type="random_word_generator"/>
|
||||
</input>
|
||||
<input into="return_salts">
|
||||
<value>false</value>
|
||||
</input>
|
||||
</encoder>
|
||||
|
||||
<!-- Random password - dictionary salt - salt provided-->
|
||||
<encoder type="hash">
|
||||
<input into="strings_to_encode">
|
||||
<generator type="password_generator"/>
|
||||
</input>
|
||||
<input into="salt">
|
||||
<generator type="random_word_generator"/>
|
||||
</input>
|
||||
<input into="return_salts">
|
||||
<value>true</value>
|
||||
</input>
|
||||
</encoder>
|
||||
|
||||
<!-- Random password - dictionary salt - salt not provided-->
|
||||
<encoder type="hash">
|
||||
<input into="strings_to_encode">
|
||||
<generator type="password_generator"/>
|
||||
</input>
|
||||
<input into="salt">
|
||||
<generator type="random_word_generator"/>
|
||||
</input>
|
||||
<input into="return_salts">
|
||||
<value>false</value>
|
||||
</input>
|
||||
</encoder>
|
||||
|
||||
<!--Number - unsalted-->
|
||||
<encoder type="hash">
|
||||
<input into="strings_to_encode">
|
||||
<generator type="random_number_generator"/>
|
||||
</input>
|
||||
</encoder>
|
||||
|
||||
<!--Number - dictionary salt - salt provided-->
|
||||
<encoder type="hash">
|
||||
<input into="strings_to_encode">
|
||||
<generator type="random_number_generator"/>
|
||||
</input>
|
||||
<input into="salt">
|
||||
<generator type="random_word_generator"/>
|
||||
</input>
|
||||
<input into="return_salts">
|
||||
<value>true</value>
|
||||
</input>
|
||||
</encoder>
|
||||
|
||||
<!-- Number - dictionary salt - salt not provided-->
|
||||
<encoder type="hash">
|
||||
<input into="strings_to_encode">
|
||||
<generator type="random_number_generator"/>
|
||||
</input>
|
||||
<input into="salt">
|
||||
<generator type="random_word_generator"/>
|
||||
</input>
|
||||
<input into="return_salts">
|
||||
<value>false</value>
|
||||
</input>
|
||||
</encoder>
|
||||
</input>
|
||||
|
||||
<network type="private_network" range="dhcp" />
|
||||
</system>
|
||||
|
||||
</scenario>
|
||||
Reference in New Issue
Block a user