(Python) Peer to peer C2 by Thomas Roccia (fr0gger)

Created the Tuesday 13 December 2022. Updated 3 months ago.


This code creates a simple server that listens for incoming connections on port 8000. When a new connection is accepted, the client is added to a list of clients. The server then receives data from the client and sends it to all of the other clients in the list. This allows the clients to communicate with each other in a peer-to-peer fashion, without the need for a central server.

Note that this is just an example, and there are many different ways that a P2P network could be used for a botnet's C&C. This code should not be used in production without further testing and security measures.


            import socket

# Create a socket for the server
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to a local address
server_socket.bind(("", 8000))

# Listen for incoming connections

# Create a list to store the clients
clients = []

while True:
  # Accept incoming connections
  client_socket, client_address = server_socket.accept()

  # Add the client to the list of clients

  # Receive data from the client
  data = client_socket.recv(1024)

  # Iterate over the clients and send the data to each of them
  for client in clients: