Git Product home page Git Product logo

hntool's Introduction

HnTool

What is it?

HnTool is an open source (GPLv2) hardening tool for Unix. It scans your system for vulnerabilities or problems in configuration files allowing you to get a quick overview of the security status of your system.

To use HnTool download it and run: ::

# ./hntool

Supported systems

HnTool was already tested and is working on:

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

If you are using HnTool on a system that is not listed above, please, let us know.

How to install

To install HnTool run the following command, as root:

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

How to use

Run HnTool with:

# ./hntool

You can also see the hntool(1) manual by typing 'man hntool' at the command line or see the usage help:

$ hntool -h

Understanding the output

There are 5 types of results:

  • 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.

How can I help?

There are several ways that you can contribute and help HnTool's development. You can contribute with code, patchs, bugs and feature requests.

To report a bug or a feature request for HnTool, file a issue in our Google Code page: https://github.com/hdoria/HnTool

If you're reporting a bug, please give concrete examples of how and where the problem occurs.

If you've a patch (fixing a bug or a new HnTool module), then you can file an issue on Google Code too: http://code.google.com/p/hntool/issues/list

HnTool's source is available on:

https://github.com/hdoria/HnTool

How to create a module

This section documents the innards of HnTool and specifies how to create a new module.

The main HnTool program (hntool.py) runs a list of rules defined in __files__ and __services__.

  • files : defines the rules which process simple files and configs.

  • services : defines the rules which checks the security on services and daemons.

Once your module is finalized, remember to add it to the appropriate array (__files__ or __services__) defined in hntool/__init__.py

A sample HnTool module is like this (hntool/ssh.py):

import os
import HnTool.modules.util
from HnTool.modules.rule import Rule as MasterRule

class Rule(MasterRule):
def __init__(self, options):
    MasterRule.__init__(self, options)
    self.short_name="ssh"
    self.long_name="Checks security problems on sshd config file"
    self.type="config"
    self.required_files = ['/etc/ssh/sshd_config', '/etc/sshd_config']

def requires(self):
    return self.required_files

def analyze(self, options):
    check_results = self.check_results
    ssh_conf_file = self.required_files

    for sshd_conf in ssh_conf_file:
        if os.path.isfile(sshd_conf):
            # dict with all the lines
            lines = HnTool.modules.util.hntool_conf_parser(sshd_conf)

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

    return check_results

Mostly, the code is self-explanatory. The following are the list of the attributes and methods that each HnTool module must have:

  • self.short_name String containing a short name of the module. Usually,this is the same as the basename of the module file.

  • self.long_name 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.

  • self.type "files" or "config" for a module processing simple files and configs "services" for a module processing services and daemons

hntool's People

Contributors

arthurassuncao avatar coreb1t avatar dogoncouch avatar garrocho avatar hdoria avatar matheussl avatar skateforever avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hntool's Issues

setup.py with --prefix option: module not found errors (Debian-based distros)

The recommended install method:
python setup.py install --prefix /usr/ --root /
Installs packages to /usr/lib/pythonx.x/site-packages. Debian (and its derivatives) stopped putting site-packages in their sys.path, and now uses dist-packages instead, so you'll get module not found errors for all of the required modules. the --prefix option overrides Debian's default path for installing modules.

Running setup.py like this works fine:
python setup.py install

incorrect-fsf-address

Due https://fedoraproject.org/wiki/Common_Rpmlint_issues#incorrect-fsf-address I need to tell upstream that hntool should fix this issue.

List of afftected files:
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/apache.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/remote.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/ssh.py
hntool.noarch: E: incorrect-fsf-address /usr/share/doc/hntool/LICENSE
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/util.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/ports.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/vsftpd.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/init.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/postgresql.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/proftpd.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/php.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/filesystems.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/authentication.py
hntool.noarch: E: incorrect-fsf-address /usr/bin/hntool
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/system-wide.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/output/terminal.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/core.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/output/init.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/output/html.py
hntool.noarch: E: incorrect-fsf-address /usr/lib/python2.7/site-packages/HnTool/modules/rule.py

Another question, I'm maintaining hntool package in Fedora, but upstream looks dead, do you have plans to keep hntool development or should I retire it from Fedora?
Thanks,

Filipe R.

Test only one requirement

Return true if only one file is valid.

def requirements_met(pfile):
'''This method should check if all the requirements (files)
are met (one or more files can be found on the system)'''

for f in pfile:
    if os.path.isfile(f):
        return True  # <---------------------

return False

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.