channel

package
v1.48.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

The channel package is the container for first-party framework C2 structures and variables, it holds the internal settings for multiple types of C2s. It is also passed to other external C2 components in order to support extracting components such as lhost and lport.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	IPAddr   string
	HTTPAddr string
	Port     int
	HTTPPort int
	Timeout  int
	IsClient bool
	Shutdown *atomic.Bool
	Sessions map[string]Session
	Input    io.Reader
	Output   io.Writer // Currently unused but figured we'd add it ahead of time
}

func (*Channel) AddSession added in v1.43.0

func (c *Channel) AddSession(conn *net.Conn, addr string) bool

AddSession adds a remote connection for session tracking. If a network connection is being tracked it can be added here and will be cleaned up and closed automatically by the C2 on shutdown.

func (*Channel) GetSessionIDByConn added in v1.48.0

func (c *Channel) GetSessionIDByConn(conn net.Conn) (string, bool)

Returns the session ID that contains a given connection

func (*Channel) HasSessions added in v1.43.0

func (c *Channel) HasSessions() bool

HasSessions checks if a channel has any tracked sessions. This can be used to lookup if a C2 successfully received callbacks:

c, ok := c2.GetInstance(conf.C2Type)
c.Channel().HasSessions()

func (*Channel) RemoveSession added in v1.43.0

func (c *Channel) RemoveSession(id string) bool

RemoveSession removes a specific session ID and if a connection exists, closes it.

func (*Channel) RemoveSessions added in v1.43.0

func (c *Channel) RemoveSessions() bool

RemoveSessions removes all tracked sessions and closes any open connections if applicable.

func (*Channel) UpdateLastSeenByConn added in v1.48.0

func (c *Channel) UpdateLastSeenByConn(conn net.Conn, timeStamp time.Time) bool

Updates the LastSeen value for provided connection to the provided time

type Session added in v1.43.0

type Session struct {
	RemoteAddr     string
	ConnectionTime time.Time

	Active   bool
	LastSeen time.Time
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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