Skip to main content

HTTP/2 Single Packet Attack low level library based on Scapy

Project description

H2SpaceX   H2SpaceX

pypi: 1.2.0 Python: 3.8.8 License: GPL v3

HTTP/2 low level library based on Scapy which can be used for Single Packet Attack (Race Condition on H2)

Dive into Single Packet Attack Article

I wrote an article and published it at InfoSec Write-ups:

TODO

  • Single Packet Attack - POST
    • implement
  • Single Packet Attack - GET
    • Content-Length: 1 Method
    • POST Request with x-override-method: GET header
  • Response Parsing
    • implement
    • implement threaded response parser
    • add response times in nano seconds for timing attacks
    • Body Decompression
      • gzip
      • br
      • deflate
  • Proxy
    • Socks5 Proxy

More Research

Some following statements are just ideas and not tested or implemented.

  • More Request in a Single Packet
    • Increase MSS (Idea by James Kettle)
    • Out of Order TCP Packets (Idea by James Kettle)
    • IP Fragmentation
  • Proxy the Single Packet Request through SOCKS
  • Single Packet Attack on GET Requests
    • Content-Length: 1 Method (Idea by James Kettle)
    • x-override-method: GET Method (Idea by James Kettle)
    • Index HPACK Headers to Make GET Requests Smaller
    • HEADERS Frame without END_HEADER Flag
    • HEADERS Frame Without Some Pseudo Headers

Installation

H2SpaceX works with Python 3 (preferred: >=3.10)

pip install h2spacex

Error in Installation

if you get errors of scapy:

pip install --upgrade scapy

Quick Start

You can import the HTTP/2 TLS Connection and set up the connection. After setting up the connection, you can do other things:

from h2spacex import H2OnTlsConnection

h2_conn = H2OnTlsConnection(
    hostname='http2.github.io',
    port_number=443,
    ssl_log_file_path="PATH_TO_SSL_KEYS.log"  # optional (if you want to log ssl keys to read the http/2 traffic in wireshark)
)

h2_conn.setup_connection()
...

see more examples in Wiki Page

Examples

See examples which contain some Portswigger race condition examples.

Examples Page

Enhanced Single Packet Attack Method (Black Hat 2024) for Timing Attacks

James Kettle introduced an improved version of Single Packet Attack in Black Hat 2024 for timing attacks:

Impvoved Version Image

You can implement this method easily using send_ping_frame() method.

See this Wiki and Parse Response (Threaded) + Response Times for Timing Attacks part:

Improved Version of SPA Sample Exploit

Reference of Improved Method:

References & Resources

I also got some ideas from a previous developed library h2tinker.

Finally, thanks again to James Kettle for directly helping and pointing some other techniques.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

h2spacex-1.2.0.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

h2spacex-1.2.0-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file h2spacex-1.2.0.tar.gz.

File metadata

  • Download URL: h2spacex-1.2.0.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.8

File hashes

Hashes for h2spacex-1.2.0.tar.gz
Algorithm Hash digest
SHA256 46c1767fd7d9ae48a158da137b95a02ac59ae9e6b16ea994173e136d6bce5f6a
MD5 da598b5b283902ae3a8e6fc277c5c8b2
BLAKE2b-256 d005d6837e9d657da3ed823b355465a1bc5e342e37a121fc1397c860a1471ef1

See more details on using hashes here.

File details

Details for the file h2spacex-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: h2spacex-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.8

File hashes

Hashes for h2spacex-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de71725ae322238b2dd96087e13fa3f8da5538cfd1e25600661d5170c2fdf0e3
MD5 cee285ccaeedac74f9c7d1201d0ec1d4
BLAKE2b-256 e7b8589b6208500fcb873c4c53463759d85170cc1b766312dcfdd5b05a0d5e13

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page