mirror of https://gitee.com/openkylin/genmai.git
!355 新增基线扫 描项'74关闭系统不必要的端口53'
Merge pull request !355 from a-alpha/alpha-dev
This commit is contained in:
commit
0c74defdeb
|
@ -0,0 +1,69 @@
|
|||
|
||||
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 port53():
|
||||
output = os.popen('sudo firewall-cmd --zone=public --query-port=53/tcp 2>&1').read().strip()
|
||||
if "no" == output or "找不到命令" in output:
|
||||
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'
|
||||
|
||||
port53()
|
||||
exit(0)
|
|
@ -0,0 +1,22 @@
|
|||
FormatVer: 20230623
|
||||
Id: port53
|
||||
Belong: baseline
|
||||
SiteInfo:
|
||||
Name: 74关闭系统不必要的端口53
|
||||
Power : "root"
|
||||
SiteRequests:
|
||||
Implement:
|
||||
ImArray:
|
||||
- Inter : python3
|
||||
InterArgs :
|
||||
Exec : 74关闭系统不必要的端口53.py
|
||||
Args :
|
||||
Inter:
|
||||
- "[ERROR]"
|
||||
Condition: None
|
||||
RepairArgs:
|
||||
- Inter : python3
|
||||
InterArgs :
|
||||
Exec :
|
||||
Args :
|
||||
RepairPower: #root # root权限或者普通用户权限
|
|
@ -0,0 +1,69 @@
|
|||
|
||||
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 port69():
|
||||
output = os.popen('sudo firewall-cmd --zone=public --query-port=69/tcp 2>&1').read().strip()
|
||||
if "no" == output or "找不到命令" in output:
|
||||
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'
|
||||
|
||||
port69()
|
||||
exit(0)
|
|
@ -0,0 +1,22 @@
|
|||
FormatVer: 20230623
|
||||
Id: port69
|
||||
Belong: baseline
|
||||
SiteInfo:
|
||||
Name: 75关闭系统不必要的端口69
|
||||
Power : "root"
|
||||
SiteRequests:
|
||||
Implement:
|
||||
ImArray:
|
||||
- Inter : python3
|
||||
InterArgs :
|
||||
Exec : 75关闭系统不必要的端口69.py
|
||||
Args :
|
||||
Inter:
|
||||
- "[ERROR]"
|
||||
Condition: None
|
||||
RepairArgs:
|
||||
- Inter : python3
|
||||
InterArgs :
|
||||
Exec :
|
||||
Args :
|
||||
RepairPower: #root # root权限或者普通用户权限
|
Loading…
Reference in New Issue