Update public source

This commit is contained in:
2026-10-06 21:08:12 +03:00
commit f231cc5b1f
102 changed files with 48249 additions and 0 deletions
+278
View File
@@ -0,0 +1,278 @@
from datetime import datetime, timezone
from pathlib import Path
class Session:
"""
Управление текущей сессией захвата.
Одна сессия содержит:
- pcapng захват
- GPS трек
- результаты парсинга
- hashcat файлы
Все данные одной поездки находятся
внутри одного каталога.
"""
def __init__(
self,
directory
):
#
# Время запуска
#
self.start_time = datetime.now(
timezone.utc
)
#
# Каталог сессии
#
name = self.start_time.strftime(
"%Y%m%d_%H%M%S"
)
self.path = (
Path(directory) / name
)
self.path.mkdir(
parents=True,
exist_ok=True
)
# =====================================================
# Основной захват
# =====================================================
self.capture_file = (
self.path /
"capture.pcapng"
)
# =====================================================
# GPS
# =====================================================
self.gps_file = (
self.path /
"gps_track.nmea"
)
# =====================================================
# Результаты hcxpcapngtool
# =====================================================
#
# Список точек доступа
#
self.access_points_file = (
self.path /
"access_points.csv"
)
#
# Hashcat формат
#
# WPA-PBKDF2-PMKID+EAPOL
#
self.handshakes_file = (
self.path /
"handshakes.22000"
)
#
# ESSID список
#
self.essid_file = (
self.path /
"essid.txt"
)
#
# Identity список
#
self.identity_file = (
self.path /
"identities.txt"
)
#
# Лог работы парсера
#
self.parser_log = (
self.path /
"parser.log"
)
# =====================================================
# Статистика текущей сессии
# =====================================================
#
# Все NMEA сообщения
#
self.nmea_messages = 0
#
# Валидные GPS позиции
#
self.gps_positions = 0
#
# Последняя координата
#
self.current_gps = None
@classmethod
def from_existing(
cls,
path
):
"""
Открывает уже существующую
сессию из каталога captures.
"""
obj = cls.__new__(cls)
obj.start_time = datetime.now(
timezone.utc
)
obj.path = Path(path)
obj.capture_file = (
obj.path /
"capture.pcapng"
)
obj.gps_file = (
obj.path /
"gps_track.nmea"
)
obj.access_points_file = (
obj.path /
"access_points.csv"
)
obj.handshakes_file = (
obj.path /
"handshakes.22000"
)
obj.essid_file = (
obj.path /
"essid.txt"
)
obj.identity_file = (
obj.path /
"identities.txt"
)
obj.parser_log = (
obj.path /
"parser.log"
)
obj.nmea_messages = 0
obj.gps_positions = 0
obj.current_gps = None
return obj
# =========================================================
# Время работы
# =========================================================
def elapsed(
self
):
return int(
(
datetime.now(
timezone.utc
)
-
self.start_time
).total_seconds()
)
# =========================================================
# GPS статистика
# =========================================================
def add_nmea(self):
"""
Увеличить счетчик
полученных NMEA сообщений.
"""
self.nmea_messages += 1
def update_gps(
self,
gps
):
"""
Обновить последнюю GPS координату.
"""
self.current_gps = gps
self.gps_positions += 1