-
-
Notifications
You must be signed in to change notification settings - Fork 66
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: Add responses for TCP #168
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: milinddethe15 <[email protected]>
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.
Please add a README.md into the responses folder with a not where the responses are sourced from.
Just to confirm:
|
1 and 2 is correct. For 3, just read once, no need to read until max payload, that is just protection. |
Signed-off-by: milinddethe15 <[email protected]>
what tool should I use to hit the target? |
try netcat: |
I tried to test it and the banner isn't sent as soon as connected, but until attacker's payload. Is this how it should work? |
You need to send the banner before we peek the connection here |
Signed-off-by: milinddethe15 <[email protected]>
Tested locally with TCP port 4444. works good. |
//go:embed banners/* | ||
var bannerFiles embed.FS | ||
|
||
func SendBanner(conn net.Conn, port uint16) error { |
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.
Needs doc string
|
||
func SendBanner(conn net.Conn, port uint16) error { | ||
bannerPath := fmt.Sprintf("banners/%d_tcp", port) | ||
banner, err := bannerFiles.ReadFile(bannerPath) |
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.
open the file and then use io.Copy
to write the file content into the connection.
} | ||
if _, err := conn.Write(banner); err != nil { | ||
return fmt.Errorf("failed to write banner: %w", err) | ||
} |
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.
We still want to produce an event after sending the banner, see example
if err := tcp.SendBanner(conn, md.TargetPort); err != nil { | ||
log.Error("failed to send service banner", producer.ErrAttr(err)) | ||
} |
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.
My concern now is that we write the banner without peeking and potentially detecting the HTTP payload. Maybe we should try to read it and, if we time out, send the banner.
Have a look at the failing test. |
fixes #53
TCP handler can handle other target ports without need of seperate port handlers.