JavaScript
  Home arrow JavaScript arrow Page 2 - Programmatic GET Requests with JavaScript:...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Programmatic GET Requests with JavaScript: Simple Way to Hack Your Site
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 25
    2005-07-13

    Table of Contents:
  • Programmatic GET Requests with JavaScript: Simple Way to Hack Your Site
  • A Quick Look At The XMLHttpRequest Object
  • When High Levels of Traffic Are Dangerous
  • Automated GET requests
  • Massive HTTP requests: Using a Timer

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Programmatic GET Requests with JavaScript: Simple Way to Hack Your Site - A Quick Look At The XMLHttpRequest Object


    (Page 2 of 5 )

    A good place to start explaining how http requests are really used to attack a website is having a quick look at the XMLHttpRequest object. Since it’s not the primary concern of the article, I’ll give only brief reference about its methods and properties. There is plenty of information on the Web, just in case you’re interested on learning more on it. Otherwise, if you’re already familiar working with this object, feel free to skip this section and jump straight to the next one.

    Essentially, the XMLHttpRequest object allows you to make requests to an http server, and get a response from it, without page reloads. All the requests can be handled in the background, in a transparent way. This means that the client-server interaction might be carried out silently, without notifying the user about what’s happening behind the scenes.

    As any standard object, the XMLHttpRequest object exposes several useful methods, which may be resumed in the below list:

    • open("method","URL",async,"uname","pswd"): opens a http socket connection to the specified URL, using the given request method (GET/POST/PUT). Usually, the third parameter “async” is set to true, in order to make asynchronous requests. Basically, when an asynchronous request is made, the script won’t wait for the response from the server, and continue its execution after the “send()” method is invoked. Otherwise, the script will continue executing only after a server response is received. The other parameters are optional, in situations where "username” and “password” parameters are required for accessing documents.
    • send(string): sends the specified request. Commonly, in POST requests, the name/value pairs are passed as arguments to this method.
    • setRequestHeader("header name","header value"): allows a person to specify the name/value pair of the header to be send to the server, for instance: "Content-Type:text/html; charset=iso-8859-1".
    • getResponseHeader("headername"): returns the value of the given http header.
    • getAllResponseHeaders(): returns a string containing the complete set of http headers.
    • abort(): halts the request.

    Aside from the methods described above, the object presents the following properties:

    • readyState: returns the state of the object, according to the request’s progress. Its possible values are: 0 = uninitialized, 1 = loading, 2 = loaded, 3 = interactive, 4 = complete.
    • responseText: returns the server response as a string. This property is useful to get the content of a web page, when used in conjunction with the GET method.
    • status: returns the request status as a numeric value. For instance, "200" for "OK".
    • statusText: as the name suggests, returns the request status as a string. For instance: "Not Found" for a 404 HTTP error.
    • responseXML: returns the server response as XML.
    • onreadystatechange: the proper event handler, which is triggered at every state change. On asynchronous requests, it’s useful for controlling the logic of the program, in accordance to the request status.

    Now that you’ve learned the basics of the XMLHttpRequest object, these boring details are out of your way. You can turn your attention to the next few lines, where I’ll explain trough a simple example, how a potential attacker can use the object’s capabilities to inflict damage to unwarned websites using Denial of Service attacks (DoS).

    More JavaScript Articles
    More By Alejandro Gervasio


       · The first part of the article is intended to show how automated JavaScript-based GET...
       · Hifirst of all thank you for your great article, it's so nice, I didn't know...
       · Thanks for the comments on the article. Pointing out to your question, the answer is...
       · Hey Alejandro, how're ya?you thanking me for the comment, come on man, thank...
       · Hello bijan,Glad to hear from you again. Despite the fact that writing a comment...
       · Hi.As usual I congratulate you for the goodarticle.I read in MDC:As a...
       · Hello Wisher,Thank you for the kind comments on my AJAX article. I’m glad you...
       · Hi.Thanks so much for the useful and readyreplay.I've just noticed the...
       · Hi Wisher,I'm glad to know my post was useful to you.Best Regards.
     

    JAVASCRIPT ARTICLES

    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT