Skip to main content

Hopper

Based on the emailtrail project, hopper is a python 2 & 3 package to track received from header hops.

Get structured information about each hop - Hostnames, Protocol used, Timestamp, and Delay.

Table of Contents

Usage

We can analyse an email source or raw headers

email = """
Delivered-To: money@capitalism.com
Received: by 10.129.52.209 with SMTP id b200csp1430876ywa;
        Tue, 10 Oct 2017 01:17:02 -0700 (PDT)
X-Received: by 10.31.153.20 with SMTP id b20mr6116862vke.110.1507623422746;
        Tue, 10 Oct 2017 01:17:02 -0700 (PDT)
Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65])
        by mx.google.com with SMTPS id b31sor1345013uaa.124.2017.10.10.01.17.02
        for <money@capitalism.com>
        (Google Transport Security);
        Tue, 10 Oct 2017 01:17:02 -0700 (PDT)
Received-SPF: pass (google.com: domain of bags@test_email.ua.edu designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65;
X-Received: by 10.176.85.196 with SMTP id w4mr6874179uaa.75.1507623422198; Tue, 10 Oct 2017 01:17:02 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.103.79.86 with HTTP; Tue, 10 Oct 2017 01:17:01 -0700 (PDT)
From: Mr. Money Bags <bags@moneyrules.com>
Date: Tue, 10 Oct 2017 01:17:01 -0700
Subject:
To: money@capitalism.com;
Content-Type: text/plain; charset="UTF-8"
Bcc: satan@wallstreet.com

A business opportunity awaits
"""

Lets analyse it

from hopper import Hopper
Hopper.analyse(email)
{
  'To': u'money@capitalism.com;',
  'From': u'Mr. Money Bags <bags@moneyrules.com>',
  'Bcc': u'satan@wallstreet.com',
  'Cc': u'None',
  'total_delay': 1,
  'trail': [
    {
      'delay': 0,
      'from': '',
      'protocol': 'HTTP',
      'receivedBy': '10.103.79.86',
      'timestamp': 1507623421
    },
    {
      'delay': 1,
      'from': 'mail-sor-f65.google.com',
      'protocol': 'SMTPS',
      'receivedBy': 'mx.google.com',
      'timestamp': 1507623422
    },
    {
      'delay': 0,
      'from': '',
      'protocol': 'SMTP',
      'receivedBy': '10.129.52.209',
      'timestamp': 1507623422
    }
  ]
}

The analyse function returns a python dictionary.

The trail shows the email hops sorted in chronological order. Each intermediary email server adds a Received header to the mail, from which the module parses the following information:

  • protocol : e.g HTTP, SMTP etc.
  • from : The name the sending computer gave for itself
  • receivedBy: The receiving computers name
  • timestamp : Unix epoch

An empty string value is set for fields which couldn't be determined.

  • delay: The delay (in seconds) is computed by taking the difference of two consecutive hops. In above example there was a delay of 1 sec from 10.103.79.86 to mx.google.com

Caveats

Sometimes during delay calculation the timestamp difference may be negative.

  • It's not possible for a server to recieve the email before previous one,
  • It means that either one or both of the servers clocks are off.
  • We assume a delay of 0 for this hop.

Contributing

emailtrail uses pipenv for managing virtual env and package versions.

  • Fork the repo and clone it.
  • In project root: pipenv install --dev --two. This installs packages required for testing and linting
  • Jump into your virutal env: pipenv shell
  • Running tests: pytest
  • If you want to understand the code, read the test cases first.
  • Make your changes -> Pass the tests -> Push to your branch -> Create pull request -> Profit ??

Metadata

Release files for hopper 0.0.1

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

Source distribution (sdist)

Source distribution for hopper 0.0.1
File Size Uploaded Provenance
hopper-0.0.1.tar.gz 5.9 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for hopper 0.0.1
File Interpreter ABI Platform
hopper-0.0.1-py3-none-any.whl Python 3 none any Details
hopper-0.0.1-py2-none-any.whl Python 2 none any Details

Total release size: 21.8 kB

Release files / hopper-0.0.1.tar.gz

Download URL hopper-0.0.1.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1e0e44c925ff82b857586e5b121087570c0bbc75b6a2d40855835ebcc86f1144
BLAKE2b-256 checksum
How to use checksums
62d5254bdc4fe0c91530ee3b7b4c98396d108e0c3a55f6bff90dd3bd00680c13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

Release files / hopper-0.0.1-py3-none-any.whl

Download URL hopper-0.0.1-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2136b6d1af18130bb5908edf399b0e4fcabc006f15e28ab56ce710c1993d0fdf
BLAKE2b-256 checksum
How to use checksums
16d54648a6dd07f9bb78f5a6208a2e0bfc1c665b2afb30a3d7786c2772638ed4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

Release files / hopper-0.0.1-py2-none-any.whl

Download URL hopper-0.0.1-py2-none-any.whl
Size 8.0 kB
Tags Python 2
SHA-256 checksum
How to use checksums
b0218d2b983d9cf3cb4195430754e6acf66e4f06c83fe49dcde9608ca83d18b5
BLAKE2b-256 checksum
How to use checksums
e340764a89a854b5948115435457a8403a97091fbe35ecce23d22c5a94f2c17e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

Security for hopper 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

3 release files No provenance

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