A security agent tool to scan files and folders for malware using GLIMPS Malware Detect on Windows and GNU/Linux host systems.
- File and folder scanning: Scan individual files or entire directory structures
- Real-time monitoring: Watch directories for changes and automatically scan new/modified files
- Archive extraction: Extract and scan content from various archive formats
- Quarantine management: Automatically quarantine malicious files with encryption
- Cache system: Avoid re-scanning files that haven't changed
- Multiple actions: Configurable actions when malware is detected (quarantine, delete, move, log)
- Plugin system: Extensible architecture with built-in plugins for specialized processing (ONLY FOR GNU/Linux)
GMHost is built on a modular plugin architecture that enables extensible file processing capabilities:
Processing Flow:
- File Detection: Files are discovered through scan or monitoring commands
- Plugin Pipeline: Files pass through registered plugins in sequence
- Analysis: Clean files are sent to GLIMPS Malware Detect for analysis
- Action Processing: Results trigger configured actions (quarantine, delete, move, etc.)
- Reporting: Session and report plugins generate consolidated output
Plugin Integration Points:
- OnStartScanFile: Intercept files before analysis (filtering, preprocessing)
- OnFileScanned: Process analysis results (logging, custom actions)
- OnReport: Handle generated reports (consolidation, forwarding)
- XtractFile: Custom archive extraction logic
- GenerateReport: Custom report generation and formatting
GLIMPS Malware Host connector is a tool to scan files with GLIMPS Malware Detect
Usage:
GMHost [flags]
GMHost [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
monitoring Start monitoring location with GLIMPS Malware host
quarantine Handle GLIMPS Malware host quarantined files
scan Scan folders
Global Flags:
--cache string location of the cache DB
--config string config file (default "/etc/gmhost/config.yml")
--debug print debug strings
--extract extract archive and scan inner files
--gdetect-token string GLIMPS Malware Detect token
--gdetect-url string GLIMPS Malware Detect url (E.g https://gmalware.ggp.glimps.re)
--gdetect-syndetect use syndetect API to analyze files
-h, --help help for GMHost
--insecure do not check certificates
--max-file-size string max file size to push to GLIMPS Malware Detect (default "100MiB")
--move-destination string folder where legit files will be moved
--move-source string root folder from where to move files
--print-location string destination file for report logs
--quarantine string location of the quarantine folder (default "/var/lib/gmhost/quarantine")
--quiet print no information
--scan-validity duration Validity duration for each scan result (default 168h0m0s)
--timeout duration Time allowed to analyze each file (default 5m0s)
--verbose print more information
--workers int number of files analyzed at the same time (default 4)Scan files or directories for malware.
GMHost scan [flags] [path...]
Scan-specific Flags:
--gui enable graphical user interface (Windows only)Examples:
# Scan a single file
GMHost scan /path/to/file.exe
# Scan a directory
GMHost scan /path/to/directory
# Scan with GUI (Windows)
GMHost scan --gui C:\Users\Username\DownloadsStart real-time monitoring of directories for file changes.
GMHost monitoring [flags] [path...]
Monitoring-specific Flags:
--mod-delay duration Time waited between two modifications of a file before submitting it (default 30s)
--pre-scan start monitoring with a scan of existing files
--scan-period duration re-scan all files every scan-periodExamples:
# Monitor a directory with pre-scan
GMHost monitoring --pre-scan /home/user/Downloads
# Monitor with periodic re-scanning
GMHost monitoring --scan-period 1h /path/to/watchManage quarantined files.
GMHost quarantine [command]
Available Commands:
list List GLIMPS Malware host quarantined files
restore Restore quarantined filesExamples:
# List quarantined files
GMHost quarantine list
# Restore a specific file by ID
GMHost quarantine restore d86b21405852d8642ca41afae9dcf0f532e2d67973b0648b0af7c26933f1becbGMHost features an extensible plugin architecture that allows for specialized processing of files during the scanning pipeline. Plugins can intercept files at various stages, perform custom analysis, generate reports, and integrate with external systems.
All plugins must implement the plugins.Plugin interface:
type Plugin interface {
Init(configPath string, hcc HCContext) error
Close(ctx context.Context) error
}Plugins interact with the host connector through the HCContext interface:
type HCContext interface {
SetXTractFile(f XtractFileFunc)
RegisterOnStartScanFile(f OnStartScanFile)
RegisterOnFileScanned(f OnFileScanned)
RegisterOnReport(f OnReport)
RegisterGenerateReport(f GenerateReport)
GenerateReport(reportContext report.ScanContext, reports []report.Report) (io.Reader, error)
GetLogger() *slog.Logger
}Plugins can register callbacks for different stages of the scanning pipeline:
OnStartScanFile: Called before a file begins scanningOnFileScanned: Called after a file completes scanningOnReport: Called when a scan report is generatedGenerateReport: Custom report generation functionXtractFileFunc: Custom file extraction function
package main
import (
"context"
"log/slog"
"github.com/glimps-re/host-connector/pkg/plugins"
)
type MyPlugin struct {
logger *slog.Logger
config MyConfig
}
type MyConfig struct {
Setting1 string `yaml:"setting1"`
Setting2 int `yaml:"setting2"`
}
var HCPlugin MyPlugin
func (p *MyPlugin) Init(configPath string, hcc plugins.HCContext) error {
p.logger = hcc.GetLogger()
// Load configuration and register callbacks
hcc.RegisterOnStartScanFile(p.OnStartScanFile)
return nil
}
func (p *MyPlugin) Close(ctx context.Context) error {
// Cleanup plugin resources
return nil
}
func (p *MyPlugin) OnStartScanFile(file string, sha256 string) *gdetect.Result {
// Custom file processing logic
return nil
}
func main() {}Plugins are compiled as Go modules and loaded dynamically:
go build -buildmode=plugin -o myplugin.so main.goGMHost includes comprehensive unit tests for all built-in plugins:
- Extract Plugin: 24.9% coverage (focused on main plugin interface)
- Filetype Filter Plugin: 96.7% coverage
- Session Plugin: Coverage for all major functionality
- Report Plugin: 87.8% coverage
- Plugin Interface: Complete interface compliance testing
Run plugin tests:
# Test specific plugin
cd cmd/plugins/session && go test -v
# Test with coverage
go test -cover
# Test all plugins
find cmd/plugins -name "*_test.go" -execdir go test \;- Sandboxing: Plugins run in the same process space as GMHost
- Resource Limits: Configure appropriate limits to prevent resource exhaustion
- Input Validation: Plugins should validate all input data
- Logging: Use structured logging for audit trails
- Error Handling: Robust error handling prevents plugin failures from affecting the main application
The default configuration file is located at:
- Linux:
/etc/gmhost/config.ymlor~/.config/gmhost/config.yml - Windows:
%APPDATA%\gmhost\config.yml
workers: 4
extract: true
paths:
- C:\Users\YourUser\Documents
- /home/user/Downloads
actions:
delete: true
quarantine: true
moveLegit: false
print: true
log: true
monitoring:
preScan: true
reScan: true
period: 1h
modificationDelay: 30s
gdetect:
url: https://gmalware.ggp.glimps.re
token: 00000000-00000000-00000000-00000000-00000000
timeout: 5m
tags: ["Server1"]
insecure: false
syndetect: false
quarantine:
location: C:\Program Files\GMHost\quarantine
password: infected
cache:
location: C:\Program Files\GMHost\cache.db
scanValidity: 168h
move:
source: C:\path\to\source
destination: C:\path\to\destination
print:
location: C:\Program Files\GMHost\reports.logworkers: Number of files analyzed simultaneously (1-20, default: 4)extract: Extract and scan archive contents (default: false)maxFileSize: Maximum file size to analyze (default: "100MiB")paths: List of directories to monitor/scan
Configure what happens when malware is detected:
delete: Delete malicious files after quarantine (default: true)quarantine: Copy malicious files to quarantine folder (default: true)moveLegit: Move legitimate files after analysis (default: false)print: Print scan results to console (default: true)log: Log scan results (default: true)
preScan: Scan existing files when starting monitoring (default: true)reScan: Periodically re-scan all files (default: true)period: Time between full re-scans (default: 1h)modificationDelay: Wait time after file modification before scanning (default: 30s)
url: GLIMPS Malware Detect API endpointtoken: Authentication token for GLIMPS Malware Detecttimeout: Maximum time to wait for analysis (default: 5m)tags: Additional tags for submissions (default: ["GMHost"])insecure: Skip SSL certificate verification (default: false)syndetect: Use Syndetect API for analysis (default: false)
location: Directory to store quarantined filespassword: Password for encrypting quarantined files (default: "infected")
location: Cache database file location (empty for in-memory)scanValidity: How long scan results remain valid (default: 168h)
source: Root directory for files to be moveddestination: Target directory for legitimate files
location: File path for detailed reports (empty for stdout)
GMHost can extract and analyze files from various archive formats when the extract option is enabled:
Supported formats:
- ZIP
- GZIP
- TAR
- BZIP2
- RAR
- 7Z
- ISO
- Brotli
- LZ4
- XZ
- Zstandard
- S2
- Snappy
- Zlib
- LZW
Important notes:
- The extractor does not remove malicious files from archives
- If any file in an archive is malicious, the entire archive is considered malicious
- Archive contents are extracted to temporary directories and cleaned up after analysis
- Files larger than
maxFileSizewithin archives are skipped
When a file is scanned, multiple actions can be triggered based on the results:
- When: Malware is detected
- Effect: Creates an encrypted, protected copy of the malicious file in the quarantine folder
- Details: Files are encrypted using AES with a password and stored with metadata
- When: Malware is detected (after quarantine if enabled)
- Effect: Removes the original malicious file from the filesystem
- When: No malware is detected and file is in the source directory
- Effect: Moves legitimate files to the destination folder, preserving directory structure
- When: Always (configurable verbosity)
- Effect: Outputs scan results to console or specified log file
- When: Always
- Effect: Logs detailed scan information using structured logging
Download the MSI installer from the releases page and run it. This will:
- Install GMHost to
C:\Program Files\GMHost\ - Add right-click context menu items for scanning
- Create a default configuration file
Download the appropriate binary from the releases page:
# Download and install
wget https://github.com/glimps-re/host-connector/releases/latest/download/gmhost-linux-amd64
chmod +x gmhost-linux-amd64
sudo mv gmhost-linux-amd64 /usr/local/bin/gmhost
# Create config directory
sudo mkdir -p /etc/gmhostTo run GMHost monitoring at Windows startup:
REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "GMHost" /t REG_SZ /F /D "C:\Program Files\GMHost\gmhost.exe monitoring"The Windows installer automatically adds context menu items:
- Right-click any file or folder: "GMHost-Scan"
- Right-click
.lockfiles: "GMHost-Restore"
GMHost quarantine listOutput example:
|ID |Reason |File |
|d86b21405852d8642ca41afae9dcf0f532e2d67973b0648b0af7c26933f1becb|malware: eicar |eicar.txt |
# Restore by ID
GMHost quarantine restore d86b21405852d8642ca41afae9dcf0f532e2d67973b0648b0af7c26933f1becb
# Restore by filename (if .lock extension is included)
GMHost quarantine restore d86b21405852d8642ca41afae9dcf0f532e2d67973b0648b0af7c26933f1becb.lockWarning: Only restore files if you are certain they are safe. Restored files will be in their original, unencrypted form.
GMHost respects the following environment variables:
GDETECT_TOKEN: GLIMPS Malware Detect authentication tokenGDETECT_URL: GLIMPS Malware Detect API endpointTMPDIR: Temporary directory for archive extraction (Unix)
GMHost uses structured JSON logging. Log levels can be controlled with the --debug flag:
- Default: INFO level and above
--debug: DEBUG level and above--quiet: ERROR level only
Example log entry:
{"time":"2024-01-25T12:55:00Z","level":"INFO","msg":"info scanned","file":"/path/to/file","sha256":"abc123...","malware":true,"malwares":["trojan.win32.test"]}- Workers: Increase
workersfor faster scanning of many files, but be mindful of system resources - Cache: Enable persistent cache to avoid re-scanning unchanged files
- File size limits: Adjust
maxFileSizebased on your needs and GLIMPS Malware Detect limits - Network timeouts: Increase
timeoutfor large files or slow connections
- "File too large" warnings: Increase
maxFileSizeor enableextractfor archives - Permission denied: Ensure GMHost has read access to target directories and write access to quarantine/cache locations
- Connection timeouts: Check network connectivity to GLIMPS Malware Detect and increase
timeout - High CPU usage: Reduce number of
workersor adjust monitoring frequency
Enable debug logging for detailed troubleshooting:
GMHost --debug scan /path/to/problematic/file- Quarantined files are encrypted but should still be handled with care
- The quarantine password is stored in plain text in the configuration file
- GMHost requires network access to GLIMPS Malware Detect for analysis
- Consider firewall rules to restrict GMHost's network access to only necessary endpoints
- Documentation: GitHub Repository
- Issues: GitHub Issues
- API Documentation: GoDoc
This project is licensed under the MIT License - see the LICENSE file for details.