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.20.0-cp314-cp314t-manylinux_2_34_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.34+ x86-64

mercury_python-2.20.0-cp314-cp314t-manylinux_2_34_aarch64.whl (14.0 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.14tmacOS 15.0+ ARM64

mercury_python-2.20.0-cp314-cp314-manylinux_2_34_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

mercury_python-2.20.0-cp314-cp314-manylinux_2_34_aarch64.whl (14.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.14macOS 15.0+ ARM64

mercury_python-2.20.0-cp313-cp313-manylinux_2_34_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

mercury_python-2.20.0-cp313-cp313-manylinux_2_34_aarch64.whl (14.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

mercury_python-2.20.0-cp312-cp312-manylinux_2_34_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

mercury_python-2.20.0-cp312-cp312-manylinux_2_34_aarch64.whl (14.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

mercury_python-2.20.0-cp311-cp311-manylinux_2_34_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

mercury_python-2.20.0-cp311-cp311-manylinux_2_34_aarch64.whl (14.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

mercury_python-2.20.0-cp310-cp310-manylinux_2_34_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

mercury_python-2.20.0-cp310-cp310-manylinux_2_34_aarch64.whl (14.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.10macOS 15.0+ ARM64

mercury_python-2.20.0-cp39-cp39-manylinux_2_34_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

mercury_python-2.20.0-cp39-cp39-manylinux_2_34_aarch64.whl (14.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ ARM64

mercury_python-2.20.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.20.0-cp314-cp314t-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp314-cp314t-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 40113e9e7b3e630d195c9d7f12b8fa22a355927099073c34eda3ba37203e9c77
MD5 bf7182b65b907e34ed9d1796a9fc20d4
BLAKE2b-256 3e4c6ba07244dbd51ecec64b2ef12b63c92634cc0f6ff3eb0260cad73dc70c0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp314-cp314t-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 3c46cffb5e418227dda5b9e8fb4af7792f0e0c0fc34f9d4823a23ef13925fd1f
MD5 472dd8029a96b1f1eac2c050b40b49b6
BLAKE2b-256 bab42cd49fa0fea69366d8874b10b5fc4f41e277ecb6c93646fe0aee3175dc2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp314-cp314t-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 dd2a09767001e6b49424151138491757cfb3041dea6d61fb0b298663e39b3d61
MD5 bbd1a16828de32ea2238f39723139e0f
BLAKE2b-256 39ba914bdf28e4be61cf51491d835c54142bb4270e94468a9983da7d3f3f3da4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5c415ab74801c265dd24a0f0f8c07ca14fd3c4c09f59d06f85676eb4609d6747
MD5 f2208af4d6abe40562462fc929f61272
BLAKE2b-256 81e096e8ed23f6882284e3828703e1360db8c58d522dc912adddc2a13e6bd52f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 6f87eac026c4364b14b101387c8cf6ae9bdb1a40405d74e5a3647386940dff4e
MD5 fc6ca1ecd0424ec22b8e9b6e4213bd21
BLAKE2b-256 e737356ec21ea3a9589a4751e0fcd9cde199f548ea5f7b522b321d5e76fcef36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ced7665e1531de0059504d52aae665a1d6e5d3e3ccf7f0cf75a0acd498165963
MD5 fd2231971bbda768c31110564d4a3d49
BLAKE2b-256 b83a02728bc952a1eabc8320a419c7795042ee57706bd249608189272c7a205b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a85072a2e93070133ea367e9030377ce1ab1bef8e384a0f02e474a34dbdac366
MD5 d4b191a5c405ce928a4559ed40329660
BLAKE2b-256 a795ad4494061dc7d78bcf8781342697320e1ce8a1e7e38d821b33003c3a494f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 4daae4fd196804d9e1806b32795064cbee4d1de90b90604aedfcb322b98ad927
MD5 bfed759ebe39dec7a77927959fa92d6c
BLAKE2b-256 48f82e3077489aafe79e31441a3318f44d391f3459f729e52dcd65b26a4a92b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 892612233b4b2c3bafee56665dc48c6e798c7dac7c76202b2cefb66187cdd06b
MD5 c3c8fd1abe9b2e32f3d2645f63027e05
BLAKE2b-256 0443496213737f44992b0586832872791ff2d0bf4d2e897645c95777bdede4c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6dd54174407b230a1695e9ca61040e0992bed14f2e4c8570798d2e7b9aa45c5e
MD5 233f9aa8e183fdf5aaea3895b3933b63
BLAKE2b-256 c9d4768225eceeaae29cdbaf611cc1ac5931640e275d335392c217615305c3be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 daa95075161cabededfe5a5a45bd609c6da9f43a96de6fe73d66a6de0589e824
MD5 3c354d4941bd4ac3716e8687abc9a57e
BLAKE2b-256 fdbfe37bca69d0bde01c516f86a75ae24299b7f37d906124f085f4f71513c820

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 73d9b4c2718187230eea514c9344b31e310b08045c9649c52f880cd2efd588c1
MD5 509b90baa2542b40b745505aafddf737
BLAKE2b-256 9b0f49f6f769b43767aa52e465338c5ebc3cf5f2778a3f2cd3b85a8dd9ebe760

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c2eb74513129d09df946fc8cc92dde36ea053833447e34205c7ff297643850a8
MD5 4a7bb51738dd3996430ac2dc5bfc342e
BLAKE2b-256 857adf79f520125416f1fa756081842d945852f63e45525ef8d7870970f0d9d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp311-cp311-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 51d72aeeb2e52ff6955cc33ae765f6170a9f59c60b8ec7cba729e7b8d31959f3
MD5 a9108d5e557f4d550cd5d79bc253f563
BLAKE2b-256 30f1f3df64f7cbfce42a6a7a8a9b18a27732c2e2fc253284d560357de8d04303

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 892a84255595d716b9697774dfa315d41d15b39d827d66967e6addad4d694afa
MD5 14aa3a3ca7c19ac635403eac92ac0f9e
BLAKE2b-256 00bd29240a3525363d10a842aa9dcef83ed50e43ef2cfbcf2497d92e3e1673f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 574d0669cd3721116d73209a852bf32a1ad4790d774c16515c1d756cc9d8a6fc
MD5 43e8420ec1b4d842fe96c98a79d349b2
BLAKE2b-256 e2a1ec301d438d1010f78ff3beb934bdedac4e93002f037deb77e085e4c59e35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp310-cp310-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 5deec4ce6d883fd8843fc755074055bf78497a48bf1d1b15b7519fae05d18507
MD5 5b3ec01fcf0afbf62f98d24cdfe20745
BLAKE2b-256 e15e46fb77784580b722c18456f0a7adb1e0abd0c3e64e5c99efe7f8d11b6ccd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ea56dde708ab2515a963ee06bab69b4c827cdcc1859f8ebee226ab10451e2078
MD5 34f8c83e38ac0f5c63dba9a2b03ac5a0
BLAKE2b-256 e6dab846a6b99fc4fb1591659c1d1d8ac1091665d5f5bf4f1cd0d8c1722754c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4e54bcbd4903aae9b4f55a170f92f3ddbbd47d5a6153d3d90b5e9f2060498786
MD5 74c4777f7341120be6cde1f562bdacc0
BLAKE2b-256 3cea77503bf559506dbe79a1f004cdae109d9a07f0fa3ffb018a0cd69bf26868

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp39-cp39-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 479a5c48192be1845ad848c2238f4b82a58d12e6a0715d26dd9dfd8459ee9e4a
MD5 bd7f67fe1316e7b189fe6b106e2457f8
BLAKE2b-256 562fa4ec68a7209a68d1128d4b921fe99e9fdf4e9f368490b3117bef31ec2031

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mercury_python-2.20.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 dc115719dc8df3a3e09fde9706fab9c90bce79372d06a8bb99f9e8675f8432a7
MD5 9ea584d0ec0bca784f9328086bf722ab
BLAKE2b-256 548731cf4150cd03c975b70ebe4de39d667743e551eb2648b3555c594e2d5dbf

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.20.0 This release

21 files

2.19.0

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