Ім'я файлу: Zvit№1ПСМ.doc Розширення: doc Розмір: 128кб. Дата: 05.12.2023 скачати Пов'язані файли: 5.docx Лаба 4_РТП_СЗІ_Кліщ Богдан.docx Лаба 5_РТП_СЗІ_Кліщ.docx Тести, статистика праці.docx Реферат Лесько П.В. Авторське право ЕЛЕП-11.docx.doc Індивідуальна нормативне.docx lab2.docx ЦЕРКВА РІЗДВА ПРЕСВЯТОЇ БОГОРОДИЦІ У САМБОРІ.docx ШАБЕЛЬКО КУРСОВА.docx Розраха.docx Сучасні методики здорового харчування.docx Звіт до БД 2.docx звіт_від_ред.docx lab_8_Kravets.docx Сєрий.docx Сенсорне виховання.doc СПЗ_ЛАБ_1.docx lab5_бд.docx Фізика5 Моя лаба.doc Вебинар англ.docx 5.docx ЛР 3 ФДП.docx Методичка до ПЗ №5-6.doc зразок РГР 2021 (1).docx курсова 1.docx Міністерство_освіти_та_науки_України_PI.docx Контрольна робота Павло Коцаба.docx Метод Баркера.docx Grej_R._S.docx знайомий реферат.docx ОКРО.docx МІНІСТЕРСТВО ОСВІТИ І НАУКИ УКРАЇНИ НАЦІОНАЛЬНИЙ УНІВЕРСИТЕТ «ЛЬВІВСЬКА ПОЛІТЕХНІКА» ІКТА кафедра БІТ З В І Т до лабораторної роботи №1 з курсу: «Програмування скриптовими мовами» на тему: « Аналіз журналів NGINX за допомогою Python» Виконав: ст. гр. КБ-309 Шаповалов Б.Д. Прийняв: ПавликевичА.М. Львів 2023 Завдання: Проаналізувати записи журналу web-сервера NGINX на наявність запитів з IP адрес з негативною репутацією, використовуючи інформацію з публічної системи агрегації індикаторів загроз MalLverse Результат роботи скрипта має видати перелік знайдених унікальних IP адрес доповнених інформацією з MalLverse Журнал NGINX з даними для аналізу https://drive.google.com/file/d/1PzZCDA8NCgJOg4yBQwVMhCxxuUK0smch/view?usp=share_li nk Довідкові матеріали: 1. Часто вживані формати журналів (log files) hUps://www.crowdstrike.com/cybersecurity-101/observability/log-file-formats/ 2. Формат журналу NGINX hUp://fileformats.archiveteam.org/wiki/Combined_Log_Format 3. Приклади скриптів-парсерів a. hUps://linuxtech.in/efficiently-parsing-nginx-log-files-using-python/ b. hUps://dev.to/ksndeveloper/parsing-nginx-logs-using-python-1m6k 4. Система MalLverse hUps://whaLs.malLverse.com 5. Модуль Python для роботи з MalLverse API hUps://github.com/malLverse/pythonmalLverse#table-of-contents 6. Аналіз інформації з MalLverse на Python hUps://infosecwriteups.com/python-threathunLng-tools-part-3-interacLng-with-apis-1b133d9a7ada (копія - hUps://drive.google.com/file/d/1VGld5yVs422_Ej9Em10js4018Xn45Bk/view?usp=share_link Виконання роботи: Скрипт: import ipaddress import colorama import pandas as pd from maltiverse import Maltiverse api = Maltiverse(auth_token='eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjIzMjU0NDIwNTYsImlhdCI6MTY5NDcyMjA1Niwic3ViIjoxNjc1OSwidXNlcm5hbWUiOiJhbmRyaWkua3VraGFydWsua2IiLCJhZG1pbiI6ZmFsc2UsInRlYW1faWQiOjI3OSwidGVhbV9uYW1lIjoibHBudSIsInRlYW1fbGVhZGVyIjpmYWxzZSwidGVhbV9yZXNlYXJjaGVyIjpmYWxzZSwidGVhbV9pbmRleCI6ImlvYy1scG51LWI3MTk2NDk2LTUxYTItMTFlZS1iOWQwLTAyNDJhYzEyMDAwNyIsImFwaV9saW1pdCI6MjUwMDB9.iAJBdU0T0tn142nZyF0L7SWe3TqOeOOOYyM92ghH4GI') def log_error(exception): print(colorama.Fore.RED + str(exception) + colorama.Style.RESET_ALL) def get_ips_dataframe(log_file_name): global log_file ip_addresses = [] try: log_file = open(log_file_name, 'r') except FileNotFoundError as e: log_error(e) exit(1) for line in log_file: ip_addresses.append(line.split(' ')[0].strip()) log_file.close() ip_addresses = list(set(ip_addresses)) return pd.DataFrame(ip_addresses, columns=['ip']) def validate_ip(ip_df): ip_df['valid'] = ip_df['ip'].apply(lambda x: True if ipaddress.ip_address(x) else False) return ip_df def main(): ips_df = get_ips_dataframe('career_nginx_all.log') ips_df = validate_ip(ips_df) valid_ip_df = ips_df[ips_df['valid'] == True] valid_ip_df = valid_ip_df.drop(columns=['valid']) for ip in valid_ip_df['ip']: print(api.ip_get(ip)) if __name__ == '__main__': main() Результат: {'address': '132 24 Wonmi-2dong Wonmi-gu Buchoen-shi\nKYONGGI Korea', 'as_name': 'AS3786 LG DACOM Corporation', 'asn_cidr': '61.32.0.0/13', 'asn_country_code': 'KR', 'asn_date': '2000-09-18 00:00:00', 'asn_registry': 'apnic', 'cidr': ['61.37.198.0/26'], 'city': 'Suwon', 'classification': 'neutral', 'country_code': 'KR', 'creation_time': '2023-09-13 18:29:59', 'email': ['b4029573@users.bora.net'], 'ip_addr': '61.37.198.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'location': {'lat': 37.2859, 'lon': 127.0099}, 'modification_time': '2023-09-13 18:29:59', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'registrant_name': 'LEEBOCHEON\nPC Game Plaza User in\nWonmi-gu Buchoen-shi KYONGGI', 'type': 'ip'} {'address': '3990 E. Broad Street', 'as_name': 'AS749 - DoD Network Information Center', 'asn_cidr': '21.0.0.0/8', 'asn_country_code': 'US', 'asn_date': '1991-07-01 00:00:00', 'asn_registry': 'arin', 'cidr': ['21.0.0.0/8'], 'city': 'Columbus', 'classification': 'neutral', 'country_code': 'US', 'creation_time': '2023-09-13 18:30:01', 'email': ['disa.columbus.ns.mbx.arin-registrations@mail.mil', 'disa.columbus.ns.mbx.hostmaster-dod-nic@mail.mil'], 'ip_addr': '21.76.149.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2009-06-19 00:00:00', 'location': {'lat': 39.9611755, 'lon': -82.9987942}, 'modification_time': '2023-09-13 18:30:01', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'postal_code': '43216', 'registrant_name': 'DoD Network Information Center', 'state': 'OH', 'type': 'ip'} {'address': 'Sky Network Services\n1 Brick Lane\nLondon\nE1 6PU\nUK', 'as_name': 'AS5607 Sky UK Limited', 'asn_cidr': '2.120.0.0/13', 'asn_country_code': 'GB', 'asn_date': '2010-04-14 00:00:00', 'asn_registry': 'ripencc', 'cidr': ['2.120.0.0/15'], 'city': 'Worthing', 'classification': 'neutral', 'country_code': 'GB', 'creation_time': '2023-09-13 18:30:03', 'email': ['abuse@sky.uk'], 'ip_addr': '2.120.192.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2016-06-17 14:34:51', 'location': {'lat': 50.8289, 'lon': -0.3759}, 'modification_time': '2023-09-13 18:30:03', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'registrant_name': 'Sky UK Limited', 'type': 'ip'} {'address': '3990 E. Broad Street', 'as_name': 'AS749 - DoD Network Information Center', 'asn_cidr': '11.0.0.0/8', 'asn_country_code': 'US', 'asn_date': '1984-01-19 00:00:00', 'asn_registry': 'arin', 'cidr': ['11.0.0.0/8'], 'city': 'Columbus', 'classification': 'neutral', 'country_code': 'US', 'creation_time': '2023-09-13 18:30:04', 'email': ['disa.columbus.ns.mbx.hostmaster-dod-nic@mail.mil', 'disa.columbus.ns.mbx.arin-registrations@mail.mil'], 'ip_addr': '11.103.192.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2007-08-22 00:00:00', 'location': {'lat': 39.9611755, 'lon': -82.9987942}, 'modification_time': '2023-09-13 18:30:04', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'postal_code': '43216', 'registrant_name': 'DoD Network Information Center', 'state': 'OH', 'type': 'ip'} {'address': 'Jeollanam-do Naju-si Jinheung-gil', 'as_name': 'AS4766 - Korea Telecom', 'asn_cidr': '39.24.0.0/13', 'asn_country_code': 'KR', 'asn_date': '2011-03-30 00:00:00', 'asn_registry': 'apnic', 'cidr': ['39.16.0.0/12'], 'city': 'Seongnam-si', 'classification': 'neutral', 'country_code': 'KR', 'creation_time': '2023-09-13 18:30:05', 'email': ['irt@nic.or.kr', 'kornet_ip@kt.com'], 'ip_addr': '39.30.133.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'location': {'lat': 37.4449168, 'lon': 127.1388684}, 'modification_time': '2023-09-13 18:30:05', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'postal_code': '13437', 'registrant_name': 'Korea Telecom', 'type': 'ip'} {'address': 'No.31 ,jingrong street,beijing\n100032', 'as_name': 'AS4134 Chinanet', 'asn_cidr': '49.64.0.0/11', 'asn_country_code': 'CN', 'asn_date': '2010-11-15 00:00:00', 'asn_registry': 'apnic', 'cidr': ['49.64.0.0/11'], 'city': 'Nanjing', 'classification': 'neutral', 'country_code': 'CN', 'creation_time': '2023-09-13 18:30:07', 'email': ['jsipmanager@163.com', 'anti-spam@chinatelecom.cn'], 'ip_addr': '49.76.149.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'location': {'lat': 32.0617, 'lon': 118.7778}, 'modification_time': '2023-09-13 18:30:07', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'registrant_name': 'CHINANET jiangsu province network\nChina Telecom\n260 Zhongyang Road,Nanjing 210037', 'type': 'ip'} {'address': 'Via Jervis, 13\nIvrea (TO)\nITALY', 'as_name': 'AS30722 Vodafone Italia S p A', 'asn_cidr': '2.46.0.0/15', 'asn_country_code': 'IT', 'asn_date': '2010-04-29 00:00:00', 'asn_registry': 'ripencc', 'cidr': ['2.46.0.0/16', ' 2.47.0.0/19'], 'city': 'San Salvo', 'classification': 'neutral', 'country_code': 'IT', 'creation_time': '2023-09-13 18:30:08', 'email': ['italy.abuse@mail.vodafone.it', 'IP-ASSIGN@mail.vodafone.it'], 'ip_addr': '2.46.198.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2019-10-31 09:09:43', 'location': {'lat': 42.0441, 'lon': 14.7333}, 'modification_time': '2023-09-13 18:30:08', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'registrant_name': 'IP addresses assigned to VF-IT customers', 'type': 'ip'} {'address': '410 Terry Ave N.', 'asn_cidr': 'NA', 'asn_country_code': 'US', 'asn_date': '2017-12-20 00:00:00', 'asn_registry': 'arin', 'cidr': ['3.0.0.0/9'], 'city': 'Seattle', 'classification': 'neutral', 'country_code': 'US', 'creation_time': '2023-09-13 18:30:09', 'email': ['amzn-noc-contact@amazon.com', 'aws-routing-poc@amazon.com', 'aws-rpki-routing-poc@amazon.com', 'abuse@amazonaws.com'], 'ip_addr': '3.55.198.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2022-05-18 00:00:00', 'location': {'lat': 47.6062095, 'lon': -122.3320708}, 'modification_time': '2023-09-13 18:30:09', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'postal_code': '98104', 'registrant_name': 'Amazon Technologies Inc.', 'state': 'WA', 'type': 'ip'} {'address': '410 Terry Ave N.', 'as_name': 'AS16509 - Amazon.com, Inc.', 'asn_cidr': '13.36.0.0/14', 'asn_country_code': 'US', 'asn_date': '2020-08-05 00:00:00', 'asn_registry': 'arin', 'cidr': ['13.24.0.0/13', ' 13.48.0.0/13', ' 13.32.0.0/12', ' 13.56.0.0/14'], 'city': 'Paris', 'classification': 'neutral', 'country_code': 'FR', 'creation_time': '2023-09-13 18:30:10', 'email': ['amzn-noc-contact@amazon.com', 'aws-routing-poc@amazon.com', 'aws-rpki-routing-poc@amazon.com', 'abuse@amazonaws.com'], 'ip_addr': '13.39.198.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2021-02-10 00:00:00', 'location': {'lat': 48.856614, 'lon': 2.3522219}, 'modification_time': '2023-09-13 18:30:10', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'postal_code': '75007', 'registrant_name': 'Amazon Technologies Inc.', 'state': 'WA', 'type': 'ip'} {'address': 'Vodafone Greece Fixed (ex Hellas On Line S.A.)\n1-3, Tzavella Str\n15231 , Halandri, Athens, Greece', 'as_name': 'AS3329 Vodafone panafon Hellenic Telecommunications Company SA', 'asn_cidr': '5.55.192.0/19', 'asn_country_code': 'GR', 'asn_date': '2012-05-29 00:00:00', 'asn_registry': 'ripencc', 'cidr': ['5.55.0.0/16'], 'city': 'Athens', 'classification': 'neutral', 'country_code': 'GR', 'creation_time': '2023-09-13 18:30:11', 'email': ['abusevfgr@vodafone.com'], 'ip_addr': '5.55.198.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2012-05-29 11:19:38', 'location': {'lat': 37.9842, 'lon': 23.7353}, 'modification_time': '2023-09-13 18:30:11', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'registrant_name': 'Hellas On Line S.A.', 'type': 'ip'} {'address': '3990 E. Broad Street', 'as_name': 'AS749 - DoD Network Information Center', 'asn_cidr': '11.0.0.0/8', 'asn_country_code': 'US', 'asn_date': '1984-01-19 00:00:00', 'asn_registry': 'arin', 'cidr': ['11.0.0.0/8'], 'city': 'Whitehall', 'classification': 'neutral', 'country_code': 'US', 'creation_time': '2023-09-13 18:30:12', 'email': ['disa.columbus.ns.mbx.arin-registrations@mail.mil', 'disa.columbus.ns.mbx.hostmaster-dod-nic@mail.mil'], 'ip_addr': '11.90.192.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2007-08-22 00:00:00', 'location': {'lat': 39.9667308, 'lon': -82.8854559}, 'modification_time': '2023-09-13 18:30:12', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'postal_code': '43213', 'registrant_name': 'DoD Network Information Center', 'state': 'OH', 'type': 'ip'} {'address': 'Bouygues Telecom\n13-15 avenue du Marechal Juin\n92366 Meudon-la-Foret cedex\nFrance', 'as_name': 'AS5410 Bouygues Telecom SA', 'asn_cidr': '5.48.0.0/14', 'asn_country_code': 'FR', 'asn_date': '2012-05-22 00:00:00', 'asn_registry': 'ripencc', 'cidr': ['5.49.64.0/18', ' 5.49.128.0/17'], 'city': 'Mantes-la-Jolie', 'classification': 'neutral', 'country_code': 'FR', 'creation_time': '2023-09-13 18:30:13', 'email': ['MBX_ABUSE@bouyguestelecom.fr'], 'ip_addr': '5.49.198.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2016-03-02 11:13:23', 'location': {'lat': 48.9833, 'lon': 1.7167}, 'modification_time': '2023-09-13 18:30:13', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'registrant_name': 'Pool for Broadband CABLE customers', 'type': 'ip'} {'address': '1 Raffles Place # 59-00 One Raffles Place, Tower One Singapore, Singapore', 'asn_cidr': 'NA', 'asn_country_code': 'SG', 'asn_date': '1989-02-21 00:00:00', 'asn_registry': 'apnic', 'cidr': ['43.0.0.0/10'], 'city': 'Singapore', 'classification': 'neutral', 'country_code': 'SG', 'creation_time': '2023-09-13 18:30:14', 'email': ['anti-spam@list.alibaba-inc.com'], 'ip_addr': '43.38.198.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'location': {'lat': 1.3553794, 'lon': 103.8677444}, 'modification_time': '2023-09-13 18:30:14', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'postal_code': '550304', 'registrant_name': 'Aliyun Computing Co.LTD', 'type': 'ip'} {'address': '410 Terry Ave N.', 'as_name': 'AS16509 - Amazon.com, Inc.', 'asn_cidr': '3.124.0.0/14', 'asn_country_code': 'US', 'asn_date': '2017-12-20 00:00:00', 'asn_registry': 'arin', 'cidr': ['3.0.0.0/9'], 'city': 'Frankfurt', 'classification': 'neutral', 'country_code': 'DE', 'creation_time': '2023-09-13 18:30:15', 'email': ['abuse@amazonaws.com', 'amzn-noc-contact@amazon.com', 'aws-rpki-routing-poc@amazon.com', 'aws-routing-poc@amazon.com'], 'ip_addr': '3.126.192.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2022-05-18 00:00:00', 'location': {'lat': 50.1109221, 'lon': 8.6821267}, 'modification_time': '2023-09-13 18:30:15', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'postal_code': '60311', 'registrant_name': 'Amazon Technologies Inc.', 'state': 'WA', 'type': 'ip'} {'address': '410 Terry Ave N.', 'as_name': 'AS16509 - Amazon.com, Inc.', 'asn_cidr': '3.104.0.0/14', 'asn_country_code': 'US', 'asn_date': '2017-12-20 00:00:00', 'asn_registry': 'arin', 'cidr': ['3.0.0.0/9'], 'city': 'Sydney', 'classification': 'neutral', 'country_code': 'AU', 'creation_time': '2023-09-13 18:30:16', 'email': ['amzn-noc-contact@amazon.com', 'aws-routing-poc@amazon.com', 'abuse@amazonaws.com', 'aws-rpki-routing-poc@amazon.com'], 'ip_addr': '3.104.192.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2022-05-18 00:00:00', 'location': {'lat': -33.8688197, 'lon': 151.2092955}, 'modification_time': '2023-09-13 18:30:16', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'postal_code': '2000', 'registrant_name': 'Amazon Technologies Inc.', 'state': 'WA', 'type': 'ip'} {'message': 'Bad request. Not a valid public IP address', 'status': 'fail'} {'address': '3990 E. Broad Street', 'as_name': 'AS749 - DoD Network Information Center', 'asn_cidr': '26.0.0.0/8', 'asn_country_code': 'US', 'asn_date': '1995-05-01 00:00:00', 'asn_registry': 'arin', 'cidr': ['26.0.0.0/8'], 'city': 'Cupertino', 'classification': 'neutral', 'country_code': 'US', 'creation_time': '2023-09-13 18:30:17', 'email': ['disa.columbus.ns.mbx.arin-registrations@mail.mil', 'disa.columbus.ns.mbx.hostmaster-dod-nic@mail.mil'], 'ip_addr': '26.39.198.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2009-06-19 00:00:00', 'location': {'lat': 37.3229978, 'lon': -122.0321823}, 'modification_time': '2023-09-13 18:30:17', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'postal_code': '95014', 'registrant_name': 'DoD Network Information Center', 'state': 'CA', 'type': 'ip'} {'address': '3990 E. Broad Street', 'as_name': 'AS749 - DoD Network Information Center', 'asn_cidr': '28.0.0.0/8', 'asn_country_code': 'US', 'asn_date': '1996-03-11 00:00:00', 'asn_registry': 'arin', 'cidr': ['28.0.0.0/8'], 'city': 'Whitehall', 'classification': 'neutral', 'country_code': 'US', 'creation_time': '2023-09-13 18:30:18', 'email': ['disa.columbus.ns.mbx.hostmaster-dod-nic@mail.mil', 'disa.columbus.ns.mbx.arin-registrations@mail.mil'], 'ip_addr': '28.78.149.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2009-03-23 00:00:00', 'location': {'lat': 39.9667308, 'lon': -82.8854559}, 'modification_time': '2023-09-13 18:30:18', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'postal_code': '43213', 'registrant_name': 'DoD Network Information Center', 'state': 'OH', 'type': 'ip'} {'address': '3990 E. Broad Street', 'as_name': 'AS749 - DoD Network Information Center', 'asn_cidr': '22.0.0.0/8', 'asn_country_code': 'US', 'asn_date': '1989-06-26 00:00:00', 'asn_registry': 'arin', 'cidr': ['22.0.0.0/8'], 'city': 'Whitehall', 'classification': 'neutral', 'country_code': 'US', 'creation_time': '2023-09-13 18:30:19', 'email': ['disa.columbus.ns.mbx.arin-registrations@mail.mil', 'disa.columbus.ns.mbx.hostmaster-dod-nic@mail.mil'], 'ip_addr': '22.94.192.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'last_updated': '2009-04-15 00:00:00', 'location': {'lat': 39.9667308, 'lon': -82.8854559}, 'modification_time': '2023-09-13 18:30:19', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'postal_code': '43213', 'registrant_name': 'DoD Network Information Center', 'state': 'OH', 'type': 'ip'} {'address': 'PT. TELKOM INDONESIA\nSTO Telkom Gambir 3th Floor\nMedan Merdeka Selatan\nJAKARTA', 'as_name': 'AS17974 PT Telekomunikasi Indonesia', 'asn_cidr': '36.76.144.0/20', 'asn_country_code': 'ID', 'asn_date': '2011-01-14 00:00:00', 'asn_registry': 'apnic', 'cidr': ['36.76.144.0/20'], 'city': 'Medan', 'classification': 'neutral', 'country_code': 'ID', 'creation_time': '2023-09-13 18:30:20', 'email': ['abuse@telkom.co.id', 'djimie@telkom.co.id', 'febrian.setiadi@telkom.co.id'], 'ip_addr': '36.76.149.1', 'is_cdn': False, 'is_cnc': False, 'is_distributing_malware': False, 'is_hosting': False, 'is_iot_threat': False, 'is_known_attacker': False, 'is_known_scanner': False, 'is_mining_pool': False, 'is_open_proxy': False, 'is_sinkhole': False, 'is_tor_node': False, 'is_vpn_node': False, 'location': {'lat': 3.5846999999999998, 'lon': 98.6629}, 'modification_time': '2023-09-13 18:30:20', 'number_of_blacklisted_domains_resolving': 0, 'number_of_domains_resolving': 0, 'number_of_offline_malicious_urls_allocated': 0, 'number_of_online_malicious_urls_allocated': 0, 'number_of_whitelisted_domains_resolving': 0, 'registrant_name': 'PT TELKOM INDONESIA Menara Multimedia Lt.7 Jl. Kebon sirih No.12 JAKARTA', 'type': 'ip'} Висновки: Виконавши лабораторну роботу я отримав навички роботи з аналізу журналів NGINX за допомогою Python. Створив скрипт призначений для обробки файлу журналу (лог-файлу), який містить інформацію про IP-адреси. Він виконує такі основні завдання: імпортує необхідні бібліотеки, такі як `ipaddress`, `colorama`, `pandas`, та `Maltiverse`; встановлює підключення до сервісу Maltiverse з використанням аутентифікаційного токену; визначає функцію `log_error` для виведення помилок у червоному кольорі; створює функцію `get_ips_dataframe`, яка зчитує заданий лог-файл і витягує з нього IP-адреси. Якщо файл не знайдено, виводить помилку; визначує функцію `validate_ip`, яка перевіряє валідність кожної IP-адреси з отриманого набору і позначає їх як правильні або неправильні; у функції `main` скрипт викликає функції для отриманих IP-адрес. Він спочатку витягує всі IP-адреси з лог-файлу, потім валідує їх та виводить інформацію про кожну валідну IP-адресу за допомогою сервісу Maltiverse; умовний блок `if __name__ == '__main__'` визначає, що функція `main` буде викликана лише при запуску цього скрипта напряму. Скрипт призначений для аналізу IP-адрес з лог-файлу та отримання інформації про них з використанням сервісу Maltiverse. |