Coder Social home page Coder Social logo

silentsoul04 / timeless-timing-attacks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from distrinet/timeless-timing-attacks

0.0 0.0 0.0 6 KB

A Python implementation that facilitates finding timeless timing attack vulnerabilities.

Python 100.00%

timeless-timing-attacks's Introduction

h2time

h2time.py is a Python implementation that can be used to test HTTP/2 servers for Timeless Timing Attack vulnerabilities.

Requirements

  • Python 3.7.x or higher - tested with Python 3.8.5
  • The hyper-h2 Python package (pip install h2) - tested with 3.2.0
  • OpenSSL

Usage

A very basic example is given below, for additonal examples, please refer to examples.py.

from h2time import H2Request, H2Time

r1 = H2Request('GET', 'https://tom.vg/?1')
r2 = H2Request('GET', 'https://tom.vg/?2')
async with H2Time(r1, r2) as h2t:
    results = await h2t.run_attack()
    print('\n'.join(map(lambda x: ','.join(map(str, x)), results)))

First two H2Request objects are created, which are then passed on to H2Time. Note that both requests should be to the same server (as this is the basic requirement to perform timeless timing attacks). When the run_attack() method is called, the client will start sending request-pairs and will try to ensure that both arrive at the same time at the server (the final bytes of each request should be placed in a single TCP packet). On the first request, additional parameters are added to the URL to offset the difference in time when requests can start being processed (the number is defined by the num_padding_params parameter - default: 40).

H2Time can operate in a sequential mode, where it waits to send the next request-pair until the response for the previous one has been received. When the sequential is set to False, all request-pairs will be sent at once, at an interval of a number of milliseconds defined by the inter_request_time_ms parameter.

The results that are returned is a list of tuples with 3 elements: (0) difference of response time (in nanoseconds) between the second request and the first one, (1): response status of the first request, (2): response status of the second request.

If the difference in response time is negative, this means that a response for the second request was received first. To perform a timeless timing attack, one should only need to take into account whether the result is positive or negative (positive indicates that the processing time of the first request takes less time than processing the second request).

Timing attack best practices

Timing attacks can be quite tricky to exploit, so it's best to follow these best practices:

  • Alternate between choosing which request to send first: change between H2Time(r1, r2) and H2Time(r2, r1) to avoid bias that may be introduced by the first request (support for this in h2time.py is planned)
  • The number of request parameters that are needed may be server-dependent, so it's best to first experiment with what values work best (for 2 requests that have the same processing time, the distribution of positive & negative timing result should be 50/50)

A word of caution

Please be aware that this Python implementation may still be a bit rough around the edges. As it will be further developed, it is likely that there will be breaking changes. If you encounter any issue with it, please file an issue! For any other questions, suggestions and remarks, feel free to contact me.

timeless-timing-attacks's People

Contributors

tomvangoethem avatar vikvanderlinden 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.