Skip to content

Commit

Permalink
Add simple local port scanning page. (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdzwinel authored Sep 20, 2024
1 parent 4c59b99 commit 6338a1b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ <h2>Privacy Protections Tests</h2>
<li><a href='./privacy-protections/amp-loop-protection/'>AMP Loop Protection</a></li>
<li><a href='./privacy-protections/query-parameters/'>Query Parameters</a></li>
<li><a href='./content-scope-scripts/runtime-checks/'>Runtime checks</a></li>
<li><a href='./privacy-protections/local-port-scan/'>Local port scanning</a></li>
</ul>

<h2 id="autofill">Autofill</h2>
Expand Down
1 change: 1 addition & 0 deletions privacy-protections/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ <h1>Privacy Protections Tests</h1>
<li><a href='./amp/'>AMP Links</a></li>
<li><a href='./amp-loop-protection/'>AMP Loop Protection</a></li>
<li><a href='./query-parameters/'>Query Parameters</a></li>
<li><a href='./local-port-scan/'>Local port scanning</a></li>
</ul>

</body>
Expand Down
50 changes: 50 additions & 0 deletions privacy-protections/local-port-scan/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Local port scanning</title>

</head>
<body>
<p><a href="../../">[Home]</a><a href="../">[Privacy Protections Tests]</a><strong>[Local Port Scanning]</strong></p>

<p>Trackers scan local network as a fingerprinting technique. This page runs such a scan.</p>
<p>Depending if this page was loaded over http or https this page will load local resources over the same protocol.</P>

<p>Scan range: <input id="range" value='192.168.1' />.*</p>
<p>Timeout: <input id="timeout" value='1000' />ms</p>
<button id="start">start</button>

<ul id="output"></ul>

<script>
const protocol = location.protocol;
const output = document.getElementById('output');

async function run () {
output.innerHTML = '';
const timeout = Number.parseInt(document.getElementById('timeout').value, 10);
const ipPrefix = document.getElementById('range').value;

for (let i = 0; i < 256; i++) {
const fullIP = `${ipPrefix}.${i}`;
const url = `${protocol}//${fullIP}/`;
const startTime = Date.now();
try {
const result = await fetch(url, { signal: AbortSignal.timeout(timeout) });
console.log(result);
} catch {

}
const responseTime = Date.now() - startTime;

output.innerHTML += `<li style='color: ${responseTime < 50 ? 'green' : 'red'}'>${fullIP} (${responseTime}ms)</li>`;
}
}

document.getElementById('start').addEventListener('click', run);
</script>

</body>
</html>

0 comments on commit 6338a1b

Please sign in to comment.