{"id":338691,"date":"2022-09-24T09:00:05","date_gmt":"2022-09-24T09:00:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=338691"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=338691","title":{"rendered":"<span>\u0421\u043a\u0430\u043d\u0435\u0440 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 Python \u0438\u043b\u0438 \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0430\u043d\u0435\u0440 \u0437\u0430 6 \u0447\u0430\u0441\u043e\u0432<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043c\u043d\u0435 \u0434\u043e\u0432\u0435\u043b\u043e\u0441\u044c \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u0435 \u043f\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u043d\u0430\u0443\u0447\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 \u0432 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u043c \u0433\u043e\u0440\u043e\u0434\u0435 \u0421\u0430\u043d\u043a\u0442-\u041f\u0435\u0442\u0435\u0440\u0431\u0443\u0440\u0433 \u0432 \u0421\u041f\u0431\u0413\u0423\u0422. \u041e\u0434\u043d\u043e \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u0438\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043a\u0430\u043d\u0435\u0440\u0430 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u042f\u041f  \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u043f\u0440\u0438\u0435\u0442\u0430\u0440\u043d\u043e\u0433\u043e \u041f\u041e \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u0434\u043e\u043c \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u043c\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u043a\u0430\u043d\u0435\u0440\u043e\u0432 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u043a\u043e\u0434\u043e\u043c. \u042d\u0442\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0438 \u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u043c\u043e\u0438\u043c \u043a\u043e\u043b\u043b\u0435\u0433\u043e\u0439 \u043c\u044b \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0432 \u044d\u0442\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u0442\u0430\u043f<\/h2>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u0434\u0430\u043b\u0438 \u043d\u0430 \u044d\u0442\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0434\u0432\u0430 \u0434\u043d\u044f, \u0430 \u044d\u0442\u0438 \u0434\u043d\u0438 \u0431\u044b\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0434\u043e \u043e\u0442\u0432\u0430\u043b\u0430, \u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0430\u043d\u0435\u0440 \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u043d\u043e\u0447\u044c \u043f\u0435\u0440\u0435\u0434 \u0441\u0434\u0430\u0447\u0435\u0439 \u043e\u0442\u0447\u0435\u0442\u0430 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c (\u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f). \u0420\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043a\u0430\u043d\u0430 \u043f\u043e\u0440\u0442\u043e\u0432 \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c <strong>nmap<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 kali. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u043b\u0430\u0433\u0430 -sV \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u043a\u0430\u043a\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0438 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u043e\u0440\u0442\u0435 \u0445\u043e\u0441\u0442\u0430. <\/p>\n<pre><code class=\"python\">    nm = nmap.PortScanner()     # \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f nmap     scan_raw_result = nm.scan(hosts=network_prefix, arguments='-v -n -A')<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u0430\u0440\u0441\u0438\u043b \u044d\u0442\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0441 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0440\u0442 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0445\u043e\u0441\u0442\u0430.<\/p>\n<pre><code class=\"python\">for host, result in scan_raw_result['scan'].items():         if result['status']['state'] == 'up':             print('#' * 17 + 'Host:' + host + '#' * 17)             idno = 1             for port in result['tcp']:                     print('-' * 17 + \"\u0414\u0435\u0442\u0430\u043b\u0438 TCP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430\" + '[' + str(idno) + ']' + '-' * 17)                 idno += 1                 print('\u041d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430 TCP:' + str(port))                                  print('\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0435\u043b:' + result['tcp'][port]['state'])                                  print('\u043f\u0440\u0438\u0447\u0438\u043d\u0430:' + result['tcp'][port]['reason'])                                  print('\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f:' + result['tcp'][port]['extrainfo'])                                  print('\u0418\u043c\u044f:' + result['tcp'][port]['name'])                                  cur_ver = result['tcp'][port]['version']                 print('\u0432\u0435\u0440\u0441\u0438\u044f:' + result['tcp'][port]['version'])                                  print('\u0441\u0435\u0440\u0432\u0438\u0441:' + result['tcp'][port]['product'])                 cur_soft_title = result['tcp'][port]['product']                 if ' ' in cur_soft_title:                     cur_soft_title = cur_soft_title.split()[0].lower()                 if ('windows' in cur_soft_title) or ('linux' in cur_soft_title) or ('microsoft' in cur_soft_title):                     cur_soft_title = None                 print('3 '+cur_soft_title)                                  print('CPE:' + result['tcp'][port]['cpe'])                                  print(\"\u0421\u0446\u0435\u043d\u0430\u0440\u0438\u0439:\" + result['tcp'][port]['script'])                  if cur_ver != '' and cur_soft_title != '':                     os.system('python nist_scanner.py -s {} {}'.format(str(cur_soft_title), str(cur_ver)))                 if cur_ver and cur_soft_title:                     BDU_check(cur_soft_title, cur_ver)              idno = 1             for port in result['udp']:                 print('-' * 17 + \"\u0414\u0435\u0442\u0430\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 UDP\" + '[' + str(idno) + ']' + '-' * 17)                 idno += 1                 print('\u041d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430 UDP:' + str(port))                 print('state:' + result['udp'][port]['state'])                 print('reason:' + result['udp'][port]['reason'])                 print('\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f:' + result['udp'][port]['extrainfo'])                 print('\u0418\u043c\u044f:' + result['udp'][port]['name'])                 print('\u0432\u0435\u0440\u0441\u0438\u044f:' + result['udp'][port]['version'])                 cur_ver =result['udp'][port]['version']                 cur_soft_title = result['udp'][port]['product']                 print('\u0441\u0435\u0440\u0432\u0438\u0441:' + cur_soft_title)                 if ' ' in cur_soft_title:                     cur_soft_title = cur_soft_title.split()[0].lower()                 if 'windows' in cur_soft_title or 'linux' in cur_soft_title :                     cur_soft_title = None                 print('CPE:' + result['udp'][port]['cpe'])                 print(\"script:\" + result['udp'][port]['script'])                 if cur_ver != '' and cur_soft_title != '':                     os.system('python nist_scanner.py -s {} {}'.format(str(cur_soft_title), str(cur_ver)))                 if cur_ver and cur_soft_title:                     BDU_check(cur_soft_title, cur_ver)<\/code><\/pre>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d: <a href=\"https:\/\/russianblogs.com\/article\/7503575156\/\" rel=\"noopener noreferrer nofollow\">https:\/\/russianblogs.com\/article\/7503575156\/<\/a><\/p>\n<h2>\u0410 \u043a\u0430\u043a \u0431\u044b\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435?<\/h2>\n<p>\u041c\u043d\u043e\u0433\u0438\u0435 \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u0438 \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c, \u043b\u0438\u0448\u044c \u043d\u0430\u0443\u0447\u0438\u0432\u0448\u0438\u0441\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c nmap \u0438\u0437 \u043f\u0438\u0442\u043e\u043d\u0430 \u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u0442\u043e-\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0434\u043b\u044f nmap, \u0442\u0430\u043a\u0438\u043c \u043a\u0430\u043a Vulscan, \u043d\u043e \u0442\u043e\u0436\u0435 \u043d\u0435 \u0443\u0432\u0435\u043d\u0447\u0430\u043b\u043e\u0441\u044c \u0443\u0441\u043f\u0435\u0445\u043e\u043c, \u0442\u0430\u043a \u043a\u0430\u043a (\u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043c\u043d\u0435) \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043b\u044e\u0431\u043e\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a CVE, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430.<\/p>\n<p>\u041f\u043e\u0434\u0443\u043c\u0430\u0432, \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438, \u0447\u0442\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0437\u0435\u0440\u043a\u0430\u043b\u0430 \u0431\u0430\u0437 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 &#8212; \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0438\u0434\u0435\u044f (\u043a\u0430\u043a \u0432 \u043a\u043e\u043d\u0446\u0435 \u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c). \u0421\u043a\u0430\u0447\u0430\u043b\u0438 json NIST (https:\/\/nvd.nist.gov\/feeds\/json\/cve\/1.1\/nvdcve-1.1-{YEAR}.json.gz, \u0433\u0434\u0435 \u0432\u043c\u0435\u0441\u0442\u043e {YEAR} \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043e\u0434 \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 2002-\u043d\u0430\u0448 \u0433\u043e\u0434) \u0438 \u0411\u0414\u0423 \u0424\u0421\u0422\u042d\u041a (<a href=\"https:\/\/bdu.fstec.ru\/files\/documents\/vullist.xlsx\" rel=\"noopener noreferrer nofollow\">https:\/\/bdu.fstec.ru\/files\/documents\/vullist.xlsx<\/a>). \u0417\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0431\u044b\u043b \u0432\u0437\u044f\u0442 \u043f\u0430\u0440\u0441\u0435\u0440 CVE, \u0433\u0434\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0441\u0435 CVE, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0442\u044b \u0443\u043a\u0430\u0436\u0435\u0448\u044c (<a href=\"https:\/\/github.com\/stratosphereips\/nist-cve-search-tool\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/stratosphereips\/nist-cve-search-tool<\/a>). \u041f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0432 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434 \u0441\u0435\u0431\u044f \u044d\u0442\u043e\u0442 \u043a\u043e\u0434, \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043b\u0438 \u043c\u043d\u0435 \u0434\u0430\u043d\u043d\u0430\u044f CVE \u0438\u043b\u0438 \u043d\u0435\u0442, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043f\u043e \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u042f \u043f\u043e\u0440\u044b\u043b\u0441\u044f \u0432 \u0437\u0435\u0440\u043a\u0430\u043b\u0435 NIST&#8217;\u0430 \u0432 json-\u0444\u0430\u0439\u043b\u0430\u0445 \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 cve \u0435\u0441\u0442\u044c \u043a\u043b\u044e\u0447 &#171;cpe23Uri&#187;, \u0433\u0434\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u043e\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0434\u0435\u0442 \u0440\u0435\u0447\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 CVE, \u0430 \u0442\u0430\u043a\u0436\u0435 &#171;versionEndExcluding&#187; \u0438 &#171;versionStartExcluding&#187;, \u0433\u0434\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0441 \u043a\u0430\u043a\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u0430\u043d\u043d\u0430\u044f \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c \u0438 \u043f\u043e \u043a\u0430\u043a\u0443\u044e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cf9\/fc4\/cda\/cf9fc4cda0aa94c49c1b49c421490a74.png\" alt=\"\u0421\u043a\u0440\u0438\u043d \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 cve \u043f\u043e osquery\" title=\"\u0421\u043a\u0440\u0438\u043d \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 cve \u043f\u043e osquery\" width=\"auto\" height=\"auto\" data-src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cf9\/fc4\/cda\/cf9fc4cda0aa94c49c1b49c421490a74.png\"\/><figcaption>\u0421\u043a\u0440\u0438\u043d \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 cve \u043f\u043e osquery<\/figcaption><\/figure>\n<p>\u042d\u0442\u043e \u0438 \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0430\u0440\u0441\u0438\u0442\u044c.<\/p>\n<pre><code class=\"python\">def search(j, s, v): # j-json, s-name of service, v-verison of service     i = 0     regex = re.compile(f'({s})', re.I)     for entry in j['CVE_Items']:         if 'cve' in entry:             desc = entry['configurations']['nodes']             for d in desc:                 for cpe in d['cpe_match']:                     if regex.search(cpe['cpe23Uri']) != None:                         if 'versionEndExcluding' in cpe and version.parse(v) &lt; version.parse(cpe['versionEndExcluding']):                             if 'versionStartExcluding' in cpe and version.parse(v) > version.parse(cpe['versionStartExcluding']):                                 CVEs.append(entry)                                 i += 1                                 break                             else:                                 CVEs.append(entry)                                 i += 1                                 break         if i == count:             break<\/code><\/pre>\n<p>\u041f\u043e\u043a\u0430 \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u043e\u043c json, \u043c\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u0433\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u043e\u043c csv-\u0444\u0430\u0439\u043b\u0430 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043e\u0442 \u0424\u0421\u0422\u042d\u041a, \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0431\u044b\u043b\u0438 CVE \u043a\u0430\u043a \u043e\u0442 \u0411\u0414\u0423 \u0424\u0421\u0422\u042d\u041a, \u0442\u0430\u043a \u0438 \u043e\u0442 NIST.<\/p>\n<p>\u0417\u0430\u0439\u0434\u044f \u043d\u0430 \u0441\u0430\u0439\u0442 \u0411\u0414\u0423 \u0424\u0421\u0422\u042d\u041a \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0432\u0438\u0434\u0435 xlsx \u0444\u0430\u0439\u043b\u0430. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u043f\u0435\u0440\u0435\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 csv. \u0418 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0435\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 csv, \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0411\u0414\u0423 \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0432\u0435\u0440\u043d\u044b\u0435 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"python\">def BDU_check(cur_soft_title, cur_ver):     with open('vullist_1.csv', encoding='utf-8') as csvfile:         # print(123)         reader = csv.DictReader(csvfile)         i = 0         for row in reader:             soft_title = str(row['\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u041f\u041e'])             versions = row['\u0412\u0435\u0440\u0441\u0438\u044f \u041f\u041e']             if cur_soft_title.lower() in soft_title.lower():                 cve_row = row['\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438']                 for current_service_version in versions.split(','):                      # \u043d\u0438\u0436\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u0432\u0435\u0440\u0441\u0438\u0438                     if '\u043e\u0442' in current_service_version:                         begin_version = re.search('[^\\d.]?[\\d.]+[^\\d.]?', str(current_service_version)+' ')[0]                         while re.search('[\\d]', begin_version[0]) is None:                             begin_version = begin_version[1:]                         while re.search(\"[\\d]\", begin_version[-1]) is None:                             begin_version = begin_version[:-1]                      if '\u0434\u043e' in current_service_version:                         end_version = re.search('[^\\d.]?[\\d.]+[^\\d.]?', str(current_service_version)+ ' ')                         end_version = end_version[0]                          while re.search('[^\\d]', end_version[0]):                             end_version = end_version[1:]                         while re.search('[^\\d]', end_version[-1]):                             end_version = end_version[:-1]                          cur_ver = re.search('[^\\d.]?[\\d.]+[^\\d.]?', str(cur_ver)+ ' ')                         cur_ver = cur_ver[0]                          while re.search('[^\\d]', cur_ver[0]):                              end_version = end_version[1:]                         while re.search('[^\\d]', cur_ver[-1]):                              cur_ver = cur_ver[:-1]                     flag_begin_vesion = (begin_version and (not end_version) and (version.parse(begin_version) &lt;= version.parse(cur_ver)))                     flag_end_vesion = ((not begin_version) and (end_version) and (version.parse(cur_ver) &lt;= version.parse(end_version)))                     flag_both_vesion = (begin_version and (end_version) and (version.parse(begin_version) &lt;= version.parse(cur_ver)) and (version.parse(cur_ver) &lt;= version.parse(end_version)))                                          if flag_begin_vesion or flag_end_vesion or flag_both_vesion:                         print('\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440         : ' + str(row['\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440']))                         print('CVE                   : ' + str(cve_row))                         print('\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u041f\u041e             : '+ str(row['\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u041f\u041e']))                         print('\u0412\u0435\u0440\u0441\u0438\u044f \u041f\u041e             : '+ str(row['\u0412\u0435\u0440\u0441\u0438\u044f \u041f\u041e']))                         print('\u0412\u0435\u0440\u0441\u0438\u044f \u041f\u041e \u043e\u0431\u0449. \u043f\u0440\u0438\u0437\u043d\u0430\u043a: '+ str(current_service_version))                         print('\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438   : ' + str(row['\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438']))                         print('----------------------------\\n')                         break             i += 1<\/code><\/pre>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u041f\u041e \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u0430, \u043d\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 80-90% \u043d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0438 \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043b\u0438 \u043d\u0430\u0448\u0438 \u043c\u043e\u0434\u0443\u043b\u0438 (\u043d\u0435 \u0431\u0435\u0437 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u043d\u0435\u0447\u043d\u043e), \u0443 \u043d\u0430\u0441 \u0438 \u0432\u044b\u0448\u0435\u043b \u0441\u043a\u0430\u043d\u0435\u0440, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u044c \u0432 \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u0435.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438:<\/h2>\n<p>Git-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c\u0438: <a href=\"https:\/\/github.com\/mksmp\/vulnerability_scanner\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/mksmp\/vulnerability_scanner<\/a><\/p>\n<p>\u0421\u043e\u0430\u0432\u0442\u043e\u0440: <\/p>\n<p><a href=\"https:\/\/github.com\/aleksey2101\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/aleksey2101<\/a><\/p>\n<p><a class=\"mention\" href=\"\/users\/aleksey2_1\">@aleksey2_1<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/689942\/\"> https:\/\/habr.com\/ru\/post\/689942\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043c\u043d\u0435 \u0434\u043e\u0432\u0435\u043b\u043e\u0441\u044c \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u0435 \u043f\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u043d\u0430\u0443\u0447\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 \u0432 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u043c \u0433\u043e\u0440\u043e\u0434\u0435 \u0421\u0430\u043d\u043a\u0442-\u041f\u0435\u0442\u0435\u0440\u0431\u0443\u0440\u0433 \u0432 \u0421\u041f\u0431\u0413\u0423\u0422. \u041e\u0434\u043d\u043e \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u0438\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043a\u0430\u043d\u0435\u0440\u0430 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u042f\u041f  \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u043f\u0440\u0438\u0435\u0442\u0430\u0440\u043d\u043e\u0433\u043e \u041f\u041e \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u0434\u043e\u043c \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u043c\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u043a\u0430\u043d\u0435\u0440\u043e\u0432 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u043a\u043e\u0434\u043e\u043c. \u042d\u0442\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0438 \u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u043c\u043e\u0438\u043c \u043a\u043e\u043b\u043b\u0435\u0433\u043e\u0439 \u043c\u044b \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0432 \u044d\u0442\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u0442\u0430\u043f<\/h2>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u0434\u0430\u043b\u0438 \u043d\u0430 \u044d\u0442\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0434\u0432\u0430 \u0434\u043d\u044f, \u0430 \u044d\u0442\u0438 \u0434\u043d\u0438 \u0431\u044b\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0434\u043e \u043e\u0442\u0432\u0430\u043b\u0430, \u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0430\u043d\u0435\u0440 \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u043d\u043e\u0447\u044c \u043f\u0435\u0440\u0435\u0434 \u0441\u0434\u0430\u0447\u0435\u0439 \u043e\u0442\u0447\u0435\u0442\u0430 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c (\u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f). \u0420\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043a\u0430\u043d\u0430 \u043f\u043e\u0440\u0442\u043e\u0432 \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c <strong>nmap<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 kali. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u043b\u0430\u0433\u0430 -sV \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u043a\u0430\u043a\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0438 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u043e\u0440\u0442\u0435 \u0445\u043e\u0441\u0442\u0430. <\/p>\n<pre><code class=\"python\">    nm = nmap.PortScanner()     # \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f nmap     scan_raw_result = nm.scan(hosts=network_prefix, arguments='-v -n -A')<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u0430\u0440\u0441\u0438\u043b \u044d\u0442\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0441 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0440\u0442 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0445\u043e\u0441\u0442\u0430.<\/p>\n<pre><code class=\"python\">for host, result in scan_raw_result['scan'].items():         if result['status']['state'] == 'up':             print('#' * 17 + 'Host:' + host + '#' * 17)             idno = 1             for port in result['tcp']:                     print('-' * 17 + \"\u0414\u0435\u0442\u0430\u043b\u0438 TCP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430\" + '[' + str(idno) + ']' + '-' * 17)                 idno += 1                 print('\u041d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430 TCP:' + str(port))                                  print('\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u0435\u043b:' + result['tcp'][port]['state'])                                  print('\u043f\u0440\u0438\u0447\u0438\u043d\u0430:' + result['tcp'][port]['reason'])                                  print('\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f:' + result['tcp'][port]['extrainfo'])                                  print('\u0418\u043c\u044f:' + result['tcp'][port]['name'])                                  cur_ver = result['tcp'][port]['version']                 print('\u0432\u0435\u0440\u0441\u0438\u044f:' + result['tcp'][port]['version'])                                  print('\u0441\u0435\u0440\u0432\u0438\u0441:' + result['tcp'][port]['product'])                 cur_soft_title = result['tcp'][port]['product']                 if ' ' in cur_soft_title:                     cur_soft_title = cur_soft_title.split()[0].lower()                 if ('windows' in cur_soft_title) or ('linux' in cur_soft_title) or ('microsoft' in cur_soft_title):                     cur_soft_title = None                 print('3 '+cur_soft_title)                                  print('CPE:' + result['tcp'][port]['cpe'])                                  print(\"\u0421\u0446\u0435\u043d\u0430\u0440\u0438\u0439:\" + result['tcp'][port]['script'])                  if cur_ver != '' and cur_soft_title != '':                     os.system('python nist_scanner.py -s {} {}'.format(str(cur_soft_title), str(cur_ver)))                 if cur_ver and cur_soft_title:                     BDU_check(cur_soft_title, cur_ver)              idno = 1             for port in result['udp']:                 print('-' * 17 + \"\u0414\u0435\u0442\u0430\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 UDP\" + '[' + str(idno) + ']' + '-' * 17)                 idno += 1                 print('\u041d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430 UDP:' + str(port))                 print('state:' + result['udp'][port]['state'])                 print('reason:' + result['udp'][port]['reason'])                 print('\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f:' + result['udp'][port]['extrainfo'])                 print('\u0418\u043c\u044f:' + result['udp'][port]['name'])                 print('\u0432\u0435\u0440\u0441\u0438\u044f:' + result['udp'][port]['version'])                 cur_ver =result['udp'][port]['version']                 cur_soft_title = result['udp'][port]['product']                 print('\u0441\u0435\u0440\u0432\u0438\u0441:' + cur_soft_title)                 if ' ' in cur_soft_title:                     cur_soft_title = cur_soft_title.split()[0].lower()                 if 'windows' in cur_soft_title or 'linux' in cur_soft_title :                     cur_soft_title = None                 print('CPE:' + result['udp'][port]['cpe'])                 print(\"script:\" + result['udp'][port]['script'])                 if cur_ver != '' and cur_soft_title != '':                     os.system('python nist_scanner.py -s {} {}'.format(str(cur_soft_title), str(cur_ver)))                 if cur_ver and cur_soft_title:                     BDU_check(cur_soft_title, cur_ver)<\/code><\/pre>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d: <a href=\"https:\/\/russianblogs.com\/article\/7503575156\/\" rel=\"noopener noreferrer nofollow\">https:\/\/russianblogs.com\/article\/7503575156\/<\/a><\/p>\n<h2>\u0410 \u043a\u0430\u043a \u0431\u044b\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435?<\/h2>\n<p>\u041c\u043d\u043e\u0433\u0438\u0435 \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u0438 \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c, \u043b\u0438\u0448\u044c \u043d\u0430\u0443\u0447\u0438\u0432\u0448\u0438\u0441\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c nmap \u0438\u0437 \u043f\u0438\u0442\u043e\u043d\u0430 \u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u0442\u043e-\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0434\u043b\u044f nmap, \u0442\u0430\u043a\u0438\u043c \u043a\u0430\u043a Vulscan, \u043d\u043e \u0442\u043e\u0436\u0435 \u043d\u0435 \u0443\u0432\u0435\u043d\u0447\u0430\u043b\u043e\u0441\u044c \u0443\u0441\u043f\u0435\u0445\u043e\u043c, \u0442\u0430\u043a \u043a\u0430\u043a (\u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043c\u043d\u0435) \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043b\u044e\u0431\u043e\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a CVE, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430.<\/p>\n<p>\u041f\u043e\u0434\u0443\u043c\u0430\u0432, \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438, \u0447\u0442\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0437\u0435\u0440\u043a\u0430\u043b\u0430 \u0431\u0430\u0437 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 &#8212; \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0438\u0434\u0435\u044f (\u043a\u0430\u043a \u0432 \u043a\u043e\u043d\u0446\u0435 \u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c). \u0421\u043a\u0430\u0447\u0430\u043b\u0438 json NIST (https:\/\/nvd.nist.gov\/feeds\/json\/cve\/1.1\/nvdcve-1.1-{YEAR}.json.gz, \u0433\u0434\u0435 \u0432\u043c\u0435\u0441\u0442\u043e {YEAR} \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043e\u0434 \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 2002-\u043d\u0430\u0448 \u0433\u043e\u0434) \u0438 \u0411\u0414\u0423 \u0424\u0421\u0422\u042d\u041a (<a href=\"https:\/\/bdu.fstec.ru\/files\/documents\/vullist.xlsx\" rel=\"noopener noreferrer nofollow\">https:\/\/bdu.fstec.ru\/files\/documents\/vullist.xlsx<\/a>). \u0417\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0431\u044b\u043b \u0432\u0437\u044f\u0442 \u043f\u0430\u0440\u0441\u0435\u0440 CVE, \u0433\u0434\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0441\u0435 CVE, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0442\u044b \u0443\u043a\u0430\u0436\u0435\u0448\u044c (<a href=\"https:\/\/github.com\/stratosphereips\/nist-cve-search-tool\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/stratosphereips\/nist-cve-search-tool<\/a>). \u041f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0432 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434 \u0441\u0435\u0431\u044f \u044d\u0442\u043e\u0442 \u043a\u043e\u0434, \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043b\u0438 \u043c\u043d\u0435 \u0434\u0430\u043d\u043d\u0430\u044f CVE \u0438\u043b\u0438 \u043d\u0435\u0442, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043f\u043e \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u042f \u043f\u043e\u0440\u044b\u043b\u0441\u044f \u0432 \u0437\u0435\u0440\u043a\u0430\u043b\u0435 NIST&#8217;\u0430 \u0432 json-\u0444\u0430\u0439\u043b\u0430\u0445 \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 cve \u0435\u0441\u0442\u044c \u043a\u043b\u044e\u0447 &#171;cpe23Uri&#187;, \u0433\u0434\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u043e\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0434\u0435\u0442 \u0440\u0435\u0447\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 CVE, \u0430 \u0442\u0430\u043a\u0436\u0435 &#171;versionEndExcluding&#187; \u0438 &#171;versionStartExcluding&#187;, \u0433\u0434\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0441 \u043a\u0430\u043a\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u0430\u043d\u043d\u0430\u044f \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c \u0438 \u043f\u043e \u043a\u0430\u043a\u0443\u044e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<figure class=\"\"><figcaption>\u0421\u043a\u0440\u0438\u043d \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 cve \u043f\u043e osquery<\/figcaption><\/figure>\n<p>\u042d\u0442\u043e \u0438 \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0430\u0440\u0441\u0438\u0442\u044c.<\/p>\n<pre><code class=\"python\">def search(j, s, v): # j-json, s-name of service, v-verison of service     i = 0     regex = re.compile(f'({s})', re.I)     for entry in j['CVE_Items']:         if 'cve' in entry:             desc = entry['configurations']['nodes']             for d in desc:                 for cpe in d['cpe_match']:                     if regex.search(cpe['cpe23Uri']) != None:                         if 'versionEndExcluding' in cpe and version.parse(v) &lt; version.parse(cpe['versionEndExcluding']):                             if 'versionStartExcluding' in cpe and version.parse(v) > version.parse(cpe['versionStartExcluding']):                                 CVEs.append(entry)                                 i += 1                                 break                             else:                                 CVEs.append(entry)                                 i += 1                                 break         if i == count:             break<\/code><\/pre>\n<p>\u041f\u043e\u043a\u0430 \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u043e\u043c json, \u043c\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u0433\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u043e\u043c csv-\u0444\u0430\u0439\u043b\u0430 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043e\u0442 \u0424\u0421\u0422\u042d\u041a, \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0431\u044b\u043b\u0438 CVE \u043a\u0430\u043a \u043e\u0442 \u0411\u0414\u0423 \u0424\u0421\u0422\u042d\u041a, \u0442\u0430\u043a \u0438 \u043e\u0442 NIST.<\/p>\n<p>\u0417\u0430\u0439\u0434\u044f \u043d\u0430 \u0441\u0430\u0439\u0442 \u0411\u0414\u0423 \u0424\u0421\u0422\u042d\u041a \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0432\u0438\u0434\u0435 xlsx \u0444\u0430\u0439\u043b\u0430. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u043f\u0435\u0440\u0435\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 csv. \u0418 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0435\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 csv, \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0411\u0414\u0423 \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0432\u0435\u0440\u043d\u044b\u0435 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"python\">def BDU_check(cur_soft_title, cur_ver):     with open('vullist_1.csv', encoding='utf-8') as csvfile:         # print(123)         reader = csv.DictReader(csvfile)         i = 0         for row in reader:             soft_title = str(row['\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u041f\u041e'])             versions = row['\u0412\u0435\u0440\u0441\u0438\u044f \u041f\u041e']             if cur_soft_title.lower() in soft_title.lower():                 cve_row = row['\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438']                 for current_service_version in versions.split(','):                      # \u043d\u0438\u0436\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u0432\u0435\u0440\u0441\u0438\u0438                     if '\u043e\u0442' in current_service_version:                         begin_version = re.search('[^\\d.]?[\\d.]+[^\\d.]?', str(current_service_version)+' ')[0]                         while re.search('[\\d]', begin_version[0]) is None:                             begin_version = begin_version[1:]                         while re.search(\"[\\d]\", begin_version[-1]) is None:                             begin_version = begin_version[:-1]                      if '\u0434\u043e' in current_service_version:                         end_version = re.search('[^\\d.]?[\\d.]+[^\\d.]?', str(current_service_version)+ ' ')                         end_version = end_version[0]                          while re.search('[^\\d]', end_version[0]):                             end_version = end_version[1:]                         while re.search('[^\\d]', end_version[-1]):                             end_version = end_version[:-1]                          cur_ver = re.search('[^\\d.]?[\\d.]+[^\\d.]?', str(cur_ver)+ ' ')                         cur_ver = cur_ver[0]                          while re.search('[^\\d]', cur_ver[0]):                              end_version = end_version[1:]                         while re.search('[^\\d]', cur_ver[-1]):                              cur_ver = cur_ver[:-1]                     flag_begin_vesion = (begin_version and (not end_version) and (version.parse(begin_version) &lt;= version.parse(cur_ver)))                     flag_end_vesion = ((not begin_version) and (end_version) and (version.parse(cur_ver) &lt;= version.parse(end_version)))                     flag_both_vesion = (begin_version and (end_version) and (version.parse(begin_version) &lt;= version.parse(cur_ver)) and (version.parse(cur_ver) &lt;= version.parse(end_version)))                                          if flag_begin_vesion or flag_end_vesion or flag_both_vesion:                         print('\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440         : ' + str(row['\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440']))                         print('CVE                   : ' + str(cve_row))                         print('\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u041f\u041e             : '+ str(row['\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u041f\u041e']))                         print('\u0412\u0435\u0440\u0441\u0438\u044f \u041f\u041e             : '+ str(row['\u0412\u0435\u0440\u0441\u0438\u044f \u041f\u041e'])) <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-338691","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=338691"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338691\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=338691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=338691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=338691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}