from scapy.all import rdpcap, wrpcap, IP
def mask_ip(ip):
# IP 주소의 마지막 옥텟을 0으로 변경하여 C클래스까지 마스킹
parts = ip.split('.')
if len(parts) == 4:
parts[-1] = '92'
return '.'.join(parts)
return ip
def 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:
packet[IP].src = mask_ip(packet[IP].src)
if packet[IP].dst in target_ips:
packet[IP].dst = mask_ip(packet[IP].dst)
# 수정 패킷 파일 저장
wrpcap(output_file, packets)
# 파일 경로 설정
input_file = ''
output_file = ''
# 마스킹할 IP 주소 리스트 설정
target_ips = ['']
# IP 주소 마스킹 함수 호출
mask_pcap(input_file, output_file, target_ips)
'IT > 보안' 카테고리의 다른 글
POSTGRESQL 계정생성 및 권한 부여 (0) | 2022.09.13 |
---|---|
MS 지원진단도구(MSDT) 원격코드실행 취약점 Follina(CVE-2022-30190) (0) | 2022.06.22 |
[리버싱]NOX_Android IDA 원격 디버깅 (0) | 2022.04.30 |
SYN Flooding 공격 (0) | 2022.02.16 |
[웹] 쿠키란 무엇인가? (0) | 2021.07.21 |