def ignore_packet(self, packet, proto):
src_ip = packet[proto].src
dst_ip = packet[proto].dst
src_port = packet[TCP].sport
dst_port = packet[TCP].dport
# Target or allow by IP
if (src_ip in self.allow or dst_ip in self.allow) or (src_ip in self.allow_src) or (dst_ip in self.allow_dst):
return True
elif (self.target and ( self.src_ip not in self.target and self.dst_ip not in self.target)) or (self.target_src and not src_ip in self.target_src) or (self.target_dst and not dst_ip in self.target_dst):
return True
# Target or allow by Port
if (src_port in self.allow_ports or dst_port in self.allow_ports) or (src_port in self.allow_sport) or (dst_port in self.allow_dport):
return True
elif (self.target_ports and (not src_port in self.target_ports and not dst_port in self.target_ports)) or (self.target_sport and not src_port in self.target_sport) or (self.target_dport and not dst_port in self.target_dport):
return True
# Target randomly
if self.randomize == "often" and randint(1, 10) < 2:
return True
elif self.randomize == "half" and randint(1, 10) < 5:
return True
elif self.randomize == "seldom" and randint(1, 10) < 8:
return True
else:
return False
###############################################################
# Scapy #
###############################################################
评论列表
文章目录