SECURITY

Web Security : Attacking AJAX - Identifying JavaScript in Applications, Tracing AJAX Activity Back to Its Source

8/30/2012 2:44:39 AM

1.1. Problem

JavaScript is incorporated from lots of different places; some are obvious and some are not. You need to find them and sometimes fetch them.

1.2. Solution

In this case, look for a few specific tags, shown here:

  • <script src="http://js.example.com/example.js">

  • onLoad=javascript:functionName()

1.3. Discussion

There are actually many, many events like onLoad(), onBlur(), onMouseOver(), onMouseOut(), and so on. You can search Google for a complete list. The important thing to know is that you may see JavaScript loaded via a <script> tag, but then it is invoked via an onMouseOver() event.

Remember that the URLs for JavaScript components are relative to the original URL of your page. If you find a tag that says <script src="js/popup.js"> and that’s in a page at http://www.example.com/myapp/app.jsp, then the URL for the popup.js script is http://www.example.com/myapp/js/popup.js.

2.1. Problem

To do better root cause analysis, you don’t just want to see the requests that come and go. You want to trace those requests back to the JavaScript that initiated them.

2.2. Solution

Firebug provides another useful feature for observing AJAX requests. In Firebug, click on the Console tab. There you should see one or more HTTP requests, each with a corresponding JavaScript line number, as shown in Figure 1. Click on this line number to reveal the JavaScript that initiated the AJAX request, alongside a full-fledged JavaScript debugger.

Figure 1. Tracing the AJAX call back to Javascript


2.3. Discussion

There are several things to notice in Figure 1. The word GET tells you that it’s a GET request instead of, say, POST. The URL that was fetched is right there next to GET. The request was triggered by a method in file main.js on line 250. That’s important to know because you won’t be able to look at the HTML of the web page and see the JavaScript. You’ll have to fetch the main.js JavaScript file and look at that, instead. It is also useful to click on the Headers tab so that you see whether or not any cookies were sent with the request.

Other  
 
Top 10
Review : Sigma 24mm f/1.4 DG HSM Art
Review : Canon EF11-24mm f/4L USM
Review : Creative Sound Blaster Roar 2
Review : Philips Fidelio M2L
Review : Alienware 17 - Dell's Alienware laptops
Review Smartwatch : Wellograph
Review : Xiaomi Redmi 2
Extending LINQ to Objects : Writing a Single Element Operator (part 2) - Building the RandomElement Operator
Extending LINQ to Objects : Writing a Single Element Operator (part 1) - Building Our Own Last Operator
3 Tips for Maintaining Your Cell Phone Battery (part 2) - Discharge Smart, Use Smart
REVIEW
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
VIDEO TUTORIAL
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
Popular Tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8