Servers#

class pync.NetcatServer(port, dest='', _4=None, _6=None, b=None, c=None, D=None, e=None, I=None, k=None, n=None, O=None, y=None, Y=None, **kwargs)[source]#

A Netcat server is iterable. You can iterate through each incoming connection.

Parameters:
  • port (int) – The port number to bind the server to.

  • dest (str, optional) – The hostname or IP address to bind the server to.

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

  • k (bool, optional) – Set to True to keep the server open between connections.

  • kwargs – Any other keyword arguments get passed to each connection.

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

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

If you don’t use the “with” statement, please make sure to use the close() method after use:

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

Use the “k” option to keep the server open and iterate through each pync.NetcatConnection.#
with NetcatServer(8000, dest='localhost', k=True) as nc:
    for connection in nc:
        connection.readwrite()
close()[source]#

Close the server.

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.NetcatTCPServer(port, dest='', _4=None, _6=None, b=None, c=None, D=None, e=None, I=None, k=None, n=None, O=None, y=None, Y=None, **kwargs)[source]#

Bases: NetcatServer

A pync.NetcatServer for the Transmission Control Protocol.

Connection#

alias of NetcatTCPConnection

next_connection()[source]#

Override in subclass Return the next NetcatConnection.

class pync.NetcatUDPServer(port, dest='', _4=None, _6=None, b=None, c=None, D=None, e=None, I=None, k=None, n=None, O=None, y=None, Y=None, **kwargs)[source]#

Bases: NetcatServer

A pync.NetcatServer for the User Datagram Protocol.

Connection#

alias of NetcatUDPConnection