Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat #1092: Validate binary values + precompile them as well #1213

Merged
merged 3 commits into from
Nov 16, 2021

Conversation

Ice3man543
Copy link
Member

@Ice3man543 Ice3man543 commented Nov 2, 2021

Proposed changes

Closes #1092

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Copy link
Contributor

@forgedhallpass forgedhallpass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The associated ticket was about validating hex values from templates when the -validate flag is used. Instead of doing so, this PR seems to change the functionality itself. Have you checked if content highlighting with the -debug flag still works after this change?

@Ice3man543
Copy link
Member Author

Basically what i did was move the binary hex decoding to the Compile function which returns errors if it finds an invalid sequence, similar to what we do for regexes. It should not really have an impact on coloring as that part is not touched.

@forgedhallpass
Copy link
Contributor

You are right, when I looked at the code I relied on the name of the variable hexa, which in fact holds binary data. Also the Binary field in the matcher is confusing, because it actually contains the data in hexadecimal format. Another reason why having meaningful variable names is important...

Copy link
Member

@ehsandeep ehsandeep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo 1.1.1.1 | ./nuclei -t a.yaml -validate

                     __     _
   ____  __  _______/ /__  (_)
  / __ \/ / / / ___/ / _ \/ /
 / / / / /_/ / /__/ /  __/ /
/_/ /_/\__,_/\___/_/\___/_/   2.5.4-dev

		projectdiscovery.io

[WRN] Use with caution. You are responsible for your actions.
[WRN] Developers assume no liability and are not responsible for any misuse or damage.
[ERR] Error occurred parsing template test.yaml: could not compile request: could not compile operators: could not compile matcher: could not hex decode binary: 00700000200000002000000
[FTL] Could not run nuclei: an error occurred during templates validation

@ehsandeep ehsandeep merged commit eaa0d37 into dev Nov 16, 2021
@ehsandeep ehsandeep deleted the validate-binary branch November 16, 2021 20:34
@ehsandeep ehsandeep added the Status: Completed Nothing further to be done with this issue. Awaiting to be closed. label Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Completed Nothing further to be done with this issue. Awaiting to be closed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Also validate the binary matcher if template validation was requested
4 participants