Skip to main content

mercury-python

The goal of the mercury-python package is to expose mercury's network protocol analysis functionality via python. The cython interface is given in mercury.pyx.

Installation

pip install mercury-python

From Source

You will first need to build mercury and install cython and optionally wheel:

pip install Cython
pip install wheel
pip install setuptools

From the top of the mercury source tree, the top-level Makefile builds the package:

make cython       # build the Cython extension and a pip-installable wheel
make test-cython  # run the cython interface tests

The wheel and the .so are placed under build/<variant>/cython/ (default variant: RelWithDebInfo).

Usage

Initialization

import mercury

libmerc = mercury.Mercury()                                                            # initialization for packet parsing
libmerc = mercury.Mercury(do_analysis=True, resources=b'/<path>/<to>/<resources.tgz>') # initialization for analysis

Parsing packets

hex_packet = '5254001235020800273a230d08004500...'
libmerc.get_mercury_json(bytes.fromhex(hex_packet))
{
    "fingerprints": {
        "tls": "tls/(0303)(13011303...)((0000)...)"
    },
    "tls": {
        "client": {
            "version": "0303",
            "random": "0d4e266cf66416689ded443b58d2b12bb2f53e8a3207148e3c8f2be2476cbd24",
            "session_id": "67b5db473da1b71fbca9ed288052032ee0d5139dcfd6ea78b4436e509703c0e4",
            "cipher_suites": "130113031302c02bc02fcca9cca8c02cc030c00ac009c013c014009c009d002f0035000a",
            "compression_methods": "00",
            "server_name": "content-signature-2.cdn.mozilla.net",
            "application_layer_protocol_negotiation": [
                "h2",
                "http/1.1"
            ],
            "session_ticket": ""
        }
    },
    "src_ip": "10.0.2.15",
    "dst_ip": "13.249.64.25",
    "protocol": 6,
    "src_port": 32972,
    "dst_port": 443,
}

Analysis

There are two methods to invoke mercury's analysis functionality. The first operates on the full hex packet:

