How do I avoid escaping certain variables with nuclei? #4606
-
problem description:nuclei built-in function escapes the parameter value passed in, but sometimes the parameter value passed in is extracted regularly and needs to be retained. For example, if I use a regular expression to extract a value like test\filepath, I use the {{replace}} function expecting to convert it to test\\filepath, but in {{replace}} \ will be escaped and the final value passed in is testfilepath. Therefore, the replacement cannot be performed normally Example:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@xxxxxxxxyyyy according to template you have provided you are incorrectly using id: escapes-value
info:
name: extracted value will be automatically escaped
author: none
severity: info
http:
- raw:
- |
POST /test?{{Path}} HTTP/1.1
Host: {{Hostname}}
id=1
- |
POST /test HTTP/1.1
Host: {{Hostname}}
id={{replace('{{extracted}}','\\','\\\\')}}
matchers:
- type: status
status:
- 200
unsafe: true
extractors:
- type: regex
name: extracted
part: body_1
group: 1
internal: true
regex:
- ":\\\\(.+)\\\\test" here's docs you can refer about dynamic extractor https://docs.projectdiscovery.io/templates/reference/extractors#dynamic-extractor and i also recommend trying out Ai template generator at https://cloud.projectdiscovery.io/templates if you are new to writing templates (cause the template you have provided is invalid with multiple errors) btw request body or regex extracted values are not interpreted or escaped (this is only done to input urls) . |
Beta Was this translation helpful? Give feedback.
@xxxxxxxxyyyy according to template you have provided you are incorrectly using
dynamic extractors
orextractors
in general . since extracted needs to be written under extractors key something like,