def check_steg(self,data): doin = True if not STEG_ENGINE_IS_ON: doin = False # LEVEL 3 : PROTOCOL FILTER if F_NIV3 != "": if self.type3 != PROTO3: doin = False # LEVEL 3 : DESTINATION ADDRESS FILTER if F_NIV3_DST != "": if self.type3 == "0800": if not (steglib.check_ip(data[30:34],netlib.format_ip(F_NIV3_DST))): # ipv6 : 0x86dd, data[38:54] doin = False else: doin = False # LEVEL 3 : SOURCE ADDRESS FILTER if F_NIV3_SRC != "": if self.type3 == "0800": if not (steglib.check_ip(data[26:30],netlib.format_ip(F_NIV3_SRC))): # ipv6 : 0x86dd, data[22:38] doin = False else: doin = False # LEVEL 4 : PROTOCOL FILTER if F_NIV4 != "": if self.type4 != PROTO4: doin = False return doin
def run(self): while self.is_running: for data in iter(self.inbuffer.get, None): # translation d'adresses niveau 2 if self.num == 0: data = data[:6]+netlib.format_mac(self.outMac)+data[12:] # switch MAC elif self.num == 1: data = netlib.format_mac(self.outMac)+data[6:] # switch MAC # translation d'adresses niveau 3 + calcul de checksums self.type3 = netlib.get_type3(data[12:14]) if self.type3 == "0806": # si ARP data = netlib.arp_rewriting(data,self.outMac,self.outIp,self.num) # optimisation : si preformat lors de init, moins de taff dans netlib elif self.type3 == "0800": # si IPv4 ipsrc = data[26:30] ipdst = data[30:34] # optimisation : passer le format_ip dans l'init if self.num == 0: if ipsrc == netlib.format_ip(self.inIp): ipsrc = netlib.format_ip(self.outIp) elif self.num == 1: if ipdst == netlib.format_ip(self.inIp): ipdst = netlib.format_ip(self.outIp) data = netlib.ip_rewriting(data,ipsrc,ipdst) # nat + checksum if netlib.udp_or_tcp(data[23]): # si udp ou tcp data = netlib.tcpudp_rewriting(data) # checksum niveau4 self.otbuffer.put(data) return
def run(self): while self.is_running: for data in iter(self.inbuffer.get, None): # translation d'adresses niveau 2 if self.num == 0: data = data[:6] + netlib.format_mac( self.outMac) + data[12:] # switch MAC elif self.num == 1: data = netlib.format_mac( self.outMac) + data[6:] # switch MAC # translation d'adresses niveau 3 + calcul de checksums self.type3 = netlib.get_type3(data[12:14]) if self.type3 == "0806": # si ARP data = netlib.arp_rewriting(data, self.outMac, self.outIp, self.num) # optimisation : si preformat lors de init, moins de taff dans netlib elif self.type3 == "0800": # si IPv4 ipsrc = data[26:30] ipdst = data[30:34] # optimisation : passer le format_ip dans l'init if self.num == 0: if ipsrc == netlib.format_ip(self.inIp): ipsrc = netlib.format_ip(self.outIp) elif self.num == 1: if ipdst == netlib.format_ip(self.inIp): ipdst = netlib.format_ip(self.outIp) data = netlib.ip_rewriting(data, ipsrc, ipdst) # nat + checksum if netlib.udp_or_tcp(data[23]): # si udp ou tcp data = netlib.tcpudp_rewriting( data) # checksum niveau4 self.otbuffer.put(data) return
def check_steg(self, data): doin = True if not STEG_ENGINE_IS_ON: doin = False # LEVEL 3 : PROTOCOL FILTER if F_NIV3 != "": if self.type3 != PROTO3: doin = False # LEVEL 3 : DESTINATION ADDRESS FILTER if F_NIV3_DST != "": if self.type3 == "0800": if not (steglib.check_ip(data[30:34], netlib.format_ip(F_NIV3_DST)) ): # ipv6 : 0x86dd, data[38:54] doin = False else: doin = False # LEVEL 3 : SOURCE ADDRESS FILTER if F_NIV3_SRC != "": if self.type3 == "0800": if not (steglib.check_ip(data[26:30], netlib.format_ip(F_NIV3_SRC)) ): # ipv6 : 0x86dd, data[22:38] doin = False else: doin = False # LEVEL 4 : PROTOCOL FILTER if F_NIV4 != "": if self.type4 != PROTO4: doin = False return doin