当前位置: 首页>>代码示例>>Python>>正文


Python GlastopfHoneypot.prepare_environment方法代码示例

本文整理汇总了Python中glastopf.glastopf.GlastopfHoneypot.prepare_environment方法的典型用法代码示例。如果您正苦于以下问题:Python GlastopfHoneypot.prepare_environment方法的具体用法?Python GlastopfHoneypot.prepare_environment怎么用?Python GlastopfHoneypot.prepare_environment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在glastopf.glastopf.GlastopfHoneypot的用法示例。


在下文中一共展示了GlastopfHoneypot.prepare_environment方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from glastopf.glastopf import GlastopfHoneypot [as 别名]
# 或者: from glastopf.glastopf.GlastopfHoneypot import prepare_environment [as 别名]
 def setUp(self):
     self.work_dir = tempfile.mkdtemp()
     GlastopfHoneypot.prepare_environment(self.work_dir)
     self.data_dir = os.path.join(self.work_dir, 'data/')
     package_directory = os.path.dirname(os.path.abspath(inspect.getfile(RequestHandler)))
     #original data as stored with new glatopf installations
     self.original_data_dir = os.path.join(package_directory, 'emulators/data/')
开发者ID:marksee,项目名称:glastopf,代码行数:9,代码来源:test_emulators.py

示例2: test_honeypot_sql

# 需要导入模块: from glastopf.glastopf import GlastopfHoneypot [as 别名]
# 或者: from glastopf.glastopf.GlastopfHoneypot import prepare_environment [as 别名]
    def test_honeypot_sql(self):
        """Objective: Testing overall Honeypot integration.
        Input: Loads the honeypot module with mongodb as main database.
        Expected Response: Honeypot responses with a non-empty HTTP response.
        Note: This test verifies the overall functionality."""

        db_file = tempfile.mkstemp()[1]
        conn_string = "sqlite:///{0}".format(db_file)
        sql_engine = create_engine(conn_string)
        helpers.populate_main_sql_testdatabase(sql_engine)

        config_file = tempfile.mkstemp()[1]

        with open(config_file, "w") as f:
            f.writelines(helpers.gen_config(conn_string))

        try:
            raw_request = "GET /honeypot_test HTTP/1.1\r\nHost: honeypot\r\n\r\n"
            source_address = ["127.0.0.1", "12345"]
            sensor_address = ["1.2.3.4", "8080"]
            GlastopfHoneypot.prepare_environment(self.tmpdir)
            self.glastopf = GlastopfHoneypot(work_dir=self.tmpdir, config=config_file)
            self.glastopf.options["enabled"] = "False"
            print "Sending request: http://localhost:8080/"
            response = self.glastopf.handle_request(raw_request, source_address, sensor_address)
            self.assertIsNot(response, None)
        finally:
            if os.path.isfile(config_file):
                os.remove(config_file)
            if os.path.isfile(db_file):
                os.remove(db_file)
开发者ID:repson,项目名称:glastopf,代码行数:33,代码来源:test_honeypot.py

示例3: setUp

# 需要导入模块: from glastopf.glastopf import GlastopfHoneypot [as 别名]
# 或者: from glastopf.glastopf.GlastopfHoneypot import prepare_environment [as 别名]
 def setUp(self):
     self.config = ConfigParser()
     self.config.add_section('main-database')
     self.config.set('main-database', 'enabled', "True")
     self.workdir = tempfile.mkdtemp()
     self.datadir = os.path.join(self.workdir, 'data')
     GlastopfHoneypot.prepare_environment(self.workdir)
开发者ID:mushorg,项目名称:glastopf,代码行数:9,代码来源:test_dork_list.py

示例4: test_honeypot_mongo

