尼克斯的硬化工具

HnTool的Python项目详细描述


这是什么?

hntool是一个用于unix的开源(gplv2)强化工具。它扫描你的系统 配置文件中的漏洞或问题允许您快速 系统安全状态概述。

要使用hntool,请下载并运行:

# ./hntool

支持的系统

hntool已经过测试,正在处理:

  • Arch Linux
  • CentOS
  • Debian
  • Fedora
  • Gentoo
  • Ubuntu

如果您在上面未列出的系统上使用HNTool,请通知我们。

如何安装

要安装hntool,请以root用户身份运行以下命令:

# python setup.py install --prefix /usr/ --root /

如何使用

使用以下命令运行hntool:

# ./hntool

在命令行中键入“man hntool”,也可以看到hntool(1)手册 或查看使用帮助:

$ hntool -h

了解输出

有5种结果:

  • OK :
    Means that the item checked is fine and that you do not need to worry
  • INFO:
    Means that you should know the item status, but probably it is fine. A port opened, for example.
  • LOW:
    Means that a security problem was found, but it does not provides a high risk for your system.
  • MEDIUM:
    Things are getting worse and you should start to worry about these itens.
  • HIGH:
    You have an important security hole/problem on your system and you should fix it NOW or run and save your life.

我能帮忙吗?

有几种方法可以帮助hntool的开发。 你可以贡献代码,补丁,错误和功能请求。

要报告HNTool的错误或功能请求,请在我们的Google代码中提交问题 页码:http://code.google.com/p/hntool/

如果您报告了一个bug,请给出具体的示例,说明 出现问题。

如果你有补丁(修复一个bug或一个新的HNoToT模块),那么你可以提交一个 谷歌代码也有问题:http://code.google.com/p/hntool/issues/list

hntool的来源位于:

http://code.google.com/p/hntool/

如何创建模块

本节记录hntool的内部结构,并指定如何创建 一个新的模块。

主hntool程序(hntool.py)运行在文件中定义的规则列表__ 以及服务。

  • __files__ :
    defines the rules which process simple files and configs.
  • __services__ :
    defines the rules which checks the security on services and daemons.

模块完成后,请记住将其添加到适当的数组中 (在hntool/\u init.py中定义的文件或服务)

hntool模块示例如下(hntool/ssh.py):

import os

class rule:
        def short_name(self):
                return "ssh"
        def long_name(self):
                return "Checks security problems on sshd config file"
        def __init__(self, options):
                pass
        def analyze(self, options):
                check_results = {'ok': [], 'low': [], 'medium': [], 'high': [], 'info': []}
                ssh_conf_file = ['/etc/ssh/sshd_config', '/etc/sshd_config']

                for sshd_conf in ssh_conf_file:
                        if os.path.isfile(sshd_conf):
                                try:
                                        fp = open(sshd_conf,'r')
                                except IOError, (errno, strerror):
                                        check_results['info'].append('Could not open %s: %s' % (sshd_conf, strerror))
                                        continue

                                lines = [x.strip('\n') for x in fp.readlines()]

                                # Checking if SSH is using the default port
                                if 'Port 22' in lines or '#Port 22' in lines:
                                        check_results['low'].append('SSH is using the default port')
                                else:
                                        check_results['ok'].append('SSH is not using the default port')

                                # Closing the sshd_config file
                                fp.close()

                        return check_results
        def type(self):
                return "files"

基本上,代码是不言而喻的。以下是方法列表 每个hntool模块必须具有:

  • short_name(self)
    Returns a string containing a short name of the module. Usually,this is the same as the basename of the module file.
  • long_name(self)
    Returns a string containing a concise description of the module. This description is used when listing all the rules using hntool -l.
  • analyze(self)
    Should return a list comprising in turn of five lists: ok, low, medium, high and info.
  • type(self)
    “files” for a module processing simple files and configs “services” for a module processing services and daemons

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Dropbox java登录   java如何将“abcd1234”转换为INT1234   java如何实现compareTo()?   java如何查看SWT示例(Eclipse)源代码?   java内存直接映射到字符串   传递字符串时java Android应用程序崩溃   java是将Android游标(sqlite)提取到数组中以在AlertDialog中使用的最有效的方法。建设者   java如何检查udp/多播端口是否打开且可用?   如何在Java中创建弱引用?   java相同的异常针对不同的异常   swing Java JFrame问题与对话框   Eclipse Mars与Maven和SVN之间的java冲突?   如何在Java+swt中将对象停靠到父窗口?   如何区分Java输入类型?   java在Spring批处理中读取一个项目并将项目列表写入文件   java如何减少数据库表行整数值   java NullPointerException,即使对象不为null   如果站点地图的URL数超过maxnumber,则java会将其拆分为多个站点地图   java JFR显示LmaxDisruptor引擎内部的CPU利用率很高