Exemplo n.º 1
0
    def test_download_redirect(self):
        # create a request to download the pdf
        result = self.client.get(url_for('cloudphish.submit', url=TEST_URL, ignore_filters='1'))

        # have the engine process it
        engine = TestEngine(analysis_pools={ANALYSIS_MODE_CLOUDPHISH: 1}, local_analysis_modes=[ANALYSIS_MODE_CLOUDPHISH])
        engine.enable_alerting()
        engine.enable_module('analysis_module_crawlphish', ANALYSIS_MODE_CLOUDPHISH)
        engine.enable_module('analysis_module_cloudphish_request_analyzer', ANALYSIS_MODE_CLOUDPHISH)

        # force this analysis to become an alert
        engine.enable_module('analysis_module_forced_detection', ANALYSIS_MODE_CLOUDPHISH)
        #engine.enable_module('analysis_module_detection', ANALYSIS_MODE_CLOUDPHISH)
        #engine.enable_module('analysis_module_alert', ANALYSIS_MODE_CLOUDPHISH)
        engine.controlled_stop()
        engine.start()
        engine.wait()

        # get the sha256_content
        submission_result = self.client.get(url_for('cloudphish.submit', url=TEST_URL, ignore_filters='1'))
        submission_result = submission_result.get_json()
        self.assertIsNotNone(submission_result[KEY_SHA256_URL])

        # change what node we are
        saq.SAQ_NODE = 'second_host'
        initialize_node()
        self.initialize_test_client()

        # we should get a redirect back to the other node
        result = self.client.get(url_for('cloudphish.download', s=submission_result[KEY_SHA256_URL]))
        self.assertEquals(result.status_code, 302)
Exemplo n.º 2
0
def set_node(name):
    """Sets the value for saq.SAQ_NODE. Typically this is auto-set using the local fqdn."""
    from saq.database import initialize_node
    global SAQ_NODE
    global SAQ_NODE_ID

    if name != SAQ_NODE:
        SAQ_NODE = name
        SAQ_NODE_ID = None
        initialize_node()