Created
July 27, 2023 06:27
-
-
Save M0nteCarl0/172a592eb1acc937e7393c694edbe240 to your computer and use it in GitHub Desktop.
Trivial SIEM python stages for MITM attack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime | |
| def analyze_authentication_logs(log_file): | |
| with open(log_file, 'r') as file: | |
| for line in file: | |
| # Анализ строк лога для обнаружения аномалий аутентификации | |
| # Например, обнаружение повышенной активности в аккаунтах пользователей | |
| if 'login failed' in line: | |
| # Ваш код обработки аномалии повышенной активности в аккаунтах | |
| log_file = 'authentication_logs.log' | |
| analyze_authentication_logs(log_file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ssl | |
| import certifi | |
| def check_certificate(server_name): | |
| context = ssl.create_default_context(cafile=certifi.where()) | |
| conn = context.wrap_socket(socket.socket(socket.AF_INET), server_hostname=server_name) | |
| try: | |
| conn.connect((server_name, 443)) | |
| cert = conn.getpeercert() | |
| # Анализ сертификата для обнаружения изменений или подделок | |
| # Например, сравнение сертификата с надежными источниками сертификации | |
| # Ваш код обработки аномалии измененного или поддельного сертификата | |
| except Exception as e: | |
| print(e) | |
| server_name = 'example.com' | |
| check_certificate(server_name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| # Настройка логгера | |
| logging.basicConfig(level=logging.INFO, filename='network_logs.log') | |
| def analyze_logs(log_file): | |
| with open(log_file, 'r') as file: | |
| for line in file: | |
| # Анализ строк лога для обнаружения аномалий | |
| # Например, обнаружение повышенного количества подключений к определенному порту | |
| if 'connection established' in line: | |
| # Ваш код обработки аномалии повышенного количества подключений | |
| log_file = 'network_logs.log' | |
| analyze_logs(log_file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from scapy.all import * | |
| def analyze_traffic(packet): | |
| if packet.haslayer(ARP): | |
| # Анализ ARP-трафика для обнаружения аномалий | |
| # Например, большое количество ARP запросов | |
| if packet[ARP].op == 1: # ARP запрос | |
| # Ваш код обработки аномалии ARP | |
| def start_traffic_monitor(): | |
| sniff(prn=analyze_traffic) | |
| start_traffic_monitor() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment