-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
redact output #5463
Merged
Merged
redact output #5463
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mzack9999
approved these changes
Jul 30, 2024
ehsandeep
requested changes
Aug 4, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- handle values with spaces (values after space left as it is, see example below for Auth, UA header)
- support for redacting the values for
matched-at
as it can include query parameter (see example below)
As of now, if value contains space, only initial part gets redacted.
$ echo https://example.com | ./nuclei -t test.yaml -ms -j -rd user-agent,authorization,api -silent | jq .
{
"template-id": "basic-raw-example",
"template-path": "/Users/geekboy/Github/nuclei/test.yaml",
"template-encoded": "aWQ6IGJhc2ljLXJhdy1leGFtcGxlCgppbmZvOgogIG5hbWU6IFRlc3QgUkFXIFRlbXBsYXRlCiAgYXV0aG9yOiBwZHRlYW0KICBzZXZlcml0eTogaW5mbwoKaHR0cDoKICAtIHJhdzoKICAgICAgLSB8CiAgICAgICAgR0VUIC8/YXBpPXNlY3JldF9rZXkgSFRUUC8xLjEKICAgICAgICBIb3N0OiB7e0hvc3RuYW1lfX0KICAgICAgICBBdXRob3JpemF0aW9uOiBCYXNpYyBZbTl6WTIzNlltOXpZMjg9CiAgICAgICAgVXNlci1BZ2VudDogTW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfMTVfNCkgQXBwbGVXZWJLaXQvCgogICAgbWF0Y2hlcnM6CiAgICAgIC0gdHlwZTogd29yZAogICAgICAgIHdvcmRzOgogICAgICAgICAgLSAiVGVzdCBpcyB0ZXN0IG1hdGNoZXIgdGV4dCIKICAgICAgICBuZWdhdGl2ZTogdHJ1ZQ==",
"info": {
"name": "Test RAW Template",
"author": [
"pdteam"
],
"tags": null,
"severity": "info"
},
"type": "http",
"host": "example.com",
"port": "443",
"scheme": "https",
"url": "https://example.com",
"matched-at": "https://example.com/?api=secret_key",
"request": "GET /?api=*** HTTP/1.1\r\nHost: example.com\r\nUser-Agent: *** (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/\r\nConnection: close\r\nAuthorization: *** Ym9zY236Ym9zY28=\r\nAccept-Encoding: gzip\r\n\r\n",
"response": "HTTP/1.1 200 OK\r\nConnection: close\r\nAge: 392178\r\nCache-Control: max-age=604800\r\nContent-Type: text/html; charset=UTF-8\r\nDate: Sun, 04 Aug 2024 08:44:03 GMT\r\nEtag: \"3147526947+gzip\"\r\nExpires: Sun, 11 Aug 2024 08:44:03 GMT\r\nLast-Modified: Thu, 17 Oct 2019 07:18:26 GMT\r\nServer: ECAcc (lac/55A7)\r\nVary: Accept-Encoding\r\nX-Cache: HIT\r\n\r\n<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 2em;\n background-color: #fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n @media (max-width: 700px) {\n div {\n margin: 0 auto;\n width: auto;\n }\n }\n </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n <p>This domain is for use in illustrative examples in documents. You may use this\n domain in literature without prior coordination or asking for permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More information...</a></p>\n</div>\n</body>\n</html>\n",
"ip": "2606:2800:21f:cb07:6820:80da:af6b:8b2c",
"timestamp": "2024-08-04T14:14:03.485206+05:30",
"curl-command": "curl -X 'GET' -d '' -H 'Authorization: *** Ym9zY236Ym9zY28=' -H 'Host: example.com' -H 'User-Agent: *** (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/' 'https://example.com/?api=***'",
"matcher-status": true
}
Test Template:
id: basic-raw-example
info:
name: Test RAW Template
author: pdteam
severity: info
http:
- raw:
- |
GET /?api=secret_key HTTP/1.1
Host: {{Hostname}}
Authorization: Basic Ym9zY236Ym9zY28=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/
matchers:
- type: word
words:
- "Test is test matcher text"
negative: true
$ echo https://example.com | go run . -t test_template.yaml -ms -j -rd user-agent,authorization,api -silent | jq .
{
"template-id": "basic-raw-example",
"template-path": "/Users/dogancanbakir/Projects/nuclei/cmd/nuclei/test_template.yaml",
"template-encoded": "aWQ6IGJhc2ljLXJhdy1leGFtcGxlCgppbmZvOgogIG5hbWU6IFRlc3QgUkFXIFRlbXBsYXRlCiAgYXV0aG9yOiBwZHRlYW0KICBzZXZlcml0eTogaW5mbwoKaHR0cDoKICAtIHJhdzoKICAgICAgLSB8CiAgICAgICAgR0VUIC8/YXBpPXNlY3JldF9rZXkgSFRUUC8xLjEKICAgICAgICBIb3N0OiB7e0hvc3RuYW1lfX0KICAgICAgICBBdXRob3JpemF0aW9uOiBCYXNpYyBZbTl6WTIzNlltOXpZMjg9CiAgICAgICAgVXNlci1BZ2VudDogTW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfMTVfNCkgQXBwbGVXZWJLaXQvCgogICAgbWF0Y2hlcnM6CiAgICAgIC0gdHlwZTogd29yZAogICAgICAgIHdvcmRzOgogICAgICAgICAgLSAiVGVzdCBpcyB0ZXN0IG1hdGNoZXIgdGV4dCIKICAgICAgICBuZWdhdGl2ZTogdHJ1ZQ==",
"info": {
"name": "Test RAW Template",
"author": [
"pdteam"
],
"tags": null,
"severity": "info"
},
"type": "http",
"host": "example.com",
"port": "443",
"scheme": "https",
"url": "https://example.com",
"matched-at": "https://example.com/?api=***",
"request": "GET /?api=***\r\nHost: example.com\r\nUser-Agent: ***\r\nConnection: close\r\nAuthorization: ***\r\nAccept-Encoding: gzip\r\n\r\n",
"response": "HTTP/1.1 200 OK\r\nConnection: close\r\nAccept-Ranges: bytes\r\nAge: 434332\r\nCache-Control: max-age=604800\r\nContent-Type: text/html; charset=UTF-8\r\nDate: Mon, 05 Aug 2024 13:29:07 GMT\r\nEtag: \"3147526947+gzip\"\r\nExpires: Mon, 12 Aug 2024 13:29:07 GMT\r\nLast-Modified: Thu, 17 Oct 2019 07:18:26 GMT\r\nServer: ECAcc (dcd/7D1F)\r\nVary: Accept-Encoding\r\nX-Cache: HIT\r\n\r\n<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 2em;\n background-color: #fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n @media (max-width: 700px) {\n div {\n margin: 0 auto;\n width: auto;\n }\n }\n </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n <p>This domain is for use in illustrative examples in documents. You may use this\n domain in literature without prior coordination or asking for permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More information...</a></p>\n</div>\n</body>\n</html>\n",
"ip": "93.184.215.14",
"timestamp": "2024-08-05T16:29:07.43085+03:00",
"curl-command": "curl -X 'GET' -d '' -H 'Authorization: ***' -H 'Host: example.com' -H 'User-Agent: ***' 'https://example.com/?api=***'",
"matcher-status": true
} |
ehsandeep
approved these changes
Aug 16, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ echo https://example.com | ./nuclei -t test.yaml -ms -j -rd user-agent,authorization,api -silent | jq .
{
"template-id": "basic-raw-example",
"template-path": "/Users/geekboy/Github/nuclei/test.yaml",
"template-encoded": "aWQ6IGJhc2ljLXJhdy1leGFtcGxlCgppbmZvOgogIG5hbWU6IFRlc3QgUkFXIFRlbXBsYXRlCiAgYXV0aG9yOiBwZHRlYW0KICBzZXZlcml0eTogaW5mbwoKaHR0cDoKICAtIHJhdzoKICAgICAgLSB8CiAgICAgICAgR0VUIC8/YXBpPXNlY3JldF9rZXkgSFRUUC8xLjEKICAgICAgICBIb3N0OiB7e0hvc3RuYW1lfX0KICAgICAgICBBdXRob3JpemF0aW9uOiBCYXNpYyBZbTl6WTIzNlltOXpZMjg9CiAgICAgICAgVXNlci1BZ2VudDogTW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfMTVfNCkgQXBwbGVXZWJLaXQvCgogICAgbWF0Y2hlcnM6CiAgICAgIC0gdHlwZTogd29yZAogICAgICAgIHdvcmRzOgogICAgICAgICAgLSAiVGVzdCBpcyB0ZXN0IG1hdGNoZXIgdGV4dCIKICAgICAgICBuZWdhdGl2ZTogdHJ1ZQ==",
"info": {
"name": "Test RAW Template",
"author": [
"pdteam"
],
"tags": null,
"severity": "info"
},
"type": "http",
"host": "example.com",
"port": "443",
"scheme": "https",
"url": "https://example.com",
"matched-at": "https://example.com/?api=***",
"request": "GET /?api=***\r\nHost: example.com\r\nUser-Agent: ***\r\nConnection: close\r\nAuthorization: ***\r\nAccept-Encoding: gzip\r\n\r\n",
"response": "HTTP/1.1 200 OK\r\nConnection: close\r\nAge: 523650\r\nCache-Control: max-age=604800\r\nContent-Type: text/html; charset=UTF-8\r\nDate: Fri, 16 Aug 2024 06:09:52 GMT\r\nEtag: \"3147526947+gzip\"\r\nExpires: Fri, 23 Aug 2024 06:09:52 GMT\r\nLast-Modified: Thu, 17 Oct 2019 07:18:26 GMT\r\nServer: ECAcc (lac/55CD)\r\nVary: Accept-Encoding\r\nX-Cache: HIT\r\n\r\n<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 2em;\n background-color: #fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n @media (max-width: 700px) {\n div {\n margin: 0 auto;\n width: auto;\n }\n }\n </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n <p>This domain is for use in illustrative examples in documents. You may use this\n domain in literature without prior coordination or asking for permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More information...</a></p>\n</div>\n</body>\n</html>\n",
"ip": "2606:2800:21f:cb07:6820:80da:af6b:8b2c",
"timestamp": "2024-08-16T11:39:52.659482+05:30",
"curl-command": "curl -X 'GET' -d '' -H 'Authorization: ***' -H 'Host: example.com' -H 'User-Agent: ***' 'https://example.com/?api=***'",
"matcher-status": true
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
Closes #1586
example output when using
-redact
nuclei -tags cve -u honey.scanme.sh -header "X-API-Key: XXX" -redact x-api-key,cookie -j
Checklist