forked from ACK-J/Port_Authority
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestPortScans.html
More file actions
298 lines (258 loc) · 11.2 KB
/
TestPortScans.html
File metadata and controls
298 lines (258 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="color-scheme" content="light dark">
<title>All in One Port-Scan Test</title>
<style>
/* Color variables copied from Port Authority */
:root {
--light: #ffffff;
--dark: #23222B;
--background: var(--light);
--foreground: var(--dark);
--red: #800000;
}
@media (prefers-color-scheme: dark) {
:root {
/* Colors selected to match the settings page's wrapper container styles */
--light: #BFBFC9;
--dark: #23222B;
--background: var(--dark);
--foreground: var(--light);
--red: #B20000; /* Slightly brighter for better contrast against `--background` */
}
}
body {
background-color: color-mix(in oklab, var(--background) 95%, var(--foreground));
color: var(--foreground);
font-family: system-ui, sans-serif;
line-height: 1.5;
box-sizing: border-box;
margin: 0;
min-height: 100vh;
padding: 2vw 2vw;
display: flex;
justify-content: center;
align-items: center;
}
section {
max-width: 80ch;
background-color: var(--background);
border: 2px solid color-mix(in oklab, var(--background) 90%, var(--foreground));
border-radius: 15px;
overflow: hidden;
}
header {
background-color: var(--red);
color: var(--background);
padding: 2em 2ch;
text-align: center;
h1 {
font-size: 2rem;
margin: 0;
}
}
main {
padding: 2ch;
padding-top: 0;
overflow: auto;
}
#custom_button {
display: block;
margin: 2em auto;
padding: 0.5em 2ch;
font-size: 1.1em;
border: none;
outline: 5px solid var(--red);
border-radius: 50rem;
background-color: color-mix(in oklab, var(--background) 95%, var(--foreground));
color: var(--red);
cursor: pointer;
transition: outline .2s,
color .4s;
}
#custom_button[disabled] {
cursor: wait;
}
#custom_button:not([disabled]):is(:hover, :active, :focus) {
outline: 8px solid oklch(from var(--red) calc(l + 0.1) c h);
color: var(--foreground);
}
#plugin-button {
display: block;
width: fit-content;
margin: 0 auto;
}
code, pre {
font-family: ui-monospace, monospace;
background-color: color-mix(in oklab, var(--background) 92%, var(--foreground));
border: 1px solid color-mix(in oklab, var(--background) 85%, var(--foreground));
border-radius: 5px;
padding: 0 0.5ch;
}
pre {
padding: 0.6em 2ch;
margin: 0;
}
a {
color: oklch(from var(--red) calc(l + 0.2) c h);
text-decoration: underline oklch(from var(--red) calc(l + 0.2) c h) 2px;
}
a:is(:hover, :focus) {
color: var(--red);
text-decoration-color: var(--red);
}
</style>
</head>
<body>
<section>
<header><h1>All-in-One Port Scan Test</h1></header>
<main>
<button id="custom_button">Port Scan My Internal Network!</button>
<p>
The button above will run a port-scan of your local network. It works by triggering HTTP <code>GET</code> requests via
a hidden image's <code>src</code> attribute. The port-scan results will <em>never</em> be uploaded to remote servers and will
never leave your computer. You can verify this and fully monitor the scan from the <a href="https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/index.html" target="_blank">DevTools Network tab</a>,
or check on the list of the local domains scanned below.
</p>
<p>
To protect against private network port-scans like these there are several options:
the <a href="https://addons.mozilla.org/firefox/addon/port-authority/">Port Authority browser addon</a> is designed specifically to block private network port-scans.
Alternatively, <a href="https://addons.mozilla.org/firefox/addon/ublock-origin/" target="_blank">uBlock Origin</a> users
can add the <a href="https://github.com/gorhill/uBlock/wiki/Dashboard:-Filter-lists#block-outsider-intrusion-into-lan" target="_blank">"Block Outsider Intrusion into LAN"</a> filter list.
</p>
<a id="plugin-button" href="https://addons.mozilla.org/firefox/addon/port-authority/">
<img src="https://blog.mozilla.org/addons/files/2020/04/get-the-addon-fx-apr-2020.svg" alt="Port Authority addon for Firefox" height="60px">
</a>
<h2 id="results-label" hidden>
Requests Made:
</h2>
<pre id="results" hidden></pre>
</main>
<div id="testdiv" hidden></div>
</section>
<script>
/* DOM nodes */
const trigger_portscan_button = document.getElementById("custom_button");
const results_label = document.getElementById("results-label");
const results_container = document.getElementById("results");
const test_div = document.getElementById("testdiv");
/* DOM functionality binding */
trigger_portscan_button.addEventListener("click", custom_scan);
const log_portscan = (url) => results_container.append(url + "\n");
/* The scanner needs these global variables for an ugly hack. */
var last_scanobj_index = 0;
var scanobjs = {};
function PortScanner(ip, port)
{
// Verify port format
if (isNaN(port) || port <= 0 || port > 65535) {
alert("Bad port number");
}
const host = ip + ":" + port;
this.host = host;
this.total_time = null;
this.runHTTP = function () {
/* Save this object in the global directory (UGLY HACK). */
var our_scanobj_index = last_scanobj_index;
last_scanobj_index++;
scanobjs[our_scanobj_index] = this;
/* Create the div to load the image, passing our object's index into
the global directory so that it can be retrieved. */
test_div.innerHTML = '<img src="http://' + host +
'" alt="" onerror="error_handler(' + our_scanobj_index + ');" />';
log_portscan("http://" + host);
// XXX: What's the right way to do this in JS?
var thiss = this;
setTimeout(
function () {
/* This will be non-null if the event hasn't fired yet. */
if (scanobjs[our_scanobj_index]) {
scanobjs[our_scanobj_index] = null;
}
},
10000
);
}
this.runHTTPS = function () {
/* Save this object in the global directory (UGLY HACK). */
var our_scanobj_index = last_scanobj_index;
last_scanobj_index++;
scanobjs[our_scanobj_index] = this;
/* Create the div to load the image, passing our object's index into
the global directory so that it can be retrieved. */
test_div.innerHTML = '<img src="https://' + host +
'" alt="" onerror="error_handler(' + our_scanobj_index + ');" />';
log_portscan("https://" + host);
// XXX: What's the right way to do this in JS?
var thiss = this;
setTimeout(
function () {
/* This will be non-null if the event hasn't fired yet. */
if (scanobjs[our_scanobj_index]) {
scanobjs[our_scanobj_index] = null;
}
},
10000
);
}
this.ws = function() {
return new Promise((resolve, reject) => {
var ws = new WebSocket("ws://" + host + '/')
log_portscan("ws://" + host);
ws.onerror = function() {
// close the socket before we return
ws.close()
}
})
}
this.wss = function() {
return new Promise((resolve, reject) => {
var ws = new WebSocket("wss://" + host + '/')
log_portscan("wss://" + host);
ws.onerror = function() {
// close the socket before we return
ws.close()
}
})
}
}
function error_handler(index)
{
/* Get the PortScanner object back. */
var thiss = scanobjs[index];
/* If it's null, the scan timed out. */
if (thiss == null) {
return;
}
/* Set it to null so the timeout knows we handled it. */
scanobjs[index] = null;
}
function custom_scan()
{
const ips = [{"127.0.0.1": 80}, {"127.0.0.1": 65535}, {"0.0.0.0": 80}, {"localhost.": 80}, {"localhost.": 8080}, {"localhost": 8080}, {"localhost": 8081}, {"localhost": 8082}, {"localhost": 8083}, {"localhost": 8084}, {"localhost": 8085}, {"LoCALhOst": 443}, {"10.0.0.1": 455}, {"10.255.22.33": 80}, {"192.168.1.1": 443}, {"192.168.1.255":6463}, {"172.17.100.155": 4444}, {"172.31.255.255": 8081}, {"172.031.33.33": 445}, {"169.254.1.0": 547}, {"169.254.1.0": 21}, {"169.254.1.0": 194}];
const scripts = ["fp.disney.go.com", "h.chase.co.uk", "analytics.vacations.united.com", "tmx.bestbuy.com", "thm12.visa.com", "tmetrix.my.chick-fil-a.com", "cfa.fidelity.com", "content22.citibank.com", "deviceauth.dmv.ca.gov", "dfp.t-mobile.at", "src.ebay-us.com", "fp.disney.go.com", "fp.ups.com"];
trigger_portscan_button.disabled = true;
trigger_portscan_button.blur();
results_label.hidden = false;
results_container.hidden = false;
results_container.innerText = "";
for(const item of ips){
const [ip, port] = Object.entries(item)[0];
const scanner = new PortScanner(ip, port);
scanner.runHTTP();
scanner.runHTTPS();
scanner.ws();
scanner.wss();
}
for(const host of scripts){
const scanner = new PortScanner(host, 443);
scanner.runHTTPS();
}
trigger_portscan_button.disabled = false;
}
</script>
</body>
</html>