Giter Club home page Giter Club logo

brotxor's Introduction

BrotXOR

Simple XOR Reduction Based Attack

BrotXOR is a tool that helps in demonstrating a possible reduction based attack against XOR encrypted data with a key.length() > 4 (since you can bruteforce a 4-byte key reasonably fast). This is useful when not enough repeating blocks exist!

Premise

Attacking rolling-xor encrypted data with the following assumptions:

  • You know the size of the key and the character set it consists of
  • You know enough about the possible character set of the plaintext version
  • Encryption key repeats a max of 2 times (because encrypted blob is too small)
  • Otherwise, known attack(s) exist that attempt to determine the size of the key and recover it

note: this work was inspired while reviewing a TM ctf challenge.

Idea

The data is rolling-xor encrypted with an md5 hash value. The decryption algorithm simply takes the entered md5 hash value (32 characters) as a string, and xors each of the encrypted bytes, one character at a time from the md5 hash value, in a rolling fashion.

The problem here is that not enough encrypted data with same repeating key exists. Otherwise, the problem could be reduced to Challenge 6 of the cryptopals crypto challenges. Multiple solutions of said challenge are already published under 1, 2 and 3.

There are a couple of interesting observations in this scenario that we can exploit to reduce the search space and possibilities needed to decrypt the data, but not fully! It simply gives us an insight to reason about the possible key:value pairs at a given offset in the encrypted payload.

The idea is simple, for a key of 32-byte size, the first byte of the key that decrypts the byte at offset 0 has to be the same 1-byte key that decrypts the byte at offset 32, and so on. And since we know all the possible characters of the key and the plaintext version of the encrypted data, we can limit the decryption step to those inputs, and thereby generating a reduced list of possible key:value pairs. We can further filter the possible key:value pairs such that only alpha, numeric, or not-alpha-numeric values exist.

Depending on the distribution of the encrypted data, you would be able to recover the actual 1-byte key at a given offset. Try the code with the -r option.

With this approach, you can try crosswording the output based on certtain assumptions.

Note: Please check the code for more information.

Key steps in the code

  • Get a list of all possible keys and chars for p_1
  • Get a list of all possible keys and chars for p_2 (Key search space is limited to step 1 list of keys)
  • p_1 and p_2 lists of keys must match
  • p_3 is left alone since no matching bytes exist to compare it against

Contributing

I'm interested in hearing from you should you have a better insight into how to approach this problem.

brotxor's People

Contributors

mfmokbel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.