一个智能的Burp Suite插件,用于生成精确的正则表达式模式。
快速生成两种类型的正则表达式:
- Escape Literal - 完全精确匹配
- Smart Precise - 上下文定位 + 值匹配(推荐)
使用正则断言(lookaround assertions)实现:
- 上下文 → 用于精确定位(不包含在匹配结果中)
- 值模式 → 通用正则,可匹配同类值
HTTP响应:
{"code": 200, "message": "success", "data": {...}}操作:选中 success
生成的正则:
(?<="message":\s*")[a-z0-9]+(?=")工作原理:
(?<="message":\s*")- 正向后顾:确保前面是"message": "[a-z0-9]+- 匹配模式:任何字母数字组合(?=")- 正向先行:确保后面是"
匹配结果:
- ✅ 匹配
success(只匹配值本身) - ✅ 也能匹配
error、failed等 - ✅ 不会匹配其他字段的值(上下文限制)
- ✅ 结果中不包含
"message":或引号
Smart Precise会自动识别值的类型,生成相应的通用模式:
| 值类型 | 示例 | 生成模式 |
|---|---|---|
| Base64 | iVBORw0KGgoAAAA... |
[A-Za-z0-9+/]+=* |
| 十六进制 | abc123def456 |
[0-9a-fA-F]+ |
| UUID | 550e8400-e29b-41d4... |
[0-9a-f]{8}-[0-9a-f]{4}-... |
| 字母数字 | la91gabie35w9e8... |
[a-z0-9]+ |
| 纯数字 | 12345 |
\d+ |
| 纯字母 | success |
[a-z]+ |
- 在Burp Suite中选中要匹配的值
- 右键 → Generate Regex
- 选择模式:
- Escape Literal - 完全精确匹配选中的文本
- ✓ Smart Precise - 生成带上下文的通用模式(推荐)
- 在弹出对话框中:
- 查看生成的正则表达式
- 在完整的请求/响应中测试
- 复制到剪贴板使用
- 下载
regex-generator-1.0.jar - Burp Suite → Extender → Extensions → Add
- 选择下载的JAR文件
# 需要Java 17
export JAVA_HOME=/path/to/jdk-17
mvn clean package
# 生成的文件:target/regex-generator-1.0.jar{"message": "success"}选中 success → 生成:(?<="message":\s*")[a-z]+(?=")
可用于匹配任何message值
{"image": "iVBORw0KGgoAAAA..."}选中Base64 → 生成:(?<="image":\s*")[A-Za-z0-9+/]+=*(?=")
可用于提取任何Base64图片
{"identifier": "la91gabie35w9e8gmyrnkvryl47hzaa1"}选中identifier值 → 生成:(?<="identifier":\s*")[a-z0-9]+(?=")
可用于匹配任何identifier
- Java版本:17
- Burp API:Montoya API 2023.12.1
- 正则引擎:Java
java.util.regex.Pattern - 上下文长度:最多12个字符,自动处理换行边界
✅ 精确定位 - 使用上下文确保在正确位置匹配
✅ 值匹配 - 匹配结果只包含值本身,不含上下文
✅ 通用性强 - 自动生成可复用的模式
✅ 智能识别 - 自动检测Base64、UUID等常见格式
✅ 易于测试 - 内置测试功能,显示完整请求/响应
Generate two types of regular expressions:
- Escape Literal - Exact match only
- Smart Precise - Context positioning + Value matching (Recommended)
Uses lookaround assertions:
- Context → For precise positioning (not included in match result)
- Value pattern → Generic regex that matches similar values
HTTP Response:
{"code": 200, "message": "success", "data": {...}}Action: Select success
Generated Regex:
(?<="message":\s*")[a-z0-9]+(?=")How it works:
(?<="message":\s*")- Positive lookbehind: ensures preceded by"message": "[a-z0-9]+- Matching pattern: any alphanumeric combination(?=")- Positive lookahead: ensures followed by"
Match Results:
- ✅ Matches
success(value only) - ✅ Also matches
error,failed, etc. - ✅ Won't match values in other fields (context constraint)
- ✅ Result excludes
"message":and quotes
Smart Precise automatically recognizes value types and generates appropriate patterns:
| Type | Example | Generated Pattern |
|---|---|---|
| Base64 | iVBORw0KGgoAAAA... |
[A-Za-z0-9+/]+=* |
| Hexadecimal | abc123def456 |
[0-9a-fA-F]+ |
| UUID | 550e8400-e29b-41d4... |
[0-9a-f]{8}-[0-9a-f]{4}-... |
| Alphanumeric | la91gabie35w9e8... |
[a-z0-9]+ |
| Numeric | 12345 |
\d+ |
| Letters | success |
[a-z]+ |
- Select the value in Burp Suite
- Right-click → Generate Regex
- Choose mode:
- Escape Literal - Exact match of selected text
- ✓ Smart Precise - Generic pattern with context (Recommended)
- In the dialog:
- View generated regex
- Test in full request/response
- Copy to clipboard
- Download
regex-generator-1.0.jar - Burp Suite → Extender → Extensions → Add
- Select the JAR file
# Requires Java 17
export JAVA_HOME=/path/to/jdk-17
mvn clean package
# Output: target/regex-generator-1.0.jar{"message": "success"}Select success → Generates: (?<="message":\s*")[a-z]+(?=")
Matches any message value
{"image": "iVBORw0KGgoAAAA..."}Select Base64 → Generates: (?<="image":\s*")[A-Za-z0-9+/]+=*(?=")
Extracts any Base64 image
{"identifier": "la91gabie35w9e8gmyrnkvryl47hzaa1"}Select identifier → Generates: (?<="identifier":\s*")[a-z0-9]+(?=")
Matches any identifier value
- Java Version: 17
- Burp API: Montoya API 2023.12.1
- Regex Engine: Java
java.util.regex.Pattern - Context Length: Max 12 chars, auto-handles newline boundaries
✅ Precise Positioning - Context ensures matching at correct location
✅ Value Matching - Result contains value only, no context
✅ Highly Reusable - Auto-generates reusable patterns
✅ Smart Detection - Recognizes Base64, UUID, and other formats
✅ Easy Testing - Built-in test with full request/response view
MIT License
Issues and pull requests are welcome!
