예제 #1
0
    def test_hpfeeds_event_with_file(self):
        """Objective: Testing if a event containing a file can be transmitted using hpfriends."""

        config_file = tempfile.mkstemp()[1]
        with open(config_file, 'w') as f:
            f.writelines(helpers.gen_config(''))

        #create dummy file
        file_name = 'dummy_file'
        with open(os.path.join(self.files_dir, file_name), 'w') as f:
            f.write('test_test_test_test_test')

        logger = HPFeedsLogger(self.tmpdir,
                               config=config_file,
                               reconnect=False)
        event = attack.AttackEvent()
        event.http_request = HTTPHandler('', None)
        event.raw_request = "GET /honeypot_test HTTP/1.1\r\nHost: honeypot\r\n\r\n"
        event.file_name = file_name
        logger.insert(event)
        gevent.sleep(2)
        # if None we did not connect
        self.assertIsNotNone(logger.hpc.wait)
        error_message = logger.hpc.wait(2)
        self.assertIsNone(error_message)
예제 #2
0
    def test_hpfeeds_event(self):
        """Objective: Testing if a basic event can be transmitted using hpfriends."""

        config_file = tempfile.mkstemp()[1]
        with open(config_file, 'w') as f:
            f.writelines(helpers.gen_config(''))

        logger = HPFeedsLogger(self.tmpdir, os.getcwd(), config=config_file, reconnect=False)
        event = attack.AttackEvent()
        event.http_request = HTTPHandler('', None)
        event.raw_request = "GET /honeypot_test HTTP/1.1\r\nHost: honeypot\r\n\r\n"
        logger.insert(event)
        gevent.sleep(2)
        # if None we did not connect
        self.assertIsNotNone(logger.hpc.wait)
        error_message = logger.hpc.wait(2)
        self.assertIsNone(error_message)