Example #1
0
File: main.py Project: Zekka/bakten
 def __init__(self):
     self.services = []
     for i in plugin.find_plugins(PLUGIN_DIR):
         self.services.extend(
             CMDExporter.load_all(i)
             )
     print self.services
Example #2
0
def main():
    """Main function."""
    # Need to get plugins first for arguments to function
    plugin.find_plugins()

    parser = argparse.ArgumentParser(
        description="Automatically fixes common security vulnerabilities.",
        epilog="Default behaviour is to attempt to run all plugins")
    parser.add_argument("--list-plugins",
                        "-l",
                        action="store_true",
                        help="Lists all plugins",
                        dest="list_plugins")
    parser.add_argument("--run-plugin",
                        "-r",
                        "-p",
                        choices=get_plugins(),
                        nargs="+",
                        metavar="N",
                        help="Run specific plugins",
                        dest="plugins")
    parser.add_argument("--run-all",
                        "-R",
                        action="store_true",
                        help="Run all available plugins",
                        dest="run_all")
    parser.add_argument("--disable-root-check",
                        "--no-root",
                        "-d",
                        action="store_true",
                        help="Disable root check",
                        dest="no_root_check")
    parser.add_argument("--disable-python-check",
                        action="store_true",
                        help="Disable Python version check",
                        dest="disable_python_check")
    args = parser.parse_args()

    info("Welcome to CentSecure!")
    debug("This computer is running {} version {}".format(
        plugin.get_os(), plugin.get_os_version()))

    if args.list_plugins:
        plugins = get_plugins()
        for p in plugins:
            stdout("- {}".format(p))
        sys.exit(0)

    if not args.disable_python_check and not _check_python_version():
        warn(
            "CentSecure requires Python 3.7.x, you are using {}. Use the option --disable-python-check to bypass."
            .format(python_version()))
        sys.exit(1)

    firsttime.run_all()

    if args.run_all:
        to_run = get_plugins()
    elif args.plugins is not None:
        to_run = args.plugins
    else:
        to_run = get_default_plugins()

    if is_admin() or args.no_root_check:
        debug("Running CentSecure with the following {} plugins: {}".format(
            len(to_run), ", ".join(to_run)))
        run(to_run)
    else:
        warn(
            "CentSecure should be run as root or administator. Use the option --disable-root-check to bypass."
        )
        sys.exit(1)
Example #3
0
File: sl.py Project: Zekka/bakten
def create_handlers(responder):
    for i in find_plugins(PLUGIN_DIR):
        responder.add_module(i)