Clients#

class pync.NetcatClient(dest, port, _4=None, _6=None, b=None, c=None, D=None, e=None, I=None, n=None, O=None, P=None, p=None, r=None, s=None, w=None, X=None, x=None, y=None, Y=None, z=None, **kwargs)[source]#

A Netcat client is iterable. You can pass one or more ports and iterate through each pync.NetcatConnection.

Parameters:
  • dest (str) – The destination hostname or IP address to connect to.

  • port (int, list(int)) – The port number(s) to connect to.

  • e (str, optional) – Execute a command upon connection.

  • z (bool, optional) – Set to True to turn Zero i_o on (connect then close). Useful for simple port scanning.

You can use sub-classes of this class as a context manager using the “with” statement:

with NetcatClient(...) as nc:
    nc.readwrite()

If you choose not to use the “with” statement, please make sure to use the close() method after use:

nc = NetcatClient(...)
nc.readwrite()
nc.close()
Example:

We can connect to multiple ports one after another by passing a list of ports.#
with NetcatClient('localhost', [8000, 8001]) as nc:
    for connection in nc:
        connection.readwrite()
Using the “z” and “v” options, we can perform a simple port scan.#
with NetcatClient('localhost', [8000, 8002], z=True, v=True) as nc:
    nc.readwrite()
iter_connections()[source]#

Override in subclass Iterate through and yield each connection. Close each connection before moving on to the next.

next_connection()[source]#

Override in subclass Return the next NetcatConnection.

class pync.NetcatTCPClient(dest, port, _4=None, _6=None, b=None, c=None, D=None, e=None, I=None, n=None, O=None, P=None, p=None, r=None, s=None, w=None, X=None, x=None, y=None, Y=None, z=None, **kwargs)[source]#

Bases: NetcatClient

A pync.NetcatClient for the Transmission Control Protocol.

Connection#

alias of NetcatTCPConnection

class pync.NetcatUDPClient(dest, port, _4=None, _6=None, b=None, c=None, D=None, e=None, I=None, n=None, O=None, P=None, p=None, r=None, s=None, w=None, X=None, x=None, y=None, Y=None, z=None, **kwargs)[source]#

Bases: NetcatClient

A pync.NetcatClient for the User Datagram Protocol.

Connection#

alias of NetcatUDPConnection