Skip to content

Commit

Permalink
Create c2_client.py
Browse files Browse the repository at this point in the history
Signed-off-by: xXIamNoOneXx <143564810+xXIamNoOneXx@users.noreply.github.com>
  • Loading branch information
xXIamNoOneXx authored Sep 3, 2023
1 parent e1f9f00 commit 091bed9
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions c2_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import tkinter as tk
import socket
import logging
from cryptography.fernet import Fernet

# Configure the logging module
logging.basicConfig(filename='c2_client.log', level=logging.INFO, format='%(asctime)s - %(levelname)s: %(message)s')

class C2Client:
def __init__(self, root):
self.root = root
root.title("Concussion C2 Client")

self.server_host = 'YOUR_SERVER_IP'
self.server_port = 12345 # Match the server's port
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
# Attempt to connect to the C2 server
self.client_socket.connect((self.server_host, self.server_port))
except ConnectionRefusedError:
logging.error("Connection refused. Ensure the C2 server is running.")
self.root.destroy()
except Exception as e:
logging.error(f"Error: {e}")
self.root.destroy()

# Load the shared symmetric key (you should securely distribute this key from the server)
self.symmetric_key = b'YOUR_SHARED_SYMMETRIC_KEY'
self.cipher_suite = Fernet(self.symmetric_key)

self.setup_gui()

def setup_gui(self):
# Create and configure your GUI elements here
# ...

def send_command(self):
# Implement command sending logic here
# ...

def show_history(self):
# Implement command history retrieval logic here
# ...

def close_connection(self):
# Log connection closure when the GUI is closed
logging.info("Connection to the C2 server closed.")
self.client_socket.close()

if __name__ == "__main__":
root = tk.Tk()
client = C2Client(root)

# Configure the close button to log connection closure
root.protocol("WM_DELETE_WINDOW", client.close_connection)

root.mainloop()

0 comments on commit 091bed9

Please sign in to comment.