How to use the thug.__configuration_path__ function in thug

To help you get started, we’ve selected a few thug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github buffer / thug / tests / Logging / test_ThugLogging.py View on Github external
import os
import logging

import thug
from thug.ThugAPI.ThugOpts import ThugOpts
from thug.DOM.HTTPSession import HTTPSession
from thug.Logging.ThugLogging import ThugLogging
from thug.Classifier.URLClassifier import URLClassifier
from thug.Classifier.SampleClassifier import SampleClassifier

configuration_path = thug.__configuration_path__

log                    = logging.getLogger("Thug")
log.configuration_path = configuration_path
log.personalities_path = os.path.join(configuration_path, "personalities") if configuration_path else None

log.PyHooks          = dict()
log.ThugOpts         = ThugOpts()
log.HTTPSession      = HTTPSession()
log.URLClassifier    = URLClassifier()
log.SampleClassifier = SampleClassifier()

thug_logging = ThugLogging(thug.__version__)


class TestThugLogging:
    js       = "var i = 0;"
github buffer / thug / tests / DOM / test_Personality.py View on Github external
import os
import logging

import thug

from thug.DOM.Personality import Personality
from thug.ThugAPI.ThugVulnModules import ThugVulnModules
from thug.ThugAPI.ThugOpts import ThugOpts

log = logging.getLogger("Thug")

configuration_path = thug.__configuration_path__
log.personalities_path = os.path.join(configuration_path, "personalities") if configuration_path else None

log.ThugVulnModules = ThugVulnModules()
log.ThugOpts = ThugOpts()

log.ThugOpts.useragent = 'winxpie60'


class TestPersonality(object):
    def test_personality(self):
        personality = Personality()

        assert 'Windows NT 5.1' in personality.userAgent
        assert 'Mozilla/4.0 (Windows XP 5.1) Java' in personality.javaUserAgent
        assert '6.0' in personality.browserVersion
        assert 'Win32' in personality.platform
github buffer / thug / tests / Logging / modules / test_ElasticSearch.py View on Github external
def test_disable_conf(self, mocked_parser):
        log.ThugOpts.elasticsearch_logging = True
        log.configuration_path = configuration_path
        assert log.ThugOpts.elasticsearch_logging

        elastic_search = ElasticSearch(thug.__version__)
        enabled = elastic_search.enabled
        assert not enabled

        log.ThugOpts.elasticsearch_logging = False
        log.configuration_path = thug.__configuration_path__
        assert not log.ThugOpts.elasticsearch_logging
github buffer / thug / tests / Logging / modules / test_JSON.py View on Github external
# coding=utf-8
import os
import shutil
import logging

from six import StringIO

import thug
from thug.ThugAPI.ThugOpts import ThugOpts
from thug.Logging.modules.JSON import JSON
from thug.ThugAPI.ThugVulnModules import ThugVulnModules
from thug.Logging.ThugLogging import ThugLogging
from thug.Encoding.Encoding import Encoding

configuration_path = thug.__configuration_path__

log = logging.getLogger("Thug")

log.personalities_path = os.path.join(configuration_path, "personalities") if configuration_path else None
log.ThugOpts           = ThugOpts()
log.configuration_path = configuration_path
log.ThugLogging        = ThugLogging(thug.__version__)
log.ThugVulnModules    = ThugVulnModules()
log.Encoding           = Encoding()
log.PyHooks            = dict()

json = JSON(thug.__version__)


class TestJSON:
    cve  = "CVE-XXXX"
github buffer / thug / tests / Logging / modules / test_ElasticSearch.py View on Github external
from mock import patch
import six.moves.configparser as ConfigParser

from elasticmock import elasticmock

import thug
from thug.Logging.modules.ElasticSearch import ElasticSearch
from thug.ThugAPI.ThugVulnModules import ThugVulnModules
from thug.ThugAPI.ThugOpts import ThugOpts

log = logging.getLogger("Thug")

cwd_path = os.path.dirname(os.path.realpath(__file__))
configuration_path = os.path.join(cwd_path, os.pardir, os.pardir, "test_files")

