From ffdf6262e3deac4dfa3fc5f4378a9780630381ce Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 5 Jul 2025 13:00:38 -0400 Subject: [PATCH] Desktop Icon & Copy to Clipboard --- README | 13 +++++++++++-- client.go | 27 ++++++++++++++++++++++++++- go.mod | 1 + go.sum | 2 ++ net-lock.png | Bin 0 -> 1263 bytes vaultClient.desktop | 12 ++++++++++++ 6 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 net-lock.png create mode 100644 vaultClient.desktop 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 0000000000000000000000000000000000000000..9ddfe8d0112d35f6e2b27a35acca356550dd7994 GIT binary patch literal 1263 zcmV1{~wr$(2jkRstR-I(fHf!6qZPi^nSnp=CG2i?BYg;|%&N;TR^q2b&>?2Q~ zHO0MY>pCo5u@Hi!Jk3Vpz6((AS`QsQ$db1$3w`^mO}wO-st{7jD0oG*C@K49s6}&j z{$`9CJKV~PY039pfaZDelI069WA;=R&HIe&2xg3*G{&}K^%A6K3TyAXfSAtfHf&yl z;iCr|RjRa-S3ghV(*oFZY|dU!0^-s8F2IWlD;wfI{W2{Ih2qm|MnFh-ljh%+w>=9| z2JgIY0?AFeq=ZI3HWi-?5}@Ak=wAN`SNHlpuI>$dTs?^H^*L9!dYntir{bJ|0tt;c zE7d04vp~;=oYQF>2{B!PtvMT!p_Z^CZx9ac9)Xj(@i={C5_J2=V0YnQFoB%>Ey&0e zU^<=&R(sC^J?hiJxe=2l_Jts&VfgTL$j9fvVpsr&X$hR>rLYiU z`4BG>0X-UUZo{Ega2ZFyYnug^X#%XL20}g};P}Cw(Cuo2{rL^Cb8AiHudjftl_gQQ zJ{~*Q{{~h|89~HLgwI`#K(mV6gq{?X(D(_@IsDJj=m{`-HS}jtW4_*=4ShWqV2w8^ z&yBh`0(ZLxh*w{Im3#k#H@VL)CnPw)RHJ$o)UH(>rArle{Qc+8DVINIHLUh-*TB`& z!SKDD$jC@zg9Z)Iv13P6sZzxr78cg#s&{-C_w`FDHCi(&D#}DhTSPBM z-S+L}`F&a`zn9N%6PAe*MiDzZd-Z=buaI-d^gRm%xpnoKt`N@yBZR{$GFnwUFxPP|ozgz`#i?mqvRi<+LFF zyxISOCy3{X*NFFs&xs$1KZt*cU?Pl&AR^Bn!`S`v&;KNTB)%X%Al^8i_rzoQ+wgyZ Z{{VJVi3ce89bNzc002ovPDHLkV1gY}aoqp_ literal 0 HcmV?d00001 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;