[Python] pcap 파일 마스킹 소스코드
2025. 4. 4.
from scapy.all import rdpcap, wrpcap, IPdef mask_ip(ip): # IP 주소의 마지막 옥텟을 0으로 변경하여 C클래스까지 마스킹 parts = ip.split('.') if len(parts) == 4: parts[-1] = '92' return '.'.join(parts) return ipdef mask_pcap(input_file, output_file, target_ips): packets = rdpcap(input_file) for packet in packets: if IP in packet: if packet[IP].src in target_ips: ..