在本地维护远端肉鸡的虚拟状态,以减少不必要的 Webhook 通讯

This commit is contained in:
栀染
2026-03-08 01:30:09 +00:00
parent db3816d8e2
commit 977614953c
3 changed files with 39 additions and 24 deletions
-15
View File
@@ -1,15 +0,0 @@
target:
webhook_url: "http://localhost:8000/webhook"
agent_name: "OpenClaw-Bot"
auth_token: "optional-token-if-needed"
attacker_server:
host: "0.0.0.0"
port: 8080
public_ip: "http://attacker-ip:8080"
optimization:
target_model: "gpt-4"
population_size: 20
max_iterations: 100
initial_trigger_seed: "ignore previous instructions"
+29
View File
@@ -0,0 +1,29 @@
import os
from typing import Dict, List, Optional
class VirtualOS:
def __init__(self, target_id: str):
self.target_id = target_id
self.cwd: str = "/"
self.env: Dict[str, str] = {}
self.vfs_cache: Dict[str, List[str]] = {} # path -> list of files
self.is_initialized: bool = False
def update_cwd(self, new_cwd: str):
self.cwd = new_cwd
def update_env(self, env_vars: Dict[str, str]):
self.env.update(env_vars)
def cache_directory(self, path: str, contents: List[str]):
self.vfs_cache[path] = contents
def get_cached_dir(self, path: str) -> Optional[List[str]]:
return self.vfs_cache.get(path)
def resolve_path(self, target_path: str) -> str:
"""解析绝对或相对路径"""
if target_path.startswith("/"):
return os.path.normpath(target_path)
else:
return os.path.normpath(os.path.join(self.cwd, target_path))
+10 -9
View File
@@ -1,9 +1,10 @@
requests>=2.31.0
cma>=3.3.0
tiktoken>=0.6.0
flask>=3.0.0
numpy>=1.26.0
pyyaml>=6.0
rich>=13.7.0
torch>=2.2.0
transformers>=4.38.0
fastapi==0.104.1
uvicorn==0.24.0
requests==2.31.0
cma==3.3.0
tiktoken==0.5.1
openai==1.3.5
rich==13.7.0
tenacity==8.2.3
pyyaml==6.0.1
pydantic==2.5.2