From 4dec1195ac2500b461a08f0674d73ccb6a1ee391 Mon Sep 17 00:00:00 2001 From: chenxinquan Date: Thu, 16 Nov 2023 15:09:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9F=BA=E7=BA=BF=E6=89=AB?= =?UTF-8?q?=20=E6=8F=8F=E9=A1=B9'28ipv6=E4=B8=8D=E5=BA=94=E6=8E=A5?= =?UTF-8?q?=E6=94=B6icmp=E5=AE=89=E5=85=A8=E9=87=8D=E5=AE=9A=E5=90=91'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../28/28ipv6不应接收icmp安全重定向.py | 72 +++++++++++++++++++ .../28/28ipv6不应接收icmp安全重定向.yaml | 22 ++++++ 2 files changed, 94 insertions(+) create mode 100755 data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/28/28ipv6不应接收icmp安全重定向.py create mode 100755 data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/28/28ipv6不应接收icmp安全重定向.yaml diff --git a/data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/28/28ipv6不应接收icmp安全重定向.py b/data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/28/28ipv6不应接收icmp安全重定向.py new file mode 100755 index 0000000..a309b00 --- /dev/null +++ b/data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/28/28ipv6不应接收icmp安全重定向.py @@ -0,0 +1,72 @@ + +import os +import sys + +################################ +# 常量 + +# for get_env_lang() +STR_GET_ENV_LANG_ZH = "语言环境为中文" +STR_GET_ENV_LANG_EN = "语言环境为英文" +STR_GET_ENV_LANG_UNKNOW = "语言环境未知" + +################################ +# 环境检查函数 + +def get_env_lang(): +# lang = os.getenv("LANG") +# if lang.startswith("zh"): +# return STR_GET_ENV_LANG_ZH +# elif lang.startswith("en"): +# return STR_GET_ENV_LANG_EN +# else: +# return STR_GET_ENV_LANG_UNKNOW +# + if arg_lang == "zh": + return STR_GET_ENV_LANG_ZH + elif arg_lang == "en": + return STR_GET_ENV_LANG_EN + else: + return STR_GET_ENV_LANG_UNKNOW + +def is_root(): + if os.geteuid() == 0: + print(STR_IS_ROOT_TRUE) + return True + else: + print(STR_IS_ROOT_FALSE) + return False + +################################ +# 辅助函数 +def l_print(zh_str, en_str) : + if STR_GET_ENV_LANG_ZH == get_env_lang() : + print(zh_str); + else : + print(en_str); + + +################################ +# 功能函数 +def net_ipv6(): + + output1 = os.popen('sudo sysctl net.ipv6.conf.all.accept_redirects 2>&1').read().strip() + output2 = os.popen('sudo sysctl net.ipv6.conf.default.accept_redirects 2>&1').read().strip() + + if "net.ipv6.conf.all.accept_redirects = 0" in output1 and "net.ipv6.conf.default.accept_redirects = 0" in output2: + l_print("[OK] 测试通过", + "[OK] pass") + else: + l_print("[ERROR] 测试未通过", + "[ERROR] fail") + +################################ +# main +if __name__ == "__main__": + if len(sys.argv)>1: + arg_lang = sys.argv[1] + else: + arg_lang = 'zh' + + net_ipv6() + exit(0) diff --git a/data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/28/28ipv6不应接收icmp安全重定向.yaml b/data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/28/28ipv6不应接收icmp安全重定向.yaml new file mode 100755 index 0000000..5f6a66c --- /dev/null +++ b/data/BaseLine/LocalServices/TestingDepartmentPrivateUseCases/28/28ipv6不应接收icmp安全重定向.yaml @@ -0,0 +1,22 @@ +FormatVer: 20230623 +Id: net_ipv6 +Belong: baseline +SiteInfo: + Name: 28ipv6不应接收icmp安全重定向 +Power : "root" +SiteRequests: + Implement: + ImArray: + - Inter : python3 + InterArgs : + Exec : 28ipv6不应接收icmp安全重定向.py + Args : + Inter: + - "[ERROR]" + Condition: None +RepairArgs: + - Inter : python3 + InterArgs : + Exec : + Args : + RepairPower: #root # root权限或者普通用户权限