## https://sploitus.com/exploit?id=491D1267-61DE-5B66-A7F9-232C19C265B1
# Nuclei2Xray
A tool written in Go language, used to convert Nucleiβs POCs to Xrayβs POC format. ## Features
- Supports converting Nuclei YAML POCs to Xray YAML format.
- Supports conversion of POCs for HTTP and Network types.
- Supports conversion of matchers and extractors.
- Supports batch conversion of all POC files in a directory.
- Automatically handles fields like request methods, paths, headers, and body.
- Supports parsing raw request formats.
## Installation
### Compile from source code
```bash
git clone
cd nuclei2xray
go mod download
go build -o nuclei2xray
```
## Usage
### Single-file conversion
```bash
# Basic usage
nuclei2xray -i nuclei_poc.yaml -o xray_poc.yml
# Not specifying an output file (default: same as input file, in the same directory; will overwrite the original POC)
nuclei2xray -i nuclei_poc.yaml
# It is recommended to use -o to specify the output directory to preserve the original Nuclei POC
```
### Batch conversion
```bash
# Convert all .yaml and .yml files in the directory to the same output directory
nuclei2xray -d ./nuclei_pocs/
# Convert all .yaml and .yml files in the directory to a specified output directory
nuclei2xray -d ./nuclei_pocs/ -o ./xray_poc/
```
### View help
```bash
nuclei2xray -h
```
## Conversion instructions
### Supported Nuclei POC features
- β HTTP requests (GET, POST, PUT, DELETE, etc.)
- β Raw request formats
- β Headers and Body
- β Matchers:
- Status matching
- Size matching
- Word matching
- Regex matching
- DSL matching
- Binary matching
- β Extractors:
- Regex extraction
- JSON extraction
- XPath extraction
- DSL extraction
- β Network requests
- β Variables
- β Metadata
### Conversion mappings
| Nuclei Field | Xray Field | Description |
|-------------|------------|--------------|
| `info.name` | `name` | POC name |
| `info.author` | `detail.author` | Author |
| `info.description` | `detail.description` | Description |
| `info.reference` | `detail.links` | Reference links |
| `info.tags` | `detail.tags` | Tags |
| `http[].method` | `rules[].method` | HTTP method |
| `http[].path` | `rules[].path` | Request path |
| `http[].headers` | `rules[].headers` | Request headers |
| `http[].body` | `rules[].body` | Request body |
| `http[].matchers` | `rules[].search` / `rules[].expression` | Matching rules |
| `http[].extractors` | `rules[].output` | Extraction rules |
| `variables` | `set` | Variable settings |
## Example
### Nuclei POC example
```yaml
id: test-poc
info:
name: Test Vulnerability
author: test
severity: high
description: Test description
http:
- method: GET
path:
- "{{BaseURL}}/test"
```
### Matchers:
- Type: Word
Words:
- "vulnerable"
Condition: And
### Converted Xray POC
```yaml
Name: Test Vulnerability
Transport: http
Rules:
r0:
Request:
Cache: True
Method: GET
Path: "{{BaseURL}}/test"
FollowRedirects: True
Expression: Response.Status == 200 && Response.Body.String.Contains("vulnerable")
r0():
Detail:
Author: test
Description: Test description
Tags: []
Vulnerability:
Level: High
```
## Notes
1. Some complex Nuclei features may not be fully converted and require manual adjustment.
2. DSL expressions will be kept as they are, but may need to be adjusted according to Xray syntax.
3. During batch conversion, if the output directory (-o) is not specified, the output files will be saved in the same directory as the input files.
4. During batch conversion, if the output directory (-o) is specified, the original directory structure will be maintained.
5. Failures during batch conversion will be logged in the `conversion_failures.log` file at the root of the project, facilitating subsequent troubleshooting.
6. It is recommended to verify the effectiveness of the POC after conversion.
## Version History
### v1.1.1 (2025-XX-XX)
- **Improvement**: The default output file name is exactly the same as the input file (including the extension), which helps maintain naming consistency across different directories. If the `-o` option is not specified, the converted file will overwrite the original one.
### v1.1.0 (2024-XX-XX)
- **Fixes**: Fixed issues with handling `{{BaseURL}}` in the path field.
- Added the `removeBaseURL` function to properly handle the `{{BaseURL}}` placeholder in paths.
- Ensured that the converted path field starts with `/`, meeting Xrayβs path format requirements.
- If the path only contains `{{BaseURL}}$, it will be converted to `/`.
### v1.0.0 (2024-XX-XX)
- **Initial version**: Implemented full conversion from Nuclei to Xray.
**Core Features**:
- β HTTP request conversion (support for GET, POST, PUT, DELETE, etc.)
- β Network requests conversion (TCP/UDP protocols)
- β Raw request format parsing and conversion
- β Request headers and request bodies conversion
- β Variable conversion, supporting Nuclei variable expressions to Xray format
**Matchers Support**:
- β Status code matching
- β Response size matching
- β Word keyword matching
- β Regular expression matching
- β DSL expression matching
- β Binary matching
- β Support for AND/OR condition combinations
**Extractors Support**:
- β Regular expression extraction
- β JSON path extraction
- β XPath extraction
- β DSL expression extraction
**Metadata Conversion**:
- β POC name, author, and description conversion
- β Reference link conversion
- β Tag conversion
- β Severity mapping
- β CVE/CWE ID conversion
**Batch Processing**:
- β Support for single-file conversion
- β Support for batch conversion of all YAML files in a directory
- β Support for recursive directory scanning
- β Support for maintaining the directory structure during conversion
- β Automatically skip converted files with `.xray.yml` or older `_xray.yml` extensions
- β Automatically skip the `xray_poc` directory
## Contributions
Feel free to submit Issues and Pull Requests!
## License
MIT License
[source-iocs-preserved method=response.body_string.contains('vulnerable')]