-
-
Notifications
You must be signed in to change notification settings - Fork 83
feat: support service banner for TCP #168
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
Open
milinddethe15
wants to merge
9
commits into
mushorg:main
Choose a base branch
from
milinddethe15:feat/add-banners
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5b68e34
feat: Add responses for TCP
milinddethe15 f2ad60e
add banners for service ports
milinddethe15 beeb301
handle service banner
milinddethe15 97785ca
send banner after timeout
milinddethe15 c71654b
Merge branch 'mushorg:main' into feat/add-banners
milinddethe15 8279706
log if error
milinddethe15 f5caeca
update test
milinddethe15 17d8f51
Merge branch 'mushorg:main' into feat/add-banners
milinddethe15 07e10d3
handle conn
milinddethe15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package tcp | ||
|
||
import ( | ||
"embed" | ||
"fmt" | ||
"io" | ||
"log/slog" | ||
"net" | ||
|
||
"github.com/mushorg/glutton/connection" | ||
"github.com/mushorg/glutton/producer" | ||
"github.com/mushorg/glutton/protocols/interfaces" | ||
) | ||
|
||
//go:embed banners/* | ||
var bannerFiles embed.FS | ||
|
||
// SendBanner retrieves and sends service banner for the specified port. | ||
func SendBanner(port uint16, conn net.Conn, md connection.Metadata, logger interfaces.Logger, h interfaces.Honeypot) error { | ||
bannerPath := fmt.Sprintf("banners/%d_tcp", port) | ||
banner, err := bannerFiles.Open(bannerPath) | ||
if err != nil { | ||
return fmt.Errorf("failed to get banner: %w", err) | ||
} | ||
defer banner.Close() | ||
|
||
bannerData, err := io.ReadAll(banner) | ||
if err != nil { | ||
return fmt.Errorf("failed to read banner content: %w", err) | ||
} | ||
if _, err := conn.Write(bannerData); err != nil { | ||
return fmt.Errorf("failed to write banner: %w", err) | ||
} | ||
if err = h.ProduceTCP("banner", conn, md, bannerData, nil); err != nil { | ||
logger.Error("Failed to produce message", producer.ErrAttr(err), slog.String("handler", "banner")) | ||
} | ||
return nil | ||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
+OK |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Microsoft Windows XP [Version 5.1.2600] | ||
(C) Copyright 1985-2001 Microsoft Corp. | ||
|
||
C:\WINDOWS\system32> |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
220 Welcome to localhost |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
250 localhost ESMTP Postfix |
Binary file not shown.
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Microsoft Windows XP [Version 5.1.2600] | ||
(C) Copyright 1985-2001 Microsoft Corp. | ||
|
||
C:\WINDOWS\system32> |
Binary file not shown.
Binary file not shown.
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
SIP/2.0 200 OK | ||
Via: SIP/2.0/TCP 127.0.0.1:5060;branch=1234567890 | ||
From: sip:[email protected];tag=bad-012345 | ||
To: <sip:[email protected];user=phone>;tag=bad-012345 | ||
Call-ID: 1348979872-797979222304855 | ||
Cseq: 15 INVITE | ||
Contact: sip:[email protected] | ||
Content-Length: 401 | ||
Content-Type: application/sdp | ||
|
||
v=0 | ||
Anonymous 1234567890 9876543210 IN IP4 127.0.0.1 | ||
s=SIGMA is the best | ||
s=gotcha | ||
c=IN IP4 127.0.0.1 | ||
t=0 0 | ||
m=audio 36952 RTP/AVP 107 119 100 106 6 0 97 105 98 8 18 3 5 101 | ||
a=rtpmap:107 BV32/16000 | ||
a=rtpmap:119 BV32-FEC/16000 | ||
a=rtpmap:100 SPEEX/16000 | ||
a=rtpmap:106 SPEEX-FEC/16000 | ||
a=rtpmap:97 SPEEX/8000 | ||
a=rtpmap:105 SPEEX-FEC/8000 | ||
a=rtpmap:98 iLBC/8000 | ||
a=rtpmap:101 telephone-event/8000 | ||
a=fmtp:101 0-11 |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
RFB 003.008 |
Binary file not shown.
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
HTTP/1.1 200 OK | ||
Connection: close | ||
Date: Sun, 27 Nov 2005 13:07:34 GMT | ||
Server: Microsoft-IIS/6.0 | ||
X-Powered-By: ASP.NET | ||
X-AspNet-Version: 2.0.50727 | ||
Accept-Ranges: bytes | ||
Content-Length: 30 | ||
Cache-Control: private | ||
Content-Type: text/html; charset=utf-8 | ||
|
||
<HTML> | ||
<BODY> | ||
</BODY> | ||
</HTML> |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Service banners are sourced from: https://github.com/armedpot/honeytrap/tree/master/etc/responses. |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
+OK |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Microsoft Windows XP [Version 5.1.2600] | ||
(C) Copyright 1985-2001 Microsoft Corp. | ||
|
||
C:\WINDOWS\system32> |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
220 Welcome to localhost |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
250 localhost ESMTP Postfix |
Binary file not shown.
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Microsoft Windows XP [Version 5.1.2600] | ||
(C) Copyright 1985-2001 Microsoft Corp. | ||
|
||
C:\WINDOWS\system32> |
Binary file not shown.
Binary file not shown.
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
SIP/2.0 200 OK | ||
Via: SIP/2.0/TCP 127.0.0.1:5060;branch=1234567890 | ||
From: sip:[email protected];tag=bad-012345 | ||
To: <sip:[email protected];user=phone>;tag=bad-012345 | ||
Call-ID: 1348979872-797979222304855 | ||
Cseq: 15 INVITE | ||
Contact: sip:[email protected] | ||
Content-Length: 401 | ||
Content-Type: application/sdp | ||
|
||
v=0 | ||
Anonymous 1234567890 9876543210 IN IP4 127.0.0.1 | ||
s=SIGMA is the best | ||
s=gotcha | ||
c=IN IP4 127.0.0.1 | ||
t=0 0 | ||
m=audio 36952 RTP/AVP 107 119 100 106 6 0 97 105 98 8 18 3 5 101 | ||
a=rtpmap:107 BV32/16000 | ||
a=rtpmap:119 BV32-FEC/16000 | ||
a=rtpmap:100 SPEEX/16000 | ||
a=rtpmap:106 SPEEX-FEC/16000 | ||
a=rtpmap:97 SPEEX/8000 | ||
a=rtpmap:105 SPEEX-FEC/8000 | ||
a=rtpmap:98 iLBC/8000 | ||
a=rtpmap:101 telephone-event/8000 | ||
a=fmtp:101 0-11 |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
RFB 003.008 |
Binary file not shown.
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
HTTP/1.1 200 OK | ||
Connection: close | ||
Date: Sun, 27 Nov 2005 13:07:34 GMT | ||
Server: Microsoft-IIS/6.0 | ||
X-Powered-By: ASP.NET | ||
X-AspNet-Version: 2.0.50727 | ||
Accept-Ranges: bytes | ||
Content-Length: 30 | ||
Cache-Control: private | ||
Content-Type: text/html; charset=utf-8 | ||
|
||
<HTML> | ||
<BODY> | ||
</BODY> | ||
</HTML> |
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.
Uh oh!
There was an error while loading. Please reload this page.