• 大小: 1.12MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-18
  • 语言: Python
  • 标签:

资源简介

Scantron是一个分布式nmap扫描仪,由两个组件组成。 第一个是主节点,由用于调度扫描和存储nmap扫描目标和结果的Web前端组成。 第二个组件是从主服务器提取扫描作业并执行实际nmap扫描的代理程序。

资源截图

代码片段和文件信息

#!/usr/bin/env python
# Standard Python libraries.
import argparse
import json
import multiprocessing
import os
import queue
import sys
import threading
import time

# Third party Python libraries.


# Custom Python libraries.
import modules.api
import modules.logger
import modules.nmap_scanner


class Worker(threading.Thread):
    “““Worker thread“““

    def __init__(self):
        “““Initialize Worker thread.“““

        threading.Thread.__init__(self)

    def run(self):
        “““Start Worker thread.“““

        while True:
            # Grab scan_job_dict off the queue.
            scan_job_dict = agent.queue.get()

            try:
                # Kick off scan.
                nmap_process = multiprocessing.Process(target=modules.nmap_scanner.scan_site args=(scan_job_dict))
                nmap_process.start()

            except Exception as e:
                modules.logger.ROOT_LOGGER.error(“Failed to start scan. Exception: {}“.format(e))

            agent.queue.task_done()


class Agent:
    “““Main Agent class“““

    def __init__(self config_file):
        “““Initialize Agent class“““

        self.config_file = config_file

        # Load configuration file.
        self.config_data = self.load_config(self.config_file)

        # Create queue.
        self.queue = queue.Queue()

    def load_config(self config_file):
        “““Load the agent_config.json file and return a JSON object.“““

        if os.path.isfile(config_file):
            with open(config_file) as fh:
                json_data = json.loads(fh.read())
                return json_data

        else:
            modules.logger.ROOT_LOGGER.error(“{} does not exist or contains no data.“.format(config_file))
            sys.exit(0)

    def go(self):
        “““Start the scan agent.“““

        # Assign log level.  See README.md for more information.
        modules.logger.ROOT_LOGGER.setLevel((6 - self.config_data[“log_verbosity“]) * 10)

        # Kickoff the threadpool.
        for i in range(self.config_data[“number_of_threads“]):
            thread = Worker()
            thread.daemon = True
            thread.start()

        modules.logger.ROOT_LOGGER.info(
            “Starting scan agent: {}“.format(self.config_data[“scan_agent“]) exc_info=False
        )

        while True:
            try:
                # Retrieve any new scan jobs from master through API.
                scan_jobs = modules.api.check_for_scan_jobs(self.config_data)

                if scan_jobs:
                    for scan_job in scan_jobs:
                        modules.logger.ROOT_LOGGER.info(“Executing scan job ID: {}“.format(scan_job[“id“]))

                        # Create new dictionary that will contain scan_job and config_data information.
                        scan_job_dict = {}
                        scan_job_dict[“scan_job“] = scan_job
                        scan_job_dict[“config_data“] = self.config_data

                        # Verify files exist by trying t

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-07-20 11:42  scantron-master\
     文件        1348  2019-07-20 11:42  scantron-master\.gitignore
     文件         561  2019-07-20 11:42  scantron-master\LICENSE
     文件       20750  2019-07-20 11:42  scantron-master\README.md
     目录           0  2019-07-20 11:42  scantron-master\agent\
     文件        5708  2019-07-20 11:42  scantron-master\agent\agent.py
     文件         332  2019-07-20 11:42  scantron-master\agent\agent_config.json
     目录           0  2019-07-20 11:42  scantron-master\agent\logs\
     文件          24  2019-07-20 11:42  scantron-master\agent\logs\README
     目录           0  2019-07-20 11:42  scantron-master\agent\modules\
     文件           0  2019-07-20 11:42  scantron-master\agent\modules\__init__.py
     文件        3101  2019-07-20 11:42  scantron-master\agent\modules\api.py
     文件         390  2019-07-20 11:42  scantron-master\agent\modules\logger.py
     文件        6175  2019-07-20 11:42  scantron-master\agent\modules\nmap_scanner.py
     文件         206  2019-07-20 11:42  scantron-master\agent\modules\utils.py
     文件         600  2019-07-20 11:42  scantron-master\agent\nfs_watcher.sh
     目录           0  2019-07-20 11:42  scantron-master\agent\nmap_results\
     文件          48  2019-07-20 11:42  scantron-master\agent\nmap_results\README
     文件         111  2019-07-20 11:42  scantron-master\agent\requirements.txt
     文件         260  2019-07-20 11:42  scantron-master\agent\scantron-agent.service
     目录           0  2019-07-20 11:42  scantron-master\agent\target_files\
     文件          48  2019-07-20 11:42  scantron-master\agent\target_files\README
     目录           0  2019-07-20 11:42  scantron-master\ansible-playbooks\
     文件          53  2019-07-20 11:42  scantron-master\ansible-playbooks\agent.yml
     文件         110  2019-07-20 11:42  scantron-master\ansible-playbooks\ansible.cfg
     目录           0  2019-07-20 11:42  scantron-master\ansible-playbooks\group_vars\
     文件         990  2019-07-20 11:42  scantron-master\ansible-playbooks\group_vars\all
     文件          49  2019-07-20 11:42  scantron-master\ansible-playbooks\hosts
     文件          71  2019-07-20 11:42  scantron-master\ansible-playbooks\master.yml
     目录           0  2019-07-20 11:42  scantron-master\ansible-playbooks\roles\
     目录           0  2019-07-20 11:42  scantron-master\ansible-playbooks\roles\add_users\
............此处省略229个文件信息

评论

共有 条评论