0

I want to write a script generator based on whats happening on the website, and for that I have written javascript - ajax based script generator, where on every page i do include the js file and within function block of page where page is submited I call the function of javascript to initiate reading of page variables ( DOM ) by getElementsByTagName(*), and after looping through it, I write predefined format to a file using ajax.

this all is done for the same site where its running, however now as when I needed to implement same for any other site as recorder and script generator as whats done on the website and to log into file, neither I can include my script on to any other external website nor put function call before submit to read dom and throw into file.

here is dummy code of js

 beginRecording();

function beginRecording()
{
    if(RECORD_BIT == 1)
    { 
       processPageData();   
    }
}

function processPageData()
{
  var i
  var obj = document
  var posArray = new Array();
  var allElement = obj.getElementsByTagName("*");
  var dataArrayString = "";

  for(i=0; i < allElement.length; i++)
  {
    if (allElement[i].getAttribute('id') != null && allElement[i].getAttribute('id') != "") 
    {
        posArray[posArray.length] = allElement[i].getAttribute('id');
    }
 }

 for(i = 0 ; i < posArray.length ; i++)
 {
    dataArrayString = dataArrayString+"SET  "+posArray[i]+"="+getValueFromPage(posArray[i]);
 }



  writePostData(dataArrayString);

}

The function writePostData, does ajax and writes/ updates file on the server by logging what was on DOM element, and I send couple of more details liek GET/POST or page name and so on..

beginRecording() is called on the page before javascript does a submit as document.forms[0].submit(), so that it can capture POST.

I read about cross domain ajax, but still I am not sure how can I monitor HTTP (read GET / POST and data on page or URL) of any external website without adding my script into that file, and write to file

any help or direction would be great.

NitinKumar.001
  • 179
  • 5
  • 17
  • 1
    Sounds like you should be writing a browser plugin and not a web page. – epascarello Jun 20 '12 at 18:01
  • Hi Epascarello, Thanks for the suggestion, I was able to create browser plugin using crossrider which is able to capture get and post, and on IE using activex, I am able to write captures to a file. tested on yahoo and other, just need to add them to trusted site, which is acceptable. however if page has framesets, say header / body / footer, and footer is doing some action on body, I am unable to capture post of frames within frameset ? can I capture that using javascript, I tried using self.frames.count and then parent.frames[index].document.location.href , but still unable to capture that. – NitinKumar.001 Jun 29 '12 at 17:31

1 Answers1

1

You can't include javascript on a remote site, or monitor it's HTTP requests both of those things would be catastrophic to security...

Dan Smith
  • 5,685
  • 32
  • 33
  • Thanks for reply, I know that I could not inject script on to other website, however as firefox does capture even POST data and I can see that on firebug, under net -> html -> and expanding post request then under post tab. If i strictly use firefox with firebug to monitor, can I capture the POST data or POST / GET request what is logged by firebug ? – NitinKumar.001 Jun 20 '12 at 18:27
  • You'd have to build a firefox extension to do that, that information isn't available to a general website - the user has to chose to install what you're proposing. What exactly are you trying to achieve here? Perhaps we can suggest a better way to get the result you want. – Dan Smith Jun 20 '12 at 22:39
  • thanks for reply, we have a response monitor tool, which repeatedly monitors predefined sets of action and monitors the response time and generate the graph to demonstrate on entire day the how long the action took time, and produces graphs for its reporting, however the script which tells what to do, like set username=x password=y and post over http on this IP, currently required to be written manually, and for that you need to know what input parameters, their id and value user wants to test repeatedly, but to generate that script is error prone,so we wanted a recorder while navigating site – NitinKumar.001 Jun 21 '12 at 16:45