Quick-n-dirty web server
Quick-n-dirty Python web server
Python 3 can nativly serve files out of the current directory over HTTP.
The default
$PORT
is 8080.Some useful
http.server
flags:Link to original
--bind ADDRESS
,-b ADDRESS
Specify alternate bind address [default: all interfaces]
--directory DIRECTORY
,-d DIRECTORY
Specify alternative directory [default: current directory]
A simple reverse shell
Python reverse shell
Adapted from slyth11907 / Cheatsheets / Cheatsheet_ReverseShells.
Catch it with netcat or socat.
Link to original
Exploiting python pickles
How to exploit Python pickles
One way to attack Python webapps is to exploit pickles, and in particular the
pickle.loads()
operation which reconstructs objects from an encoded data stream. When an object is reconstructed it is actually fully initialized, which means that things likeobject.__reduce__()
are run.For example, the TryHackMe’s OWASP Top 10 room has us use the following code to create a malicious base64 encoded object to feed
pickle.loads()
(LOCAL_IP
gets replaced by your machine’s IP):What’s getting encoded here is the
Link to originalrce
class. Python will callrce.__reduce__()
to determine how to initialize this class whenpickle.loads()
deserializes it, and__reduce__()
will return the tuple(os.system, (command,))
, wherecommand
is basically our standard Metasploit reverse shell. Python then initializes the class by usingos.system
to callcommand
, and there’s our reverse shell!