From 0d8f4d2ff94a8008febafe6a649060c651925dd1 Mon Sep 17 00:00:00 2001 From: zhaohui Date: Thu, 8 Jan 2026 15:06:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E9=99=90=E5=88=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/send_user.php | 11 ++++++-- crontab/crosscheck_auto_shell_v2.php | 55 ++++++++++++++++++++++++++++++------ 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/api/send_user.php b/api/send_user.php index b680203..e3ee3cb 100644 --- a/api/send_user.php +++ b/api/send_user.php @@ -14,15 +14,22 @@ $need_login_file = __DIR__ . '/../cookie_file/needlogin_'.$user.'.txt'; // 需 $done_login_file = __DIR__ . '/../cookie_file/'.$user.'.txt'; // 已登录的账号文件 $ban_file = __DIR__ . '/../cookie_file/ban_'.$user.'.txt'; // 被禁用的账号文件 $fail_login_file = __DIR__ . '/../cookie_file/fail_'.$user.'.txt'; // 错误登录的账号文件 +$ban_server_file = __DIR__ . '/../cookie_file/server_ban.txt'; // 被禁用服务器的账号文件 // 检测是否被禁用 if(file_exists($ban_file)){ exit('ban'); } -// 检测是否错误登录超过5次 + +// 检测是否被禁用服务器 +if(file_exists($ban_server_file)){ + exit('server_ban'); +} + +// 检测是否错误登录超过15次 if(file_exists($fail_login_file)){ $fail_login_times = file_get_contents($fail_login_file); - if($fail_login_times+0 >= 5){ + if($fail_login_times+0 >= 15){ exit('fail'); } } diff --git a/crontab/crosscheck_auto_shell_v2.php b/crontab/crosscheck_auto_shell_v2.php index db31a2c..4bfacba 100644 --- a/crontab/crosscheck_auto_shell_v2.php +++ b/crontab/crosscheck_auto_shell_v2.php @@ -25,8 +25,19 @@ try{ foreach($list as $v){ $need_login_file = $dir.$v; - $fail_login_file = $dir.'fail_'.$v; - $ban_file = $dir.'ban_'.$v; + + // 获得文件内容 + $param = file_get_contents($need_login_file); + + // 获得crosscheck账号密码 + $arr_user_info = explode("\n", $param); + $user = ltrim($arr_user_info[0]); + $passwd = ltrim($arr_user_info[1]); + $tenant = ltrim($arr_user_info[2]); + + $fail_login_file = $dir.'fail_'.$user.'.txt'; + $ban_file = $dir.'ban_'.$user.'.txt'; + $ban_server_file = $dir.'server_ban.txt'; // 检测是否被禁用 if(file_exists($ban_file)){ @@ -42,14 +53,28 @@ try{ continue; } } - // 获得文件内容 - $param = file_get_contents($need_login_file); - // 获得crosscheck账号密码 - $arr_user_info = explode("\n", $param); - $user = ltrim($arr_user_info[0]); - $passwd = ltrim($arr_user_info[1]); - $tenant = ltrim($arr_user_info[2]); + // 检测是否被禁用服务器 + if(file_exists($ban_server_file)){ + $ban_server_limit_times = 3; + // 获得文件的创建时间 + $create_time = filemtime($ban_server_file); + // 检查是否超过1小时 + if(time() - $create_time > 60*60){ + // 重置禁用服务器文件 + unlink($ban_server_file); + file_put_contents($ban_server_file, ($ban_server_limit_times-1) . PHP_EOL); + // 记录日志 + $str_log = date('Y-m-d H:i:s')."|重置禁用服务器文件server_ban.txt|".$user; + file_put_contents($log_file, $str_log . PHP_EOL, FILE_APPEND); + } + + $ban_server_info = file_get_contents($ban_server_file); + $arr_ban_server_info = explode("\n", $ban_server_info); + if($arr_ban_server_info[0]+0 >= $ban_server_limit_times){ + continue; + } + } // 账号cookie文件路径 $cookie_path = __DIR__ . '/../cookie_file/'.$user.'.txt'; @@ -101,6 +126,17 @@ try{ // 记录日志 $str_log = date('Y-m-d H:i:s')."|登录失败|第".$fail_info."次|".$user."|运行时间:".$run_time_str; file_put_contents($log_file, $str_log . PHP_EOL, FILE_APPEND); + + // 服务器被限制访问 + if(strpos($console_str, '当前页面URL') == false){ + // 写入被禁用服务器文件 + $ban_server_info = @$arr_ban_server_info[0]+1; + file_put_contents($ban_server_file, $ban_server_info . PHP_EOL); + + // 记录日志 + $str_log = date('Y-m-d H:i:s')."|服务器被禁用|".$user."|运行时间:".$run_time_str; + file_put_contents($log_file, $str_log . PHP_EOL, FILE_APPEND); + } }else{ // 记录日志 @@ -110,6 +146,7 @@ try{ unlink($need_login_file); @unlink($fail_login_file); @unlink($ban_file); + @unlink($ban_server_file); } system("pkill -9 chrome"); $sec = rand(100,245);