During Red Team exercises, we may gain access to systems but in tightly controlled environments, it can be tough to move around, and netcat may not be readily available for a particular OS. Well, never fear, Python to the rescuse once again. I discovered a really useful module recently, appropriately named nclib. Look how easy this makes coding sockets become!
#!/usr/bin/python3
from nclib import Netcat
nc = Netcat(listen=(‘192.168.134.129’, 56838))
nc.interact()
The 3 lines of code above is doing what nc -l -p 56838 would do, and the module does a whole lot more. You can build tools using the module and then use Pyinstaller to “one folder” or “one file” them up for easy deployment to whatever system you need it on.