diff --git a/README b/README index 4b2e3bc..a4adf93 100644 --- a/README +++ b/README @@ -2,6 +2,7 @@ go get github.com/mattn/go-sqlite3 go get golang.org/x/crypto/bcrypt go get gopkg.in/yaml.v2 +go get github.com/atotto/clipboard go mod download golang.org/x/term go mod tidy @@ -10,8 +11,9 @@ go run chaKey.go nano default.yaml sudo mkdir /etc/cliVault -sudo mv encrypted_aes_key.pem /etc/cliVault/ -sudo cp default.yaml /etc/cliVault/config.yaml +sudo chown $USER:$USER /etc/cliVault +mv encrypted_aes_key.pem /etc/cliVault/ +cp default.yaml /etc/cliVault/config.yaml sudo apt install gcc CGO_ENABLED=1 go build -o cliVault server.go @@ -32,4 +34,11 @@ sudo systemctl start cliVault ## Client ``` go build -o vaultClient client.go +sudo cp vaultClient /usr/local/bin/ +sudo cp net-lock.png /usr/share/icons/net-lock.png + +cp vaultClient.desktop ~/.local/share/applications/ +update-desktop-database ~/.local/share/applications + +OR use /usr/local/share/applications -- for all users ``` diff --git a/client.go b/client.go index d92e839..41a827c 100644 --- a/client.go +++ b/client.go @@ -4,6 +4,7 @@ import ( "crypto/sha256" "crypto/rand" "golang.org/x/crypto/chacha20poly1305" + "github.com/atotto/clipboard" "encoding/base64" "encoding/gob" "encoding/hex" @@ -113,6 +114,21 @@ func chDec(eText string)(string) { return string(decrypted) } +func copyText(text string) { + err := clipboard.WriteAll(text) + if err != nil { + fmt.Println("Failed to copy to clipboard:", err) + return + } + fmt.Println("Text copied to clipboard!") +} + +func pause() { + var input string + fmt.Print("Press Enter to continue...") + fmt.Scanln(&input) +} + func main() { configFilePtr := flag.String("config", "config.yaml", "Path to the YAML configuration file") flag.Parse() @@ -120,6 +136,7 @@ func main() { if *configFilePtr == "" { fmt.Println("Please specify a configuration file using -config") flag.Usage() + pause() os.Exit(1) } @@ -127,6 +144,7 @@ func main() { yamlFile, err := ioutil.ReadFile(*configFilePtr) if err != nil { log.Fatalf("Error reading YAML file: %v\n", err) + pause() } // Parse the YAML @@ -134,11 +152,13 @@ func main() { err = yaml.Unmarshal(yamlFile, &config) if err != nil { log.Fatalf("Error parsing YAML file: %v\n", err) + pause() } // Print the ChaKey if config.Auth.ChaKey == "" { fmt.Println("Warning: ChaKey not found in configuration file") + pause() } ChaKey = []byte(config.Auth.ChaKey) @@ -212,18 +232,23 @@ func main() { if err := enc.Encode(req); err != nil { fmt.Println("Failed to send request:", err) + pause() return } var res Response if err := dec.Decode(&res); err != nil { fmt.Println("Failed to receive response:", err) + pause() return } if res.Message != "" { fmt.Println("Server response:", res.Message) } else { - fmt.Println("Server response:", chDec(res.Enc)) + passwd := chDec(res.Enc) + fmt.Println("Server response:", passwd) + copyText(passwd) } + pause() } diff --git a/go.mod b/go.mod index 201d71b..72e5c6a 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( ) require ( + github.com/atotto/clipboard v0.1.4 // indirect golang.org/x/sys v0.33.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 45ea190..98c626b 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= +github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A= github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= diff --git a/net-lock.png b/net-lock.png new file mode 100644 index 0000000..9ddfe8d Binary files /dev/null and b/net-lock.png differ diff --git a/vaultClient.desktop b/vaultClient.desktop new file mode 100644 index 0000000..2ca1a04 --- /dev/null +++ b/vaultClient.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Version=1.0 +Name=PWD_Server +Comment=Password Server +GenericName=PWD_Server +Keywords=pass,password +Exec=/usr/local/bin/vaultClient -config /etc/cliVault/config.yaml +Terminal=false +Type=Application +Path=/etc/cliVault +Icon=/usr/share/icons/net-lock.png +Categories=GNOME;GTK;