Move bitwise XOR to encoders instead of generators

This commit is contained in:
ts
2018-10-19 16:39:40 +01:00
parent 1afb8834c6
commit 1916cd84c0
4 changed files with 13 additions and 13 deletions

View File

@@ -29,17 +29,17 @@ class BitwiseXORChallengeGenerator < StringEncoder
end
generated_bit_stream = generated_bit_stream.join
# Add String B to self.outputs
self.outputs << generated_bit_stream
# bitwise xor
decimal_result = binary_string_to_mask.to_i(2) ^ generated_bit_stream.to_i(2)
# Turn decimal result back into a string of bits
binary_string_c = decimal_result.to_s(2)
# prepend leading 0's to the result and add String C to self.outputs
self.outputs << binary_string_c.to_s.rjust(number_of_bytes * 8, '0')
# prepend leading 0's to the result
result = binary_string_c.to_s.rjust(number_of_bytes * 8, '0')
# join the binary strings with an underscore
self.outputs << "#{generated_bit_stream}_#{result}"
end
def get_options_array

View File

@@ -1,18 +1,18 @@
<?xml version="1.0"?>
<generator xmlns="http://www.github/cliffe/SecGen/generator"
<encoder xmlns="http://www.github/cliffe/SecGen/encoder"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.github/cliffe/SecGen/generator">
<name>Bitwise XOR Challenge Generator</name>
xsi:schemaLocation="http://www.github/cliffe/SecGen/encoder">
<name>Bitwise XOR Challenge encoder</name>
<author>Thomas Shaw</author>
<module_license>MIT</module_license>
<description>Binary bitwise XOR operation module. Takes a string input, generates a random bitstream of equal length.,
XOR's the 2 strings, outputs the binary streams.
XOR's the 2 strings, outputs the binary streams joined with an underscore.
</description>
<type>ctf_challenge</type>
<type>bitstream_generator</type>
<type>string_generator</type>
<type>ascii_reversible</type>
<type>string_encoder</type>
<type>local_calculation</type>
<platform>linux</platform>
<platform>windows</platform>
@@ -23,11 +23,11 @@
Decode the result into it's ASCII representation.
</solution>
<read_fact>string_to_mask</read_fact>
<read_fact>string_to_encode</read_fact>
<default_input into="string_to_mask">
<generator type="flag_generator"/>
</default_input>
<output_type>generated_strings</output_type>
</generator>
</encoder>