2011年5月12日 星期四

XMLHttpRequest 的應用:灌垃圾資料給釣魚網站

今天有一個許久未聯絡的同學忽然間丟MSN水球給我,第一時間的直覺就是詐騙,要買遊戲儲值卡的。果不其然,聊不到兩句就開始問我有沒有空,可不可以幫他買卡等等,我用幾個爛藉口推掉之後,他留下一個超連結就離線了。

點擊超連結,果然出現一個很像 Windows Live 登入的網頁,做得十分粗糙,連 Title 都沒有改,還是“Untitled Document”,唉~~要騙人帳號也搞像一點嘛!於是我就拿出了我之前寫的小程式,一個 html 檔案,填入了一些資料,開始向那個釣魚網站灌垃圾資料

這隻程式很簡單,就是使用 XMLHttpRequest 對釣魚網站 POST 假資料,假資料當然是使用亂數產生,主要的部份是這樣子的:

//產生一個XMLHttpRequest物件
function initRequest()
{
  var A=null;
  try
  {
    A = new ActiveXObject("Msxml2.XMLHTTP")
  }
  catch(e)
  {
    try
    {
      A = new ActiveXObject("Microsoft.XMLHTTP")
    }
    catch(oc)
    {
      A = null
    }
  }
  if (!A && typeof XMLHttpRequest != "undefined")
  {
    A = new XMLHttpRequest()
  }
  if (!A && window.createRequest)
  {
    try
    {
      A = window.createRequest();
    } catch (e)
    {
      A = null;
    }
  }
  return A
}
//取亂數帳號密碼,塞入釣魚網頁
function DoBurst()
{
  try
  {
    // 宣告變數
    username = "";
    password = "";
    // 取得輸入資料
    actionUrl = document.getElementById("actionUrl").value;
    usernameId = document.getElementById("usernameId").value;
    passwordId = document.getElementById("passwordId").value;
     // 取亂數拼湊假的帳號跟密碼
    c = Math.floor(Math.random() * 8) + 5;
    for (n=0; n < c; n++)
    {
      username += charSet.charAt(Math.floor(Math.random() * charSet.length));
    }
    username += document.getElementById("usernameSuffix").value;
    c = Math.floor(Math.random() * 8) + 5;
    for (n=0; n < c; n++)
    {
      password += charSet.charAt(Math.floor(Math.random() * charSet.length));
    }

    // submit
    url = actionUrl + "?" + usernameId + "=" + username + "&" + passwordId

+ "=" + password;

 

    if (typeof XmlHttp == "undefined")
    {
      XmlHttp = initRequest();
    }

 

    XmlHttp.open("POST", url, true);
    XmlHttp.onreadystatechange = ShowResult;
    XmlHttp.send("");
    // 計數器累加,並更新畫面
    i++;
    document.getElementById("sendTimes").innerText = i;
  }
  catch(e)
  {
  }
}

然後使用 interval 定時重複執行,就這樣簡單!