Skip to content

Commit 50a6443

Browse files
committed
Improved search for distinct URLs & Added functionality to configure similarity threshold from the options page
1 parent f7ea449 commit 50a6443

File tree

8 files changed

+124
-16
lines changed

8 files changed

+124
-16
lines changed

LICENSE

100644100755
File mode changed.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ It is recommended to pin the extension to the toolbar to check if a new modified
4545
4. Click on any URL in the list to open it in a new tab.
4646
5. To clear the list, click on the trash can icon in the top right corner of the popup.
4747

48+
## Options/Customization
49+
50+
To modify the similarity threshold using the options page of the extension, follow these steps:
51+
1. Click on the debugHunter extension icon in the Chrome toolbar.
52+
2. Click on the gear icon in the top right corner of the popup to open the options page.
53+
3. In the options page, use the slider to set the similarity threshold to the desired value (default 0.97)
54+
4855
## Contributing
4956

5057
We welcome contributions! Please feel free to submit pull requests or open issues to improve debugHunter.

background.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function preprocessText(text) {
9999
}
100100

101101
// Function to check if two responses are meaningfully different
102-
function isDifferentResponse(originalText, modifiedText) {
102+
function isDifferentResponse(originalText, modifiedText, similarityThreshold) {
103103
// Preprocess the texts before comparison
104104
const preprocessedOriginalText = preprocessText(originalText);
105105
const preprocessedModifiedText = preprocessText(modifiedText);
@@ -110,9 +110,6 @@ function isDifferentResponse(originalText, modifiedText) {
110110
preprocessedModifiedText
111111
);
112112

113-
// Set a threshold for similarity; responses with similarity below this threshold are considered different
114-
const similarityThreshold = 0.90;
115-
116113
// Return true if the similarity is below the threshold
117114
return similarity < similarityThreshold;
118115
}
@@ -127,7 +124,15 @@ async function binarySearch(url, includedParams, searchParams, originalText) {
127124
const modifiedUrl = appendQueryParam(url, searchParams[0]);
128125
const modifiedResponse = await fetch(modifiedUrl);
129126
const modifiedText = await modifiedResponse.text();
130-
if (isDifferentResponse(originalText, modifiedText)) {
127+
128+
// Load similarityThreshold from storage
129+
const storedSettings = await new Promise(resolve => {
130+
chrome.storage.sync.get('similarityThreshold', resolve);
131+
});
132+
133+
const similarityThreshold = storedSettings.similarityThreshold || 0.97;
134+
135+
if (isDifferentResponse(originalText, modifiedText, similarityThreshold)) {
131136
addModifiedUrl(modifiedUrl);
132137
}
133138
return;
@@ -145,7 +150,14 @@ async function binarySearch(url, includedParams, searchParams, originalText) {
145150
const modifiedResponse = await fetch(modifiedUrl);
146151
const modifiedText = await modifiedResponse.text();
147152

148-
if (isDifferentResponse(originalText, modifiedText)) {
153+
// Load similarityThreshold from storage
154+
const storedSettings = await new Promise(resolve => {
155+
chrome.storage.sync.get('similarityThreshold', resolve);
156+
});
157+
158+
const similarityThreshold = storedSettings.similarityThreshold || 0.97;
159+
160+
if (isDifferentResponse(originalText, modifiedText, similarityThreshold)) {
149161
// If the response is different, add the modified URL and search for more modifications
150162
addModifiedUrl(modifiedUrl);
151163
await binarySearch(url, includedParams, searchParams.slice(0, middleIndex), originalText);
@@ -174,4 +186,4 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
174186

175187
// Expose getModifiedUrls and clearModifiedUrls functions to popup
176188
window.getModifiedUrls = getModifiedUrls;
177-
window.clearModifiedUrls = clearModifiedUrls;
189+
window.clearModifiedUrls = clearModifiedUrls;

manifest.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
22
"manifest_version": 2,
33
"name": "debugHunter",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"description": "Discover hidden debugging parameters and uncover web application secrets",
6+
"options_page": "options.html",
67
"icons": {
78
"48": "images/icon.png"
89
},
910
"permissions": [
1011
"webRequest",
1112
"webRequestBlocking",
13+
"storage",
1214
"<all_urls>"
1315
],
1416
"background": {

options.html

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400&display=swap" rel="stylesheet">
7+
<style>
8+
body {
9+
font-family: 'Roboto';
10+
margin: 30px;
11+
max-width: 600px;
12+
color: white;
13+
background-color: #888888;
14+
}
15+
16+
h1 {
17+
font-size: 24px;
18+
font-weight: 300;
19+
margin-bottom: 20px;
20+
}
21+
22+
label {
23+
font-size: 16px;
24+
font-weight: 400;
25+
display: block;
26+
margin-bottom: 5px;
27+
}
28+
29+
input[type="range"] {
30+
width: 100%;
31+
margin-bottom: 20px;
32+
}
33+
34+
p {
35+
font-size: 14px;
36+
font-weight: 300;
37+
margin-top: 5px;
38+
}
39+
</style>
40+
<title>Options</title>
41+
</head>
42+
<body>
43+
<h1>Options</h1>
44+
<label for="similarityThreshold">Similarity Threshold</label>
45+
<input type="range" id="similarityThreshold" name="similarityThreshold" min="0" max="1" step="0.01" value="0.97">
46+
<p>Current value: <span id="similarityThresholdValue">0.97</span></p>
47+
<br><br><p>The similarity threshold determines the minimum similarity score required for a pair of URLs to be considered the same. The value ranges from 0 to 1, where 0 means that any pair of URLs is considered the same, and 1 means that only identical URLs are considered the same. The closer the value is to 1, the more similar the URLs need to be to be considered the same.</p>
48+
<p><b>Default value is: 0.97</b></p>
49+
<script src="options.js"></script>
50+
</body>
51+
</html>

options.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
document.addEventListener('DOMContentLoaded', () => {
2+
// Get the similarity threshold slider and display elements
3+
const similarityThresholdSlider = document.getElementById('similarityThreshold');
4+
const similarityThresholdValue = document.getElementById('similarityThresholdValue');
5+
6+
// Function to update the display value
7+
function updateDisplayValue(value) {
8+
similarityThresholdValue.textContent = value;
9+
}
10+
11+
// Load the saved similarity threshold value
12+
chrome.storage.sync.get('similarityThreshold', (data) => {
13+
const value = data.similarityThreshold || 0.97;
14+
similarityThresholdSlider.value = value;
15+
updateDisplayValue(value);
16+
});
17+
18+
// Save the similarity threshold value when the slider changes
19+
similarityThresholdSlider.addEventListener('input', (e) => {
20+
const value = e.target.value;
21+
updateDisplayValue(value);
22+
chrome.storage.sync.set({ similarityThreshold: value }, () => {
23+
console.log('Similarity threshold saved:', value);
24+
});
25+
});
26+
});
27+

popup.html

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
<html>
33
<head>
44
<meta charset="UTF-8">
5-
<link href="https://fonts.googleapis.com/css?family=Anonymous+Pro&display=swap" rel="stylesheet" />
5+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
66
<style>
77
body {
8-
font-family: "Anonymous Pro", monospace;
9-
background-color: #585858;
8+
font-family: "SFMono-Medium";
9+
background-color: #888888;
1010
color: white;
1111
width: 500px;
1212
max-height: 2000px;
1313
padding: 15px;
1414
}
1515

1616
h2 {
17-
font-size: 14px;
17+
font-size: 12px;
1818
margin-bottom: 12px;
1919
margin-top: 50px;
2020
}
@@ -35,21 +35,22 @@
3535

3636
li {
3737
background-color: #333;
38+
font-size: 10px;
3839
margin-bottom: 5px;
3940
padding: 5px;
4041
border-radius: 3px;
4142
}
4243

4344
button {
4445
background-color: rgb(130, 0, 0);
45-
font-family: "Anonymous Pro", monospace;
46+
font-family: "SFMono-Medium";
4647
border: none;
4748
color: white;
4849
padding: 5px 10px;
4950
text-align: center;
5051
text-decoration: none;
5152
display: inline-block;
52-
font-size: 12px;
53+
font-size: 11px;
5354
margin: 5px 2px;
5455
cursor: pointer;
5556
border-radius: 2px;
@@ -80,7 +81,11 @@
8081
</head>
8182
<body>
8283
<div class="banner"><img src="images/banner.png" width="150" height="40" ></div>
83-
<div class="info-container"><a href="#" id="info-icon">ℹ️</a></div>
84+
<div class="info-container">
85+
<a href="#" id="options-link"><i class="fa fa-cog"></i></a>
86+
<a href="#" id="info-icon"></i>
87+
</a>
88+
</div>
8489
<div class="window">
8590
<h2>Modified Response URLs</h2>
8691
<ul id="modifiedUrls"></ul>

popup.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ document.getElementById("clearUrls").addEventListener("click", () => {
2626

2727
document.getElementById('info-icon').addEventListener('click', () => {
2828
chrome.tabs.create({ url: 'https://github.com/devploit/debugHunter' });
29-
});
29+
});
30+
31+
document.getElementById('options-link').addEventListener('click', () => {
32+
chrome.runtime.openOptionsPage();
33+
});

0 commit comments

Comments
 (0)