- Install mitmproxy tool
- Set LANG environment variable
export LANG=en_US.UTF-8
-
Ensure Firefox browser is installed
-
Run following command
firefox -p
-
Click on "Create Profile" > "Next"
-
Enter a profile name (e.g.
SecQAtion
) -
Choose a folder path
-
Select newly created profile
-
Uncheck
Use the selected profile without asking at startup
checkbox
-
In the Firefox browser, go to "Settings" page
-
Click on "Settings..." button
-
Select "Manual proxy configuration" radio button
-
Enter
127.0.0.1
as HTTP Proxy value -
Enter
8080
as HTTP Port value -
Click on "OK" button
Mitmproxy can decrypt encrypted traffic on the fly, as long as the client trusts mitmproxy’s built-in certificate authority. Usually this means that the mitmproxy CA certificate has to be installed on the client device.
Ref: https://docs.mitmproxy.org/stable/concepts-certificates/
-
Open a command prompt and type:
mitmdump
-
In the Firefox browser, navigate to mitm.it
-
Follow certificate installation instructions
$ cd ~/Downloads $ openssl x509 -in mitmproxy-ca-cert.pem -inform PEM -out mitmproxy-ca-cert.crt $ sudo mkdir /usr/share/ca-certificates/extra $ sudo cp mitmproxy-ca-cert.crt /usr/share/ca-certificates/extra/mitmproxy.crt $ sudo dpkg-reconfigure ca-certificates
-
Select "yes" when asked to trust new certificates from certificate authorities
-
Select the newly added certificate by pressing [TAB] button,
-
In Firefox browser, go to "Settings" page
-
Click on "View Certificates"
-
Choose the CA certificate "mitmproxy-ca-cert.crt"
-
Select the checkbox labeled as "Trust this CA to identify websites."
-
Click on "OK"
- Open a terminal window by pressing [CTRL]+[ALT]+T
- Start mitmproxy by running following command:
mitmproxy
- Open Firefox browser, and load the newly created browser profile (with proxy mode enabled)
- Navigate to https://defendtheweb.net/
- The secure website should load successfully
- You should see the captured server requests and responses in mitmproxy screen
- Your browser is configured and ready for use.
- mitmproxy should intercept all server requests and responses while automated test cases get executed by the robot framework
- Irrelevant browser traffic should be ignored
- All of the captured traffic should be saved to a file
- It should be possible to open the saved output file and analyze the intercepted traffic
init.sh
mitmdump -p 8080 -w +traffic.mitm "! ~u firefox|ocsp|mozilla|googleapis" &
robot -d ~/PycharmProjects/secqation/nullcon2021/Results ~/PycharmProjects/secqation/nullcon2021/Tests/App.robot
pkill mitmdump
echo "Test Complete."
Note: You must update the absolute path to "Results" and "Tests" folder as per your own directory structure.
Run following two commands, and take a short break:
chmod +x init.sh
./init.sh
Observation:
- "traffic.mitm" file was created
- File size is 0, indicating no traffic was captured
- What went wrong?
- Locate the folder that stores data related to custom Firefox browser profile (that we created earlier), e.g.,
/home/secqation/Desktop/NullconTraining2021/4-browser-profile
- In PyCharm, open "Common.robot" file under "Resources" folder
- Update the value of global variable
${FIREFOX_PROXY_PROFILE}
. Set it as absolute path to Firefox profile directory.
-
Re-run the bash script
./init.sh
-
Notice that server traffic has been captured and saved successfully in the file
traffic.mitm
-
Run following command to analyze the saved traffic
mitmweb -r traffic.mitm
-
Also, access
log.html
file from Results folder, to view data scraped from the target website
While the robots were at work, it was a break for you. With a refreshed mind, now is the time to look at all the gathered data and identify potential attack vectors.
The cuurrent data set can give you a good understanding about the target application.
After having a first look at the target application, if there's a need, the robot test cases can be enhanced further to automate the form filling process, or any other manual task, including reading emails from your email account or running commands in your bash shell, etc.
If you have clarity in your mind regarding the exact steps that you wish to perform, writing robot test cases is really a trivial process.