-
Notifications
You must be signed in to change notification settings - Fork 427
Allow custom banner on attack domains #1273
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
base: main
Are you sure you want to change the base?
Allow custom banner on attack domains #1273
Conversation
WalkthroughDocumentation added for placeholder support ( Changes
Sequence DiagramsequenceDiagram
participant Client
participant Handler
participant Banner as Banner/Template
Client->>Handler: GET /
rect rgb(230, 245, 230)
Note over Handler: New placeholder substitution
alt Custom Banner exists
Handler->>Banner: Replace {REFLECTION}, {DOMAIN}
Banner-->>Handler: Substituted content
Handler-->>Client: Custom banner response
else No custom banner
alt Reflection empty
Handler-->>Client: Standard banner response
else Reflection present
Handler-->>Client: JSON/XML reflection response
end
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Areas for attention:
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/server/http_server.go (1)
66-67: Incorrect variable used for logging custom index path.Line 66 uses
options.HTTPDirectoryto compute the absolute path, but line 68 reads fromoptions.HTTPIndex. The log message at line 67 will display the wrong path if these differ.Apply this diff to fix the logging:
- abs, _ := filepath.Abs(options.HTTPDirectory) + abs, _ := filepath.Abs(options.HTTPIndex) gologger.Info().Msgf("Using custom server index: %s", abs)Note: This is a pre-existing bug, not introduced by this PR, but worth fixing while working on the custom banner feature.
🧹 Nitpick comments (1)
pkg/server/http_server.go (1)
64-65: Update comment to mention both supported placeholders.The comment should reflect that both
{REFLECTION}and{DOMAIN}placeholders are now supported in the custom index file.Apply this diff to update the comment:
// If custom index, read the custom index file and serve it. -// Supports {DOMAIN} placeholders. +// Supports {REFLECTION} and {DOMAIN} placeholders.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
README.md(1 hunks)pkg/server/http_server.go(1 hunks)
🔇 Additional comments (2)
README.md (1)
605-606: LGTM! Clear documentation of placeholder support.The documentation accurately describes the new placeholder functionality for custom index files, explaining both
{REFLECTION}(for inverted ID) and{DOMAIN}(for server domain name) substitution.pkg/server/http_server.go (1)
280-284: LGTM! Placeholder substitution logic correctly implements the feature.The refactored conditional logic correctly serves the custom banner with
{REFLECTION}and{DOMAIN}placeholder substitution whenever a custom banner is configured. The fallback to the standard banner when no custom banner exists and reflection is empty preserves the expected behavior.This changes the previous behavior where the custom banner was only shown when reflection was empty—now it's always shown when configured, with the reflection value substituted via the placeholder. This aligns with the PR objectives to distinguish web clients using custom HTML on attack domains.
I would expect to always get a custom banner on the index of all the subdomains when the
-http-indexis set. But that's not the current behavior. This is a solution that allow to keep the reflection of the inverted domain in the response and at the same time have the custom index page.Use case:
I am trying to distinguish web clients, to do so I add a custom HTML that may do extra interactions depending on the client.
Summary by CodeRabbit
New Features
Documentation