本文整理汇总了Python中sflib.SpiderFoot.error方法的典型用法代码示例。如果您正苦于以下问题:Python SpiderFoot.error方法的具体用法?Python SpiderFoot.error怎么用?Python SpiderFoot.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sflib.SpiderFoot
的用法示例。
在下文中一共展示了SpiderFoot.error方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sflib import SpiderFoot [as 别名]
# 或者: from sflib.SpiderFoot import error [as 别名]
def __init__(self, opts):
global sf
# connect() will create the database file if it doesn't exist, but
# at least we can use this opportunity to ensure we have permissions to
# read and write to such a file.
dbh = sqlite3.connect(opts['__database'], timeout=10)
if dbh == None:
sf.fatal("Could not connect to internal database, and couldn't create " + \
opts['__database'])
dbh.text_factory = str
self.conn = dbh
self.dbh = dbh.cursor()
sf = SpiderFoot(opts)
# Now we actually check to ensure the database file has the schema set
# up correctly.
try:
self.dbh.execute('SELECT COUNT(*) FROM tbl_scan_config')
except sqlite3.Error:
# .. If not set up, we set it up.
try:
self.create()
except BaseException as e:
sf.error("Tried to set up the SpiderFoot database schema, but failed: " + \
e.args[0])
return
示例2: __init__
# 需要导入模块: from sflib import SpiderFoot [as 别名]
# 或者: from sflib.SpiderFoot import error [as 别名]
def __init__(self, opts):
global sf
# connect() will create the database file if it doesn't exist, but
# at least we can use this opportunity to ensure we have permissions to
# read and write to such a file.
dbh = sqlite3.connect(opts['__database'], timeout=10)
if dbh == None:
sf.error("Could not connect to internal database. Check that " + \
opts['__database'] + " exists and is readable and writable.")
dbh.text_factory = str
self.conn = dbh
self.dbh = dbh.cursor()
sf = SpiderFoot(opts)
# Now we actually check to ensure the database file has the schema set
# up correctly.
try:
self.dbh.execute('SELECT COUNT(*) FROM tbl_scan_config')
except sqlite3.Error:
sf.error("Found spiderfoot.db but it doesn't appear to be in " \
"the expected state - ensure the schema is created.")
return
示例3: tbl_event_types
# 需要导入模块: from sflib import SpiderFoot [as 别名]
# 或者: from sflib.SpiderFoot import error [as 别名]
#.........这里部分代码省略.........
"INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('URL_UPLOAD_HISTORIC', 'Historic URL (Accepts Uploads)', 0, 'DESCRIPTOR')",
"INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('USERNAME', 'Username', 0, 'ENTITY')",
"INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('VULNERABILITY', 'Vulnerability in Public Domain', 0, 'DESCRIPTOR')",
"INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('WEBSERVER_BANNER', 'Web Server', 0, 'DATA')",
"INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('WEBSERVER_HTTPHEADERS', 'HTTP Headers', 1, 'DATA')",
"INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('WEBSERVER_STRANGEHEADER', 'Non-Standard HTTP Header', 0, 'DATA')",
"INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('WEBSERVER_TECHNOLOGY', 'Web Technology', 0, 'DESCRIPTOR')"
]
def __init__(self, opts):
self.sf = SpiderFoot(opts)
# connect() will create the database file if it doesn't exist, but
# at least we can use this opportunity to ensure we have permissions to
# read and write to such a file.
dbh = sqlite3.connect(self.sf.myPath() + "/" + opts['__database'], timeout=10)
if dbh is None:
self.sf.fatal("Could not connect to internal database, and couldn't create " + opts['__database'])
dbh.text_factory = str
self.conn = dbh
self.dbh = dbh.cursor()
# Now we actually check to ensure the database file has the schema set
# up correctly.
try:
self.dbh.execute('SELECT COUNT(*) FROM tbl_scan_config')
self.conn.create_function("REGEXP", 2, __dbregex__)
except sqlite3.Error:
# .. If not set up, we set it up.
try:
self.create()
except BaseException as e:
self.sf.error("Tried to set up the SpiderFoot database schema, but failed: " + e.args[0])
return
#
# Back-end database operations
#
# Create the back-end schema
def create(self):
try:
for qry in self.createQueries:
self.dbh.execute(qry)
self.conn.commit()
except sqlite3.Error as e:
raise BaseException("SQL error encountered when setting up database: " + e.args[0])
# Close the database handle
def close(self):
self.dbh.close()
# Search results
# criteria is search criteria such as:
# - scan_id (search within a scan, if omitted search all)
# - type (search a specific type, if omitted search all)
# - value (search values for a specific string, if omitted search all)
# - regex (search values for a regular expression)
# ** at least two criteria must be set **
def search(self, criteria, filterFp=False):
if criteria.values().count(None) == 3:
return False
qvars = list()
qry = "SELECT ROUND(c.generated) AS generated, c.data, \
示例4: __init__
# 需要导入模块: from sflib import SpiderFoot [as 别名]
# 或者: from sflib.SpiderFoot import error [as 别名]
#.........这里部分代码省略.........
# Get internet TLDs
tlddata = self.sf.cacheGet("internet_tlds", self.config['_internettlds_cache'])
# If it wasn't loadable from cache, load it from scratch
if tlddata == None:
self.config['_internettlds'] = self.sf.optValueToData(self.config['_internettlds'])
self.sf.cachePut("internet_tlds", self.config['_internettlds'])
else:
self.config["_internettlds"] = tlddata.splitlines()
for modName in self.moduleList:
if modName == '':
continue
module = __import__('modules.' + modName, globals(), locals(), [modName])
mod = getattr(module, modName)()
mod.__name__ = modName
# A bit hacky: we pass the database object as part of the config. This
# object should only be used by the internal SpiderFoot modules writing
# to the database, which at present is only sfp__stor_db.
# Individual modules cannot create their own SpiderFootDb instance or
# we'll get database locking issues, so it all goes through this.
self.config['__sfdb__'] = dbh
# Set up the module
# Configuration is a combined global config with module-specific options
#modConfig = deepcopy(self.config)
modConfig = self.config['__modules__'][modName]['opts']
for opt in self.config.keys():
modConfig[opt] = self.config[opt]
mod.clearListeners() # clear any listener relationships from the past
mod.setup(self.sf, self.target, modConfig)
self.moduleInstances[modName] = mod
# Override the module's local socket module
# to be the SOCKS one.
if self.config['_socks1type'] != '':
mod._updateSocket(socket)
self.sf.status(modName + " module loaded.")
# Register listener modules and then start all modules sequentially
for module in self.moduleInstances.values():
for listenerModule in self.moduleInstances.values():
# Careful not to register twice or you will get duplicate events
if listenerModule in module._listenerModules:
continue
# Note the absence of a check for whether a module can register
# to itself. That is intentional because some modules will
# act on their own notifications (e.g. sfp_dns)!
if listenerModule.watchedEvents() != None:
module.registerListener(listenerModule)
dbh.scanInstanceSet(self.config['__guid__'], status='RUNNING')
self.status = "RUNNING"
# Create the "ROOT" event which un-triggered modules will link events to
rootEvent = SpiderFootEvent("INITIAL_TARGET", self.target, "SpiderFoot UI")
dbh.scanEventStore(self.config['__guid__'], rootEvent)
# Start the modules sequentially.
for module in self.moduleInstances.values():
# Check in case the user requested to stop the scan between modules initializing
if module.checkForStop():
dbh.scanInstanceSet(self.config['__guid__'], status='ABORTING')
self.status = "ABORTING"
aborted = True
break
# Many modules' start() method will return None, as most will rely on
# notifications during the scan from other modules.
module.start()
# Check if any of the modules ended due to being stopped
for module in self.moduleInstances.values():
if module.checkForStop():
aborted = True
if aborted:
self.sf.status("Scan [" + self.config['__guid__'] + "] aborted.")
dbh.scanInstanceSet(self.config['__guid__'], None, time.time() * 1000, 'ABORTED')
self.status = "ABORTED"
else:
self.sf.status("Scan [" + self.config['__guid__'] + "] completed.")
dbh.scanInstanceSet(self.config['__guid__'], None, time.time() * 1000, 'FINISHED')
self.status = "FINISHED"
except BaseException as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
self.sf.error("Unhandled exception (" + e.__class__.__name__ + ") " + \
"encountered during scan. Please report this as a bug: " + \
repr(traceback.format_exception(exc_type, exc_value, exc_traceback)), False)
self.sf.status("Scan [" + self.config['__guid__'] + "] failed: " + str(e))
dbh.scanInstanceSet(self.config['__guid__'], None, time.time() * 1000, 'ERROR-FAILED')
self.status = "ERROR-FAILED"
self.moduleInstances = None
dbh.close()
self.sf.setDbh(None)
self.sf.setScanId(None)
示例5: tbl_event_types
# 需要导入模块: from sflib import SpiderFoot [as 别名]
# 或者: from sflib.SpiderFoot import error [as 别名]
#.........这里部分代码省略.........
"INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_PASSWORD', 'URL (Accepts Passwords)', 0)",
"INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_UPLOAD', 'URL (Accepts Uploads)', 0)",
"INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('WEBSERVER_BANNER', 'Web Server', 0)",
"INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('WEBSERVER_HTTPHEADERS', 'HTTP Headers', 1)",
"INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('WEBSERVER_STRANGEHEADER', 'Non-Standard HTTP Header', 0)",
"INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('WEBSERVER_TECHNOLOGY', 'Web Technology', 0)"
]
def __init__(self, opts):
self.sf = SpiderFoot(opts)
# connect() will create the database file if it doesn't exist, but
# at least we can use this opportunity to ensure we have permissions to
# read and write to such a file.
dbh = sqlite3.connect(self.sf.myPath() + "/" + opts['__database'], timeout=10)
if dbh == None:
self.sf.fatal("Could not connect to internal database, and couldn't create " + \
opts['__database'])
dbh.text_factory = str
self.conn = dbh
self.dbh = dbh.cursor()
# Now we actually check to ensure the database file has the schema set
# up correctly.
try:
self.dbh.execute('SELECT COUNT(*) FROM tbl_scan_config')
self.conn.create_function("REGEXP", 2, __dbregex__)
except sqlite3.Error:
# .. If not set up, we set it up.
try:
self.create()
except BaseException as e:
self.sf.error("Tried to set up the SpiderFoot database schema, but failed: " + \
e.args[0])
return
#
# Back-end database operations
#
# Create the back-end schema
def create(self):
try:
for qry in self.createQueries:
self.dbh.execute(qry)
self.conn.commit()
except sqlite3.Error as e:
raise BaseException("SQL error encountered when setting up database: " +
e.args[0])
# Close the database handle
def close(self):
self.dbh.close()
# Search results
# criteria is search criteria such as:
# - scan_id (search within a scan, if omitted search all)
# - type (search a specific type, if omitted search all)
# - value (search values for a specific string, if omitted search all)
# - regex (search values for a regular expression)
# ** at least two criteria must be set **
def search(self, criteria):
if criteria.values().count(None) == 3:
return False
示例6: __init__
# 需要导入模块: from sflib import SpiderFoot [as 别名]
# 或者: from sflib.SpiderFoot import error [as 别名]
#.........这里部分代码省略.........
# Create a unique ID for this scan and create it in the back-end DB.
self.config['__guid__'] = dbh.scanInstanceGenGUID(self.target)
self.sf.setScanId(self.config['__guid__'])
self.myId = self.config['__guid__']
dbh.scanInstanceCreate(self.config['__guid__'], self.name, self.target)
dbh.scanInstanceSet(self.config['__guid__'], time.time() * 1000, None, 'STARTING')
self.status = "STARTING"
# Save the config current set for this scan
self.config['_modulesenabled'] = self.moduleList
dbh.scanConfigSet(self.config['__guid__'], self.sf.configSerialize(self.config))
self.sf.status("Scan [" + self.config['__guid__'] + "] initiated.")
# moduleList = list of modules the user wants to run
try:
for modName in self.moduleList:
if modName == '':
continue
module = __import__('modules.' + modName, globals(), locals(), [modName])
mod = getattr(module, modName)()
mod.__name__ = modName
# A bit hacky: we pass the database object as part of the config. This
# object should only be used by the internal SpiderFoot modules writing
# to the database, which at present is only sfp_stor_db.
# Individual modules cannot create their own SpiderFootDb instance or
# we'll get database locking issues, so it all goes through this.
self.config['__sfdb__'] = dbh
# Set up the module
# Configuration is a combined global config with module-specific options
#modConfig = deepcopy(self.config)
modConfig = self.config['__modules__'][modName]['opts']
for opt in self.config.keys():
modConfig[opt] = self.config[opt]
mod.clearListeners() # clear any listener relationships from the past
mod.setup(self.sf, self.target, modConfig)
self.moduleInstances[modName] = mod
self.sf.status(modName + " module loaded.")
# Register listener modules and then start all modules sequentially
for module in self.moduleInstances.values():
for listenerModule in self.moduleInstances.values():
# Careful not to register twice or you will get duplicate events
if listenerModule in module._listenerModules:
continue
# Note the absence of a check for whether a module can register
# to itself. That is intentional because some modules will
# act on their own notifications (e.g. sfp_dns)!
if listenerModule.watchedEvents() != None:
module.registerListener(listenerModule)
dbh.scanInstanceSet(self.config['__guid__'], status='RUNNING')
self.status = "RUNNING"
# Create the "ROOT" event which un-triggered modules will link events to
rootEvent = SpiderFootEvent("INITIAL_TARGET", self.target, "SpiderFoot UI")
dbh.scanEventStore(self.config['__guid__'], rootEvent)
# Start the modules sequentially.
for module in self.moduleInstances.values():
# Check in case the user requested to stop the scan between modules initializing
if module.checkForStop():
dbh.scanInstanceSet(self.config['__guid__'], status='ABORTING')
self.status = "ABORTING"
aborted = True
break
# Many modules' start() method will return None, as most will rely on
# notifications during the scan from other modules.
module.start()
# Check if any of the modules ended due to being stopped
for module in self.moduleInstances.values():
if module.checkForStop():
aborted = True
if aborted:
self.sf.status("Scan [" + self.config['__guid__'] + "] aborted.")
dbh.scanInstanceSet(self.config['__guid__'], None, time.time() * 1000, 'ABORTED')
self.status = "ABORTED"
else:
self.sf.status("Scan [" + self.config['__guid__'] + "] completed.")
dbh.scanInstanceSet(self.config['__guid__'], None, time.time() * 1000, 'FINISHED')
self.status = "FINISHED"
except Exception as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
self.sf.error("Unhandled exception encountered during scan. " + \
"Please report this as a bug: " + \
repr(traceback.format_exception(exc_type, exc_value, exc_traceback)), False)
self.sf.status("Scan [" + self.config['__guid__'] + "] failed: " + str(e))
dbh.scanInstanceSet(self.config['__guid__'], None, time.time() * 1000, 'ERROR-FAILED')
self.status = "ERROR-FAILED"
self.moduleInstances = None
dbh.close()
self.sf.setDbh(None)
self.sf.setScanId(None)