spidey121 commited on
Commit
93b1bab
·
1 Parent(s): f14c7a7

fix round 1

Browse files
Files changed (3) hide show
  1. env/env.py +7 -9
  2. openenv.yaml +6 -6
  3. requirements.txt +1 -0
env/env.py CHANGED
@@ -16,6 +16,9 @@ class DeceptionEnv:
16
  self.deployed = False
17
 
18
  def reset(self):
 
 
 
19
  self.done = False
20
  self.current_step = 0
21
  self.detected = False
@@ -41,26 +44,22 @@ class DeceptionEnv:
41
 
42
  detected_any = False
43
 
44
- # Detect brute force
45
  if failed_logins > 3:
46
  reward += 0.15
47
  detected_any = True
48
 
49
- # Detect port scan
50
  for r in requests_log:
51
  if isinstance(r, dict) and r.get("type") == "port_scan":
52
  reward += 0.15
53
  detected_any = True
54
  break
55
 
56
- # Detect SQL injection
57
  for r in requests_log:
58
  if isinstance(r, dict) and r.get("type") == "sql_injection":
59
  reward += 0.15
60
  detected_any = True
61
  break
62
 
63
- # Detect directory traversal
64
  for r in requests_log:
65
  if isinstance(r, dict) and r.get("type") == "directory_traversal":
66
  reward += 0.15
@@ -70,16 +69,18 @@ class DeceptionEnv:
70
  if detected_any:
71
  self.detected = True
72
  else:
73
- reward -= 0.05
74
 
75
  # ---------------- Deploy Honeypot ----------------
76
  elif action == "deploy_honeypot":
 
77
  deploy_honeypot()
78
  reward += 0.30
79
  self.deployed = True
80
 
81
  # ---------------- Fake Database ----------------
82
  elif action == "fake_database":
 
83
  fake_database()
84
  reward += 0.20
85
  self.deployed = True
@@ -87,7 +88,6 @@ class DeceptionEnv:
87
  # ---------------- Block Attacker ----------------
88
  elif action == "block_ip":
89
 
90
- # Only allow block after detection + deception
91
  if (
92
  logs.get("suspicious_ips")
93
  and self.detected
@@ -102,14 +102,12 @@ class DeceptionEnv:
102
  self.done = True
103
 
104
  else:
105
- # Early block penalty
106
- reward += 0.05
107
 
108
  # ---------------- Episode Boundary ----------------
109
  if self.current_step >= self.max_steps:
110
  self.done = True
111
 
112
- # ---------------- Clamp reward ----------------
113
  reward = min(max(reward, 0.0), 1.0)
114
 
115
  self._state = logs
 
16
  self.deployed = False
17
 
18
  def reset(self):
19
+
20
+ requests.post(f"{SERVER}/reset")
21
+
22
  self.done = False
23
  self.current_step = 0
24
  self.detected = False
 
44
 
45
  detected_any = False
46
 
 
47
  if failed_logins > 3:
48
  reward += 0.15
49
  detected_any = True
50
 
 
51
  for r in requests_log:
52
  if isinstance(r, dict) and r.get("type") == "port_scan":
53
  reward += 0.15
54
  detected_any = True
55
  break
56
 
 
57
  for r in requests_log:
58
  if isinstance(r, dict) and r.get("type") == "sql_injection":
59
  reward += 0.15
60
  detected_any = True
61
  break
62
 
 
63
  for r in requests_log:
64
  if isinstance(r, dict) and r.get("type") == "directory_traversal":
65
  reward += 0.15
 
69
  if detected_any:
70
  self.detected = True
71
  else:
72
+ reward -= 0.10
73
 
74
  # ---------------- Deploy Honeypot ----------------
75
  elif action == "deploy_honeypot":
76
+
77
  deploy_honeypot()
78
  reward += 0.30
79
  self.deployed = True
80
 
81
  # ---------------- Fake Database ----------------
82
  elif action == "fake_database":
83
+
84
  fake_database()
85
  reward += 0.20
86
  self.deployed = True
 
88
  # ---------------- Block Attacker ----------------
89
  elif action == "block_ip":
90
 
 
91
  if (
92
  logs.get("suspicious_ips")
93
  and self.detected
 
102
  self.done = True
103
 
104
  else:
105
+ reward -= 0.10
 
106
 
107
  # ---------------- Episode Boundary ----------------
108
  if self.current_step >= self.max_steps:
109
  self.done = True
110
 
 
111
  reward = min(max(reward, 0.0), 1.0)
112
 
113
  self._state = logs
openenv.yaml CHANGED
@@ -1,19 +1,19 @@
1
  name: ai-deception-openenv
2
  version: 1
3
  environment: cyber-security
4
- description: AI Cyber Deception Environment for detecting, deceiving, and blocking cyber attacks
5
 
6
  entrypoint: inference.py
7
 
 
 
 
 
 
8
  tasks:
9
  - name: easy
10
- description: Detect cyber attack
11
-
12
  - name: medium
13
- description: Detect attack and deploy deception
14
-
15
  - name: hard
16
- description: Detect, deceive, and block attacker
17
 
18
  actions:
19
  - detect_attack
 
1
  name: ai-deception-openenv
2
  version: 1
3
  environment: cyber-security
4
+ framework: openenv
5
 
6
  entrypoint: inference.py
7
 
8
+ api:
9
+ reset: /reset
10
+ step: /step
11
+ state: /state
12
+
13
  tasks:
14
  - name: easy
 
 
15
  - name: medium
 
 
16
  - name: hard
 
17
 
18
  actions:
19
  - detect_attack
requirements.txt CHANGED
@@ -5,3 +5,4 @@ pydantic
5
  openai
6
  gunicorn
7
  uvicorn
 
 
5
  openai
6
  gunicorn
7
  uvicorn
8
+ openenv-core