From 251f58d5133b20a76f0b2d5a3c61bcce20b20463 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Sat, 29 Mar 2025 17:06:49 +0100 Subject: [PATCH] banIP: update 1.5.5-2 * fixed a JSON reporting issue (when the map and NFT counters are disabled) * optimized the getfetch function call within the reporting function * removed the stale IPv6 links in the becyber feed * cosmetics Signed-off-by: Dirk Brenken --- net/banip/Makefile | 2 +- net/banip/files/banip-functions.sh | 11 ++++++----- net/banip/files/banip.feeds | 2 -- net/banip/files/banip.tpl | 7 +++---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/net/banip/Makefile b/net/banip/Makefile index 76110a391..db132ac66 100644 --- a/net/banip/Makefile +++ b/net/banip/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=banip PKG_VERSION:=1.5.5 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_LICENSE:=GPL-3.0-or-later PKG_MAINTAINER:=Dirk Brenken diff --git a/net/banip/files/banip-functions.sh b/net/banip/files/banip-functions.sh index 6694e60a7..e9d16d1d1 100644 --- a/net/banip/files/banip-functions.sh +++ b/net/banip/files/banip-functions.sh @@ -324,7 +324,7 @@ f_actual() { # get fetch utility # f_getfetch() { - local util utils insecure + local util utils insecure update="0" ban_fetchcmd="$(command -v "${ban_fetchcmd}")" if { [ "${ban_autodetect}" = "1" ] && [ -z "${ban_fetchcmd}" ]; } || [ ! -x "${ban_fetchcmd}" ]; then @@ -340,6 +340,7 @@ f_getfetch() { ;; esac if [ -x "$(command -v "${util}")" ]; then + update="1" ban_fetchcmd="$(command -v "${util}")" uci_set banip global ban_fetchcmd "${util}" uci_commit "banip" @@ -373,7 +374,7 @@ f_getfetch() { ;; esac - f_log "debug" "f_getfetch ::: auto: ${ban_autodetect}, cmd: ${ban_fetchcmd:-"-"}, fetch_parm: ${ban_fetchparm:-"-"}, rdap_parm: ${ban_rdapparm:-"-"}, etag_parm: ${ban_etagparm:-"-"}, , geo_parm: ${ban_geoparm:-"-"}" + f_log "debug" "f_getfetch ::: auto/update: ${ban_autodetect}/${update}, cmd: ${ban_fetchcmd:-"-"}" } # get wan interfaces @@ -1277,7 +1278,7 @@ f_genstatus() { end_time="$(date "+%s")" duration="$(((end_time - ban_starttime) / 60))m $(((end_time - ban_starttime) % 60))s" fi - runtime="$(date "+%Y-%m-%d %H:%M:%S"), mode: ${ban_action:-"-"}, duration: ${duration:-"-"}, memory: ${mem_free} MB available, ${mem_max} MB max. used" + runtime="$(date "+%Y-%m-%d %H:%M:%S"), duration: ${duration:-"-"}, mode: ${ban_action:-"-"}, memory: ${mem_free} MB available, ${mem_max} MB max. used" fi [ -s "${ban_customfeedfile}" ] && custom_feed="1" [ "${ban_splitsize:-"0"}" -gt "0" ] && split="1" @@ -1417,7 +1418,6 @@ f_report() { local quantity chunk map_jsn chain set_elements set_json sum_setelements sum_synflood sum_udpflood sum_icmpflood sum_ctinvalid sum_tcpinvalid output="${1}" f_conf - f_getfetch f_mkdir "${ban_reportdir}" report_jsn="${ban_reportdir}/ban_report.jsn" report_txt="${ban_reportdir}/ban_report.txt" @@ -1577,6 +1577,7 @@ f_report() { # if [ "${ban_nftcount}" = "1" ] && [ "${ban_map}" = "1" ] && [ "${output}" = "json" ] && [ -s "${report_jsn}" ]; then cnt="1" + f_getfetch json_init if json_load_file "${ban_rtfile}" >/dev/null 2>&1; then json_get_values jsnval "active_uplink" >/dev/null 2>&1 @@ -1729,7 +1730,7 @@ f_report() { printf "[%s]]\n" "${jsn}" else jsn="$("${ban_catcmd}" ${report_jsn})" - printf "%s\n" "${jsn}" + printf "[%s]\n" "${jsn}" fi ;; "mail") diff --git a/net/banip/files/banip.feeds b/net/banip/files/banip.feeds index 203ebd903..406a364bd 100644 --- a/net/banip/files/banip.feeds +++ b/net/banip/files/banip.feeds @@ -16,9 +16,7 @@ }, "becyber":{ "url_4": "https://raw.githubusercontent.com/duggytuxy/malicious_ip_addresses/main/botnets_zombies_scanner_spam_ips.txt", - "url_6": "https://raw.githubusercontent.com/duggytuxy/malicious_ip_addresses/main/botnets_zombies_scanner_spam_ips_ipv6.txt", "rule_4": "/^127\\./{next}/^(([1-9][0-9]{0,2}\\.){1}([0-9]{1,3}\\.){2}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])(\\/(1?[0-9]|2?[0-9]|3?[0-2]))?)$/{printf \"%s,\\n\",$1}", - "rule_6": "/^(([0-9A-f]{0,4}:){1,7}[0-9A-f]{0,4}:?(\\/(1?[0-2][0-8]|[0-9][0-9]))?)$/{printf \"%s,\\n\",$1}", "chain": "in", "descr": "malicious attacker IPs" }, diff --git a/net/banip/files/banip.tpl b/net/banip/files/banip.tpl index 284901538..7f58cc8f2 100644 --- a/net/banip/files/banip.tpl +++ b/net/banip/files/banip.tpl @@ -15,10 +15,9 @@ fi banip_info="$(/etc/init.d/banip status 2>/dev/null)" report_info="$("${ban_catcmd}" "${ban_reportdir}/ban_report.txt" 2>/dev/null)" log_info="$(${logread_cmd})" -system_info="$( - strings /etc/banner 2>/dev/null - "${ban_ubuscmd}" call system board | "${ban_awkcmd}" 'BEGIN{FS="[{}\"]"}{if($2=="kernel"||$2=="hostname"||$2=="system"||$2=="model"||$2=="description")printf " + %-12s: %s\n",$2,$4}' -)" +system_info="$(strings /etc/banner 2>/dev/null + "${ban_ubuscmd}" call system board | + "${ban_awkcmd}" 'BEGIN{FS="[{}\"]"}{if($2=="kernel"||$2=="hostname"||$2=="system"||$2=="model"||$2=="description")printf " + %-12s: %s\n",$2,$4}')" # content header #