Create dataset
Browse files
dataset
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import random
|
3 |
+
from datetime import datetime, timedelta
|
4 |
+
|
5 |
+
# Generate random timestamps
|
6 |
+
def random_timestamp():
|
7 |
+
start = datetime(2024, 1, 1)
|
8 |
+
return start + timedelta(seconds=random.randint(0, 60 * 60 * 24 * 30))
|
9 |
+
|
10 |
+
# Generate random IPs
|
11 |
+
def random_ip():
|
12 |
+
return ".".join(str(random.randint(0, 255)) for _ in range(4))
|
13 |
+
|
14 |
+
# Dataset parameters
|
15 |
+
protocols = ["TCP", "UDP", "ICMP"]
|
16 |
+
actions = ["Allow", "Deny"]
|
17 |
+
threat_levels = ["Low", "Medium", "High", "Critical"]
|
18 |
+
threat_types = ["DDoS", "Brute Force", "SQL Injection", "Port Scan", "Malware"]
|
19 |
+
response_actions = ["Blocked", "Alerted", "Monitored", "Escalated"]
|
20 |
+
|
21 |
+
# Create dataset
|
22 |
+
data = {
|
23 |
+
"timestamp": [random_timestamp().strftime("%Y-%m-%d %H:%M:%S") for _ in range(500)],
|
24 |
+
"source_ip": [random_ip() for _ in range(500)],
|
25 |
+
"destination_ip": [random_ip() for _ in range(500)],
|
26 |
+
"protocol": [random.choice(protocols) for _ in range(500)],
|
27 |
+
"port": [random.randint(20, 65535) for _ in range(500)],
|
28 |
+
"action": [random.choice(actions) for _ in range(500)],
|
29 |
+
"threat_level": [random.choice(threat_levels) for _ in range(500)],
|
30 |
+
"threat_type": [random.choice(threat_types) for _ in range(500)],
|
31 |
+
"response_action": [random.choice(response_actions) for _ in range(500)],
|
32 |
+
}
|
33 |
+
|
34 |
+
# Convert to DataFrame
|
35 |
+
df = pd.DataFrame(data)
|
36 |
+
|
37 |
+
# Save as CSV
|
38 |
+
df.to_csv("nsg_dataset.csv", index=False)
|
39 |
+
|
40 |
+
print("✅ NSG Dataset (500 records) created successfully!")
|