Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions modules/test/ntp/python/src/ntp_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""NTP test module"""
from test_module import TestModule
from scapy.all import rdpcap, IP, IPv6, NTP, UDP, Ether
from scapy.error import Scapy_Exception
import os
from collections import defaultdict

Expand Down Expand Up @@ -185,8 +186,12 @@ def extract_ntp_data(self):

# Read the pcap files
packets = (rdpcap(self.startup_capture_file) +
rdpcap(self.monitor_capture_file) +
rdpcap(self.ntp_server_capture_file))
rdpcap(self.monitor_capture_file))

try:
packets += rdpcap(self.ntp_server_capture_file)
except (FileNotFoundError, Scapy_Exception):
LOGGER.error('ntp.pcap not found or empty, ignoring')

# Iterate through NTP packets
for packet in packets:
Expand Down Expand Up @@ -238,9 +243,15 @@ def extract_ntp_data(self):

def _ntp_network_ntp_support(self):
LOGGER.info('Running ntp.network.ntp_support')
packet_capture = (rdpcap(STARTUP_CAPTURE_FILE) +
rdpcap(MONITOR_CAPTURE_FILE) +
rdpcap(NTP_SERVER_CAPTURE_FILE))

# Read the pcap files
packet_capture = (rdpcap(self.startup_capture_file) +
rdpcap(self.monitor_capture_file))

try:
packet_capture += rdpcap(self.ntp_server_capture_file)
except (FileNotFoundError, Scapy_Exception):
LOGGER.error('ntp.pcap not found or empty, ignoring')

device_sends_ntp4 = False
device_sends_ntp3 = False
Expand Down Expand Up @@ -276,9 +287,15 @@ def _ntp_network_ntp_support(self):

def _ntp_network_ntp_dhcp(self):
LOGGER.info('Running ntp.network.ntp_dhcp')
packet_capture = (rdpcap(STARTUP_CAPTURE_FILE) +
rdpcap(MONITOR_CAPTURE_FILE) +
rdpcap(NTP_SERVER_CAPTURE_FILE))

# Read the pcap files
packet_capture = (rdpcap(self.startup_capture_file) +
rdpcap(self.monitor_capture_file))

try:
packet_capture += rdpcap(self.ntp_server_capture_file)
except (FileNotFoundError, Scapy_Exception):
LOGGER.error('ntp.pcap not found or empty, ignoring')

device_sends_ntp = False
ntp_to_local = False
Expand Down
Loading