def get_ip(ip, port, rate):
if os.path.exists("mres.txt"):
os.remove("mres.txt")
if os.path.exists("nres.xml"):
os.remove("nres.xml")
os.system('masscan ' + ip + ' -Pn --ports ' + port + ' ' + rate + ' -oG mres.txt')
hosts = {}
with open('mres.txt', 'r') as f:
for line in f.readlines():
line = (line.split("#")[0]).strip()
if line == "":
continue
m = re.search("Host: (\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}).*Ports: (\d{1,})", line)
if m is None:
continue
if m.group(1) in hosts.keys():
hosts[m.group(1)].append(m.group(2))
else:
hosts[m.group(1)] = [m.group(2)]
for host in hosts:
os.system("%s -p %s --script vulners --script-args mincvss=5.0 --append-output -oX nres.xml" % ("nmap -Pn -sV -O --osscan-limit " + host, ",".join(hosts[host])))
#print("debug: " + "%s -p %s --script vulners --script-args mincvss=5.0 --append-output -oX nres.xml" % ("nmap -Pn -sV -O --osscan-limit " + host, ",".join(hosts[host])))
try:
file = open('/usr/somefile')
except IOError as e:
os.system("ls")
else: <<--пишет ошибка в связи с форматированием но не пойму что не так.. отступы на месте
with file:
print('ls not found')
else:
^
TabError: inconsistent use of tabs and spaces in indentation
Traceback (most recent call last):
File "./t.py", line 4, in
j = json.loads("{u'hashmap': [{u'hash': u'6d3f4796275bb54c21a33b82f399cc6d', u'key': u'assessment'}]}")
File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 1 column 2 (char 1)
index.html