Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

[PEP 8] - Style Violation Fixes Part 1

Gormogoncbb14492ed74
diff --git a/modules/sfp_intfiles.py b/modules/sfp_intfiles.py
index 7e395f37..e914d188 100644
--- a/modules/sfp_intfiles.py
+++ b/modules/sfp_intfiles.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_intfiles
# Purpose: From Spidering and from searching search engines, identifies
# files of potential interest.
@@ -9,26 +9,27 @@
# Created: 06/04/2014
# Copyright: (c) Steve Micallef 2014
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import re
import urllib
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_intfiles(SpiderFootPlugin):
"""Interesting Files:Identifies potential files of interest, e.g. office documents."""
# Default options
opts = {
- 'pages': 20, # Number of search results pages to iterate
- 'fileexts': [ "doc", "docx", "ppt", "pptx", "pdf", 'xls', 'xlsx' ],
- 'usesearch': True,
+ 'pages': 20, # Number of search results pages to iterate
+ 'fileexts': ["doc", "docx", "ppt", "pptx", "pdf", 'xls', 'xlsx'],
+ 'usesearch': True,
'searchengine': "yahoo"
}
# Option descriptions
optdescs = {
- 'pages': "Number of search engine results pages to iterate through if using one.",
+ 'pages': "Number of search engine results pages to iterate through if using one.",
'fileexts': "File extensions of files you consider interesting.",
'usesearch': "Use search engines to quickly find files. If false, only spidering will be used.",
'searchengine': "If using a search engine, which one? google, yahoo or bing."
@@ -45,13 +46,13 @@ class sfp_intfiles(SpiderFootPlugin):
# What events is this module interested in for input
def watchedEvents(self):
- return [ "INTERNET_NAME", "LINKED_URL_INTERNAL" ]
+ return ["INTERNET_NAME", "LINKED_URL_INTERNAL"]
# What events this module produces
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "SEARCH_ENGINE_WEB_CONTENT", "INTERESTING_FILE" ]
+ return ["SEARCH_ENGINE_WEB_CONTENT", "INTERESTING_FILE"]
def yahooCleaner(self, string):
return " url=\"" + urllib.unquote(string.group(1)) + "\" "
@@ -80,8 +81,8 @@ class sfp_intfiles(SpiderFootPlugin):
continue
else:
self.results.append(eventData)
- evt = SpiderFootEvent("INTERESTING_FILE", eventData,
- self.__name__, event)
+ evt = SpiderFootEvent("INTERESTING_FILE", eventData,
+ self.__name__, event)
self.notifyListeners(evt)
return None
@@ -90,25 +91,25 @@ class sfp_intfiles(SpiderFootPlugin):
# Sites hosted on the domain
if self.opts['searchengine'].lower() == "google":
pages = self.sf.googleIterate("site:" + eventData + "+" + \
- "%2Bext:" + fileExt, dict(limit=self.opts['pages'],
- useragent=self.opts['_useragent'],
- timeout=self.opts['_fetchtimeout']))
+ "%2Bext:" + fileExt, dict(limit=self.opts['pages'],
+ useragent=self.opts['_useragent'],
+ timeout=self.opts['_fetchtimeout']))
if self.opts['searchengine'].lower() == "bing":
pages = self.sf.bingIterate("site:" + eventData + "+" + \
- "%2Bext:" + fileExt, dict(limit=self.opts['pages'],
- useragent=self.opts['_useragent'],
- timeout=self.opts['_fetchtimeout']))
+ "%2Bext:" + fileExt, dict(limit=self.opts['pages'],
+ useragent=self.opts['_useragent'],
+ timeout=self.opts['_fetchtimeout']))
if self.opts['searchengine'].lower() == "yahoo":
pages = self.sf.yahooIterate("site:" + eventData + "+" + \
- "%2Bext:" + fileExt, dict(limit=self.opts['pages'],
- useragent=self.opts['_useragent'],
- timeout=self.opts['_fetchtimeout']))
+ "%2Bext:" + fileExt, dict(limit=self.opts['pages'],
+ useragent=self.opts['_useragent'],
+ timeout=self.opts['_fetchtimeout']))
if pages is None:
self.sf.info("No results returned from " + self.opts['searchengine'] + \
- " for " + fileExt + " files.")
+ " for " + fileExt + " files.")
continue
for page in pages.keys():
@@ -122,13 +123,12 @@ class sfp_intfiles(SpiderFootPlugin):
return None
# Submit the gresults for analysis
- evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", pages[page],
- self.__name__, event)
+ evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", pages[page],
+ self.__name__, event)
self.notifyListeners(evt)
if self.opts['searchengine'].lower() == "yahoo":
- res = re.sub("RU=(.[^\/]+)\/RK=", self.yahooCleaner,
- pages[page], 0)
+ res = re.sub("RU=(.[^\/]+)\/RK=", self.yahooCleaner, pages[page], 0)
else:
res = pages[page]
@@ -143,10 +143,10 @@ class sfp_intfiles(SpiderFootPlugin):
self.results.append(link)
if self.sf.urlFQDN(link).endswith(eventData) and \
- "." + fileExt.lower() in link.lower():
+ "." + fileExt.lower() in link.lower():
self.sf.info("Found an interesting file: " + link)
- evt = SpiderFootEvent("INTERESTING_FILE", link,
- self.__name__, event)
+ evt = SpiderFootEvent("INTERESTING_FILE", link,
+ self.__name__, event)
self.notifyListeners(evt)
# End of sfp_intfiles class
diff --git a/modules/sfp_ir.py b/modules/sfp_ir.py
index 1410e3b5..c2338d42 100644
--- a/modules/sfp_ir.py
+++ b/modules/sfp_ir.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_ir
# Purpose: Queries Internet registryes like RIPE (incl. ARIN) to get
# netblocks and other bits of info.
@@ -9,17 +9,18 @@
# Created: 8/12/2013
# Copyright: (c) Steve Micallef 2013
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import re
import json
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_ir(SpiderFootPlugin):
"""Internet Registries:Queries Internet Registries to identify netblocks and other info."""
# Default options
- opts = { }
+ opts = {}
results = dict()
currentEventSrc = None
@@ -40,26 +41,26 @@ class sfp_ir(SpiderFootPlugin):
# What events is this module interested in for input
def watchedEvents(self):
return ['IP_ADDRESS', 'NETBLOCK_MEMBER', 'NETBLOCK_OWNER',
- 'BGP_AS_OWNER', 'BGP_AS_MEMBER' ]
+ 'BGP_AS_OWNER', 'BGP_AS_MEMBER']
# What events this module produces
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "NETBLOCK_MEMBER", "NETBLOCK_OWNER", "BGP_AS_MEMBER",
- "RAW_RIR_DATA", "BGP_AS_OWNER", "BGP_AS_PEER" ]
+ return ["NETBLOCK_MEMBER", "NETBLOCK_OWNER", "BGP_AS_MEMBER",
+ "RAW_RIR_DATA", "BGP_AS_OWNER", "BGP_AS_PEER"]
# Fetch content and notify of the raw data
def fetchRir(self, url):
if self.memCache.has_key(url):
res = self.memCache[url]
else:
- res = self.sf.fetchUrl(url, timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ res = self.sf.fetchUrl(url, timeout=self.opts['_fetchtimeout'],
+ useragent=self.opts['_useragent'])
if res['content'] is not None:
self.memCache[url] = res
- evt = SpiderFootEvent("RAW_RIR_DATA", res['content'], self.__name__,
- self.currentEventSrc)
+ evt = SpiderFootEvent("RAW_RIR_DATA", res['content'], self.__name__,
+ self.currentEventSrc)
self.notifyListeners(evt)
return res
@@ -130,14 +131,14 @@ class sfp_ir(SpiderFootPlugin):
for rec in data:
for d in rec:
if d["key"].lower().startswith("org") or \
- d["key"].lower().startswith("as") or \
- d["key"].lower().startswith("aut") or \
- d["key"].lower().startswith("descr") and \
- d["value"].lower() not in [ "null", "none", "none specified" ]:
+ d["key"].lower().startswith("as") or \
+ d["key"].lower().startswith("aut") or \
+ d["key"].lower().startswith("descr") and \
+ d["value"].lower() not in ["null", "none", "none specified"]:
if ownerinfo.has_key(d["key"]):
ownerinfo[d["key"]].append(d["value"])
else:
- ownerinfo[d["key"]] = [ d["value"] ]
+ ownerinfo[d["key"]] = [d["value"]]
self.sf.debug("Returning ownerinfo: " + str(ownerinfo))
return ownerinfo
@@ -197,7 +198,7 @@ class sfp_ir(SpiderFootPlugin):
self.opts['_internettlds'])
# Slightly more complex..
- rx = [
+ rx = [
'^{0}[-_/\'\"\\\.,\?\! ]',
'[-_/\'\"\\\.,\?\! ]{0}$',
'[-_/\'\"\\\.,\?\! ]{0}[-_/\'\"\\\.,\?\! ]'
@@ -217,7 +218,7 @@ class sfp_ir(SpiderFootPlugin):
for r in rx:
if re.match(r.format(kw), string, re.IGNORECASE) is not None:
return True
-
+
return False
# Owns the AS or not?
@@ -269,7 +270,7 @@ class sfp_ir(SpiderFootPlugin):
if len(ownerinfo) > 0:
evt = SpiderFootEvent("BGP_AS_PEER", ownertext,
- self.__name__, event)
+ self.__name__, event)
self.notifyListeners(evt)
# BGP AS Owner -> Other Netblocks
@@ -288,7 +289,7 @@ class sfp_ir(SpiderFootPlugin):
# Technically this netblock was identified via the AS, not
# the original IP event, so link it to asevt, not event.
evt = SpiderFootEvent("NETBLOCK_OWNER", netblock,
- self.__name__, event)
+ self.__name__, event)
self.notifyListeners(evt)
return None
diff --git a/modules/sfp_junkfiles.py b/modules/sfp_junkfiles.py
index 8c809975..85392d10 100644
--- a/modules/sfp_junkfiles.py
+++ b/modules/sfp_junkfiles.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_junkfiles
# Purpose: From Spidering, identifies backup and temporary files.
#
@@ -8,21 +8,22 @@
# Created: 23/08/2014
# Copyright: (c) Steve Micallef 2014
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_junkfiles(SpiderFootPlugin):
"""Junk Files:Looks for old/temporary and other similar files."""
# Default options
opts = {
- 'fileexts': [ 'tmp', 'bak', 'old', 'backup', 'new'],
- 'urlextstry': [ 'html', 'htm', 'php', 'jsp', 'txt', 'js' ],
- 'files': [ 'x', 'xxx', 'crap', 'old', 'a', 'aaa', 'z', 'zzz',
- 'out', 'sql', "passwd", ".htaccess", ".htpasswd",
- "Thumbs.db", "asd", "asdf" ],
- 'dirs': [ 'zip', 'tar.gz', 'tgz', 'tar' ]
+ 'fileexts': ['tmp', 'bak', 'old', 'backup', 'new'],
+ 'urlextstry': ['html', 'htm', 'php', 'jsp', 'txt', 'js'],
+ 'files': ['x', 'xxx', 'crap', 'old', 'a', 'aaa', 'z', 'zzz',
+ 'out', 'sql', "passwd", ".htaccess", ".htpasswd",
+ "Thumbs.db", "asd", "asdf"],
+ 'dirs': ['zip', 'tar.gz', 'tgz', 'tar']
}
# Option descriptions
@@ -44,13 +45,13 @@ class sfp_junkfiles(SpiderFootPlugin):
# What events is this module interested in for input
def watchedEvents(self):
- return [ "LINKED_URL_INTERNAL" ]
+ return ["LINKED_URL_INTERNAL"]
# What events this module produces
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "JUNK_FILE" ]
+ return ["JUNK_FILE"]
# Handle events sent to this module
def handleEvent(self, event):
@@ -68,7 +69,7 @@ class sfp_junkfiles(SpiderFootPlugin):
# http://www/blah/abc.html -> try http://www/blah/abc.html.[fileexts]
for ext in self.opts['urlextstry']:
if "." + ext + "?" in eventData or "." + ext + "#" in eventData or \
- eventData.endswith(ext):
+ eventData.endswith(ext):
bits = eventData.split("?")
for x in self.opts['fileexts']:
self.sf.debug("Trying " + x + " against " + eventData)
@@ -77,18 +78,18 @@ class sfp_junkfiles(SpiderFootPlugin):
self.results.append(fetch)
else:
continue
- res = self.sf.fetchUrl(fetch,
- timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ res = self.sf.fetchUrl(fetch,
+ timeout=self.opts['_fetchtimeout'],
+ useragent=self.opts['_useragent'])
if res['content'] is not None and res['code'] != "404":
- evt = SpiderFootEvent("JUNK_FILE", fetch,
- self.__name__, event)
+ evt = SpiderFootEvent("JUNK_FILE", fetch,
+ self.__name__, event)
self.notifyListeners(evt)
# http://www or http://www/
# -> try index pages
if eventData.endswith("/") or eventData.count("/") == 2:
- for ext in [ "index.html", "index.htm", "default.htm" ]:
+ for ext in ["index.html", "index.htm", "default.htm"]:
self.sf.debug("Trying " + ext + " against " + eventData)
for x in self.opts['fileexts']:
fetch = eventData + "/" + ext + "." + x
@@ -97,11 +98,11 @@ class sfp_junkfiles(SpiderFootPlugin):
else:
continue
res = self.sf.fetchUrl(fetch,
- timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ timeout=self.opts['_fetchtimeout'],
+ useragent=self.opts['_useragent'])
if res['content'] is not None and res['code'] != "404":
evt = SpiderFootEvent("JUNK_FILE", fetch,
- self.__name__, event)
+ self.__name__, event)
self.notifyListeners(evt)
base = self.sf.urlBaseDir(eventData)
@@ -112,17 +113,17 @@ class sfp_junkfiles(SpiderFootPlugin):
# http://www/blah/abc.html -> try http://www/blah.[dirs]
for dirfile in self.opts['dirs']:
self.sf.debug("Trying " + dirfile + " against " + eventData)
- fetch = base[0:len(base)-1] + "." + dirfile
+ fetch = base[0:len(base) - 1] + "." + dirfile
if fetch not in self.results:
self.results.append(fetch)
else:
continue
res = self.sf.fetchUrl(fetch,
- timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ timeout=self.opts['_fetchtimeout'],
+ useragent=self.opts['_useragent'])
if res['content'] is not None and res['code'] != "404":
evt = SpiderFootEvent("JUNK_FILE", fetch,
- self.__name__, event)
+ self.__name__, event)
self.notifyListeners(evt)
# http://www/blah/abc.html -> try http://www/blah/[files]
@@ -134,11 +135,11 @@ class sfp_junkfiles(SpiderFootPlugin):
else:
continue
res = self.sf.fetchUrl(fetch,
- timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ timeout=self.opts['_fetchtimeout'],
+ useragent=self.opts['_useragent'])
if res['content'] is not None and res['code'] != "404":
evt = SpiderFootEvent("JUNK_FILE", fetch,
- self.__name__, event)
+ self.__name__, event)
self.notifyListeners(evt)
return None
diff --git a/modules/sfp_malcheck.py b/modules/sfp_malcheck.py
index 42849972..b289b773 100644
--- a/modules/sfp_malcheck.py
+++ b/modules/sfp_malcheck.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_malcheck
# Purpose: Checks if an ASN, IP or domain is malicious.
#
@@ -8,7 +8,7 @@
# Created: 14/12/2013
# Copyright: (c) Steve Micallef, 2013
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
from netaddr import IPAddress, IPNetwork
import re
@@ -19,7 +19,7 @@ malchecks = {
'id': 'abusezeusdomain',
'type': 'list',
'checks': ['domain'],
- 'url': 'https://zeustracker.abuse.ch/blocklist.php?download=baddomains'
+ 'url': 'https://zeustracker.abuse.ch/blocklist.php?download=baddomains'
},
'abuse.ch Zeus Tracker (IP)': {
'id': 'abusezeusip',
@@ -31,34 +31,34 @@ malchecks = {
'id': 'abusespydomain',
'type': 'list',
'checks': ['domain'],
- 'url': 'https://spyeyetracker.abuse.ch/blocklist.php?download=domainblocklist'
+ 'url': 'https://spyeyetracker.abuse.ch/blocklist.php?download=domainblocklist'
},
'abuse.ch SpyEye Tracker (IP)': {
'id': 'abusespyip',
'type': 'list',
'checks': ['ip', 'netblock'],
- 'url': 'https://spyeyetracker.abuse.ch/blocklist.php?download=ipblocklist'
+ 'url': 'https://spyeyetracker.abuse.ch/blocklist.php?download=ipblocklist'
},
'abuse.ch Palevo Tracker (Domain)': {
'id': 'abusepalevodomain',
'type': 'list',
'checks': ['domain'],
- 'url': 'https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist'
+ 'url': 'https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist'
},
'abuse.ch Palevo Tracker (IP)': {
'id': 'abusepalevoip',
'type': 'list',
'checks': ['ip', 'netblock'],
- 'url': 'https://palevotracker.abuse.ch/blocklists.php?download=ipblocklist'
+ 'url': 'https://palevotracker.abuse.ch/blocklists.php?download=ipblocklist'
},
'Google SafeBrowsing (Domain/IP)': {
'id': 'googledomain',
'type': 'query',
- 'checks': ['domain', 'ip' ],
+ 'checks': ['domain', 'ip'],
'url': 'http://www.google.com/safebrowsing/diagnostic?site={0}',
- 'badregex': [ '.*may harm your computer.*',
- '.*this site has hosted malicious software.*'
- ],
+ 'badregex': ['.*may harm your computer.*',
+ '.*this site has hosted malicious software.*'
+ ],
'goodregex': []
},
'Google SafeBrowsing (ASN)': {
@@ -66,9 +66,9 @@ malchecks = {
'type': 'query',
'checks': ['asn'],
'url': 'http://www.google.com/safebrowsing/diagnostic?site=AS:{0}',
- 'badregex': [ '.*for example.*, that appeared to function as intermediaries.*',
- '.*this network has hosted sites that have distributed malicious.*'
- ],
+ 'badregex': ['.*for example.*, that appeared to function as intermediaries.*',
+ '.*this network has hosted sites that have distributed malicious.*'
+ ],
'goodregex': []
},
'McAfee Site Advisor': {
@@ -116,91 +116,92 @@ malchecks = {
'TOR Node List': {
'id': 'tornodes',
'type': 'list',
- 'checks': [ 'ip', 'netblock' ],
+ 'checks': ['ip', 'netblock'],
'url': 'http://torstatus.blutmagie.de/ip_list_all.php/Tor_ip_list_ALL.csv'
},
'blocklist.de List': {
'id': 'blocklistde',
'type': 'list',
- 'checks': [ 'ip', 'netblock' ],
+ 'checks': ['ip', 'netblock'],
'url': 'http://lists.blocklist.de/lists/all.txt'
},
'Autoshun.org List': {
'id': 'autoshun',
'type': 'list',
- 'checks': [ 'ip', 'netblock' ],
+ 'checks': ['ip', 'netblock'],
'url': 'http://www.autoshun.org/files/shunlist.csv',
'regex': '{0},.*'
},
'Internet Storm Center': {
'id': 'isc',
'type': 'query',
- 'checks': [ 'ip' ],
+ 'checks': ['ip'],
'url': 'https://isc.sans.edu/api/ip/{0}',
- 'badregex': [ '.*attacks.*' ],
+ 'badregex': ['.*attacks.*'],
'goodregex': []
},
'AlienVault IP Reputation Database': {
'id': 'alienvault',
'type': 'list',
- 'checks': [ 'ip', 'netblock' ],
+ 'checks': ['ip', 'netblock'],
'url': 'https://reputation.alienvault.com/reputation.generic',
'regex': '{0} #.*'
},
'OpenBL.org Blacklist': {
'id': 'openbl',
'type': 'list',
- 'checks': [ 'ip', 'netblock' ],
+ 'checks': ['ip', 'netblock'],
'url': 'http://www.openbl.org/lists/base.txt'
},
'ThreatExpert.com Database': {
'id': 'threatexpert',
'type': 'query',
- 'checks': [ 'ip', 'domain' ],
+ 'checks': ['ip', 'domain'],
'url': 'http://www.threatexpert.com/reports.aspx?find={0}&tf=3',
- 'badregex': [ '.*<strong>Findings</strong>.*' ],
+ 'badregex': ['.*<strong>Findings</strong>.*'],
'goodregex': []
},
'TotalHash.com Database': {
'id': 'totalhash',
'type': 'query',
- 'checks': [ 'ip', 'domain' ],
+ 'checks': ['ip', 'domain'],
'url': 'http://totalhash.com/search/dnsrr:*{0}%20or%20ip:{0}',
- 'badregex': [ '.*<a href=\"/analysis.*' ],
+ 'badregex': ['.*<a href=\"/analysis.*'],
'goodregex': []
},
'Nothink.org SSH Scanners': {
'id': 'nothinkssh',
'type': 'list',
- 'checks': [ 'ip', 'netblock', 'domain' ],
+ 'checks': ['ip', 'netblock', 'domain'],
'url': 'http://www.nothink.org/blacklist/blacklist_ssh_week.txt'
},
'Nothink.org Malware IRC Traffic': {
'id': 'nothinkirc',
'type': 'list',
- 'checks': [ 'ip', 'netblock', 'domain' ],
+ 'checks': ['ip', 'netblock', 'domain'],
'url': 'http://www.nothink.org/blacklist/blacklist_malware_irc.txt'
},
'Nothink.org Malware HTTP Traffic': {
'id': 'nothinkhttp',
'type': 'list',
- 'checks': [ 'ip', 'netblock', 'domain' ],
+ 'checks': ['ip', 'netblock', 'domain'],
'url': 'http://www.nothink.org/blacklist/blacklist_malware_http.txt'
},
'malwaredomains.com Domains': {
'id': 'malwaredomains',
'type': 'list',
- 'checks': [ 'domain' ],
+ 'checks': ['domain'],
'url': 'http://mirror2.malwaredomains.com/files/domains.txt',
'regex': '.*\t{0}\t[a-zA-Z].*'
- }
+ }
}
+
class sfp_malcheck(SpiderFootPlugin):
"""Malicious Check:Check if a website, IP or ASN is considered malicious by various sources."""
# Default options
- opts = {
+ opts = {
'abusezeusdomain': True,
'abusezeusip': True,
'abusespydomain': True,
@@ -227,7 +228,7 @@ class sfp_malcheck(SpiderFootPlugin):
'nothinkssh': True,
'nothinkirc': True,
'nothinkhttp': True,
- 'aaacheckaffiliates': True, # prefix with aaa so they appear on the top of the UI list
+ 'aaacheckaffiliates': True, # prefix with aaa so they appear on the top of the UI list
'aaacheckcohosts': True,
'aaacacheperiod': 18,
'aaachecknetblocks': True,
@@ -264,7 +265,7 @@ class sfp_malcheck(SpiderFootPlugin):
'nothinkhttp': 'Enable Nothink.org Malware HTTP traffic check?',
'aaacheckaffiliates': "Apply checks to affiliates?",
'aaacheckcohosts': "Apply checks to sites found to be co-hosted on the target's IP?",
- 'aaacacheperiod': "Hours to cache list data before re-fetching.",
+ 'aaacacheperiod': "Hours to cache list data before re-fetching.",
'aaachecknetblocks': "Report if any malicious IPs are found within owned netblocks?",
'aaachecksubnets': "Check if any malicious IPs are found within the same subnet of the target?"
}
@@ -288,30 +289,30 @@ class sfp_malcheck(SpiderFootPlugin):
# * = be notified about all events.
def watchedEvents(self):
return ["INTERNET_NAME", "IP_ADDRESS", "BGP_AS_OWNER", "BGP_AS_MEMBER",
- "NETBLOCK_MEMBER", "AFFILIATE_INTERNET_NAME", "AFFILIATE_IPADDR",
- "CO_HOSTED_SITE", "NETBLOCK_OWNER" ]
+ "NETBLOCK_MEMBER", "AFFILIATE_INTERNET_NAME", "AFFILIATE_IPADDR",
+ "CO_HOSTED_SITE", "NETBLOCK_OWNER"]
# What events this module produces
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "MALICIOUS_ASN", "MALICIOUS_IPADDR", "MALICIOUS_INTERNET_NAME",
- "MALICIOUS_AFFILIATE_IPADDR", "MALICIOUS_AFFILIATE_INTERNET_NAME",
- "MALICIOUS_SUBNET", "MALICIOUS_COHOST", "MALICIOUS_NETBLOCK" ]
+ return ["MALICIOUS_ASN", "MALICIOUS_IPADDR", "MALICIOUS_INTERNET_NAME",
+ "MALICIOUS_AFFILIATE_IPADDR", "MALICIOUS_AFFILIATE_INTERNET_NAME",
+ "MALICIOUS_SUBNET", "MALICIOUS_COHOST", "MALICIOUS_NETBLOCK"]
# Check the regexps to see whether the content indicates maliciousness
def contentMalicious(self, content, goodregex, badregex):
# First, check for the bad indicators
if len(badregex) > 0:
for rx in badregex:
- if re.match(rx, content, re.IGNORECASE|re.DOTALL):
+ if re.match(rx, content, re.IGNORECASE | re.DOTALL):
self.sf.debug("Found to be bad")
return True
# Finally, check for good indicators
if len(goodregex) > 0:
for rx in goodregex:
- if re.match(rx, content, re.IGNORECASE|re.DOTALL):
+ if re.match(rx, content, re.IGNORECASE | re.DOTALL):
self.sf.debug("Found to be good")
return False
@@ -330,9 +331,9 @@ class sfp_malcheck(SpiderFootPlugin):
if res['content'] is None:
self.sf.error("Unable to fetch " + url.format(target), False)
return None
- if self.contentMalicious(res['content'],
- malchecks[check]['goodregex'],
- malchecks[check]['badregex']):
+ if self.contentMalicious(res['content'],
+ malchecks[check]['goodregex'],
+ malchecks[check]['badregex']):
return url.format(target)
return None
@@ -366,7 +367,7 @@ class sfp_malcheck(SpiderFootPlugin):
# Cycle through each IP and check if it's in the netblock.
if malchecks[check].has_key('regex'):
rx = malchecks[check]['regex'].replace("{0}", \
- "(\d+\.\d+\.\d+\.\d+)")
+ "(\d+\.\d+\.\d+\.\d+)")
pat = re.compile(rx, re.IGNORECASE)
self.sf.debug("New regex for " + check + ": " + rx)
for line in data['content'].split('\n'):
@@ -385,11 +386,11 @@ class sfp_malcheck(SpiderFootPlugin):
try:
if IPAddress(ip) in IPNetwork(target):
self.sf.debug(ip + " found within netblock/subnet " + \
- target + " in " + check)
+ target + " in " + check)
return url
except Exception as e:
- self.sf.debug("Error encountered parsing: " + str(e))
- continue
+ self.sf.debug("Error encountered parsing: " + str(e))
+ continue
return None
@@ -405,7 +406,7 @@ class sfp_malcheck(SpiderFootPlugin):
rxTgt = unicode(malchecks[check]['regex']).format(target)
for line in data['content'].split('\n'):
if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
+ re.match(rxTgt, line, re.IGNORECASE):
self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
return url
return None
@@ -414,8 +415,8 @@ class sfp_malcheck(SpiderFootPlugin):
for check in malchecks.keys():
cid = malchecks[check]['id']
if cid == resourceId and itemType in malchecks[check]['checks']:
- self.sf.debug("Checking maliciousness of " + target + " (" + \
- itemType + ") with: " + cid)
+ self.sf.debug("Checking maliciousness of " + target + " (" + \
+ itemType + ") with: " + cid)
if malchecks[check]['type'] == "query":
return self.resourceQuery(cid, target, itemType)
if malchecks[check]['type'] == "list":
@@ -440,7 +441,7 @@ class sfp_malcheck(SpiderFootPlugin):
if eventName == 'CO_HOSTED_SITE' and not self.opts['aaacheckcohosts']:
return None
if eventName == 'AFFILIATE_DOMAIN' or eventName == 'AFFILIATE_IPADDR' \
- and not self.opts['aaacheckaffiliates']:
+ and not self.opts['aaacheckaffiliates']:
return None
if eventName == 'NETBLOCK_OWNER' and not self.opts['aaachecknetblocks']:
return None
@@ -451,19 +452,19 @@ class sfp_malcheck(SpiderFootPlugin):
cid = malchecks[check]['id']
# If the module is enabled..
if self.opts[cid]:
- if eventName in [ 'IP_ADDRESS', 'AFFILIATE_IPADDR' ]:
+ if eventName in ['IP_ADDRESS', 'AFFILIATE_IPADDR']:
typeId = 'ip'
if eventName == 'IP_ADDRESS':
evtType = 'MALICIOUS_IPADDR'
else:
evtType = 'MALICIOUS_AFFILIATE_IPADDR'
- if eventName in [ 'BGP_AS_OWNER', 'BGP_AS_MEMBER' ]:
- typeId = 'asn'
+ if eventName in ['BGP_AS_OWNER', 'BGP_AS_MEMBER']:
+ typeId = 'asn'
evtType = 'MALICIOUS_ASN'
- if eventName in [ 'INTERNET_NAME', 'CO_HOSTED_SITE',
- 'AFFILIATE_INTERNET_NAME', ]:
+ if eventName in ['INTERNET_NAME', 'CO_HOSTED_SITE',
+ 'AFFILIATE_INTERNET_NAME', ]:
typeId = 'domain'
if eventName == "INTERNET_NAME":
evtType = "MALICIOUS_INTERNET_NAME"
diff --git a/modules/sfp_names.py b/modules/sfp_names.py
index ecdd2c72..1789a019 100644
--- a/modules/sfp_names.py
+++ b/modules/sfp_names.py
@@ -1,5 +1,5 @@
# coding: utf-8
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_names
# Purpose: Identify human names in content fetched.
#
@@ -8,16 +8,17 @@
# Created: 24/03/2014
# Copyright: (c) Steve Micallef
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import re
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_names(SpiderFootPlugin):
"""Name Extractor:Attempt to identify human names in fetched content."""
# Default options
- opts = {
+ opts = {
'algotune': 50
}
@@ -49,10 +50,10 @@ class sfp_names(SpiderFootPlugin):
self.results = dict()
d = self.builddict(["english.0", "english.2", "english.4",
- "british.0", "british.2", "british.4",
- "american.0", "american.2", "american.4"])
+ "british.0", "british.2", "british.4",
+ "american.0", "american.2", "american.4"])
self.n = self.builddict(["names.list"])
- self.fq = [ "north", "south", "east", "west", "santa", "san", "blog", "sao" ]
+ self.fq = ["north", "south", "east", "west", "santa", "san", "blog", "sao"]
# Take dictionary words out of the names list to keep things clean
self.d = list(set(d) - set(self.n))
@@ -71,7 +72,7 @@ class sfp_names(SpiderFootPlugin):
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "HUMAN_NAME" ]
+ return ["HUMAN_NAME"]
# Handle events sent to this module
def handleEvent(self, event):
@@ -91,8 +92,8 @@ class sfp_names(SpiderFootPlugin):
# Shouldn't encounter "Firstname's Secondname"
first = r[0].lower()
- if first[len(first)-2] == "'" or first[len(first)-1] == "'":
- continue
+ if first[len(first) - 2] == "'" or first[len(first) - 1] == "'":
+ continue
# Strip off trailing ' or 's
secondOrig = r[1].replace("'s", "")
diff --git a/modules/sfp_pageinfo.py b/modules/sfp_pageinfo.py
index 906e0be9..bd1457d6 100644
--- a/modules/sfp_pageinfo.py
+++ b/modules/sfp_pageinfo.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_pageinfo
# Purpose: SpiderFoot plug-in for scanning retreived content by other
# modules (such as sfp_spider) and building up information about
@@ -10,7 +10,7 @@
# Created: 02/05/2012
# Copyright: (c) Steve Micallef 2012
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import re
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
@@ -18,20 +18,21 @@ from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
# Indentify pages that use Javascript libs, handle passwords, have forms,
# permit file uploads and more to come.
regexps = dict({
- 'URL_JAVASCRIPT': list(['text/javascript', '<script ']),
- 'URL_FORM': list(['<form ', 'method=[PG]', '<input ']),
- 'URL_PASSWORD': list(['<input.*type=[\"\']*password']),
- 'URL_UPLOAD': list(['type=[\"\']*file']),
- 'URL_JAVA_APPLET': list(['<applet ']),
- 'URL_FLASH': list(['\.swf[ \'\"]'])
+ 'URL_JAVASCRIPT': list(['text/javascript', '<script ']),
+ 'URL_FORM': list(['<form ', 'method=[PG]', '<input ']),
+ 'URL_PASSWORD': list(['<input.*type=[\"\']*password']),
+ 'URL_UPLOAD': list(['type=[\"\']*file']),
+ 'URL_JAVA_APPLET': list(['<applet ']),
+ 'URL_FLASH': list(['\.swf[ \'\"]'])
})
+
class sfp_pageinfo(SpiderFootPlugin):
"""Page Info:Obtain information about web pages (do they take passwords, do they contain forms,
etc.)"""
# Default options
- opts = { }
+ opts = {}
results = dict()
@@ -50,8 +51,8 @@ etc.)"""
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "URL_STATIC", "URL_JAVASCRIPT", "URL_FORM", "URL_PASSWORD",
- "URL_UPLOAD", "URL_JAVA_APPLET", "URL_FLASH", "PROVIDER_JAVASCRIPT" ]
+ return ["URL_STATIC", "URL_JAVASCRIPT", "URL_FORM", "URL_PASSWORD",
+ "URL_UPLOAD", "URL_JAVA_APPLET", "URL_FLASH", "PROVIDER_JAVASCRIPT"]
# Handle events sent to this module
def handleEvent(self, event):
@@ -65,7 +66,7 @@ etc.)"""
eventName = event.eventType
srcModuleName = event.module
eventData = event.data
- eventSource = event.sourceEvent.data # will be the URL of the raw data
+ eventSource = event.sourceEvent.data # will be the URL of the raw data
self.sf.debug("Received event, " + eventName + ", from " + srcModuleName)
@@ -93,7 +94,7 @@ etc.)"""
self.sf.info("Matched " + regexpGrp + " in content from " + eventSource)
self.results[eventSource].append(regexpGrp)
evt = SpiderFootEvent(regexpGrp, eventSource,
- self.__name__, event.sourceEvent)
+ self.__name__, event.sourceEvent)
self.notifyListeners(evt)
# If no regexps were matched, consider this a static page
@@ -110,7 +111,7 @@ etc.)"""
if '://' in match and not self.getTarget().matches(self.sf.urlFQDN(match)):
self.sf.debug("Externally hosted Javascript found at: " + match)
evt = SpiderFootEvent("PROVIDER_JAVASCRIPT", match,
- self.__name__, event.sourceEvent)
+ self.__name__, event.sourceEvent)
self.notifyListeners(evt)
return None
diff --git a/modules/sfp_pastebin.py b/modules/sfp_pastebin.py
index 070e17a9..78a8a181 100644
--- a/modules/sfp_pastebin.py
+++ b/modules/sfp_pastebin.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_pastebin
# Purpose: Searches Google for PasteBin content related to the domain in
# question.
@@ -9,22 +9,23 @@
# Created: 20/03/2014
# Copyright: (c) Steve Micallef 2014
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import re
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_pastebin(SpiderFootPlugin):
"""PasteBin:PasteBin scraping (via Google) to identify related content."""
# Default options
opts = {
- 'pages': 20 # Number of google results pages to iterate
+ 'pages': 20 # Number of google results pages to iterate
}
# Option descriptions
optdescs = {
- 'pages': "Number of search results pages to iterate through."
+ 'pages': "Number of search results pages to iterate through."
}
results = list()
@@ -38,13 +39,13 @@ class sfp_pastebin(SpiderFootPlugin):
# What events is this module interested in for input
def watchedEvents(self):
- return [ "INTERNET_NAME", "IP_ADDRESS", "EMAILADDR" ]
+ return ["INTERNET_NAME", "IP_ADDRESS", "EMAILADDR"]
# What events this module produces
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "SEARCH_ENGINE_WEB_CONTENT", "PASTEBIN_CONTENT" ]
+ return ["SEARCH_ENGINE_WEB_CONTENT", "PASTEBIN_CONTENT"]
def handleEvent(self, event):
eventName = event.eventType
@@ -57,9 +58,9 @@ class sfp_pastebin(SpiderFootPlugin):
self.results.append(eventData)
# Sites hosted on the domain
- pages = self.sf.googleIterate("site:pastebin.com +\"" + eventData + "\"",
- dict(limit=self.opts['pages'],
- useragent=self.opts['_useragent'], timeout=self.opts['_fetchtimeout']))
+ pages = self.sf.googleIterate("site:pastebin.com +\"" + eventData + "\"",
+ dict(limit=self.opts['pages'],
+ useragent=self.opts['_useragent'], timeout=self.opts['_fetchtimeout']))
if pages is None:
self.sf.info("No results returned from Google PasteBin search.")
@@ -76,8 +77,8 @@ class sfp_pastebin(SpiderFootPlugin):
return None
# Submit the google results for analysis
- evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", pages[page],
- self.__name__, event)
+ evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", pages[page],
+ self.__name__, event)
self.notifyListeners(evt)
# Fetch the PasteBin page
@@ -97,24 +98,24 @@ class sfp_pastebin(SpiderFootPlugin):
return None
res = self.sf.fetchUrl(link, timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ useragent=self.opts['_useragent'])
if res['content'] is None:
self.sf.debug("Ignoring " + link + " as no data returned")
continue
evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT",
- res['content'], self.__name__, event)
+ res['content'], self.__name__, event)
self.notifyListeners(evt)
# Sometimes pastebin search results false positives
if re.search("[^a-zA-Z\-\_0-9]" + re.escape(eventData) + \
- "[^a-zA-Z\-\_0-9]", res['content'], re.IGNORECASE) is None:
+ "[^a-zA-Z\-\_0-9]", res['content'], re.IGNORECASE) is None:
continue
try:
- startIndex = res['content'].index(eventData)-120
- endIndex = startIndex+len(eventData)+240
+ startIndex = res['content'].index(eventData) - 120
+ endIndex = startIndex + len(eventData) + 240
except BaseException as e:
self.sf.debug("String not found in pastebin content.")
continue
@@ -122,9 +123,8 @@ class sfp_pastebin(SpiderFootPlugin):
data = res['content'][startIndex:endIndex]
evt = SpiderFootEvent("PASTEBIN_CONTENT",
- "<SFURL>" + link + "</SFURL>\n" + "\"... " + data + " ...\"",
- self.__name__, event)
+ "<SFURL>" + link + "</SFURL>\n" + "\"... " + data + " ...\"",
+ self.__name__, event)
self.notifyListeners(evt)
-
# End of sfp_pastebin class
diff --git a/modules/sfp_pgp.py b/modules/sfp_pgp.py
index 6ee6767d..6f26dfe9 100644
--- a/modules/sfp_pgp.py
+++ b/modules/sfp_pgp.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_pgp
# Purpose: SpiderFoot plug-in for looking up received e-mails in PGP
# key servers as well as finding e-mail addresses belonging to
@@ -10,11 +10,12 @@
# Created: 17/02/2015
# Copyright: (c) Steve Micallef 2015
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import re
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_pgp(SpiderFootPlugin):
"""PGP Key Look-up:Look up e-mail addresses in PGP public key servers."""
@@ -23,14 +24,14 @@ class sfp_pgp(SpiderFootPlugin):
# Default options
opts = {
# options specific to this module
- 'keyserver_search': "http://pgp.mit.edu/pks/lookup?op=index&search=",
- 'keyserver_fetch': "http://pgp.mit.edu/pks/lookup?op=get&search="
+ 'keyserver_search': "http://pgp.mit.edu/pks/lookup?op=index&search=",
+ 'keyserver_fetch': "http://pgp.mit.edu/pks/lookup?op=get&search="
}
# Option descriptions
optdescs = {
'keyserver_search': "PGP public key server URL to find e-mail addresses on a domain. Domain will get appended.",
- 'keyserver_fetch': "PGP public key server URL to find the public key for an e-mail address. Email address will get appended."
+ 'keyserver_fetch': "PGP public key server URL to find the public key for an e-mail address. Email address will get appended."
}
def setup(self, sfc, userOpts=dict()):
@@ -49,7 +50,7 @@ class sfp_pgp(SpiderFootPlugin):
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "EMAILADDR", "PGP_KEY" ]
+ return ["EMAILADDR", "PGP_KEY"]
# Handle events sent to this module
def handleEvent(self, event):
@@ -68,8 +69,8 @@ class sfp_pgp(SpiderFootPlugin):
# Get e-mail addresses on this domain
if eventName == "DOMAIN_NAME":
res = self.sf.fetchUrl(self.opts['keyserver_search'] + eventData,
- timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ timeout=self.opts['_fetchtimeout'],
+ useragent=self.opts['_useragent'])
if res['content'] is not None:
pat = re.compile("([a-zA-Z\.0-9_\-]+@[a-zA-Z\.0-9\-]+\.[a-zA-Z\.0-9\-]+)")
matches = re.findall(pat, res['content'])
@@ -90,10 +91,10 @@ class sfp_pgp(SpiderFootPlugin):
if eventName == "EMAILADDR":
res = self.sf.fetchUrl(self.opts['keyserver_fetch'] + eventData,
- timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ timeout=self.opts['_fetchtimeout'],
+ useragent=self.opts['_useragent'])
if res['content'] is not None:
- pat = re.compile("(-----BEGIN.*END.*BLOCK-----)", re.MULTILINE|re.DOTALL)
+ pat = re.compile("(-----BEGIN.*END.*BLOCK-----)", re.MULTILINE | re.DOTALL)
matches = re.findall(pat, res['content'])
for match in matches:
self.sf.debug("Found public key: " + match)
diff --git a/modules/sfp_portscan_tcp.py b/modules/sfp_portscan_tcp.py
index f8876e5b..1024e913 100644
--- a/modules/sfp_portscan_tcp.py
+++ b/modules/sfp_portscan_tcp.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_portscan_tcp
# Purpose: SpiderFoot plug-in for performing a basic TCP port scan of IP
# addresses identified.
@@ -9,7 +9,7 @@
# Created: 20/02/2013
# Copyright: (c) Steve Micallef 2013
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
from netaddr import IPAddress, IPNetwork
import socket
@@ -17,31 +17,32 @@ import random
import threading
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_portscan_tcp(SpiderFootPlugin):
"""Port Scanner - TCP:Scans for commonly open TCP ports on Internet-facing systems."""
# Default options
opts = {
- # Commonly used ports on external-facing systems
- 'ports': [ '21', '22', '23', '25', '53', '79', '80', '81', '88', '110','111',
- '113', '119', '123', '137', '138', '139', '143', '161', '179',
- '389', '443', '445', '465', '512', '513', '514', '515', '3306',
- '5432', '1521', '2638', '1433', '3389', '5900', '5901', '5902',
- '5903', '5631', '631', '636',
- '990', '992', '993', '995', '1080', '8080', '8888', '9000' ],
- 'timeout': 15,
- 'maxthreads': 10,
- 'randomize': True,
- 'netblockscan': True,
- 'netblockscanmax': 24
+ # Commonly used ports on external-facing systems
+ 'ports': ['21', '22', '23', '25', '53', '79', '80', '81', '88', '110', '111',
+ '113', '119', '123', '137', '138', '139', '143', '161', '179',
+ '389', '443', '445', '465', '512', '513', '514', '515', '3306',
+ '5432', '1521', '2638', '1433', '3389', '5900', '5901', '5902',
+ '5903', '5631', '631', '636',
+ '990', '992', '993', '995', '1080', '8080', '8888', '9000'],
+ 'timeout': 15,
+ 'maxthreads': 10,
+ 'randomize': True,
+ 'netblockscan': True,
+ 'netblockscanmax': 24
}
# Option descriptions
optdescs = {
- 'maxthreads': "Number of ports to try to open simultaneously (number of threads to spawn at once.)",
- 'ports': "The TCP ports to scan. Prefix with an '@' to iterate through a file containing ports to try (one per line), e.g. @C:\ports.txt or @/home/bob/ports.txt. Or supply a URL to load the list from there.",
- 'timeout': "Seconds before giving up on a port.",
- 'randomize': "Randomize the order of ports scanned.",
+ 'maxthreads': "Number of ports to try to open simultaneously (number of threads to spawn at once.)",
+ 'ports': "The TCP ports to scan. Prefix with an '@' to iterate through a file containing ports to try (one per line), e.g. @C:\ports.txt or @/home/bob/ports.txt. Or supply a URL to load the list from there.",
+ 'timeout': "Seconds before giving up on a port.",
+ 'randomize': "Randomize the order of ports scanned.",
'netblockscan': "Port scan all IPs within identified owned netblocks?",
'netblockscanmax': "Maximum netblock/subnet size to scan IPs within (CIDR value, 24 = /24, 16 = /16, etc.)"
}
@@ -58,8 +59,8 @@ class sfp_portscan_tcp(SpiderFootPlugin):
self.opts[opt] = userOpts[opt]
if self.opts['ports'][0].startswith("http://") or \
- self.opts['ports'][0].startswith("https://") or \
- self.opts['ports'][0].startswith("@"):
+ self.opts['ports'][0].startswith("https://") or \
+ self.opts['ports'][0].startswith("@"):
self.portlist = self.sf.optValueToData(self.opts['ports'][0])
else:
self.portlist = self.opts['ports']
@@ -78,7 +79,7 @@ class sfp_portscan_tcp(SpiderFootPlugin):
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "TCP_PORT_OPEN", "TCP_PORT_OPEN_BANNER" ]
+ return ["TCP_PORT_OPEN", "TCP_PORT_OPEN_BANNER"]
def tryPort(self, ip, port):
try:
@@ -107,8 +108,8 @@ class sfp_portscan_tcp(SpiderFootPlugin):
# Spawn threads for scanning
while i < len(portList):
self.sf.info("Spawning thread to check port: " + str(portList[i]) + " on " + ip)
- t.append(threading.Thread(name='sfp_portscan_tcp_' + str(portList[i]),
- target=self.tryPort, args=(ip, portList[i])))
+ t.append(threading.Thread(name='sfp_portscan_tcp_' + str(portList[i]),
+ target=self.tryPort, args=(ip, portList[i])))
t[i].start()
i += 1
@@ -133,7 +134,7 @@ class sfp_portscan_tcp(SpiderFootPlugin):
self.notifyListeners(evt)
if resArray[cp] != "" and resArray[cp] != True:
bevt = SpiderFootEvent("TCP_PORT_OPEN_BANNER", resArray[cp],
- self.__name__, evt)
+ self.__name__, evt)
self.notifyListeners(bevt)
@@ -155,7 +156,7 @@ class sfp_portscan_tcp(SpiderFootPlugin):
for ip in net:
ipaddr = str(ip)
- if ipaddr.split(".")[3] in [ '255', '0']:
+ if ipaddr.split(".")[3] in ['255', '0']:
continue
if '255' in ipaddr.split("."):
continue
@@ -164,7 +165,7 @@ class sfp_portscan_tcp(SpiderFootPlugin):
scanIps.append(eventData)
except BaseException as e:
self.sf.error("Strange netblock identified, unable to parse: " + \
- eventData + " (" + str(e) + ")", False)
+ eventData + " (" + str(e) + ")", False)
return None
for ipAddr in scanIps:
@@ -180,9 +181,9 @@ class sfp_portscan_tcp(SpiderFootPlugin):
for port in self.portlist:
if self.checkForStop():
return None
-
+
if i < self.opts['maxthreads']:
- portArr.append(port)
+ portArr.append(port)
i += 1
else:
self.sendEvent(self.tryPortWrapper(ipAddr, portArr), event)
diff --git a/modules/sfp_sharedip.py b/modules/sfp_sharedip.py
index bb9c25f2..62ef1d4b 100644
--- a/modules/sfp_sharedip.py
+++ b/modules/sfp_sharedip.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_sharedip
# Purpose: Searches Bing and/or Robtex.com for hosts sharing the same IP.
#
@@ -8,12 +8,13 @@
# Created: 12/04/2014
# Copyright: (c) Steve Micallef 2014
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import re
import socket
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_sharedip(SpiderFootPlugin):
"""Shared IP:Search Bing and/or Robtex.com for hosts sharing the same IP."""
@@ -44,13 +45,13 @@ class sfp_sharedip(SpiderFootPlugin):
# What events is this module interested in for input
def watchedEvents(self):
- return [ "IP_ADDRESS" ]
+ return ["IP_ADDRESS"]
# What events this module produces
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "CO_HOSTED_SITE", "SEARCH_ENGINE_WEB_CONTENT" ]
+ return ["CO_HOSTED_SITE", "SEARCH_ENGINE_WEB_CONTENT"]
def validateIP(self, host, ip):
try:
@@ -125,7 +126,8 @@ class sfp_sharedip(SpiderFootPlugin):
# Bing
if self.opts['source'].lower() == "bing":
results = self.sf.bingIterate("ip:" + eventData, dict(limit=self.opts['pages'],
- useragent=self.opts['_useragent'], timeout=self.opts['_fetchtimeout']))
+ useragent=self.opts['_useragent'],
+ timeout=self.opts['_fetchtimeout']))
myres = list()
if results is None:
self.sf.info("No data returned from Bing.")
@@ -151,8 +153,8 @@ class sfp_sharedip(SpiderFootPlugin):
myres.append(site)
# Submit the bing results for analysis
- evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", results[key],
- self.__name__, event)
+ evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", results[key],
+ self.__name__, event)
self.notifyListeners(evt)
# End of sfp_sharedip class