Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#
# 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)
# 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
def __init__(self):
BaseClassifier.__init__(self)
# 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)
def __init__(self):
BaseClassifier.__init__(self)
# 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)