pync#

pync.pync(args, stdin=None, stdout=None, stderr=None, Netcat=<class 'pync.netcat.Netcat'>)[source]#

Create and run a Netcat instance. This is similar to running pync from the command-line.

Parameters
  • args (str) – A string containing command-line arguments.

  • stdin (file, optional) – A file-like object to read outgoing network data from.

  • stdout (file, optional) – A file-like object to write incoming network data to.

  • stderr (file, optional) – A file-like object to write error/verbose/debug messages to.

Returns

Error status code depending on success (0) or failure (>0).

Return type

int

Examples

Create a local TCP server on port 8000.#
from pync import pync
pync('-l localhost 8000')
Connect to a local TCP server on port 8000.#
from pync import pync
pync('localhost 8000')
Create a local TCP server to host a file on port 8000.#
from pync import pync
with open('file.in', 'rb') as f:
    pync('-l localhost 8000', stdin=f)
Connect to a local TCP server to download a file on port 8000.#
from pync import pync
with open('file.out', 'wb') as f:
    pync('localhost 8000', stdout=f)