goscreenmonit

package module
v0.0.0-...-a2f796e Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

README

GoScreenMonit

Project Status: ⚠️ early development

Go Screen Monitor captures screenshots of a logged in user and sends them off to a monitor server.

Screenshots can be viewed by logging in to the web server and selecting a connected agent.

Sample

The client and server are both located in the cmd directory. Use go build to create the executables, then you can use the CLI arguments specified below.

Server

To run the server, do the following:

  1. copy the credentials.json.sample to credentials.json in the same directory as the built executable, then modify to add user logins.
  2. run genkeypair.sh to generate a tls key pair used for the web server and for agent to server communication.
  3. ensure you have a recent version of nodejs installed then run npm install && npm run build inside the ui directory.
  4. before running, ensure you have the following directory structure setup:
/goscreenmonit        (root project directory)
  - smserver          (server binary built with `go build ./cmd/smserver`)
  - server.key        (tls key file)
  - server.crt        (tls certificate file)
  - credentials.json  (web server authentication credentials)
  - ui                (ui source directory)
    - build           (directory of the built ui source files)

To run the server, use the following:

$ ./smserver -mserver :3000 -wserver :8080

Client

The client can be run with the following command.

smclient.exe -server 192.168.1.5:3000 -fps 5

You can also install the client on a windows pc with:

smclient.exe install watch -server 192.168.1.5:3000 -fps 5

This will install a watchdog service that will run on every subsequent user login with the specified parameters.

Todo

  • Increase security validation between agent and server
  • Provide a better authentication mechanism
  • Clean up the POC user interface
  • Increase data transmission efficiency from web server to UI
  • Look into a more efficient screen capture option

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureScreen

func CaptureScreen(index int) (*image.RGBA, error)

Capture screen by index

func CreateRegistration

func CreateRegistration(host, user string) ([]byte, error)

Create a registration message

func CreateRequest

func CreateRequest(reqtype uploadpb.ClientRequest_RequestType, message protoreflect.ProtoMessage) ([]byte, error)

Create a client request container with a message

func CreateResponse

func CreateResponse(restype uploadpb.ServerResponse_MessageType) ([]byte, error)

Create a server response container with a message

func CreateUpload

func CreateUpload(images [][]byte) ([]byte, error)

Create an image upload message

func DecodeImage

func DecodeImage(encimg []byte) ([]byte, error)

Decompress images with zlib

func EncodeImage

func EncodeImage(img []byte) ([]byte, error)

Compress screenshot with zlib

func GetScreenCount

func GetScreenCount() int

Get number of screens

func Init

func Init()

Init any setup code

func ReadCommand

func ReadCommand(conn net.Conn, datapipe chan []byte)

Accept and process requests from other end of socket

func ReadConnBytes

func ReadConnBytes(count uint64, conn net.Conn) ([]byte, error)

Helper function to read a certain amount of data into a buffer

func SendMessage

func SendMessage(msg []byte, conn net.Conn) error

Send a message by sending the message size before the message itself

Types

type RegisteredClient

type RegisteredClient struct {
	Address      string
	Conn         net.Conn
	Register     *uploadpb.Register
	LatestUpload *uploadpb.ImageUpload
	Listeners    []*func()
}

type Registration

type Registration struct {
	Host string
	User string
}

type Server

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

func NewServer

func NewServer(address, certPath, keyPath string) *Server

Create and start a new server

func (*Server) AddClientListener

func (server *Server) AddClientListener(address string, ln *func()) error

Register a listener for client image updates

func (*Server) GetClient

func (server *Server) GetClient(address string) *RegisteredClient

Access a single client

func (*Server) GetClients

func (server *Server) GetClients() map[string]*RegisteredClient

Provide access to client list

func (*Server) RemoveClientListener

func (server *Server) RemoveClientListener(address string, ln *func()) error

Remove a registered listener to cleanup

func (*Server) Start

func (server *Server) Start(quit chan int)

Start checks if already running before running listen

type Session

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

func NewSession

func NewSession(address string, fps int, registration Registration) *Session

Create a new session that automatically connects to the server

func (*Session) Start

func (session *Session) Start(quit chan int)

Start a new session

func (*Session) Stop

func (session *Session) Stop()

Stop the session

type WebServer

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

Runs a web server front-end for the monitor server backend

func NewWebServer

func NewWebServer(address, cert, key string, monitorsrv *Server) *WebServer

Create a web server

func (*WebServer) Start

func (server *WebServer) Start()

Start running the web server

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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