ws

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package ws will provide websocket functionality to keep the browser windows in sync

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeWS

func ServeWS(hub *Hub, w http.ResponseWriter, r *http.Request) bool

ServeWS will handle the socket connections

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a middleman between the websocket connection and the hub.

type Conn

type Conn interface {
	Read(ctx context.Context) (websocket.MessageType, []byte, error)
	Close(code websocket.StatusCode, reason string) error
	Write(ctx context.Context, tp websocket.MessageType, data []byte) error
}

type DNSEvent

type DNSEvent struct {
	Type   string    `json:"type"`   // "dns"
	Name   string    `json:"name"`   // queried hostname
	QType  string    `json:"qtype"`  // "A", "MX", "TXT" …
	Source string    `json:"source"` // client IP:port
	Time   time.Time `json:"timestamp"`
}

type HTTPEvent

type HTTPEvent struct {
	Type       string            `json:"type"`       // "http"
	Method     string            `json:"method"`     // "GET", "POST", "PUT", "DELETE"
	URL        string            `json:"url"`        // full URL including query string
	Body       string            `json:"body"`       // request/response body
	Parameters string            `json:"parameters"` // query parameters
	Headers    map[string]string `json:"headers"`    // HTTP headers
	Source     string            `json:"source"`     // client IP:port
	UserAgent  string            `json:"useragent"`  // browser/user agent string
	Status     int               `json:"status"`     // HTTP status code
	Timestamp  time.Time         `json:"timestamp"`
}

type Hub

type Hub struct {

	// Inbound messages from the clients.
	Broadcast chan []byte

	// Ring BUffers - capped storage survives client reconnect
	HTTPLog *RingBuffer
	DNSLog  *RingBuffer
	SMTPLog *RingBuffer
	SMBLog  *RingBuffer
	// contains filtered or unexported fields
}

Hub maintains the set of active clients and broadcasts messages to the clients.

func NewHub

func NewHub(cb *clipboard.Clipboard, cliEnabled bool) *Hub

NewHub will create a new hub

func (*Hub) Run

func (h *Hub) Run()

Run runs the hub

type NTLMEvent

type NTLMEvent struct {
	Type            string    `json:"type"`            // "ntlm"
	Username        string    `json:"username"`        // username
	Domain          string    `json:"domain"`          // domain
	Workstation     string    `json:"workstation"`     // workstation
	Challenge       string    `json:"challenge"`       // challenge
	Hash            string    `json:"hash"`            // hashcat line
	HashType        string    `json:"hashType"`        // Distinguishing between NetNTLMv1/2, SSP, LM, etc.
	HashcatMode     string    `json:"hashcatMode"`     // hashcat mode (v2 5600, v1 5500, 3000 LM, 1000 NTLM)
	CrackedPassword string    `json:"crackedPassword"` // plaintext password if cracked, empty otherwise
	Source          string    `json:"source"`          // source
	Timestamp       time.Time `json:"timestamp"`
}

type Packet

type Packet struct {
	Type    string `json:"type"`
	Content json.RawMessage
}

Packet defines a packet struct

type RingBuffer

type RingBuffer struct {
	// contains filtered or unexported fields
}

RingBuffer is a fixed-capacity thread-safe circular buffer. When full, the oldest entry is dropped to make room for the new one.

func NewRingBuffer

func NewRingBuffer(max int) *RingBuffer

func (*RingBuffer) Add

func (r *RingBuffer) Add(item []byte)

Add appends an item, evicting the oldest if at capacity.

func (*RingBuffer) Clear

func (r *RingBuffer) Clear()

Clear empties the buffer.

func (*RingBuffer) Last

func (r *RingBuffer) Last(n int) [][]byte

Last returns the most recent n items (or all if fewer exist), in oldest-first order, ready to replay on the client.

type SMTPAttachment

type SMTPAttachment struct {
	ID          string `json:"id"`
	Filename    string `json:"filename"`
	ContentType string `json:"contentType"`
	Size        int    `json:"size"`
}

type SMTPEvent

type SMTPEvent struct {
	Type        string           `json:"type"` // "smtp"
	From        string           `json:"from"`
	To          []string         `json:"to"`
	CC          []string         `json:"cc"`
	BCC         []string         `json:"bcc"`
	Subject     string           `json:"subject"`
	Body        string           `json:"body"`
	HTMLBody    string           `json:"htmlBody"`
	RawHeader   string           `json:"rawHeader"`
	Attachments []SMTPAttachment `json:"attachments"`
	Timestamp   time.Time        `json:"timestamp"`
}

type SendPacket

type SendPacket struct {
	Type    string `json:"type"`
	Content string `json:"content"`
}

SendPacket represents a response package from server to browser

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL