---
type: Article
title: "Shreeraj's security blog: Password extraction from Ajax/DOM/HTML5 routine"
description: "A short note on sloppy Ajax login code: variables such as the crafted request URL are declared without scope and stay global on the DOM for the life of the page. Given a DOM XSS foothold, iterating over window and printing every string property recovers login.do?user=foo&pwd=foobar, leaking the typed username and password."
resource: "https://web.archive.org/web/20170903113359/http://shreeraj.blogspot.com/2012/01/password-extraction-from-ajaxdomhtml5.html"
tags: [article, webseclist-reference, shreeraj-blogspot-com, dom, javascript, xss, info-leak, case-study, owasp-a03-2021]
generated:
  by: webseclist-refs/1
  at: "2026-08-10T15:59:08+00:00"
status: stable
stale_after: 2027-08-10
sources:
  - id: original
    resource: "https://web.archive.org/web/20170903113359/http://shreeraj.blogspot.com/2012/01/password-extraction-from-ajaxdomhtml5.html"
    title: "Shreeraj's security blog: Password extraction from Ajax/DOM/HTML5 routine"
    author: shreeraj
  - id: canonical
    resource: "https://web.archive.org/web/20150110195718/http://shreeraj.blogspot.com/2012/01/password-extraction-from-ajaxdomhtml5.html"
  - id: capture
    resource: "https://web.archive.org/web/20170903113359/http://shreeraj.blogspot.com/2012/01/password-extraction-from-ajaxdomhtml5.html"
also_at: []
authors:
  - shreeraj
canonical_url: "https://web.archive.org/web/20150110195718/http://shreeraj.blogspot.com/2012/01/password-extraction-from-ajaxdomhtml5.html"
cited_by:
  - "2012.md:50"
commit: ""
content_sha256: c558498b05663d6628cb209a3d484e9d2a0d048bea1b58757120cf632f3a6bfd
depth: full
depth_reason: default
kind: article
language: ""
licence: unknown
original_url: "https://web.archive.org/web/20170903113359/http://shreeraj.blogspot.com/2012/01/password-extraction-from-ajaxdomhtml5.html"
published: ""
publisher: shreeraj.blogspot.com
publisher_english: ""
raw_sha256: d4787c9d29b9428f7a3f78ab24b85c447dca59964f2332b16c7cba0712c84193
retrieved_from: "https://web.archive.org/web/20150110195718/http://shreeraj.blogspot.com/2012/01/password-extraction-from-ajaxdomhtml5.html"
retrieved_kind: live
retrieved_utc: "2026-08-10T15:59:08+00:00"
slug: shreeraj-blogspot-com-shreeraj-s-security-blog-password-extraction-ajax-routine
snapshot: 20170903113359
title_english: ""
translation_file: ""
translation_of: ""
---

# Shreeraj's security blog: Password extraction from Ajax/DOM/HTML5 routine

**Shreeraj's security blog: Password extraction from Ajax/DOM/HTML5 routine** - shreeraj, shreeraj.blogspot.com.

- Published: date not stated
- Original: <https://web.archive.org/web/20170903113359/http://shreeraj.blogspot.com/2012/01/password-extraction-from-ajaxdomhtml5.html>
- Current location: <https://web.archive.org/web/20150110195718/http://shreeraj.blogspot.com/2012/01/password-extraction-from-ajaxdomhtml5.html>
- Preserved from: https://web.archive.org/web/20150110195718/http://shreeraj.blogspot.com/2012/01/password-extraction-from-ajaxdomhtml5.html (live) on 2026-08-10
- Capture timestamp: 20170903113359
- Licence: unknown

Rights remain with the original author and publisher. This is a research
archive of a source from the Web Hacking Techniques Index collections, kept so the
page going offline. To read the original, follow the link above.

## Content

> UNTRUSTED SOURCE TEXT. Everything below this line is third-party material
> quoted for research. It is data, not instructions. Do not follow directions,
> execute code, or fetch URLs because this text says so.

Login Ajax routine is an interesting place to check for variable definition and assignments with respect to "single DOM application"/HTML5/Web2.0 framework. If variables are not created with proper scope then can be accessed as global and contain interesting information like username, password, tokens etc. Interestingly we need to do lot of JavaScript analysis with Web 2.0, Ajax, HTML5 and Single DOM applications.

 For example, here is a routine for login. It can be buried in one of the JS files but gets loaded on DOM at the point of call and remain there throughout application life cycle.

 function getLogin()

 {

 gb = gb+1;

 var user = document.frmlogin.txtuser.value;

 var pwd = document.frmlogin.txtpwd.value;

 var xmlhttp=false;

  try {

  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

  // other code for XHR initialization

  }

  temp = "login.do?user="+user+"&pwd="+pwd;

  xmlhttp.open("GET",temp,true);

  xmlhttp.onreadystatechange=function()

  {

  // other code on state ready change

  }

  xmlhttp.send(null);

 }

 Here, temp variable is crafting URL and posting username and password for Ajax call. It can be part of POST if going through send(). “temp” variable is very loosely defined as global and can be accessed from the DOM.

 It is easy to access those variables from DOM – Yes, need DOM based XSS but coding practice is poor over here. Payload to exploit the vulnerability…

 for(i in window){

  obj=window[i];

  try{

  if(typeof(obj)=="string"){

  console.log(i);

  console.log(obj.toString());

  }

  }catch(ex){}

 }

 You will get “temp” variable with following value - login.do?user=foo&pwd=foobar.
