资源简介
利用python实现遗传算法对正常流量和恶意流量进行区分,类似于AIS,IDS
代码片段和文件信息
#!/usr/bin/env python
import AIS
import random
import numpy as np
import math
import sklearn.neighbors.kd_tree as kt
ais_instance1=AIS.Ais()
file1=open(r“C:\Users\huangrun\Desktop\xunlian20.arff““r“)
file2=open(r“C:\Users\huangrun\Desktop\zhengchang.arff““w“)
file3=open(r“C:\Users\huangrun\Desktop\yichang.arff““w“)
file4=open(r“C:\Users\huangrun\Desktop\xunlian20.arff““r“)
file5=open(r“C:\Users\huangrun\Desktop\test.arff““r“)
file6=open(r“C:\Users\huangrun\Desktop\test.arff““r“)
file7=open(r“C:\Users\huangrun\Desktop\zhengchangtest.arff““w“)
file8=open(r“C:\Users\huangrun\Desktop\yichangtest.arff““w“)
cfs_genetic_15=[34561216182526293031363738]
ig_ranking_15=[53643029333435381239252326]
#ig_ranking_20=[536430293334353812392523263732363124]
feature_to_use_number=[53643029333435381239252326]
#feature_to_use.sort()
category=[‘nu‘‘no‘‘nu‘‘no‘‘nu‘‘nu‘‘nu‘‘nu‘‘nu‘‘nu‘‘b‘‘nu‘‘nu‘‘nu‘‘nu‘]
feature_to_use=[‘src_bytes‘‘service‘‘dst_bytes‘‘flag‘‘diff_srv_rate‘‘same_srv_rate‘‘dst_host_srv_count‘‘dst_host_same_srv_rate‘‘dst_host_diff_srv_rate‘‘dst_host_serror_rate‘‘logged_in‘‘dst_host_srv_serror_rate‘‘serror_rate‘‘count‘‘srv_serror_rate‘]
normalized=[‘logged_in‘‘serror_rate‘‘srv_serror_rate‘‘same_srv_rate‘‘diff_srv_rate‘‘dst_host_same_srv_rate‘‘dst_host_diff_srv_rate‘‘dst_host_serror_rate‘‘dst_host_srv_serror_rate‘] #string of normalized features
unnormalized=[‘src_bytes‘‘dst_bytes‘‘count‘‘dst_host_srv_count‘] #unnormalized features represented in strings e.g “count“ “srv_count“ etc.
#protocol=[]
string_service_bin=[‘0000001‘‘0000010‘‘0000011‘‘0000100‘‘0000101‘‘0000110‘‘0000111‘‘0001000‘‘0001001‘‘0001010‘‘0001011‘‘0001100‘‘0001101‘‘0001110‘‘0001111‘‘0010000‘‘0010001‘‘0010010‘‘0010011‘‘0010100‘‘0010101‘‘0010110‘‘0010111‘‘0011000‘‘0011001‘‘0011010‘‘0011011‘‘0011100‘‘0011101‘‘0011110‘‘0011111‘‘0100000‘‘0100001‘‘0100010‘‘0100011‘‘0100100‘‘0100101‘‘0100110‘‘0100111‘‘0101000‘‘0101001‘‘0101010‘‘0101011‘‘0101100‘‘0101101‘‘0101110‘‘0101111‘‘0110000‘‘0110001‘‘0110010‘‘0110011‘‘0110100‘‘0110101‘‘0110110‘‘0110111‘‘0111000‘‘0111001‘‘0111010‘‘0111011‘‘0111100‘‘0111101‘‘0111110‘‘0111111‘‘1000000‘‘1000001‘‘1000010‘‘1000011‘‘1000100‘‘1000101‘‘1000110‘]
service=[‘aol‘ ‘auth‘ ‘bgp‘ ‘courier‘ ‘csnet_ns‘ ‘ctf‘ ‘daytime‘ ‘discard‘ ‘domain‘ ‘domain_u‘ ‘echo‘ ‘eco_i‘ ‘ecr_i‘ ‘efs‘ ‘exec‘ ‘finger‘ ‘ftp‘ ‘ftp_data‘ ‘gopher‘ ‘harvest‘ ‘hostnames‘ ‘http‘ ‘http_2784‘ ‘http_443‘ ‘http_8001‘ ‘imap4‘ ‘IRC‘ ‘iso_tsap‘ ‘klogin‘ ‘kshell‘ ‘ldap‘ ‘link‘ ‘login‘ ‘mtp‘ ‘name‘ ‘netbios_dgm‘ ‘netbios_ns‘ ‘netbios_ssn‘ ‘netstat‘ ‘nnsp‘ ‘nntp‘ ‘ntp_u‘ ‘other‘ ‘pm_dump‘ ‘pop_2‘ ‘pop_3‘ ‘printer‘ ‘private‘ ‘red_i‘ ‘remote_job‘ ‘rje‘ ‘shell‘ ‘smtp‘ ‘sql_net‘ ‘ssh‘ ‘sunrpc‘ ‘supdup‘ ‘systat‘ ‘telnet‘ ‘tftp_u‘ ‘tim_i‘ ‘time‘ ‘u
- 上一篇:qt-YOLOv3页面
- 下一篇:python开发的基于串口通讯的上位机应用
评论
共有 条评论