Encoder: Morse Code. 'parentheses' mapped to [], { }, <> and () to cover as many varieties as we can. Any other character not represented in Morse Code is dropped.

This commit is contained in:
thomashaw
2017-03-03 14:09:00 +00:00
parent 253d983e01
commit 5b76e04f9b
5 changed files with 133 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
#!/usr/bin/ruby
require_relative '../../../../../lib/objects/local_string_encoder.rb'
class MorseCodeEncoder < StringEncoder
attr_accessor :morse_code_hash
def initialize
super
self.module_name = 'Morse Code Encoder'
self.strings_to_encode = []
self.morse_code_hash = {'a' => '.-',
'b' => '-...',
'c' => '-.-.',
'd' => '-..',
'e' => '.',
'f' => '..-.',
'g' => '--.',
'h' => '....',
'i' => '..',
'j' => '.---',
'k' => '-.-',
'l' => '.-..',
'm' => '--',
'n' => '-.',
'o' => '---',
'p' => '.--.',
'q' => '--.-',
'r' => '.-.',
's' => '...',
't' => '-',
'u' => '..-',
'v' => '...-',
'w' => '.--',
'x' => '-..-',
'y' => '-.--',
'z' => '--..',
' ' => '/',
'1' => '.----',
'2' => '..---',
'3' => '...--',
'4' => '....-',
'5' => '.....',
'6' => '-....',
'7' => '--...',
'8' => '---..',
'9' => '----.',
'0' => '-----',
'.' => '.-.-.-',
',' => '--..--',
':' => '---...',
'?' => '..--..',
'\'' => '.----.',
'-' => '-....-',
'/' => '-..-.',
'(' => '-.--.-',
')' => '-.--.-',
'[' => '-.--.-',
']' => '-.--.-',
'<' => '-.--.-',
'>' => '-.--.-',
'{' => '-.--.-',
'}' => '-.--.-',
'"' => '.-..-.',
'@' => '.--.-.',
'=' => '-...-',
}
end
def encode(str)
morse_string = ''
str.each_char { |char|
# if the character is in the hash convert it. if not, drop the character.
if morse_code_hash.key? char.downcase
morse_string << morse_code_hash[char.downcase] + ' '
end
}
morse_string
end
end
MorseCodeEncoder.new.run

View File

@@ -0,0 +1,26 @@
<?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>Morse Code Encoder</name>
<author>Thomas Shaw</author>
<module_license>MIT</module_license>
<description>Encodes a string into Morse code.</description>
<type>morse_code_encoder</type>
<type>ascii_reversable</type>
<type>string_encoder</type>
<platform>linux</platform>
<platform>windows</platform>
<reference>https://gist.github.com/mikedamage/105081</reference>
<read_fact>strings_to_encode</read_fact>
<default_input into="strings_to_encode">
<generator type="string_generator"/>
</default_input>
<output_type>encoded_strings</output_type>
</encoder>

View File

@@ -0,0 +1,27 @@
<?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">
<system>
<system_name>example_server</system_name>
<base platform="linux"/>
<!--select a vulnerability that leaks strings-->
<vulnerability read_fact="strings_to_leak">
<!--direct the output from below into strings_to_leak-->
<input into="strings_to_leak">
<encoder type="morse_code_encoder">
<input into="strings_to_encode">
<generator type="string_generator"/>
<generator type="flag_generator"/>
</input>
</encoder>
</input>
</vulnerability>
<network type="private_network" range="dhcp"/>
</system>
</scenario>