Skip to content

Conversation

@hulto
Copy link

@hulto hulto commented Apr 19, 2022

Built sandcat reverse shell over websockets.

Description

Have sandcat callback over a websocket to handle interactions with a low sleep.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Manually tested using caldera websocket contact branch.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 5, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@hulto hulto marked this pull request as ready for review May 5, 2022 15:53
@deacon-mp deacon-mp requested a review from Copilot September 29, 2025 23:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces WebSocket communication capabilities to the Sandcat agent as a new contact method, enabling interactive communication with low sleep intervals through a reverse shell over WebSockets.

  • Adds WebSocket dependency and implements a new Websocket contact type
  • Creates comprehensive documentation for building and developing new contact extensions
  • Implements base64-encoded message exchange over WebSocket connections

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
gocat/go.mod Adds gorilla/websocket dependency for WebSocket functionality
gocat-extensions/contact/websocket_rev_contact.go Implements complete WebSocket contact module with connection handling and message exchange
docs/Sandcat-Details.md Adds detailed documentation for building extensions and contact development

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

func (a *Websocket) SetUpstreamDestAddr(upstreamDestAddr string) {
upstreamDestAddr = "ws://localhost:7013/ws_interactive"
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

The parameter upstreamDestAddr is being overwritten with a hardcoded value, ignoring the intended upstream address. This makes the function parameter useless and forces all connections to localhost:7013.

Suggested change
upstreamDestAddr = "ws://localhost:7013/ws_interactive"

Copilot uses AI. Check for mistakes.
}
_, message, err := a.ws_client.ReadMessage()
if err != nil {
output.VerbosePrint(fmt.Sprintf("[-] Cannot recieve websocket message: %s", err.Error()))
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Spelling error: 'recieve' should be 'receive'.

Suggested change
output.VerbosePrint(fmt.Sprintf("[-] Cannot recieve websocket message: %s", err.Error()))
output.VerbosePrint(fmt.Sprintf("[-] Cannot receive websocket message: %s", err.Error()))

Copilot uses AI. Check for mistakes.
Comment on lines +140 to +142
// if val, ok := jsonData["sleep"]; ok {
// jsonData["sleep"] = float64(0)
// }
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Commented-out code should be removed rather than left in the codebase. If this functionality might be needed later, consider implementing it properly or documenting why it's disabled.

Suggested change
// if val, ok := jsonData["sleep"]; ok {
// jsonData["sleep"] = float64(0)
// }

Copilot uses AI. Check for mistakes.
// SendExecutionResults will send the execution results to the upstream destination.
func (a *Websocket) SendExecutionResults(profile map[string]interface{}, result map[string]interface{}) {
output.VerbosePrint("[*] Sending results")
_ = fmt.Sprintf("%s%s", a.upstreamDestAddr, apiBeacon)
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

This line creates a formatted string that is immediately discarded. Either remove this line or use the result if it serves a purpose.

Suggested change
_ = fmt.Sprintf("%s%s", a.upstreamDestAddr, apiBeacon)

Copilot uses AI. Check for mistakes.
@deacon-mp
Copy link
Contributor

Can you address the comments above and resubmit for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants