A Go program that captures screenshots at regular intervals and serves them via an HTTP server. Optionally, it can execute commands received via HTTP requests.
Features
Screenshot Capture: Periodically captures screenshots of the entire screen and saves them locally.
HTTP Server: Serves the saved screenshots and optionally provides an endpoint for executing system commands.
Command Execution: Run commands on the host system via HTTP requests (optional and controlled by a flag).
Installation
Clone the Repository:
git clone https://github.com/yourusername/your-repo.git
cd your-repo
Install Dependencies:
Ensure you have Go installed. Run the following commands to set up the project:
go mod tidy
Usage
Build and Run
To build and run the program with default settings:
go run main.go
Compile to executeable:
set GOOS=windows
set GOARCH=amd64
go build -o screenshot_server.exe
Command-Line Arguments
-dir: Directory to save screenshots. Default is ./screenshots/.
-addr: Address and port for the HTTP server. Default is :8080.
-interval: Interval between screenshots (e.g., 2s, 5m). Default is 2s.
-max: Maximum number of screenshots to keep before deletion. Default is 10.
-enable-command: Enable the command execution endpoint. If this flag is provided, the endpoint /sendcommand will be available.
Examples
Start the Server with Command Execution Enabled:
go run main.go -dir ./screenshots/ -addr :8080 -interval 5s -max 20 -enable-command
Start the Server with Command Execution Disabled:
go run main.go -dir ./screenshots/ -addr :8080 -interval 5s -max 20
HTTP Endpoints
/: Serves the directory containing screenshots.
/sendcommand: Executes a command on the host system. Requires command and optionally param query parameters.
Command Execution: Enabling command execution can be a security risk. Ensure you validate and sanitize input, and only enable this feature in a controlled environment.
Permissions: The program should be run with appropriate permissions to prevent unauthorized access or actions.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please follow the contribution guidelines to submit issues or pull requests.