关于 script-generator
Script Generator 用于生成经过优化和语法验证的 Python、PowerShell 或 Bash 脚本,但不会执行脚本。适用于较长脚本、多目标操作或需要重复连接与身份验证的任务。
主要功能
- 01生成 Python、PowerShell 和 Bash 脚本
- 02并发处理多个目标
- 03复用会话与身份验证
- 04交付前验证语法
- 05逐项处理错误并设置 I/O 超时
- 06避免在脚本中硬编码凭据
适用场景
- 01生成面向多个主机的操作脚本
- 02用复用会话处理重复 HTTP 请求
- 03创建包含重复身份验证握手的脚本
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ transilienceai/ communitytools --skill script-generator安装后在 Claude Code 中输入/script-generator确认已加载。
详细介绍
脚本生成器
按需生成经过优化且通过语法验证的脚本。绝不执行脚本。
使用时机
- 脚本超过约 30 行
- 对多个目标执行并行操作
- 使用多个库的模式(impacket + ldap3、pypsrp + concurrent.futures)
- 重复进行身份验证握手或连接设置
请求格式
LANGUAGE: python3 | powershell | bash
TASK: What the script should accomplish
TARGETS: IPs, hostnames, URLs
CREDENTIALS: user, pass, hash, domain, certs
AVAILABLE_LIBRARIES: What's installed
OUTPUT_FORMAT: stdout format, file writes
CONSTRAINTS: timeout, no destructive ops, output directory
CONTEXT: (optional) Prior output, errors, what failed
优化
- 多个目标 →
concurrent.futures.ThreadPoolExecutor - 对同一主机发起超过 3 个 HTTP 请求 →
requests.Session - 重复进行身份验证 → 仅验证一次,并复用会话/令牌
- 优先使用高级库(impacket、ldap3、requests)
输出
写入 OUTPUT_DIR/artifacts/<task_name>.<ext>。返回:
SCRIPT_PATH: OUTPUT_DIR/artifacts/task_name.py
LANGUAGE: python3
VALIDATION: PASSED
EXECUTION: python3 OUTPUT_DIR/artifacts/task_name.py
DEPENDENCIES: impacket, concurrent.futures (stdlib)
规则
- 绝不执行脚本——仅生成、优化和验证
- 对每项操作进行错误处理——不得使用裸
except: - 对所有 I/O 强制设置超时
- 返回前验证语法
- 不得将机密硬编码——将凭据作为变量放在顶部
评论
支持 Markdown