-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattack1.py
60 lines (50 loc) · 1.47 KB
/
attack1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from random import randint
from keras import backend as k
import pickle
import random
import numpy as np
from Action import Actions
from cnn import train
import json
import keras
from keras.models import Sequential, model_from_json
def dp(sa, sd, type): # {dp, ddos} dp()
if type == Actions.Defence1:
if random.random() > (sa - sd):
#if sa == 0.8 and sd == 0.2:
cnn_accuracy = random.uniform(0.7, 1.0)
else:
cnn_accuracy = random.uniform(0.5, 0.7)
else:
cnn_accuracy = 0
return cnn_accuracy
def ddos(sa, sd, type):
if type == Actions.Defence2:
if random.random() > (sa - sd):
#if sa == 0.8 and sd == 0.2:
cnn_accuracy = random.uniform(0.6, 0.8)
else:
cnn_accuracy = random.uniform(0.5, 0.7)
else:
cnn_accuracy = 0
return cnn_accuracy
def attack3(sa, sd, type):
if type == Actions.Defence3:
if random.random() >sa:
#if sa == 0.8 and sd == 0.2:
cnn_accuracy = random.uniform(0.6, 1.0)
else:
cnn_accuracy = random.uniform(0.5, 0.7)
else:
cnn_accuracy = 0
return cnn_accuracy
def attack4(sa, sd, type):
if type == Actions.Defence4:
if random.random() > (sa - sd):
#if sa == 0.8 and sd == 0.2:
cnn_accuracy = random.uniform(0.3, 0.9)
else:
cnn_accuracy = random.uniform(0.3, 0.7)
else:
cnn_accuracy = 0
return cnn_accuracy