log.configuration_path = thug.__configuration_path__
log.personalities_path = os.path.join(configuration_path, "personalities") if configuration_path else None

log.ThugVulnModules = ThugVulnModules()
log.ThugOpts = ThugOpts()

log.ThugOpts.useragent = 'winxpie60'

config = ConfigParser.ConfigParser()
conf_file = os.path.join(log.configuration_path, 'thug.conf')
config.read(conf_file)


class TestElasticSearch:
    @elasticmock
    def test_export(self):
        log.ThugOpts.elasticsearch_logging = True
github buffer / thug / tests / DOM / test_MimeTypes.py View on Github external
import os
import logging

import thug

from thug.ThugAPI.ThugVulnModules import ThugVulnModules
from thug.ThugAPI.ThugOpts import ThugOpts
from thug.DOM.MimeTypes import MimeTypes

log = logging.getLogger("Thug")

configuration_path = thug.__configuration_path__
log.personalities_path = os.path.join(configuration_path, "personalities") if configuration_path else None

log.ThugVulnModules = ThugVulnModules()
log.ThugOpts = ThugOpts()


class TestMimeTypes(object):
    def test_items(self):
        mimetypes = MimeTypes()

        assert mimetypes[100]['description'] is None
        assert mimetypes['application/x-ms-wmz']['description'] in ('Windows Media Player', )
        assert mimetypes.namedItem('application/x-ms-wmz')['description'] in ('Windows Media Player', )
github buffer / thug / tests / DOM / test_HTTPSession.py View on Github external
import os
import logging
import pytest

import thug

from thug.ThugAPI.ThugOpts import ThugOpts
from thug.DOM.HTTPSession import HTTPSession

configuration_path = thug.__configuration_path__

log = logging.getLogger("Thug")
log.configuration_path = configuration_path
log.personalities_path = os.path.join(configuration_path, "personalities") if configuration_path else None

log.ThugOpts = ThugOpts()


class TestHTTPSession(object):
    def test_invalid_proxy_1(self):
        with pytest.raises(SystemExit):
            s = HTTPSession('invalid')

    def test_invalid_proxy_2(self):
        with pytest.raises(SystemExit):
            s = HTTPSession('foo://bar')
github buffer / thug / tests / DOM / test_JSInspector.py View on Github external
import os
import logging

import thug

from thug.ThugAPI.ThugOpts import ThugOpts
from thug.DOM.JSInspector import JSInspector

configuration_path = thug.__configuration_path__

log = logging.getLogger("Thug")
log.configuration_path = configuration_path
log.personalities_path = os.path.join(configuration_path, "personalities") if configuration_path else None

log.ThugOpts = ThugOpts()

last_url = "https://www.google.com"
log.last_url = last_url


class WindowDict(dict):
    def __setitem__(self, key, value):
        self[key] = value

    def __getitem__(self, key):
github buffer / thug / tests / AST / disabled_test_AST.py View on Github external
import os
import logging

import thug
from thug.AST.AST import AST
from thug.ThugAPI.ThugOpts import ThugOpts
from thug.Logging.ThugLogging import ThugLogging

configuration_path     = thug.__configuration_path__
log                    = logging.getLogger("Thug")
log.configuration_path = configuration_path
log.personalities_path = os.path.join(configuration_path, "personalities") if configuration_path else None
log.ThugOpts           = ThugOpts()
log.ThugLogging        = ThugLogging(thug.__version__)


class TestAST(object):
    DEBUG = True

    def debug_info(self, script, ast):
        if not self.DEBUG:
            return

        print(script)
        print(ast.names)
github buffer / thug / thug / ThugAPI / ThugAPI.py View on Github external
    def __init__(self, configuration_path = thug.__configuration_path__):
        self.__init_conf(configuration_path)
        self.__init_jsengine()
        self.__init_pyhooks()
        self.__init_core()
        self.__init_classifiers()
        self.__init_opaque_filter()
        self.__init_trace()