支持 Debian 12
This commit is contained in:
parent
a8fb2a8dd3
commit
bc29a0b1a9
4
Makefile
4
Makefile
@ -36,8 +36,9 @@ LIBCOMMON__CFLAGS += -DHAVE_CONFIG_H -I./clamav/common -I./clamav/libclamav -I./
|
||||
LIBCOMMON_LIB += ./clamav/common/cert_util.c.o ./clamav/common/actions.c.o ./clamav/common/clamdcom.c.o ./clamav/common/getopt.c.o ./clamav/common/hostid.c.o ./clamav/common/idmef_logging.c.o ./clamav/common/misc.c.o ./clamav/common/optparser.c.o ./clamav/common/output.c.o ./clamav/common/tar.c.o ./clamav/common/linux/cert_util_linux.c.o
|
||||
|
||||
|
||||
all: libclamav_rust libclamav rhost
|
||||
|
||||
all: conf.o rhost.o libiptc.o ccronexpr.o
|
||||
rhost: conf.o rhost.o libiptc.o ccronexpr.o
|
||||
$(CC) $(ip2region_CFLAGS) ip2region/ip2region.c
|
||||
$(CC) $(ip2region_CFLAGS) ip2region/xdb_searcher.c
|
||||
$(CC) $(cJSON_CFLAGS) cJSON/cJSON.c
|
||||
@ -53,7 +54,6 @@ all: conf.o rhost.o libiptc.o ccronexpr.o
|
||||
|
||||
chmod +x $(OBG)
|
||||
|
||||
|
||||
libclamav_rust:
|
||||
cd clamav/libclamav_rust && $(CMAKE) -E env CARGO_CMD=build CARGO_TARGET_DIR=./ MAINTAINER_MODE=OFF RUSTFLAGS="" \
|
||||
cargo build --target $(ARCH) --target-dir ./
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
```text
|
||||
适用系统:
|
||||
Debian 11
|
||||
Debian 11、12
|
||||
Centos 7
|
||||
支持系统病毒扫描
|
||||
支持一次运行检测、后台运行检测
|
||||
@ -52,8 +52,6 @@ cd /root
|
||||
git clone https://git.aixiao.me/aixiao/denyhosts
|
||||
cd denyhosts
|
||||
make clean
|
||||
make libclamav_rust
|
||||
make libclamav
|
||||
make all
|
||||
或
|
||||
bash build.sh
|
||||
|
46
rhost.c
46
rhost.c
@ -468,6 +468,36 @@ char *_time()
|
||||
return strdup(temp);
|
||||
}
|
||||
|
||||
int system_version() {
|
||||
FILE *fp = fopen("/etc/debian_version", "r");
|
||||
|
||||
if (fp == NULL) {
|
||||
perror("Failed to open file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
char buff[256];
|
||||
if (fgets(buff, sizeof(buff), fp) == NULL) {
|
||||
fclose(fp);
|
||||
perror("Failed to read file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
size_t len = strlen(buff);
|
||||
if (len <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Remove trailing newline character, if present
|
||||
if (buff[len - 1] == '\n') {
|
||||
buff[len - 1] = '\0';
|
||||
}
|
||||
|
||||
return atoi(buff);
|
||||
}
|
||||
|
||||
// 封禁非法IP
|
||||
int rule(conf * conf)
|
||||
{
|
||||
@ -500,6 +530,16 @@ int rule(conf * conf)
|
||||
|
||||
|
||||
if (DEBISN_SYSTEM == check_system()) // Debian 系统规则
|
||||
{
|
||||
if (system_version() >= 12)
|
||||
{
|
||||
if ((fp = popen(GE_12, "r")) == NULL)
|
||||
{
|
||||
perror("GE_12");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tp->tm_mday >= 10)
|
||||
{
|
||||
@ -508,6 +548,7 @@ int rule(conf * conf)
|
||||
perror("GE_10");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -518,6 +559,7 @@ int rule(conf * conf)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (CENTOS_SYSTEM == check_system()) // Centos 7系统规则
|
||||
{
|
||||
if (tp->tm_mday >= 10)
|
||||
@ -936,8 +978,8 @@ static char help_information(void)
|
||||
"Options:",
|
||||
" -d : Background running",
|
||||
" -? -h --help : help information",
|
||||
" The configuration file needs to be in the same directory as the executable file!",
|
||||
" 配置文件需要与可执行文件位于同一目录中!",
|
||||
" The configuration file needs to be in the same directory as the executable file!(default rhost.conf)",
|
||||
" 配置文件需要与可执行文件位于同一目录中!(默认 rhost.conf)",
|
||||
"",
|
||||
"",
|
||||
0
|
||||
|
2
rhost.h
2
rhost.h
@ -107,7 +107,9 @@ void cron_free(void* p)
|
||||
#define BUILD(fmt...) do { fprintf(stderr,"%s %s ",__DATE__,__TIME__); fprintf(stderr, ##fmt); } while(0)
|
||||
|
||||
#define AWK " | awk -v num=%d '{a[$1]+=1;} END {for(i in a){if (a[i] >= num) {print i;}}}' "
|
||||
|
||||
#define GE_10 "grep -E \"^$(LC_ALL=\"C\" date \"+%h\").$(LC_ALL=\"C\" date \"+%d\")\" /var/log/auth.log | grep failure | grep rhost"
|
||||
#define GE_12 "grep -E \"^$(LC_ALL=\"C\" date +\"%Y-%m-%d\")\" /var/log/auth.log | grep failure | grep rhost"
|
||||
#define LE_10 "grep -E \"^$(LC_ALL=\"C\" date \"+%h\")..$(LC_ALL=\"C\" date | awk '{print $3}')\" /var/log/auth.log | grep failure | grep rhost"
|
||||
|
||||
#define CENTOS_GE_10 "grep -E \"^$(LC_ALL=\"C\" date \"+%h\").$(LC_ALL=\"C\" date \"+%d\")\" /var/log/secure | grep failure | grep rhost"
|
||||
|
Loading…
Reference in New Issue
Block a user