예제 #1
0
import analysis

attack_file = None

# check which mode the program is being run in
len_of_args = len(sys.argv)
if (len_of_args == 1):
    print '\n\tAttack data not provided, training and testing model based on pcap files in \'data/\' folder alone.'
    print '\tTo provide attack data, run the code as: python wrapper.py <attack-data-file-name>'
else:
    print '\n\tAttack data provided, as command line argument \'' + sys.argv[
        1] + '\''
    attack_file = sys.argv[1]
print '---------------------------------------------'

payloads = dpr.getPayloadStrings()

# shuffle the data to randomly pick samples
rn.shuffle(payloads)

min_length = 0
max_length = 0

while min_length == 0 and max_length == 0:
    min_length = 0
    max_length = 0
    # This is where we decide what the split ratio is
    split_ratio = 0.75
    split_index = int(len(payloads) * split_ratio)
    training = payloads[0:split_index + 1]
    test = payloads[split_index + 1:len(payloads)]
예제 #2
0
# training_protocol = "DNS"
print "Working with protocol: " + training_protocol + " : in training data."

attack_file = None

# check which mode the program is being run in 
len_of_args = len(sys.argv)
if(len_of_args == 1):
    print '\n\tAttack data not provided, training and testing model based on pcap files in \'data/\' folder alone.' 
    print '\tTo provide attack data, run the code as: python wrapper.py <attack-data-file-name>'
else:
    print '\n\tAttack data provided, as command line argument \''+sys.argv[1]+'\''
    attack_file = sys.argv[1]
print '---------------------------------------------'

payloads = dpr.getPayloadStrings(training_protocol)
# shuffle the data to randomly pick samples
rn.shuffle(payloads)

#Case: DNS traffic. 
split_ratio = 0.75
split_index = int(len(payloads)*split_ratio)
training = payloads[0:split_index+1]
test = payloads[split_index+1:len(payloads)]

if training_protocol == "HTTP": 
    min_length = 0 
    max_length = 0
elif training_protocol == "DNS":
    min_length = 0 
    max_length = 1