Skip to content

Commit 3bdc4f4

Browse files
authored
Merge pull request #50 from Critical-Infrastructure-Systems-Lab/dev
2 parents a46580c + b60a115 commit 3bdc4f4

File tree

9 files changed

+167
-145
lines changed

9 files changed

+167
-145
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
���ʫ���h������ۮ������� ��������(������2
1+
������ƙ5�é������������ ���ȕ���(������2

dhalsim/network_attacks/adversarial_models/ctown_generator_100_percent/keras_metadata.pb

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

dhalsim/network_attacks/concealment_ae_model.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from sklearn.model_selection import train_test_split
1616

1717
import joblib
18+
import numpy as np
1819

1920
# This module is based on the implementation by Alessandro Erba, original is found here:
2021
# https://github.com/scy-phy/ICS-Evasion-Attacks/blob/master/Adversarial_Attacks/Black_Box_Attack/adversarial_AE.py
@@ -72,23 +73,22 @@ def load_scaler(self, scaler_path):
7273
print('Scaler loaded')
7374

7475
# Saves the model and the scaler used to train the model
75-
def save_model(self, filename):
76-
print('saving trained model at: ', str(filename))
77-
self.generator.save(str(model_path))
76+
def save_model(self, model_filename, scaler_filename):
77+
print('saving trained model at: ', str(model_filename))
78+
self.generator.save(str(model_filename))
7879

79-
scaler_path = Path.cwd()
80-
print('saved scaler model at: ', filename)
81-
joblib.dump(self.attacker_scaler, 'ctown_attacker_scaler.gz')
80+
print('saved scaler model at: ', scaler_filename)
81+
joblib.dump(self.attacker_scaler, scaler_filename)
8282

8383
def init_generator(self, training_path):
8484
# Load and preprocess training data
85-
training_path = Path(__file__).parent/training_path/'training_data.csv'
85+
#training_path = Path(__file__).parent/training_path/'training_data.csv'
86+
training_path = Path(__file__).parent/training_path/'ground_truth_dataset.csv'
8687
# print('Reading training data from: ' + str(training_path))
8788
self.physical_pd = self.preprocess_physical(training_path)
8889

8990
# Adversarial model for concealment
90-
# toDo: Ask about this parameter
91-
hide_layers = 39
91+
hide_layers = 160
9292
self.hide_layers = hide_layers
9393
self.generator_layers = [self.feature_dims,
9494
int(self.hide_layers / 2),
@@ -130,14 +130,19 @@ def fix_sample(self, gen_examples):
130130
return gen_examples
131131

132132
def predict(self, received_values_df):
133-
print('Attempting to predict concealment values')
133+
#print('Attempting to predict concealment values')
134134
# print('Features received to predict: ' + str(received_values_df.columns))
135135
# print('Features received to train: ' + str(self.sensor_cols))
136136

137137
gen_examples = self.generator.predict(self.attacker_scaler.transform(received_values_df))
138+
#print('nan predicted values: ')
139+
# print(gen_examples)
140+
#print(np.isnan(gen_examples))
138141
gen_examples = self.fix_sample(pd.DataFrame(columns=self.sensor_cols,
139142
data=self.attacker_scaler.inverse_transform(gen_examples)))
140143

144+
#print('Model fixed values')
145+
#print(gen_examples)
141146
return gen_examples
142147

143148
def __init__(self, features_list):
@@ -146,3 +151,4 @@ def __init__(self, features_list):
146151
self.sensor_cols = [col for col in features_list if
147152
col not in ['Unnamed: 0', 'iteration', 'timestamp', 'Attack']]
148153
self.feature_dims = len(self.sensor_cols)
154+
print(f'Model has {self.feature_dims } input features' )

dhalsim/network_attacks/mitm_netfilter_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def capture(self, packet):
5858
del p[TCP].chksum
5959

6060
packet.set_payload(bytes(p))
61-
self.logger.debug(f"Value of network packet for {p[IP].dst} overwritten.")
61+
# self.logger.debug(f"Value of network packet for {p[IP].dst} overwritten.")
6262

6363
packet.accept()
6464
except Exception as exc:

0 commit comments

Comments
 (0)