Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dependency injection consistency #35

Merged
merged 1 commit into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/modules/fingerprints/cms/drupal.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import re

from lib.modules.fingerprints import FingerprintPlugin
from lib.utils.container import Services


class Drupal(FingerprintPlugin):
logger = Services.get("logger")
def process(self, headers, content):
_ = False
try:
Expand All @@ -14,4 +16,4 @@ def process(self, headers, content):
if _:
return "Drupal"
except Exception as e:
print(e)
self.logger.error(e)
5 changes: 3 additions & 2 deletions lib/modules/fingerprints/cms/joomla.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import re

from lib.modules.fingerprints import FingerprintPlugin

from lib.utils.container import Services

class Joomla(FingerprintPlugin):
logger = Services.get("logger")
def process(self, headers, content):
_ = False
try:
Expand All @@ -14,4 +15,4 @@ def process(self, headers, content):
if re.search('/templates/*', content, re.I):
return "Joomla"
except Exception as e:
print(e)
self.logger.error(e)
5 changes: 3 additions & 2 deletions lib/modules/fingerprints/cms/magento.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import re

from lib.modules.fingerprints import FingerprintPlugin

from lib.utils.container import Services

class Magento(FingerprintPlugin):
logger = Services.get("logger")
def process(self, headers, content):
_ = False
try:
Expand All @@ -15,4 +16,4 @@ def process(self, headers, content):
if _:
return "Magento"
except Exception as e:
print(e)
self.logger.error(e)
5 changes: 3 additions & 2 deletions lib/modules/fingerprints/cms/wordpress.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import re

from lib.modules.fingerprints import FingerprintPlugin

from lib.utils.container import Services

class Wordpress(FingerprintPlugin):
logger = Services.get("logger")
def process(self, headers, content):
_ = False
try:
Expand All @@ -12,4 +13,4 @@ def process(self, headers, content):
if _:
return "Wordpress"
except Exception as e:
print(e)
self.logger.error(e)
9 changes: 5 additions & 4 deletions lib/modules/fingerprints/header/cookie.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import re

from lib.modules.fingerprints import FingerprintPlugin
from lib.utils.output import Output
from lib.utils.container import Services


class Cookie(FingerprintPlugin):
output = Services.get("output")
def process(self, headers, content):
if 'set-cookie' in headers:
cookie = headers['set-cookie']
else:
cookie = None
if cookie is not None:
if re.search(r'domain=\S*', cookie, re.I):
Output().finding(
self.output.finding(
'Cookies are only accessible to this domain: %s' % re.findall(r'domain=(.+?)[\;]', cookie, re.I)[0])
if not re.search('httponly', cookie, re.I):
Output().finding('Cookies created without HTTPOnly Flag.')
self.output.finding('Cookies created without HTTPOnly Flag.')
if not re.search('secure', cookie, re.I):
Output().finding('Cookies created without Secure Flag.')
self.output.finding('Cookies created without Secure Flag.')
14 changes: 8 additions & 6 deletions lib/modules/fingerprints/header/headers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import re

from lib.modules.fingerprints import FingerprintPlugin
from lib.utils.output import Output
from lib.utils.container import Services


class Headers(FingerprintPlugin):
output = Services.get("output")
logger = Services.get("logger")
def process(self, headers, content):
fields = ('Accept',
'Accept-Charset',
Expand Down Expand Up @@ -87,16 +89,16 @@ def process(self, headers, content):
)

if not re.search(r'X-Frame-Options', str(headers.keys()), re.I):
Output().finding('X-Frame-Options header is not present.')
self.output.finding('X-Frame-Options header is not present.')

if not re.search(r'Strict-Transport-Security', str(headers.keys()), re.I):
Output().finding('Strict-Transport-Security header is not present.')
self.output.finding('Strict-Transport-Security header is not present.')

if not re.search(r'x-xss-protection', str(headers.keys()), re.I):
Output().finding('X-XSS-Protection header is not present.')
self.output.finding('X-XSS-Protection header is not present.')
try:
for key in headers.keys():
if key not in fields:
Output().finding('Uncommon header "%s" found, with contents: %s' % (key, headers[key]))
self.output.finding('Uncommon header "%s" found, with contents: %s' % (key, headers[key]))
except Exception as e:
print(e)
self.logger.error(e)
10 changes: 3 additions & 7 deletions lib/modules/fingerprints/server/server.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import re

from lib.modules.fingerprints import FingerprintPlugin

from lib.utils.container import Services

class Server(FingerprintPlugin):
logger = Services.get("logger")
def process(self, headers, content):
server = None
try:
for item in headers.items():
if re.search(r'server', item[0], re.I):
server = item[1]
# FIXME Fix the access to request URL
# if server is None:
# resp = Request().send(Request().url, headers={'Expect': 'Linguini'})
# for item in resp.headers.items():
# if re.search(r'server', item[0], re.I): server = item[1]
return server
except Exception as e:
print(e)
self.logger.error(e)