passbe/beef-migration-test-3 — Issue #439: Augment beef.net.request
Author: passbe
Created: 2011-12-09 01:00:13+00:00
State: open

Re-implement the beef.net.request() hooked browser method to increase functionality. This function will be the main method used by the framework to conduct requests originating from the hooked browser. Communication to the framework will rely on this function (thus script execution is essential).

The method will support GET and POST requests to arbitrary domains and on arbitrary ports. The unknown will be the results from the requests. Cross domain POST or GET requests are not going provide access to response content but the status code and port status may be extrapolated.

On domain requests will provide access to response content. This can be done through XMLHttpRequests or creating an iFrame and then scraping the result.

Requests will determine the state of the target TCP port. For example, a request to a filtered port will timeout and requests to ports that return an error may not be HTTP. It will be easiest to determine when a port is both HTTP and open.

The method also needs to support requesting and executing a JavaScript from off domain. This will be used when polling the framework server.

At completion of the function the DOM must be clean. That is, ensure any changes that have been made throughout the method execution have been removed. Also, multiple requests could be called at the same time. These should not interfere with each other – they must be thread safe.

The response object would look similar to the below:
response = {
status_code : 500, // 500, 404, 200, 302
response_body: "<html>….", // if not a cross domain request
port_status: “open”, // tcp port is open, closed or not http
was_cross_domain: false, // true or false
was_timedout: false, // the user specified timeout was reached
duration: 543, // how long it took for the request to complete
};

// the callback format used in beef.net.request
callback: function(response) {
// do work
}

// scheme: HTTP or HTTPS
// method: GET or POST
// domain: bindshell.net, 192.168.3.4, etc
// port: 80, 5900, etc
// path: /path/to/resource
// anchor: this is the value that comes after the # in the URL
// query: a=1&b=string&c=3.14
// timeout: timeout the request after N seconds
// execute: execute the response as if it was a JavaScript file.
// callback: call the callback function at the completion of the method
// response: this object is defined above and contains the response details

beef.net.request: function(scheme, method, domain, port, path, anchor, query, timeout, execute, callback, response) {
// do work
}

Future releases will have this method called with a binary object for the POST content.
Google Code Issue: http://code.google.com/p/beef/issues/detail?id=286