Appearance
How to Bypass disable-devtool Script in Browsers
Recently, I encountered an issue where the F12 key and various other methods could not open the DevTools (Developer Tools) in the browser. After trying multiple shortcuts and menu clicks, it was evident that the browser had been configured to disable DevTools. Our investigation led us to discover a specific JavaScript file named disable-devtool.min.js that blocks these tools.
Identifying the Issue
Upon further investigation, we found the culprit JavaScript file on GitHub and its documentation:
According to the documentation, the usage is quite simple. You just need to include the following script:
html
<script disable-devtool-auto src='https://cdn.jsdelivr.net/npm/disable-devtool/disable-devtool.min.js'></script>Solution with mitmproxy
To bypass this restriction, we can use mitmproxy to intercept and modify the script on-the-fly. Follow these steps:
Step 1: Install mitmproxy
Download windows installer from the officail website: mitmproxy download, install it.
install
mitmproxypython package.
bash
pip install mitmproxyStep 2: Create a Script to Replace the JavaScript Content
Next, create a replacement script named change_response.py and save the following code:
python
from mitmproxy import http
from mitmproxy import ctx
class EditResponse:
@staticmethod
def response(flow: http.HTTPFlow):
if flow.request.url.find("disable-devtool")!=-1:
ctx.log(f"disable-devtool url : {flow.request.url}")
ctx.log(flow.response.text)
flow.response.text = ""
addons = [
EditResponse()
]Step 3: Run mitmproxy
Execute mitmproxy using mitmdump, which is the CLI tool for mitmproxy:
bash
mitmdump -s change_response.pyThe default port is 8080, so you need to set your browser to use this proxy.
Step4: Windows Proxy Server Setting
On the windows Internet->Proxy Settting, set the proxy host and port to 127.0.0.1 and 8080 respectively
then your internet request will go to mitmproxy firstly.
You may also need to install certificates to fixed https error
Follow the tutorial at https://docs.mitmproxy.org/stable/concepts-certificates