mirror of
https://github.com/cliffe/SecGen.git
synced 2026-02-21 11:18:06 +00:00
remove bitwise_xor fixes #158
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
#!/usr/bin/ruby
|
||||
# Inputs: An ASCII string to mask
|
||||
# Outputs: 2 bit stream strings which, when XOR'd together, result in the input string.
|
||||
# Description: Input string is converted into a bit stream (String A)
|
||||
# Random equivalent length bit stream is generated (String B)
|
||||
# Strings A and B are XOR'd together to give us a third (String C)
|
||||
# Strings B and C are returned.
|
||||
|
||||
require_relative '../../../../../lib/objects/local_string_encoder.rb'
|
||||
class BitwiseXORChallengeGenerator < StringEncoder
|
||||
|
||||
def initialize
|
||||
super
|
||||
self.module_name = 'Bitwise XOR Challenge Generator'
|
||||
end
|
||||
|
||||
def encode(str)
|
||||
number_of_bytes = str.length
|
||||
|
||||
# String A: Convert input that we're hiding into binary
|
||||
binary_string_to_mask = str.unpack('B*')[0]
|
||||
|
||||
# String B: Generate bitstream
|
||||
generated_bit_stream = []
|
||||
number_of_bytes.times do
|
||||
generated_bit_stream << (1..8).map { [0, 1].sample }.join
|
||||
end
|
||||
generated_bit_stream = generated_bit_stream.join
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
BitwiseXORChallengeGenerator.new.run
|
||||
@@ -1,48 +0,0 @@
|
||||
<?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>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 joined with an underscore.
|
||||
</description>
|
||||
|
||||
<type>ctf_challenge</type>
|
||||
<type>ascii_reversible</type>
|
||||
<type>string_encoder</type>
|
||||
<type>local_calculation</type>
|
||||
<platform>linux</platform>
|
||||
<platform>windows</platform>
|
||||
<difficulty>high</difficulty>
|
||||
|
||||
<hint>Perform a bitwise XOR on both strings - https://www.youtube.com/watch?v=YtghBxoBxpA</hint>
|
||||
<solution>Example bitwise XOR tool:
|
||||
http://www.mobilefish.com/services/big_number_bitwise_calculation/big_number_bitwise_calculation.php
|
||||
Decode the result into it's ASCII representation.
|
||||
</solution>
|
||||
|
||||
<read_fact>strings_to_encode</read_fact>
|
||||
|
||||
<default_input into="strings_to_encode">
|
||||
<generator type="flag_generator"/>
|
||||
</default_input>
|
||||
|
||||
<output_type>generated_strings</output_type>
|
||||
|
||||
<!-- TODO FIXME: Issue #158: Stack level too deep -->
|
||||
<!-- In the meantime conflicts with everything to avoid being selected -->
|
||||
<conflict>
|
||||
<module_path>.*</module_path>
|
||||
</conflict>
|
||||
|
||||
<CyBOK KA="F" topic="Artifact Analysis">
|
||||
<keyword>Encoding and alternative data formats</keyword>
|
||||
</CyBOK>
|
||||
<CyBOK KA="C" topic="Symmetric Cryptography">
|
||||
<keyword>symmetric encryption and authentication</keyword>
|
||||
</CyBOK>
|
||||
|
||||
</encoder>
|
||||
Reference in New Issue
Block a user