Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable multi-level decodings to actually work (Caesar) in multi-level paths #107

Merged
merged 9 commits into from
Nov 29, 2022

Conversation

bee-san
Copy link
Owner

@bee-san bee-san commented Nov 27, 2022

Previously when we had something like:

Caesar -> Base64

Ares (and Ciphey) would take the first decoding of Caesar (Rot1(X)) and pass that to Base64. This PR makes it so all 25 shifts of Caesar (and other similar ciphers) are passed to the decoders.

This works by....

Every Text struct contains a field:

text: Vec<String>,

Which contains every decoding (even if it's just 1 decoding).

After each iteration of BFS we loop over all of our vectors we have collected and flatten them from a Vec<Vec<Text>> to a Vec<Text> where text: Vec<String> has a single element (meaning we can index into the 0th element [0] and get the result).

        let mut new_strings_to_be_added = Vec::new();
        for textStruct in new_strings{
            for decoded_text in textStruct.text{
                new_strings_to_be_added.push(
                    Text {
                        text: vec![decoded_text],
                        // quick hack
                        path: textStruct.path.clone(),
                    }
                )
            }

This introduces some issues:

  1. It is not efficient to have a O(n^2) loop after our big main loop
  2. We are using .clone() here which is slow
  3. It is not efficient to make a new vector with just 1 element
  4. It does not support nice paths. If it was Caesar, it won't say "Caesar with shift of 13" for example

This is a hack to get us to support this feature.

In the future we might want to look at:

Editing this bit of code so it supports Vectors of Vectors:
https://github.com/bee-san/Ares/blob/1bcc994052db17e7db948055d012810353c76f4d/src/searchers/bfs.rs#LL32-L33C69

Or adding another loop below this code so it turns into a O(n^2) nested loop:

while !current_strings.is_empty() {

The test was too long and taking too long to run in debug mode, changing to a smaller test
@bee-san bee-san changed the title for swan Enable multi-level decodings to actually work (Caesar) in multi-level paths Nov 29, 2022
@bee-san bee-san marked this pull request as ready for review November 29, 2022 08:35
@bee-san bee-san merged commit 507a5dc into main Nov 29, 2022
@delete-merged-branch delete-merged-branch bot deleted the bee-ares-multiple-encodings branch November 29, 2022 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant