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

Recommended 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"
            }
        ],
        ...

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mercury_python-2.19.0-cp314-cp314t-manylinux_2_34_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.34+ x86-64

mercury_python-2.19.0-cp314-cp314t-manylinux_2_34_aarch64.whl (13.5 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.34+ ARM64

mercury_python-2.19.0-cp314-cp314t-macosx_15_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.14tmacOS 15.0+ ARM64

mercury_python-2.19.0-cp314-cp314-manylinux_2_34_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

mercury_python-2.19.0-cp314-cp314-manylinux_2_34_aarch64.whl (13.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

mercury_python-2.19.0-cp314-cp314-macosx_15_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

mercury_python-2.19.0-cp313-cp313-manylinux_2_34_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

mercury_python-2.19.0-cp313-cp313-manylinux_2_34_aarch64.whl (13.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

mercury_python-2.19.0-cp313-cp313-macosx_15_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

mercury_python-2.19.0-cp312-cp312-manylinux_2_34_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

mercury_python-2.19.0-cp312-cp312-manylinux_2_34_aarch64.whl (13.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

mercury_python-2.19.0-cp312-cp312-macosx_15_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

mercury_python-2.19.0-cp311-cp311-manylinux_2_34_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

mercury_python-2.19.0-cp311-cp311-manylinux_2_34_aarch64.whl (13.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ ARM64

mercury_python-2.19.0-cp311-cp311-macosx_15_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

mercury_python-2.19.0-cp310-cp310-manylinux_2_34_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

mercury_python-2.19.0-cp310-cp310-manylinux_2_34_aarch64.whl (13.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ ARM64

mercury_python-2.19.0-cp310-cp310-macosx_15_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

mercury_python-2.19.0-cp39-cp39-manylinux_2_34_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

mercury_python-2.19.0-cp39-cp39-manylinux_2_34_aarch64.whl (13.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ ARM64

mercury_python-2.19.0-cp39-cp39-macosx_15_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

Details for the file mercury_python-2.19.0-cp314-cp314t-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp314-cp314t-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8702dcb2d507c13483a439cd3afecd50ec0d45a7e32fb8ae974cd686aa49aa59
MD5 0cd4930b7123b0e3d35e6ac4a10657d4
BLAKE2b-256 2db40f0380912c1da9009fc91ff779f22db4d9ff443fac84c40d675dfc387341

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp314-cp314t-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp314-cp314t-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 dee747d3ba8c2d890731c5edd10f8b5dc539fdd2af0e01076b4908031d77c3ef
MD5 f129a496ea76d217b6c70653f300aa14
BLAKE2b-256 00638683b5a52cf12387506f0c2110f21aa7325a345e890d2ad73fb7ad719354

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp314-cp314t-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp314-cp314t-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e3ebd7a7c3fe73974b7210b4f1d5ebecc600d6f704b6966e663410c213296f15
MD5 28031375f3acb3ff67e6e98428a680a5
BLAKE2b-256 25f7eacf3322a16a841b08e9c889eec8854a3fb47775587e5c5ba5ba56a534ef

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 cfe1e4a67641dc88d8962673cbdf9ead28c26ad4ebbbde5d3d1cf839f15d5c3f
MD5 7abdad7a3efc27db64632aa413bd9b69
BLAKE2b-256 eae36c532e0232952ed5ea1a2b804ccce59c93b96d42414defddabbb80252692

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp314-cp314-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 486411b2e0fb5d60d2a41cd0e1eccf84f2d97f0b5911c0471f3d99e95986c8f6
MD5 ffcd65b5b1e358451b628593440d1dbb
BLAKE2b-256 103f694fe78a44738684083a9d029e35c1289f3363568a53a25897d4545d4682

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 4c29f13aed1c538e51bce9fea58cd7aa0865abb6e07f97cc17cf1662d525f832
MD5 366c7315ca48767b45c31612471a893a
BLAKE2b-256 ce84f7fded4f241b83b80c838352610fbae811c2dcadd08a22ccd6a48ff23805

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8720a41038dfff9ddbd4c461267876292d1c6942d5e8dede6df6d1c528754237
MD5 779bb86329f1b70e3a22973ce127ba95
BLAKE2b-256 2ee8adb88d253cd5610990c8b2aa6e839a6ac940e726189b50f1a4a8f0dc30f2

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 32e977044db5209493ac667716aaaa25e7f0933101a1bb16992a2c0f9755f3a6
MD5 e34b2d1f88af2ca1aa427e0041ce70ff
BLAKE2b-256 e2c6a0f00b068dfb3b4e302247de0cdb4e5f615be6675ddb6a73037a8f4d5c5d

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1bab018d11ba1d71b6d959b465f94361c9c99b4df55343ed7632df9ddab2ab2a
MD5 db401651525c2bfc9074df07072aba6b
BLAKE2b-256 b8359f57817a9f134ee29170052e64c87def8739416387b1f28d0a9d80903cde

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 cfa3938fc28a4b51979d0732c7d1816886dd036702c6515aac864136f0273a45
MD5 ea3c899d6ddab9151d193686c146f4f0
BLAKE2b-256 e3dbf53202656c7d134654c34900841d7ce478934c4adb832d8893b82444380a

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 5b3f53a5373fd968bb4ffb3e450b33805e36b35680f23113f9445117af94c38a
MD5 159d9a5013303225a8b62e90b3e0368c
BLAKE2b-256 e6388be2c435bc3aefddf08a8677217b28f5ed05623167f0da388186af5dcae7

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3c7ec6dfe96528ca96e11529f0b2f349445eef9c75030712e59f98aad56783f5
MD5 7da7420c169ddb53d2d2337e070a5a37
BLAKE2b-256 dd43a55809baea743751f5d65cc552eaf3cd1c6bc000688b63e099110b25dbb4

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 44ccc9da992bebdd46170dbdbf606e1b2accaf662b1197c56c3de56cb27584ba
MD5 89a4e52fa5284c4a012a34349a2bdce9
BLAKE2b-256 c26fd662e4625bfa20d269ccaa2f1eee0bedb00f5e070d6720ce0a93c06f656c

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp311-cp311-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp311-cp311-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 8b0b110255ecbe129b79e160a8427b65ba07c479f92f4a23db96bbc455c764fd
MD5 a455082e494fc01fdd2eb913ca739afb
BLAKE2b-256 8cfb267116d5b6dfee253d8b6af3c1ab0305978b8179f2eaff53afb72304afb4

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1bb5c816bbae396558f345bafa528afd8bae965580180c6011f6067618f5f68f
MD5 a5a05280cbb0a391e507ec26b5e0fae1
BLAKE2b-256 c403b0c612250f35c11489a8858ca4407d69b816ccecdd81c327db6a45b7b342

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 967cb2013cfc2c0617edc53f92235bcbcb1df4e5f7fb63430805df6852f865ea
MD5 7f81ebb75676f1abd49f18b154f71f33
BLAKE2b-256 1173a529b5f2869c4608176cbffe31bfe793e4851ea4ce04f769877e26925ebd

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp310-cp310-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp310-cp310-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 bad8b24f680a7448c6633108e73e05446dd5902767f4a97cddf95af6b521e00b
MD5 50d7b03f41e349f240046f972d8476cc
BLAKE2b-256 cf6709612c88b12307201cdf79e0a1b1b4ae726429928e77d88be0b3737b0597

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 a938a6f76bfda51ddafb06aa60aed6e78edf6ab3bf06f1ade6ca593fd09c1b17
MD5 d8baf9128bd12390d31e66c134f76164
BLAKE2b-256 ad4b352049811fdabde8ac0377bc2a6ae1cd9ede9429941a18b4cad77ac9aaa8

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 860d190e1ff800736c3cac91b652597f55e950d7c33dc8ded705edc9d3c33416
MD5 1136f37e28e8b32e7d99c86e6b7deaed
BLAKE2b-256 704930be5ad3e35114992ffee47ee837bc9b5013d23b1f8c8584410c84a0042c

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp39-cp39-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp39-cp39-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 53f41720e83fc27c80ff3395288bbf03c5abeef2d936f2592cb0ab7b747476f4
MD5 b1bf866cb2a740d3bbcaa6ed7aa2622c
BLAKE2b-256 17f03bdf9f95455870d577f7a731e92ff4eb89979f5bb84928651318f9bf654c

See more details on using hashes here.

File details

Details for the file mercury_python-2.19.0-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for mercury_python-2.19.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 0ae4d64729818b75469605d49336f4e48454d4f79e3dde9b9a1e6b7133be1805
MD5 013269a50882741e307aeaa53a4494e0
BLAKE2b-256 2c4a82f09febd1d0a2269ff9c551994ca92231e14d3287f29538700bda22b69c

See more details on using hashes here.

Release history Release notifications | RSS feed

2.20.0

21 files

This release

2.19.0 This release

21 files

2.18.0

21 files

2.17.0

21 files

2.16.1

21 files

2.15.0

21 files

2.14.0

21 files

2.13.1

21 files

2.12.0

21 files

2.11.1

12 files

2.11.0

12 files

2.10.0

16 files

2.9.0

16 files

2.8.1

16 files

2.8.0

16 files

2.7.1

16 files

2.6.4

16 files

2.6.1

16 files

0.2.0

22 files

0.1.2

42 files

0.1.1

9 files

0.1.0

9 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