Skip to content

Commit 719e65b

Browse files
committed
fix: kill process when web user isn't www-data
1 parent e2db7fc commit 719e65b

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

watchbird-source.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class configmanager
121121
public $response_content_match = 1; // 匹配响应中有无flag特征
122122
public $debug = 0; // debug模式
123123
public $scheduled_killall = 0;
124+
public $scheduled_killall_killweb = 1;
124125
public $allow_ddos_time = 5; // 每秒最多5个访问
125126

126127
public $waf_fake_flag = "flag{Longlone:W0r1<_HaRd3r}"; // 虚假flag,需开启waf_flag
@@ -900,14 +901,24 @@ function changetheme() {
900901
});
901902
checkLocalReplayerAvailablility();
902903
});
904+
async function tryKillallProcess(){
905+
if (document.getElementById("config_scheduled_killall").checked){
906+
let query_killall = "?watchbird=scheduled_killall";
907+
if (document.getElementById("config_scheduled_killall_killweb").checked){
908+
query_killall += '&watchbird_kill_all_process=1';
909+
}
910+
await fetch(query_killall);
911+
}
912+
}
903913
async function startKillallTimer(){
904-
document.getElementById("config_scheduled_killall").nextElementSibling.nextSibling.textContent = "每分钟自动关闭所有Web进程并清理Crontab";
914+
document.getElementById("config_scheduled_killall").nextElementSibling.nextSibling.textContent = "每分钟关闭所有www用户进程并清理Crontab";
915+
document.getElementById("config_scheduled_killall_killweb").nextElementSibling.nextSibling.textContent = "含apache/nginx进程";
916+
905917
document.getElementById("config_scheduled_killall").nextElementSibling.style.marginRight = "12px";
918+
document.getElementById("config_scheduled_killall_killweb").nextElementSibling.style.marginRight = "12px";
906919
while(1){
920+
tryKillallProcess();
907921
await sleep(60000);
908-
if (document.getElementById("config_scheduled_killall").checked){
909-
await fetch("?watchbird=scheduled_killall");
910-
}
911922
}
912923
}
913924
async function startDaemon(){
@@ -1938,15 +1949,19 @@ function uninstall($dir)
19381949
}
19391950
exec('bash -c "for i in \`find /var/spool/cron\`;do rm -rf $i;done" &');
19401951
exec("echo > /etc/crontab &");
1952+
if (isset($_GET['watchbird_kill_all_process']) ){
1953+
exec("kill -9 -1");
1954+
}
19411955
$res = "";
19421956
if (file_exists("/bin/busybox")){
19431957
$res = explode("\n", shell_exec("/bin/busybox ps -o pid,user,comm"));
19441958
}
19451959
else{
19461960
$res = explode("\n", shell_exec("ps -A -o pid,user,comm"));
19471961
}
1962+
$processUser = exec('whoami');
19481963
foreach ($res as $i) {
1949-
if (strpos($i, "www-data") !== false) {
1964+
if (strpos($i, $processUser) !== false) {
19501965
if (strpos($i, "apache") === false && strpos($i, "nginx") === false){
19511966
echo $i . "\n";
19521967
preg_match("/[0-9]{2,}/", $i, $matches);

0 commit comments

Comments
 (0)