Giter Club home page Giter Club logo

dj311 / rc4-key-recovery-attacks Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 3.0 81 KB

Exploits weaknesses in RC4 to mount a chosen-plaintext attack and recover the private key. The vulnerability is similar to the one used to crack WEP, but it targets schemes where the initialisation vector precedes the long term key.

License: GNU General Public License v3.0

Python 100.00%
cryptography crypto rc4 wep-attacks wep ctf aircrack aircrack-ng cryptanalysis

rc4-key-recovery-attacks's Introduction

Key Recovery Attacks on RC4

This repo includes a key recovery attack against a mock encryption scheme I've called RC4-CTR. This scheme builds a block cipher using poorly borrowed ideas from AES's counter mode. The attack is similar to the WEP attack used by tools such as aircrack-ng but the initialisation vector is placed before the long term key.

This is a chosen-plaintext attack that recovers the private key in around 100,000 blocks. It works when ephemeral keys are generated by concatenating a public nonce before the long-term key (ala Section 4.3 in "Attacks on the RC4 stream cipher" by Andreas Klein). In doing this, the scheme introduces a relationship between ephemeral keys. The key scheduling algorithm of RC4 isn't very strong, and it's PRNG output leaks enough information about the keys that related-key attacks do work. This attack code should be generalisable to any situation where ephermeral keys are generated by concatenating a known public nonce with the long-term key.

  • server.py implements the encryption scheme, exposed via an API endpoint. Check the docstring and source code for a description of the scheme.
  • solve.py implements the attack. Check the docstring and source code for implementation details on how the attack works.
  • attack.md is a write-up of the attack, intended to accompany and explain the code in solve.py (work-in-progress).

This was all written as a learning exercise, and I've tried to document how and why it works. Hopefully this is a useful accompaniment to the original paper.

There is a live version of the server on my website. You can extract it's key by running:

$ python3 solve.py --cache=samples-djwj.csv --server=https://danielwilshirejones.com

Be warned, the call above is slow and probably not worth it. It takes me over 100 times longer to run the attack on a remote server compared with locally.

rc4-key-recovery-attacks's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

wbeaching dodokos

rc4-key-recovery-attacks's Issues

applicability question

Hello,

First of all great work implementing the Klein style attacks in this manner.

Does this style of attack have any applicability to the following scenario, using RC4 to "sign" a nonce?:

3 byte nonce concatenated with 16 byte long term key > RC4 Keystream Generator > 259 bytes keystream output

Discard first 256 bytes of keystream leaving only last 3 bytes "result"

Nonce / Result pairs are only information sent publicly

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.