How to proxy a python script through Burp Suite
- Download the certificate from Burp Suite url
- Open your web browser and go to http://burpsuite.
- Click on “CA Certificate” button on the top right corner and save the certificate locally.
- Convert the certificate to PEM encoded format
- The certificate downloaded is DER formated and needs to be PEM encoded.
- You need to run the following command:
openssl x509 -inform der -in cacert.der -out certificate.pem
- Edit your python code
- Edit your python code with the following lines just below the import of Requests and OS modules:
import os
proxy = 'http://127.0.0.1:8080'
os.environ['http_proxy'] = proxy
os.environ['HTTP_PROXY'] = proxy
os.environ['https_proxy'] = proxy
os.environ['HTTPS_PROXY'] = proxy
os.environ['REQUESTS_CA_BUNDLE'] = "/path/to/cert/certificate.pem"
- Save and run!