Skip to main content

No project description provided

Project description

TCP Traffic Generator

A simple Python script with no dependencies for generating quick TCP traffic to test a port on an endpoint.

Prerequisites

  • Install Python.
  • Ensure Python is in your PATH. In Windows, this option may need to be selected during the installation process.
  • In Windows, ensure that .py files are associated with Python. This option may need to be selected during the installation process.

Installation

From PyPI

It is recommended to use pipx for user-installed non-system Python applications:

pipx install tcpgen

If you want to install the program globally (not recommended), you can simply use pip:

pip install tcpgen

Manual Install

To install the script manually from Github, follow these instructions:

Windows

  • Create the %USERPROFILE%\.local\ and %USERPROFILE%\.local\bin\ directories
  • Add %USERPROFILE%\.local\bin to your PATH and .PY to your PATHTEXT
    • Open File Explorer > Right click This PC > Click Properties > Click Advanced System Settings > Click Environment Variables
    • Select Path for your user (not your system), click Edit, and add %USERPROFILE%\.local\bin
    • Select PATHTEXT for your system, click Edit, and add .PY to the end of the list
  • Move the tcpgen/main.py file to the %USERPROFILE%\.local\bin\ directory and rename it to tcpgen.py
  • Add the #!/usr/bin/env python shebang to the top of tcpgen.py file
  • Open a new CMD instance and run tcpgen

Linux/MacOS

  • Move the tcpgen/main.py file to ~/.local/bin/ with the name tcpgen (extension not necessary)
  • Some distros use the python command, and others use python3. Add the #!/usr/bin/env python shebang to the top of the tcpgen file. If it doesn't work, change it to #!/usr/bin/env python3
  • chmod u+x ~/.local/bin/tcpgen to make the file executable.
  • Open a new terminal session and run tcpgen

Note: The requirements.txt file contains dev dependencies only. You do not need to pip install the requirements.

Usage

No CLI Args

You can use the script without any arguments passed. For example, if using Windows, you might do this:

>tcpgen
Hostname/IP: localhost
Resolved localhost to 127.0.0.1
Ports (separated by space, e.g. 22 80 443): 22 80 443 3389
[output omitted]
Hostname/IP:
Exiting...

>

This will prompt you for a host and a list of ports until Ctrl-C is detected.

One CLI Arg

If there is only one argument, the script expects a hostname or IP address. For example:

>tcpgen localhost
Resolved localhost to 127.0.0.1
[output omitted]

>

By default, port 22 will be used. If you installed manually, you can change this by setting the DEFAULT_PORTS variable. For example:

DEFAULT_PORTS = [22, 80, 443]

More Than One CLI Arg

If there are multiple arguments, the first must be the hostname or IP address. The rest are expected to be ports. For example:

>tcpgen localhost 22 80 443 3389
Resolved localhost to 127.0.0.1
[output omitted]

>

Example

Here's what it looks like:

Windows

Ubuntu

Note that the error messages in Windows are different than Linux. In Windows, if the traffic reaches the destination but the traffic is rejected, the traffic will appear to be timed out or dropped (even with Defender Firewall turned off). Ubuntu, however, more accurately displays the error message "Connection refused". This is not a bug, but rather a difference in how the operating systems display rejected traffic. This isn't to say that Ubuntu's error messages are necessarily better, however.

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

tcpgen-0.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

tcpgen-0.1.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file tcpgen-0.1.1.tar.gz.

File metadata

  • Download URL: tcpgen-0.1.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for tcpgen-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7e47d9bfc076c4ae3830ee0ae42060139ca51631b2245062fb9713a3ab125e4b
MD5 46fc412debdbb316b45b588fd5cabef4
BLAKE2b-256 8cd27efa92fbe1145777bfcf1721a73b0d6eba5e266789fc7b073dde7dcd71c0

See more details on using hashes here.

File details

Details for the file tcpgen-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tcpgen-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for tcpgen-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 283719ad160a015ad91310be55844e21f4ede5868aebb1f0d07e318da576a35c
MD5 022f3f03d8ec6d5b3d0386aefb823f95
BLAKE2b-256 718dee47bd344f5c99ba9d195042678aa4e55ed9d92d9b77c1a88738c50e7544

See more details on using hashes here.

Supported by

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