Keyven commited on
Commit
812c2ea
·
verified ·
1 Parent(s): 526703d

Mirror von Keyven/SecIDS-CNN (Original + DOI bleiben unter Keyven)

Browse files
Files changed (6) hide show
  1. README.md +204 -0
  2. SecIDS-CNN.h5 +3 -0
  3. config.json +23 -0
  4. requirements.txt +3 -0
  5. run_model.py +14 -0
  6. secids_cnn.py +22 -0
README.md ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ language:
4
+ - en
5
+ - de
6
+ metrics:
7
+ - accuracy
8
+ - f1
9
+ - precision
10
+ - recall
11
+ - roc_auc
12
+ tags:
13
+ - IDS,
14
+ - SecIDS-CNN
15
+ - Cybersecurity
16
+ - automotive
17
+ - pi
18
+ - jetson
19
+ - CNN
20
+ - fast
21
+ - small
22
+ ---
23
+
24
+ # SecIDS-CNN: Advanced Convolutional Neural Network for Intrusion Detection in Cybersecurity and Automotive Applications
25
+
26
+
27
+ ### Model Description
28
+
29
+ SecIDS-CNN is a high-performance Convolutional Neural Network (CNN) model developed specifically for Intrusion Detection Systems (IDS) in cybersecurity and automotive network applications. Leveraging temporal patterns in network traffic, SecIDS-CNN identifies and classifies malicious activity with high accuracy, designed to meet the real-time security demands of vehicular and automotive networks. This model supports proactive threat mitigation, helping to protect in-vehicle and connected systems against cyber threats that could impact operational safety.
30
+
31
+ - **Developed by:** Keyvan Hardani
32
+ - **Model Type:** Convolutional Neural Network (CNN) for Intrusion Detection
33
+ - **Languages:** English, German
34
+ - **License:** Creative Commons Attribution Non Commercial 4.0 (cc-by-nc-4.0)
35
+ - **Finetuned from model:** None
36
+
37
+ ### Model Sources
38
+
39
+ - **Repository:** https://github.com/Keyvanhardani/SecIDS-CNN.git
40
+
41
+ ## Uses
42
+
43
+ ### Direct Use
44
+
45
+ SecIDS-CNN can be directly deployed for real-time intrusion detection within cybersecurity monitoring systems. Its design supports seamless integration into automotive communication networks, enabling anomaly detection within complex, connected vehicular systems.
46
+
47
+ ### Downstream Use
48
+
49
+ Potential applications include broader network monitoring platforms and integrated security systems in automotive and connected vehicle environments.
50
+
51
+ ### Out-of-Scope Use
52
+
53
+ SecIDS-CNN is not suited for non-network data or applications outside the network security and automotive domains. Misuse may include attempts to deploy it in systems without real-time requirements or in unrelated cybersecurity needs.
54
+
55
+ ## Bias, Risks, and Limitations
56
+
57
+ SecIDS-CNN, while highly accurate, may have a minor bias toward benign traffic when optimized for recall, which could lead to rare false negatives. Additionally, its effectiveness depends on access to live network data, essential for real-time intrusion detection.
58
+
59
+ ### Recommendations
60
+
61
+ Users should be aware of the model’s optimal use cases in real-time network environments and its limitations in handling unrelated or non-automotive network types.
62
+
63
+
64
+ ## How to Get Started with SecIDS-CNN
65
+
66
+ To get started with SecIDS-CNN, you can import the model and use it in your Python project. Follow the steps below:
67
+
68
+ ### Step 1: Install Dependencies
69
+
70
+ Clone the repository and install the necessary dependencies:
71
+
72
+ ```bash
73
+ git clone https://github.com/Keyvanhardani/SecIDS-CNN.git
74
+ cd SecIDS-CNN
75
+ pip install -r requirements.txt
76
+ ```
77
+
78
+ ### Step 2: Import the Model
79
+
80
+ Once dependencies are installed, you can import the model into your Python project:
81
+
82
+ ```python
83
+ from secids_cnn import SecIDSModel
84
+ ```
85
+
86
+ ### Step 3: Load and Use the Model
87
+
88
+ To evaluate SecIDS-CNN’s real-time detection on sample network traffic data:
89
+
90
+ ```python
91
+ # Initialize the model
92
+ model = SecIDSModel()
93
+
94
+ # Load your network traffic data (example)
95
+ data = load_network_data('path/to/your/data.csv')
96
+
97
+ # Make predictions
98
+ predictions = model.predict(data)
99
+
100
+ # Output results
101
+ print("Intrusion Detection Results:", predictions)
102
+ ```
103
+
104
+ This setup allows you to test SecIDS-CNN on provided sample data or integrate it into larger projects for real-time intrusion detection.
105
+
106
+ ## Training Details
107
+
108
+ ### Training Data
109
+
110
+ The dataset for SecIDS-CNN consists of labeled network traffic, distinguishing between benign and malicious activity. It includes data from general network and automotive sources, with features capturing packet flows, timing, and network behavior.
111
+
112
+ ### Training Procedure
113
+
114
+ The model’s training pipeline encompasses data preprocessing, feature extraction, and training on temporal network data patterns.
115
+
116
+ #### Training Hyperparameters
117
+
118
+ - **Precision Type:** FP32
119
+ - **Batch Size:** 32
120
+ - **Epochs:** 50
121
+
122
+ ### Compute Requirements
123
+
124
+ SecIDS-CNN was trained on a multi-GPU setup, with optimizations for real-time performance in security-critical applications.
125
+
126
+ ## Evaluation
127
+
128
+ ### Testing Data and Metrics
129
+
130
+ #### Testing Data
131
+
132
+ The model was evaluated on a balanced set of benign and malicious network traffic records, sourced from both general cybersecurity and automotive domains.
133
+
134
+ #### Metrics
135
+
136
+ SecIDS-CNN’s evaluation included accuracy, precision, recall, F1-score, ROC curve, and AUC, chosen for their relevance to classification performance in security applications.
137
+
138
+ ### Results
139
+
140
+ - **Accuracy:** 97.72%
141
+ - **Precision:** 97.74%
142
+ - **Recall:** 97.72%
143
+ - **F1-Score:** 0.9772
144
+
145
+ SecIDS-CNN demonstrated high reliability, achieving almost 98% accuracy in intrusion detection and benign traffic classification.
146
+
147
+ ## Model Examination
148
+
149
+ Feature importance was analyzed using SHAP (SHapley Additive exPlanations) to gain insight into feature contributions. This interpretability measure supports transparency and offers guidance for refining the model for intrusion detection.
150
+
151
+ - **Top Features:** Packet_Length_Mean, Flow_Duration
152
+ - **Least Impactful Features:** Bwd_Packet_Length_Mean, Idle_Mean
153
+
154
+ ## Environmental Impact
155
+
156
+ The estimated carbon footprint for training SecIDS-CNN was calculated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute).
157
+
158
+ - **Hardware:** Multi-GPU setup (NVIDIA RTX 4070, RTX 4090Ti)
159
+ - **Training Duration:**
160
+
161
+ Batch Size: 32
162
+ Epochs: 50
163
+ Training Duration: ~72 hours on RTX 4090Ti
164
+ Emissions: ~15 kg CO₂
165
+
166
+ ## Technical Specifications
167
+
168
+ ### Model Architecture
169
+
170
+ SecIDS-CNN utilizes a multi-layer convolutional architecture, optimized for high-throughput analysis of network traffic data, with an emphasis on capturing time-based patterns.
171
+
172
+ ### Compute Infrastructure
173
+
174
+ - **Software:** TensorFlow, Python, Keras
175
+
176
+ ### Supported Hardware
177
+
178
+ This model is lightweight and versatile for inference across a wide range of hardware, including:
179
+
180
+ - **CPUs**: Compatible with standard CPUs, allowing easy deployment on nearly any system.
181
+ - **GPUs**: Optimized for all GPUs (primarily used for training), but also enables faster inference if needed.
182
+ - **Microcontrollers and Edge Devices**: With a small model size (~700 KB), it supports microprocessors and edge devices, such as Raspberry Pi, NVIDIA Jetson Nano, and other embedded systems.
183
+
184
+ This compatibility ensures flexibility for various applications in automotive and cybersecurity environments.
185
+
186
+ ## Citation
187
+
188
+ **BibTeX:**
189
+
190
+ ```bibtex
191
+ @misc{secids-cnn,
192
+ author = {Keyvan Hardani},
193
+ title = {SecIDS-CNN: Advanced Convolutional Neural Network for Intrusion Detection},
194
+ year = {2023},
195
+ note = {Available under CC BY-NC 4.0}
196
+ }
197
+ @misc {keyvan_hardani_2024,
198
+ author = { {Keyvan Hardani} },
199
+ title = { SecIDS-CNN (Revision 5daf4a4) },
200
+ year = 2024,
201
+ url = { https://huggingface.co/Keyven/SecIDS-CNN },
202
+ doi = { 10.57967/hf/3351 },
203
+ publisher = { Hugging Face }
204
+ }
SecIDS-CNN.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:65ea9c607a99c39cfc291d5ad8a087c6968d686ac6e7b5b3e0b841ff7e402b20
3
+ size 727136
config.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "SecIDS-CNN",
3
+ "architectures": [
4
+ "CNNForBinaryClassification"
5
+ ],
6
+ "model_type": "cnn",
7
+ "input_shape": [10, 1],
8
+ "num_classes": 2,
9
+ "num_conv_layers": 2,
10
+ "conv_filters": [32, 64],
11
+ "kernel_sizes": [3, 3],
12
+ "pooling_type": "none",
13
+ "batch_norm": true,
14
+ "dense_units": [128, 1],
15
+ "activation_hidden": "relu",
16
+ "activation_output": "sigmoid",
17
+ "dropout_rate": 0.3,
18
+ "loss_function": "binary_crossentropy",
19
+ "optimizer": "adam",
20
+ "metrics": ["accuracy"],
21
+ "transformers_version": "4.38.1"
22
+ }
23
+
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ tensorflow==2.11.0 # Ensure compatibility with your model version
2
+ pandas==1.5.2 # For handling data in DataFrames
3
+ numpy==1.23.5 # Required by TensorFlow and often useful for data processing
run_model.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ from secids_cnn import SecIDSModel
3
+
4
+ # Step 1: Initialize the model
5
+ model = SecIDSModel()
6
+
7
+ # Step 2: Load network traffic data (replace 'path/to/your/data.csv' with the actual path)
8
+ data = pd.read_csv('path/to/your/data.csv')
9
+
10
+ # Step 3: Make predictions
11
+ predictions = model.predict(data)
12
+
13
+ # Output results
14
+ print("Intrusion Detection Results:", predictions)
secids_cnn.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ import pandas as pd
3
+
4
+ class SecIDSModel:
5
+ def __init__(self, model_path="SecIDS-CNN.h5"):
6
+ # Load the trained model
7
+ self.model = tf.keras.models.load_model(model_path)
8
+
9
+ def predict(self, data):
10
+ # Preprocess data if needed (assume data is a Pandas DataFrame)
11
+ processed_data = self.preprocess_data(data)
12
+
13
+ # Make predictions
14
+ predictions = self.model.predict(processed_data)
15
+
16
+ # Convert predictions to readable format if needed
17
+ return ["Attack" if pred > 0.5 else "Benign" for pred in predictions]
18
+
19
+ def preprocess_data(self, data):
20
+ # Placeholder for preprocessing logic, adjust according to your needs
21
+ # For example, you may need to scale or reshape data
22
+ return data.values