function page_xss_injector() {
for($i=0;$i<2;$i++) {
// Extract the forms url and id
$form_details =
db_fetch_array(db_query("SELECT f.id,l.path FROM {crawler_forms} f INNER JOIN {crawler_links} l ON f.page_id = l.id WHERE status = 2 LIMIT 1"));
// Visit that url
$obj = new drupal_security_scanner_test();
$session_cookie =
variable_get('security_scanner_cookie',
'');
$obj->
curl_options =
array(
CURLOPT_COOKIE => $session_cookie,
);
//$obj->drupalGet($form_details['path']);
$obj->drupalGet('http://localhost/soc2008/?q=node/add/page');
$obj->parse();
// Selecting the form that has the id that i already saved into the db(this is because sometimes there are 2 forms inside the same page)
$textfields = $obj->elements->xpath("//input[@id='edit-page-node-form']/parent::*"); /// --- [@type='textarea'|@type='textfield']
foreach ($textfields as $text) {
// Selecting only textareas and input type = 'text' before seeding
$all_inputs = $text->elements->xpath("//input[@type='text']|//textarea");
foreach ($all_inputs as $input) {
$name = (string)$input->attributes()->name;
$form_state['values'][$name] = "<script>alert('xss');</script>";
}
}
}
}