How to use the thug.Classifier.BaseClassifier.BaseClassifier 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 / thug / Classifier / URLClassifier.py View on Github external
#
# Original code written by Thorsten Sick 
# from Avira (developed for the iTES Project http://ites-project.org)
#
# Modified by Angelo Dell'Aera:
#   - Designed the more generic Classifier module and embedded this
#     module into such module
#   - Converted to YARA rules

import logging
from .BaseClassifier import BaseClassifier

log = logging.getLogger("Thug")


class URLClassifier(BaseClassifier):
    default_rule_file   = "rules/urlclassifier.yar"
    default_filter_file = "rules/urlfilter.yar"
    classifier          = "URL Classifier"

    def __init__(self):
        BaseClassifier.__init__(self)

    def classify(self, url):
        for match in self.rules.match(data = url):
            self.matches.append((url, match))

            if self.discard_url_match(url, match):
                continue

            self.handle_match_etags(match)
github buffer / thug / thug / Classifier / ImageClassifier.py View on Github external
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA

import logging
from .BaseClassifier import BaseClassifier

log = logging.getLogger("Thug")


class ImageClassifier(BaseClassifier):
    default_rule_file   = "rules/imageclassifier.yar"
    default_filter_file = "rules/imagefilter.yar"
    classifier          = "Image Classifier"

    def __init__(self):
        BaseClassifier.__init__(self)

    def classify(self, url, text):
        for match in self.rules.match(data = text):
            if (url, match) in self.matches:
                continue

            self.matches.append((url, match))

            if self.discard_url_match(url, match):
                continue
github buffer / thug / thug / Classifier / CookieClassifier.py View on Github external
def __init__(self):
        BaseClassifier.__init__(self)
github buffer / thug / thug / Classifier / VBSClassifier.py View on Github external
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA

import logging
from .BaseClassifier import BaseClassifier

log = logging.getLogger("Thug")


class VBSClassifier(BaseClassifier):
    default_rule_file   = "rules/vbsclassifier.yar"
    default_filter_file = "rules/vbsfilter.yar"
    classifier          = "VBS Classifier"

    def __init__(self):
        BaseClassifier.__init__(self)

    def classify(self, url, script):
        for match in self.rules.match(data = script):
            self.matches.append((url, match))

            if self.discard_url_match(url, match): # pragma: no cover
                continue

            self.handle_match_etags(match)
github buffer / thug / thug / Classifier / VBSClassifier.py View on Github external
def __init__(self):
        BaseClassifier.__init__(self)
github buffer / thug / thug / Classifier / JSClassifier.py View on Github external
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA

import logging
from .BaseClassifier import BaseClassifier

log = logging.getLogger("Thug")


class JSClassifier(BaseClassifier):
    default_rule_file   = "rules/jsclassifier.yar"
    default_filter_file = "rules/jsfilter.yar"
    classifier          = "JS Classifier"

    def __init__(self):
        BaseClassifier.__init__(self)

    def classify(self, url, script):
        for match in self.rules.match(data = script):
            self.matches.append((url, match))

            if self.discard_url_match(url, match): # pragma: no cover
                continue

            self.handle_match_etags(match)