def load_single(self, items, good, classify): import socket, ipaddress from flow import FlowRecord rec = FlowRecord() rec.start_time = items['start_time'] rec.duration = (items['start_time'] + items['start_msec']/1000.0) - (items['end_time'] + items['end_msec']/1000.0) rec.protocol = items['prot'] rec.src_ip = str(ipaddress.ip_address(items['src_ip'])) rec.src_port = items['src_port'] rec.dest_ip = str(ipaddress.ip_address(items['dst_ip'])) rec.dest_port = items['dst_port'] rec.total_pckts = items['packets'] rec.total_bytes = items['octets'] if classify: rec.label = items['description'] elif good: rec.label = 'non-malicous' else: rec.label = 'malicous' rec.tcp_flags = items['tcp_flags'] return rec
def load_single(self, items, good, classify): import socket, ipaddress from flow import FlowRecord rec = FlowRecord() rec.start_time = items['start_time'] rec.duration = (items['start_time'] + items['start_msec'] / 1000.0) - ( items['end_time'] + items['end_msec'] / 1000.0) rec.protocol = items['prot'] rec.src_ip = str(ipaddress.ip_address(items['src_ip'])) rec.src_port = items['src_port'] rec.dest_ip = str(ipaddress.ip_address(items['dst_ip'])) rec.dest_port = items['dst_port'] rec.total_pckts = items['packets'] rec.total_bytes = items['octets'] if classify: rec.label = items['description'] elif good: rec.label = 'non-malicous' else: rec.label = 'malicous' rec.tcp_flags = items['tcp_flags'] return rec