Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/core/main/client/net/portscanner.js
1154 views
1
//
2
// Copyright (c) 2006-2025 Wade Alcorn - [email protected]
3
// Browser Exploitation Framework (BeEF) - https://beefproject.com
4
// See the file 'doc/COPYING' for copying permission
5
//
6
7
/**
8
* Provides port scanning functions for the zombie. A mod of pdp's scanner
9
*
10
* Version: '0.1',
11
* author: 'Petko Petkov',
12
* homepage: 'http://www.gnucitizen.org'
13
* @namespace beef.net.portscanner
14
*/
15
16
beef.net.portscanner = {
17
18
/**
19
*
20
* @param callback
21
* @param target
22
* @param port
23
* @param timeout
24
*/
25
scanPort: function(callback, target, port, timeout)
26
{
27
var timeout = (timeout == null)?100:timeout;
28
var img = new Image();
29
30
img.onerror = function () {
31
if (!img) return;
32
img = undefined;
33
callback(target, port, 'open');
34
};
35
36
img.onload = img.onerror;
37
38
img.src = 'http://' + target + ':' + port;
39
40
setTimeout(function () {
41
if (!img) return;
42
img = undefined;
43
callback(target, port, 'closed');
44
}, timeout);
45
46
},
47
/**
48
*
49
* @param callback
50
* @param target
51
* @param ports_str
52
* @param timeout
53
*/
54
scanTarget: function(callback, target, ports_str, timeout)
55
{
56
var ports = ports_str.split(",");
57
58
for (index = 0; index < ports.length; index++) {
59
this.scanPort(callback, target, ports[index], timeout);
60
};
61
62
}
63
};
64
65
beef.regCmp('beef.net.portscanner');
66
67
68