# 需要导入模块: from glastopf.glastopf import GlastopfHoneypot [as 别名]
# 或者: from glastopf.glastopf.GlastopfHoneypot import prepare_environment [as 别名]
    def test_honeypot_mongo(self):
        """Objective: Testing overall Honeypot integration.
        Input: Loads the honeypot module with mongodb as main database.
        Expected Response: Honeypot responses with a non-empty HTTP response.
        Note: This test verifies the overall functionality."""

        conn_string = helpers.create_mongo_database(fill=True)
        config_file = tempfile.mkstemp()[1]

        with open(config_file, 'w') as f:
            f.writelines(helpers.gen_config(conn_string))

        try:
            raw_request = "GET /honeypot_test HTTP/1.1\r\nHost: honeypot\r\n\r\n"
            source_address = ["127.0.0.1", "12345"]
            GlastopfHoneypot.prepare_environment(self.tmpdir)
            self.glastopf = GlastopfHoneypot(work_dir=self.tmpdir, config=config_file)
            self.glastopf.options["enabled"] = "False"
            print "Sending request: http://localhost:8080/"
            connection = FakeCon()
            connection.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            response = self.glastopf.handle_request(raw_request,
                                                    source_address,
                                                    connection)
            connection.sock.close()
            self.assertIsNot(response, None)
        finally:
            helpers.delete_mongo_testdata(conn_string)
            if os.path.isfile(config_file):
                os.remove(config_file)
开发者ID:LucaBongiorni,项目名称:glastopf,代码行数:32,代码来源:test_honeypot.py

示例5: setUp

# 需要导入模块: from glastopf.glastopf import GlastopfHoneypot [as 别名]
# 或者: from glastopf.glastopf.GlastopfHoneypot import prepare_environment [as 别名]
 def setUp(self):
     self.tmpdir = tempfile.mkdtemp()
     data_dir = os.path.join(self.tmpdir, 'data')
     GlastopfHoneypot.prepare_environment(self.tmpdir)
     self.requestClassifier = request_classifier.Classifier(data_dir)
开发者ID:czardoz,项目名称:glastopf,代码行数:7,代码来源:test_classifiers.py

示例6: directory

# 需要导入模块: from glastopf.glastopf import GlastopfHoneypot [as 别名]
# 或者: from glastopf.glastopf.GlastopfHoneypot import prepare_environment [as 别名]
        file_log.setLevel(logging.DEBUG)
        file_log.setFormatter(formatter)
        root_logger.addHandler(file_log)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Glastopf runner')
    #defaults to current directory (aka. working directory)
    parser.add_argument('--workdir', dest='workdir', default=os.getcwd())
    parser.add_argument('--prepare', action='store_true', default=False)

    args = parser.parse_args()

    #prepare directory if workdir directory contains no files or if we are asked to do it.
    if args.prepare or len(os.listdir(args.workdir)) == 0:
        GlastopfHoneypot.prepare_environment(args.workdir)

    conf_parser = ConfigParser()
    if not os.path.isfile("glastopf.cfg"):
        sys.exit("Could not find configuration file: glastopf.cfg")
    conf_parser.read("glastopf.cfg")
    if conf_parser.getboolean("logging", "filelog_enabled"):
        logfile = conf_parser.get("logging", "logfile")
    else:
        logfile = None
    logconsole = conf_parser.getboolean("logging", "consolelog_enabled")
    logger = logging.getLogger()
    setup_logging(logconsole, logfile)

    host = conf_parser.get("webserver", "host")
    port = conf_parser.getint("webserver", "port")
开发者ID:abhik137,项目名称:glastopf,代码行数:33,代码来源:glastopf-runner.py

示例7: setUp

# 需要导入模块: from glastopf.glastopf import GlastopfHoneypot [as 别名]
# 或者: from glastopf.glastopf.GlastopfHoneypot import prepare_environment [as 别名]
 def setUp(self):
     self.workdir = tempfile.mkdtemp()
     self.datadir = os.path.join(self.workdir, 'data')
     GlastopfHoneypot.prepare_environment(self.workdir)
开发者ID:LucaBongiorni,项目名称:glastopf,代码行数:6,代码来源:test_dork_list.py


注:本文中的glastopf.glastopf.GlastopfHoneypot.prepare_environment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。