本文整理汇总了Python中sflib.SpiderFoot.updateSocket方法的典型用法代码示例。如果您正苦于以下问题:Python SpiderFoot.updateSocket方法的具体用法?Python SpiderFoot.updateSocket怎么用?Python SpiderFoot.updateSocket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sflib.SpiderFoot
的用法示例。
在下文中一共展示了SpiderFoot.updateSocket方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sflib import SpiderFoot [as 别名]
# 或者: from sflib.SpiderFoot import updateSocket [as 别名]
class SpiderFootScanner:
moduleInstances = None
status = "UNKNOWN"
myId = None
def __init__(self, name, target, moduleList, globalOpts, moduleOpts):
self.config = deepcopy(globalOpts)
self.sf = SpiderFoot(self.config)
self.target = target
self.moduleList = moduleList
self.name = name
return
# Status of the currently running scan (if any)
def scanStatus(self, id):
if id != self.myId:
return "UNKNOWN"
return self.status
# Stop a scan (id variable is unnecessary for now given that only one simultaneous
# scan is permitted.)
def stopScan(self, id):
if id != self.myId:
return None
if self.moduleInstances == None:
return None
for modName in self.moduleInstances.keys():
self.moduleInstances[modName].stopScanning()
# Start running a scan
def startScan(self):
self.moduleInstances = dict()
dbh = SpiderFootDb(self.config)
self.sf.setDbh(dbh)
aborted = False
# 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:
# Process global options that point to other places for data
# If a SOCKS server was specified, set it up
if self.config['_socks1type'] != '':
socksType = socks.PROXY_TYPE_SOCKS4
socksDns = self.config['_socks6dns']
socksAddr = self.config['_socks2addr']
socksPort = int(self.config['_socks3port'])
socksUsername = ''
socksPassword = ''
if self.config['_socks1type'] == '4':
socksType = socks.PROXY_TYPE_SOCKS4
if self.config['_socks1type'] == '5':
socksType = socks.PROXY_TYPE_SOCKS5
socksUsername = self.config['_socks4user']
socksPassword = self.config['_socks5pwd']
if self.config['_socks1type'] == 'HTTP':
socksType = socks.PROXY_TYPE_HTTP
self.sf.debug("SOCKS: " + socksAddr + ":" + str(socksPort) + \
"(" + socksUsername + ":" + socksPassword + ")")
socks.setdefaultproxy(socksType, socksAddr, socksPort,
socksDns, socksUsername, socksPassword)
# Override the default socket and getaddrinfo calls with the
# SOCKS ones
socket.socket = socks.socksocket
socket.create_connection = socks.create_connection
socket.getaddrinfo = socks.getaddrinfo
self.sf.updateSocket(socket)
# Override the default DNS server
if self.config['_dnsserver'] != "":
res = dns.resolver.Resolver()
res.nameservers = [ self.config['_dnsserver'] ]
dns.resolver.override_system_resolver(res)
else:
dns.resolver.restore_system_resolver()
# Set the user agent
self.config['_useragent'] = self.sf.optValueToData(self.config['_useragent'])
# Get internet TLDs
#.........这里部分代码省略.........