From 13c1d09385a7360c0068bb08cd1d7c01e18bf5cb Mon Sep 17 00:00:00 2001 From: aixiao Date: Thu, 8 Dec 2022 15:49:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9build.sh=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- build.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ conf.c | 1 + rhost.conf | 4 ++-- 4 files changed, 70 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2403deb..d50826c 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,9 @@ IPTC_CFLAGS += -DHAVE_CONFIG_H -I./libiptc -D_LARGEFILE_SOURCE=1 -D_LARGE_FILES OBG = rhost +CFLAGS += -Os -g -Wall -DCRON_USE_LOCAL_TIME -DCRON_TEST_MALLOC CLAMSCAN_CFLAGS += -Wall -Os -DHAVE_CONFIG_H -I./clamscan -I./clamscan/shared -I./clamscan/libclamav -I./clamscan/libclamunrar_iface -I/usr/include/json-c -Wdate-time -D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 SHARED_CFLAGS += -Wall -Os -DHAVE_CONFIG_H -I./clamscan -I./clamscan/shared -I./clamscan/libclamav -I./clamscan/libclamunrar_iface -I/usr/include/json-c -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -CFLAGS += -Os -g -Wall -DCRON_USE_LOCAL_TIME -DCRON_TEST_MALLOC freshclam_CFLAGS += -g -O2 -Wall -DHAVE_CONFIG_H -I./clamscan -I./clamscan/shared -I./clamscan/libclamav -I./clamscan/libclamunrar_iface -I/usr/include/json-c -Wdate-time -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 libfreshclam_CFLAGS += -g -Os -Wall -DHAVE_CONFIG_H -I./clamscan -I./clamscan/freshclam -I./clamscan/shared -I./clamscan/libclamav -I./clamscan/libclamunrar_iface -I/usr/include/json-c -Wdate-time -D_FORTIFY_SOURCE=2 freshclam_LIB += clamscan/freshclam/freshclam.o clamscan/freshclam/notify.o clamscan/freshclam/execute.o clamscan/freshclam/libfreshclam.o clamscan/freshclam/libfreshclam_internal.o clamscan/freshclam/dns.o ./clamscan/shared/libshared.a -lssl -lcrypto -lclamav -lresolv -lcurl -lz -ljson-c -lltdl -lpthread -lm diff --git a/build.sh b/build.sh index b735471..2815de8 100644 --- a/build.sh +++ b/build.sh @@ -106,8 +106,74 @@ main() tmux new-session -s main -d; tmux send -t main 'killall rhost; ./rhost -d' ENTER tmux at -t main +} + +binary() +{ + cd ~ + + + if ! test -f RHOST; then + mkdir -p RHOST + fi + + if test "$OS" = "centos"; then + wget -T 30 https://git.aixiao.me/attachments/18147490-6d10-4407-8537-03b3c1eeb357 -O RHOST/rhost + wget -T 30 https://git.aixiao.me/attachments/e6309b7b-0e98-4a11-8fc1-7c624649f3b8 -O RHOST/rhost.conf + wget -T 30 https://git.aixiao.me/attachments/1ddf1579-b660-4d91-821d-82fe5f0ec8c0 -O RHOST/freshclam.conf + + if test -f /etc/cron.d/clamav-update; then # 去除自动更新病毒库 + mv /etc/cron.d/clamav-update /root + fi + + if test -f /etc/freshclam.conf; then # 更改病毒库镜像 + sed -i "s/DatabaseMirror .*/DatabaseMirror clamavdb.c3sl.ufpr.br/g" /etc/freshclam.conf + fi + + + if test -f /etc/clamav/freshclam.conf; then + sed -i "s/DatabaseMirror .*/DatabaseMirror clamavdb.c3sl.ufpr.br/g" /etc/clamav/freshclam.conf + else + : + fi + + chmod +x RHOST/rhost + + cd ~/RHOST/ + tmux new-session -s main -d; tmux send -t main 'killall rhost; ./rhost -d' ENTER + tmux at -t main + + elif test "$OS" = "debian"; then + wget -T 30 https://git.aixiao.me/attachments/40a3317f-48eb-4465-9ae3-fc46251c5bcc -O RHOST/rhost + wget -T 30 https://git.aixiao.me/attachments/e6309b7b-0e98-4a11-8fc1-7c624649f3b8 -O RHOST/rhost.conf + wget -T 30 https://git.aixiao.me/attachments/1ddf1579-b660-4d91-821d-82fe5f0ec8c0 -O RHOST/freshclam.conf + + chmod +x RHOST/rhost + + + condition=$(awk -v num1=${OS_VER} -v num2=11 'BEGIN{print(num1>num2)?"0":"1"}') + if test "$condition" = "1"; then # Debian系统版本小于11时, libclamav库版本低时 + cd clamscan/libclamav/; bash build.sh + cp /usr/lib/x86_64-linux-gnu/libclamav.so.9.0.5 /usr/lib/x86_64-linux-gnu/libclamav.so.9.0.5.backup + cp .libs/libclamav.so.9.0.5 /usr/lib/x86_64-linux-gnu/ + cd ../../ + fi + + cd ~/RHOST/ + tmux new-session -s main -d; tmux send -t main 'killall rhost; ./rhost -d' ENTER + tmux at -t main + fi + + + + } check_os pkg_install +if test "${1}" = "binary"; then + binary + + exit 0 +fi main diff --git a/conf.c b/conf.c index 42f9935..a361c3b 100644 --- a/conf.c +++ b/conf.c @@ -344,6 +344,7 @@ void split_string(char string[], char delims[], char (*whitelist_ip)[WHITELIST_I { int i = 0; char *result = NULL; + result = strtok(string, delims); while (result != NULL) { diff --git a/rhost.conf b/rhost.conf index 4a274f3..8a1a581 100644 --- a/rhost.conf +++ b/rhost.conf @@ -13,8 +13,8 @@ global { REFUSE_NUMBER = 3; // 拒绝攻击次数 CLAMAV = 1; // clamav 是否扫描病毒(测试阶段)(1开启,非1关闭) - CLAMAV_ARG = "-r / --exclude-dir=^/sys|^/dev|^/proc|^/opt/infected|^/root|^/home|^/mnt --move=/opt/infected --max-filesize 1024M -l clamscan.log"; - CLAMAV_TIME = "* 50 13 * * *"; // clamav 扫描时间(Cron格式, 秒 分 时 天 月 周) + CLAMAV_ARG = "-r / --exclude-dir=^/sys|^/dev|^/proc|^/opt/infected|^/root|^/home|^/mnt --move=/opt/infected --max-filesize 1024M -l clamscan.log"; + CLAMAV_TIME = "* 55 14 * * *"; // clamav 扫描时间(Cron格式, 秒 分 时 天 月 周) IPV4_RESTRICTION = 1; // 是否启用IP白名单(1开启,非1关闭)