Package: tcpgen
TCP Traffic GeneratorA simple Python script with no dependencies for generating quick TCP traffic to test a port on an endpoint.PrerequisitesInstallPython.Ensure Python is in yourPATH. In Windows, this option may need to be selected during the installation process.In Windows, ensure that.pyfiles are associated with Python. This option may need to be selected during the installation process.InstallationFrom PyPIIt is recommended to usepipxfor user-installed non-system Python applications:pipx install tcpgenIf you want to install the program globally (not recommended), you can simply usepip:pip install tcpgenManual InstallTo install the script manually from Github, follow these instructions:WindowsCreate the%USERPROFILE%\.local\and%USERPROFILE%\.local\bin\directoriesAdd%USERPROFILE%\.local\binto yourPATHand.PYto yourPATHTEXTOpenFile Explorer> Right clickThis PC> ClickProperties> ClickAdvanced System Settings> ClickEnvironment VariablesSelectPathfor your user (not your system), clickEdit, and add%USERPROFILE%\.local\binSelectPATHTEXTfor your system, clickEdit, and add.PYto the end of the listMove thetcpgen/main.pyfile to the%USERPROFILE%\.local\bin\directory and rename it totcpgen.pyAdd the#!/usr/bin/env pythonshebang to the top oftcpgen.pyfileOpen a new CMD instance and runtcpgenLinux/MacOSMove thetcpgen/main.pyfile to~/.local/bin/with the nametcpgen(extension not necessary)Some distros use thepythoncommand, and others usepython3. Add the#!/usr/bin/env pythonshebang to the top of thetcpgenfile. If it doesn't work, change it to#!/usr/bin/env python3chmod u+x ~/.local/bin/tcpgento make the file executable.Open a new terminal session and runtcpgenNote: Therequirements.txtfile contains dev dependencies only. You do not need topip installthe requirements.UsageNo CLI ArgsYou 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 ArgIf 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 theDEFAULT_PORTSvariable. For example:DEFAULT_PORTS = [22, 80, 443]More Than One CLI ArgIf 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]

>ExampleHere's what it looks like: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.