libmerc.analyze_packet(bytes.fromhex(hex_packet))
{
    "tls": {
        "client": {
            "server_name": "content-signature-2.cdn.mozilla.net"
        }
    },
    "fingerprint_info": {
        "status": "labeled",
        "type": "tls",
        "str_repr": "tls/1/(0303)(13011303...)[(0000)...]"
    },
    "analysis": {
        "process": "firefox",
        "score": 0.9992411956652674,
        "malware": false,
        "p_malware": 8.626882751003134e-06
    }

The second method operates directly on the data features (network protocol fingerprint string and destination context):

libmerc.perform_analysis('tls/1/(0303)(13011303...)[(0000)...]', 'content-signature-2.cdn.mozilla.net', '13.249.64.25', 443)
{
    "fingerprint_info": {
        "status": "labeled"
    },
    "analysis": {
        "process": "firefox",
        "score": 0.9992158715704546,
        "malware": false,
        "p_malware": 8.745628825189023e-06
    }
}

Static functions

Parsing base64 representations of certificate data:

b64_cert = 'MIIJRDC...'
mercury.parse_cert(b64_cert)

output:

{
    "version": "02",
    "serial_number": "00eede6560cd35c0af02000000005971b7",
    "signature_identifier": {
        "algorithm": "sha256WithRSAEncryption"
    },
    "issuer": [
        {
            "country_name": "US"
        },
        {
            "organization_name": "Google Trust Services"
        },
        {
            "common_name": "GTS CA 1O1"
        }
    ],
    ...

Parsing base64 representations of DNS data:

b64_dns = '1e2BgAAB...'
mercury.parse_dns(b64_dns)

output:

{
    "response": {
        "question": [
            {
                "name": "live.github.com.",
                "type": "AAAA",
                "class": "IN"
            }
        ],
        ...

Metadata

Release files for mercury-python 2.21.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for mercury-python 2.21.0
File
mercury_python-2.21.0-cp314-cp314t-manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.34+ x86-64 Details
mercury_python-2.21.0-cp314-cp314t-manylinux_2_34_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.34+ ARM64 Details
mercury_python-2.21.0-cp314-cp314t-macosx_15_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 15.0+ ARM64 Details
mercury_python-2.21.0-cp314-cp314-manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ x86-64 Details
mercury_python-2.21.0-cp314-cp314-manylinux_2_34_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ ARM64 Details
mercury_python-2.21.0-cp314-cp314-macosx_15_0_arm64.whl CPython 3.14 CPython 3.14 macOS 15.0+ ARM64 Details
mercury_python-2.21.0-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
mercury_python-2.21.0-cp313-cp313-manylinux_2_34_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ ARM64 Details
mercury_python-2.21.0-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details
mercury_python-2.21.0-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
mercury_python-2.21.0-cp312-cp312-manylinux_2_34_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ ARM64 Details
mercury_python-2.21.0-cp312-cp312-macosx_15_0_arm64.whl CPython 3.12 CPython 3.12 macOS 15.0+ ARM64 Details
mercury_python-2.21.0-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details
mercury_python-2.21.0-cp311-cp311-manylinux_2_34_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ ARM64 Details
mercury_python-2.21.0-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details
mercury_python-2.21.0-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details
mercury_python-2.21.0-cp310-cp310-manylinux_2_34_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ ARM64 Details
mercury_python-2.21.0-cp310-cp310-macosx_15_0_arm64.whl CPython 3.10 CPython 3.10 macOS 15.0+ ARM64 Details
mercury_python-2.21.0-cp39-cp39-manylinux_2_34_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.34+ x86-64 Details
mercury_python-2.21.0-cp39-cp39-manylinux_2_34_aarch64.whl CPython 3.9 CPython 3.9 Linux glibc 2.34+ ARM64 Details
mercury_python-2.21.0-cp39-cp39-macosx_15_0_arm64.whl CPython 3.9 CPython 3.9 macOS 15.0+ ARM64 Details

Total release size: 219.0 MB

Release files / mercury_python-2.21.0-cp314-cp314t-manylinux_2_34_x86_64.whl

Download URL mercury_python-2.21.0-cp314-cp314t-manylinux_2_34_x86_64.whl
Size 14.1 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
1628b3bdba05b1d94ff2ca76f55a4c7cd99510be555a243517302d50abcc1adc
BLAKE2b-256 checksum
How to use checksums
0834baf78f692a0d4df013e7e8550afce63a4bd68351705acdd168092dea4670
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp314-cp314t-manylinux_2_34_aarch64.whl

Download URL mercury_python-2.21.0-cp314-cp314t-manylinux_2_34_aarch64.whl
Size 14.0 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
04a4f83175e85cf85bc0b416c63442e35acb2c1106aa00a9558823158e10ed5e
BLAKE2b-256 checksum
How to use checksums
19ef12dd84391d4ec8498cf9738096b9a5c79bd528cfa5a3ddd7aa06af28fc21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp314-cp314t-macosx_15_0_arm64.whl

Download URL mercury_python-2.21.0-cp314-cp314t-macosx_15_0_arm64.whl
Size 3.2 MB
Tags CPython 3.14 CPython 3.14 free-threading macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
d3fc00620873323678c77abdf2325660b2011d347fb0d952e4f6606dd14727b6
BLAKE2b-256 checksum
How to use checksums
2bf223fcc16136731cda8f4ba0d31a246ab00b05217543b37b32129a87259222
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp314-cp314-manylinux_2_34_x86_64.whl

Download URL mercury_python-2.21.0-cp314-cp314-manylinux_2_34_x86_64.whl
Size 14.1 MB
Tags CPython 3.14 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
623cd59996490ff751374837b8d76f73268658035f2ef470d32d46d2f5e2893b
BLAKE2b-256 checksum
How to use checksums
e845af7a3ee3591e9657dc058b4d5843ae08b4efdc8d16245fc8bbed9d51dc83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp314-cp314-manylinux_2_34_aarch64.whl

Download URL mercury_python-2.21.0-cp314-cp314-manylinux_2_34_aarch64.whl
Size 14.0 MB
Tags CPython 3.14 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
b097744e76f7fe7d9a7cd626be20f238e2f11ce3d60f47595b23d917f01de9e6
BLAKE2b-256 checksum
How to use checksums
625ccb1646843adaab880d1fa9f5f6a0883f6ca54a9acb0e1e0e3a301becb936
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp314-cp314-macosx_15_0_arm64.whl

Download URL mercury_python-2.21.0-cp314-cp314-macosx_15_0_arm64.whl
Size 3.1 MB
Tags CPython 3.14 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
416055b086ae591f943b667971654e2c17fadcadf520dc5c1d9e890e18e3188a
BLAKE2b-256 checksum
How to use checksums
a5c58553a03ae2c02f7a31c3ed3917551842cb858374ade9b04292f3f99007e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL mercury_python-2.21.0-cp313-cp313-manylinux_2_34_x86_64.whl
Size 14.1 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
2ce8eed145a22a67c20fa55306cbd6581f6dfc9e2f0d9ad0a9ef577a11661862
BLAKE2b-256 checksum
How to use checksums
343422b30ebdc3cc9d4b2fd87dee434ca4f32af1b522a59381f77417cbbaf2c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp313-cp313-manylinux_2_34_aarch64.whl

Download URL mercury_python-2.21.0-cp313-cp313-manylinux_2_34_aarch64.whl
Size 14.0 MB
Tags CPython 3.13 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
03bd746a0f02d61ec13a4af40ff47c1cbb5f945a286cb56ea6292a9ffd0ecf63
BLAKE2b-256 checksum
How to use checksums
8c906897d92379d5f07ff69c91a6ac69dd6ec44d12db8b2f752f85ae49ae9cb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp313-cp313-macosx_15_0_arm64.whl

Download URL mercury_python-2.21.0-cp313-cp313-macosx_15_0_arm64.whl
Size 3.1 MB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
d2aa63edb5d88d2fa2182956562222b3c093151d31130df0e97007f3968a119f
BLAKE2b-256 checksum
How to use checksums
1621a4949a895b9508a0b3e24f23c8f35b6e80c7ac3a35bc4135d3673387df43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL mercury_python-2.21.0-cp312-cp312-manylinux_2_34_x86_64.whl
Size 14.1 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
b4d653993f03bc7f337c63edb6e59e5fa16384829222a6af66b32bb830a24453
BLAKE2b-256 checksum
How to use checksums
c34e8204da7d4a0e1d7218f172179bdb1bf41617ebd676fcb8e2944bae87c032
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp312-cp312-manylinux_2_34_aarch64.whl

Download URL mercury_python-2.21.0-cp312-cp312-manylinux_2_34_aarch64.whl
Size 14.0 MB
Tags CPython 3.12 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
589cb3dcdd85015bbcb2d01a38d25215e457fa4265f70bdbdba89c75c28d6862
BLAKE2b-256 checksum
How to use checksums
ac3e293907abb533cb1b27a0c9f741d8832d894b06478904d1684a122448ac05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp312-cp312-macosx_15_0_arm64.whl

Download URL mercury_python-2.21.0-cp312-cp312-macosx_15_0_arm64.whl
Size 3.1 MB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
00ff639d2e8a849b49e297bbef2a3004513fb133f4a0d526fae1bc8ecd51ece5
BLAKE2b-256 checksum
How to use checksums
4748deae62bba08aefabc4137fb8381151d7077b1bc613b6df3879de2153e18b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL mercury_python-2.21.0-cp311-cp311-manylinux_2_34_x86_64.whl
Size 14.1 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
3a427d18e02acc3d237d38bf8adbe4057e830272a5ec1471ffc8cacaa29d5dd3
BLAKE2b-256 checksum
How to use checksums
f069c2cd3d95484760155f1f2e4dc9a2d948ba9c4a1409947fff4d5141143cdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp311-cp311-manylinux_2_34_aarch64.whl

Download URL mercury_python-2.21.0-cp311-cp311-manylinux_2_34_aarch64.whl
Size 14.1 MB
Tags CPython 3.11 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
71bad6b958227086fc48b155e3ab8ff397c7f37858932da9d7a6036c88250768
BLAKE2b-256 checksum
How to use checksums
8fecd479382739e9dab228e4829b4414bd9d113aa8e1f5009a4c854fe17654d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp311-cp311-macosx_15_0_arm64.whl

Download URL mercury_python-2.21.0-cp311-cp311-macosx_15_0_arm64.whl
Size 3.1 MB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
fd08c4b4691511df5b48f0cd5245ce13998b718848366affb14c411bb6b4b6a4
BLAKE2b-256 checksum
How to use checksums
0503ccb58443849c16903a1009772a89b29a774c25858a6495970c28cb44b4e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp310-cp310-manylinux_2_34_x86_64.whl

Download URL mercury_python-2.21.0-cp310-cp310-manylinux_2_34_x86_64.whl
Size 14.1 MB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
377929ff321545f299152e685c028a52eaac244b5fcd00a2747ac0c8cdb6c2a3
BLAKE2b-256 checksum
How to use checksums
08220d3ce4f0e0a9f4454e74b81608b01246117e7748eba1c619411e6809eac3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp310-cp310-manylinux_2_34_aarch64.whl

Download URL mercury_python-2.21.0-cp310-cp310-manylinux_2_34_aarch64.whl
Size 14.1 MB
Tags CPython 3.10 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
698bc5b1fca6375fa51ff7b00391b63ca83cd6b579d0d3c16ea7ab75e5705cd3
BLAKE2b-256 checksum
How to use checksums
cec541ab012ca5049c15bf0d4209921ae83537cc045bf09c9afdf78630bf8eae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp310-cp310-macosx_15_0_arm64.whl

Download URL mercury_python-2.21.0-cp310-cp310-macosx_15_0_arm64.whl
Size 3.1 MB
Tags CPython 3.10 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
298447ccaa8b3fe21ae660e8a36dadb7c14e4d357194e4f47e132970414d0412
BLAKE2b-256 checksum
How to use checksums
18676c99d50bf8807d9e4f092ceb7e5f5a47d6249ee63233aeefef185a6253a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp39-cp39-manylinux_2_34_x86_64.whl

Download URL mercury_python-2.21.0-cp39-cp39-manylinux_2_34_x86_64.whl
Size 14.1 MB
Tags CPython 3.9 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
42ab00e558e7750660b02f4385cce2c4ec4fe9fbad91da150000dc59ef1d8a5d
BLAKE2b-256 checksum
How to use checksums
e9ed43fe60551cfa38cb61b7bf3f3e7c6fc0540a412cfa2d3a63c9073b3c0674
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp39-cp39-manylinux_2_34_aarch64.whl

Download URL mercury_python-2.21.0-cp39-cp39-manylinux_2_34_aarch64.whl
Size 14.1 MB
Tags CPython 3.9 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
21c05838a96520414cb81f16757b8eecefae43a20f24925a284ea4a08ee723e7
BLAKE2b-256 checksum
How to use checksums
b28d9e7bc78174dcc3835a712bd9922b5ecf494309b169f42bb1614cadb83c07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mercury_python-2.21.0-cp39-cp39-macosx_15_0_arm64.whl

Download URL mercury_python-2.21.0-cp39-cp39-macosx_15_0_arm64.whl
Size 3.1 MB
Tags CPython 3.9 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
04cb3ed768aa242f05872f5fd8182c9e78ec231f3fa5083c9d0fe37e1268542c
BLAKE2b-256 checksum
How to use checksums
6878469af76d44f3374602d8ecf8a3db935224a75843abf602034f3e14cd0498
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release history Release notifications | RSS feed

This release

2.21.0 This release

21 release files

2.9.0

16 release files

2.8.1

16 release files

2.8.0

16 release files

2.6.4

16 release files

2.6.1

16 release files

0.2.0

22 release files

0.1.2

42 release files

0.1.1

9 release files

0.1.0

9 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page