Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/portantier/wig into porta…
Browse files Browse the repository at this point in the history
…ntier-master
  • Loading branch information
jekyc committed Mar 30, 2016
2 parents af64db8 + e9754a5 commit 7ff0b6f
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions classes/fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,41 @@
import os
import copy

import os.path

datadir = os.path.dirname(os.path.abspath(__file__))
datadir = datadir.rsplit('/', maxsplit=1)[0]
datadir += '/data'

class Fingerprints(object):

def __init__(self):

self.data = {
'cms': {
'md5': {'dir': 'data/cms/md5/', 'fps': []},
'reqex': {'dir': 'data/cms/regex/', 'fps': []},
'string': {'dir': 'data/cms/string/', 'fps': []},
'header': {'dir': 'data/cms/header/', 'fps': []}
'md5': {'dir': datadir + '/cms/md5/', 'fps': []},
'reqex': {'dir': datadir + '/cms/regex/', 'fps': []},
'string': {'dir': datadir + '/cms/string/', 'fps': []},
'header': {'dir': datadir + '/cms/header/', 'fps': []}
},
'js': {
'md5': {'dir': 'data/js/md5/', 'fps': []},
'reqex': {'dir': 'data/js/regex/', 'fps': []},
'md5': {'dir': datadir + '/js/md5/', 'fps': []},
'reqex': {'dir': datadir + '/js/regex/', 'fps': []},
},
'platform': {
'md5': {'dir': 'data/platform/md5/', 'fps': []},
'reqex': {'dir': 'data/platform/regex/', 'fps': []},
'string': {'dir': 'data/platform/string/', 'fps': []},
'header': {'dir': 'data/platform/header/', 'fps': []}
'md5': {'dir': datadir + '/platform/md5/', 'fps': []},
'reqex': {'dir': datadir + '/platform/regex/', 'fps': []},
'string': {'dir': datadir + '/platform/string/', 'fps': []},
'header': {'dir': datadir + '/platform/header/', 'fps': []}
},
'vulnerabilities': {
'cvedetails': {'dir': 'data/vulnerabilities/cvedetails/', 'fps': []},
'cvedetails': {'dir': datadir + '/vulnerabilities/cvedetails/', 'fps': []},
},
'translator': {'file': 'data/dictionary.json', 'dictionary': {}},
'error_pages': {'file': 'data/error_pages.json', 'fps': []},
'interesting': {'file': 'data/interesting.json', 'fps': []},
'subdomains': {'file': 'data/subdomains.json', 'fps': []},
'os': {'dir': 'data/os/', 'fps': []}
'translator': {'file': datadir + '/dictionary.json', 'dictionary': {}},
'error_pages': {'file': datadir + '/error_pages.json', 'fps': []},
'interesting': {'file': datadir + '/interesting.json', 'fps': []},
'subdomains': {'file': datadir + '/subdomains.json', 'fps': []},
'os': {'dir': datadir + '/os/', 'fps': []}
}

# load fingerprints
Expand All @@ -46,7 +51,7 @@ def __init__(self):
def _is_json(self, filename):
is_json = False
if len(filename.split('.')) == 2:
name,ext = filename.split('.')
name,ext = filename.split('.')
is_json = ext == 'json'

return is_json
Expand All @@ -58,8 +63,9 @@ def _get_name(self, filename):


def _open_file(self, filename):

if not self._is_json(filename): return None

try:
with open(filename) as fh:
fps = json.load(fh)
Expand All @@ -68,28 +74,28 @@ def _open_file(self, filename):
return None

return fps


def _load_subdomains(self):
self.data['subdomains']['fps'] = self._open_file(self.data['subdomains']['file'])


def _load_dictionary(self):
fps = self._open_file(self.data['translator']['file'])
if fps is not None:
if fps is not None:
self.data['translator']['dictionary'] = fps


def _load_error(self):
fps = self._open_file(self.data['error_pages']['file'])
if fps is not None:
if fps is not None:
self.data['error_pages']['fps'] = fps


def _load_os(self):
for json_file in os.listdir(self.data['os']['dir']):
for json_file in os.listdir(self.data['os']['dir']):
fps = self._open_file(self.data['os']['dir'] + '/' + json_file)
if fps is not None:
if fps is not None:
self.data['os']['fps'].extend(fps)


Expand All @@ -110,7 +116,7 @@ def _load(self):
categories = ['cms', 'js', 'platform', 'vulnerabilities']
for category in categories:
for fp_type in self.data[category]:
for json_file in os.listdir(self.data[category][fp_type]['dir']):
for json_file in os.listdir(self.data[category][fp_type]['dir']):
fps = self._open_file(self.data[category][fp_type]['dir'] + '/' + json_file)
for fp in fps:
fp['name'] = self._get_name( json_file )
Expand Down

0 comments on commit 7ff0b6f

Please sign in to comment.