From d5846bc88da84d655c4b937db47ca103cc87d81a Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 28 Feb 2020 11:59:56 -0800 Subject: [PATCH 1/8] encrypt all communication with relay --- src/tcp/tcp.go | 138 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 127 insertions(+), 11 deletions(-) diff --git a/src/tcp/tcp.go b/src/tcp/tcp.go index 138e38f..34da2ff 100644 --- a/src/tcp/tcp.go +++ b/src/tcp/tcp.go @@ -10,8 +10,10 @@ import ( "github.com/pkg/errors" "github.com/schollz/croc/v6/src/comm" + "github.com/schollz/croc/v6/src/crypt" "github.com/schollz/croc/v6/src/models" log "github.com/schollz/logger" + "github.com/schollz/pake/v2" ) type server struct { @@ -136,15 +138,57 @@ func (s *server) run() (err error) { } } +var weakKey = []byte{1, 2, 3} + func (s *server) clientCommuncation(port string, c *comm.Comm) (room string, err error) { + // establish secure password with PAKE for communication with relay + B, err := pake.InitCurve(weakKey, 1, "siec", 1*time.Millisecond) + if err != nil { + return + } + Abytes, err := c.Receive() + if err != nil { + return + } + err = B.Update(Abytes) + if err != nil { + return + } + err = c.Send(B.Bytes()) + Abytes, err = c.Receive() + if err != nil { + return + } + err = B.Update(Abytes) + if err != nil { + return + } + strongKey, err := B.SessionKey() + if err != nil { + return + } + log.Debugf("strongkey: %x", strongKey) + + // receive salt + salt, err := c.Receive() + strongKeyForEncryption, _, err := crypt.New(strongKey, salt) + if err != nil { + return + } + log.Debugf("waiting for password") - passwordBytes, err := c.Receive() + passwordBytesEnc, err := c.Receive() + if err != nil { + return + } + passwordBytes, err := crypt.Decrypt(passwordBytesEnc, strongKeyForEncryption) if err != nil { return } if strings.TrimSpace(string(passwordBytes)) != s.password { err = fmt.Errorf("bad password") - c.Send([]byte(err.Error())) + enc, _ := crypt.Decrypt([]byte(err.Error()), strongKeyForEncryption) + c.Send(enc) return } @@ -154,14 +198,22 @@ func (s *server) clientCommuncation(port string, c *comm.Comm) (room string, err banner = "ok" } log.Debugf("sending '%s'", banner) - err = c.Send([]byte(banner + "|||" + c.Connection().RemoteAddr().String())) + bSend, err := crypt.Encrypt([]byte(banner+"|||"+c.Connection().RemoteAddr().String()), strongKeyForEncryption) + if err != nil { + return + } + err = c.Send(bSend) if err != nil { return } // wait for client to tell me which room they want log.Debug("waiting for answer") - roomBytes, err := c.Receive() + enc, err := c.Receive() + if err != nil { + return + } + roomBytes, err := crypt.Decrypt(enc, strongKeyForEncryption) if err != nil { return } @@ -176,7 +228,12 @@ func (s *server) clientCommuncation(port string, c *comm.Comm) (room string, err } s.rooms.Unlock() // tell the client that they got the room - err = c.Send([]byte("ok")) + + bSend, err = crypt.Encrypt([]byte("ok"), strongKeyForEncryption) + if err != nil { + return + } + err = c.Send(bSend) if err != nil { log.Error(err) s.deleteRoom(room) @@ -187,7 +244,11 @@ func (s *server) clientCommuncation(port string, c *comm.Comm) (room string, err } if s.rooms.rooms[room].full { s.rooms.Unlock() - err = c.Send([]byte("room full")) + bSend, err = crypt.Encrypt([]byte("room full"), strongKeyForEncryption) + if err != nil { + return + } + err = c.Send(bSend) if err != nil { log.Error(err) s.deleteRoom(room) @@ -218,7 +279,11 @@ func (s *server) clientCommuncation(port string, c *comm.Comm) (room string, err }(otherConnection, c, &wg) // tell the sender everything is ready - err = c.Send([]byte("ok")) + bSend, err = crypt.Encrypt([]byte("ok"), strongKeyForEncryption) + if err != nil { + return + } + err = c.Send(bSend) if err != nil { s.deleteRoom(room) return @@ -310,13 +375,56 @@ func ConnectToTCPServer(address, password, room string, timelimit ...time.Durati if err != nil { return } + + // get PAKE connection with server to establish strong key to transfer info + A, err := pake.InitCurve(weakKey, 0, "siec", 1*time.Millisecond) + if err != nil { + return + } + err = c.Send(A.Bytes()) + if err != nil { + return + } + Bbytes, err := c.Receive() + if err != nil { + return + } + err = A.Update(Bbytes) + if err != nil { + return + } + err = c.Send(A.Bytes()) + if err != nil { + return + } + strongKey, err := A.SessionKey() + if err != nil { + return + } + log.Debugf("strong key: %x", strongKey) + + strongKeyForEncryption, salt, err := crypt.New(strongKey, nil) + // send salt + err = c.Send(salt) + if err != nil { + return + } + log.Debug("sending password") - err = c.Send([]byte(password)) + bSend, err := crypt.Encrypt([]byte(password), strongKeyForEncryption) + if err != nil { + return + } + err = c.Send(bSend) if err != nil { return } log.Debug("waiting for first ok") - data, err := c.Receive() + enc, err := c.Receive() + if err != nil { + return + } + data, err := crypt.Decrypt(enc, strongKeyForEncryption) if err != nil { return } @@ -327,12 +435,20 @@ func ConnectToTCPServer(address, password, room string, timelimit ...time.Durati banner = strings.Split(string(data), "|||")[0] ipaddr = strings.Split(string(data), "|||")[1] log.Debug("sending room") - err = c.Send([]byte(room)) + bSend, err = crypt.Encrypt([]byte(room), strongKeyForEncryption) + if err != nil { + return + } + err = c.Send(bSend) if err != nil { return } log.Debug("waiting for room confirmation") - data, err = c.Receive() + enc, err = c.Receive() + if err != nil { + return + } + data, err = crypt.Decrypt(enc, strongKeyForEncryption) if err != nil { return } From 5fce2a2e27768ac2a70c37b5fa00e6496b051876 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 28 Feb 2020 12:58:46 -0800 Subject: [PATCH 2/8] encrypt external ip --- src/croc/croc.go | 34 ++++++++++++++++++++++++++++------ src/croc/croc_test.go | 9 ++++++--- src/message/message.go | 2 +- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/croc/croc.go b/src/croc/croc.go index eacb0d7..49a8208 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -642,9 +642,8 @@ func (c *Client) procesMesssagePake(m message.Message) (err error) { salt := make([]byte, 8) rand.Read(salt) err = message.Send(c.conn[0], c.Key, message.Message{ - Type: "salt", - Bytes: salt, - Message: c.ExternalIP, + Type: "salt", + Bytes: salt, }) if err != nil { return @@ -684,9 +683,8 @@ func (c *Client) processMessageSalt(m message.Message) (done bool, err error) { if !c.Options.IsSender { log.Debug("sending salt back") err = message.Send(c.conn[0], c.Key, message.Message{ - Type: "salt", - Bytes: m.Bytes, - Message: c.ExternalIP, + Type: "salt", + Bytes: m.Bytes, }) } log.Debugf("session key is verified, generating encryption with salt: %x", m.Bytes) @@ -699,6 +697,27 @@ func (c *Client) processMessageSalt(m message.Message) (done bool, err error) { return true, err } log.Debugf("key = %+x", c.Key) + if c.Options.IsSender { + log.Debug("sending external IP") + err = message.Send(c.conn[0], c.Key, message.Message{ + Type: "externalip", + Bytes: m.Bytes, + }) + } + return +} + +func (c *Client) processExternalIP(m message.Message) (done bool, err error) { + log.Debug("received external IP") + if !c.Options.IsSender { + err = message.Send(c.conn[0], c.Key, message.Message{ + Type: "externalip", + Message: c.ExternalIP, + }) + if err != nil { + return true, err + } + } if c.ExternalIPConnected == "" { // it can be preset by the local relay c.ExternalIPConnected = m.Message @@ -711,6 +730,7 @@ func (c *Client) processMessageSalt(m message.Message) (done bool, err error) { func (c *Client) processMessage(payload []byte) (done bool, err error) { m, err := message.Decode(c.Key, payload) if err != nil { + err = fmt.Errorf("problem with decoding: %s", err.Error()) return } @@ -726,6 +746,8 @@ func (c *Client) processMessage(payload []byte) (done bool, err error) { err = c.procesMesssagePake(m) case "salt": done, err = c.processMessageSalt(m) + case "externalip": + done, err = c.processExternalIP(m) case "error": // c.spinner.Stop() fmt.Print("\r") diff --git a/src/croc/croc_test.go b/src/croc/croc_test.go index 15811e0..30464d9 100644 --- a/src/croc/croc_test.go +++ b/src/croc/croc_test.go @@ -12,15 +12,18 @@ import ( "github.com/stretchr/testify/assert" ) -func TestCroc(t *testing.T) { +func init() { log.SetLevel("trace") - defer os.Remove("README.md") go tcp.Run("debug", "8081", "pass123", "8082,8083,8084,8085") go tcp.Run("debug", "8082", "pass123") go tcp.Run("debug", "8083", "pass123") go tcp.Run("debug", "8084", "pass123") go tcp.Run("debug", "8085", "pass123") - time.Sleep(1 * time.Second) + time.Sleep(5 * time.Second) +} + +func TestCrocReadme(t *testing.T) { + defer os.Remove("README.md") log.Debug("setting up sender") sender, err := New(Options{ diff --git a/src/message/message.go b/src/message/message.go index d46f983..2f4b9dc 100644 --- a/src/message/message.go +++ b/src/message/message.go @@ -24,11 +24,11 @@ func (m Message) String() string { // Send will send out func Send(c *comm.Comm, key []byte, m Message) (err error) { + log.Debugf("writing %s message", m.Type) mSend, err := Encode(key, m) if err != nil { return } - log.Debugf("writing %s message (%d bytes)", m.Type, len(mSend)) _, err = c.Write(mSend) return } From c3adc2981ffb6ff459fd3807e5c30d815a834b34 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 28 Feb 2020 13:02:23 -0800 Subject: [PATCH 3/8] encrypt external ip --- src/message/message.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/message/message.go b/src/message/message.go index 2f4b9dc..fa35c2f 100644 --- a/src/message/message.go +++ b/src/message/message.go @@ -24,7 +24,6 @@ func (m Message) String() string { // Send will send out func Send(c *comm.Comm, key []byte, m Message) (err error) { - log.Debugf("writing %s message", m.Type) mSend, err := Encode(key, m) if err != nil { return @@ -41,7 +40,10 @@ func Encode(key []byte, m Message) (b []byte, err error) { } b = compress.Compress(b) if key != nil { + log.Debugf("writing %s message (encrypted)", m.Type) b, err = crypt.Encrypt(b, key) + } else { + log.Debugf("writing %s message", m.Type) } return } From 0b99be5b3025e9cc04fccc530294cebfc0551420 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 28 Feb 2020 13:27:44 -0800 Subject: [PATCH 4/8] update year --- LICENSE | 2 +- src/croc/croc_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 0ca9765..698785d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Zack +Copyright (c) 2017-2020 Zack Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/croc/croc_test.go b/src/croc/croc_test.go index 30464d9..d0b749b 100644 --- a/src/croc/croc_test.go +++ b/src/croc/croc_test.go @@ -19,7 +19,7 @@ func init() { go tcp.Run("debug", "8083", "pass123") go tcp.Run("debug", "8084", "pass123") go tcp.Run("debug", "8085", "pass123") - time.Sleep(5 * time.Second) + time.Sleep(1 * time.Second) } func TestCrocReadme(t *testing.T) { From a87b571376ae7f68fa9a8857df563485839781c9 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 28 Feb 2020 13:30:39 -0800 Subject: [PATCH 5/8] update dockerifle --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e05417e..88d0ee3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.12-alpine as builder +FROM golang:1.14-alpine as builder RUN apk add --no-cache git WORKDIR /go/croc COPY . . From 788a63cfa607ffc4dc498dff64259b85d9e57868 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 28 Feb 2020 13:31:04 -0800 Subject: [PATCH 6/8] update deps --- go.mod | 9 ++++----- go.sum | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index bbaf4b7..cb98ebf 100644 --- a/go.mod +++ b/go.mod @@ -10,9 +10,9 @@ require ( github.com/fatih/color v1.9.0 // indirect github.com/kalafut/imohash v1.0.0 github.com/kr/pretty v0.1.0 // indirect - github.com/mattn/go-isatty v0.0.12 // indirect + github.com/mattn/go-colorable v0.1.6 // indirect github.com/pkg/errors v0.9.1 - github.com/schollz/logger v1.1.2 + github.com/schollz/logger v1.2.0 github.com/schollz/mnemonicode v1.0.1 github.com/schollz/pake/v2 v2.0.2 github.com/schollz/peerdiscovery v1.5.0 @@ -22,9 +22,8 @@ require ( github.com/stretchr/testify v1.4.0 github.com/tscholl2/siec v0.0.0-20191122224205-8da93652b094 github.com/urfave/cli v1.22.2 - golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 - golang.org/x/net v0.0.0-20200202094626-16171245cfb2 // indirect - golang.org/x/sys v0.0.0-20200217220822-9197077df867 // indirect + golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d + golang.org/x/net v0.0.0-20200226121028-0de0cce0169b // indirect golang.org/x/text v0.3.2 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect diff --git a/go.sum b/go.sum index 5c2f0e0..3522ee2 100644 --- a/go.sum +++ b/go.sum @@ -26,6 +26,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM= @@ -40,8 +42,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/schollz/logger v1.1.2 h1:liE73zV/9dw4qswqzG0Ydxhx3ltJLLo7Gd1YbLCx21Y= -github.com/schollz/logger v1.1.2/go.mod h1:P6F4/dGMGcx8wh+kG1zrNEd4vnNpEBY/mwEMd/vn6AM= +github.com/schollz/logger v1.2.0 h1:5WXfINRs3lEUTCZ7YXhj0uN+qukjizvITLm3Ca2m0Ho= +github.com/schollz/logger v1.2.0/go.mod h1:P6F4/dGMGcx8wh+kG1zrNEd4vnNpEBY/mwEMd/vn6AM= github.com/schollz/mnemonicode v1.0.1 h1:LiH5hwADZwjwnfXsaD4xgnMyTAtaKHN+e5AyjRU6WSU= github.com/schollz/mnemonicode v1.0.1/go.mod h1:cl4UAOhUV0mkdjMj/QYaUZbZZdF8BnOqoz8rHMzwboY= github.com/schollz/pake/v2 v2.0.2 h1:p9y4Gocc5PWueyhhR7OH+Gwpu2xkP5BM9Pepl9krVfo= @@ -71,14 +73,14 @@ github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190907121410-71b5226ff739/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 h1:Sy5bstxEqwwbYs6n0/pBuxKENqOeZUgD45Gp3Q3pqLg= -golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= +golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa h1:F+8P+gmewFQYRk6JoLQLwjBCTu3mcIURZfNkVweuRKA= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= @@ -86,8 +88,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200117145432-59e60aa80a0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200217220822-9197077df867 h1:JoRuNIf+rpHl+VhScRQQvzbHed86tKkqwPMV34T8myw= -golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= From bc1f89ff68c34ec5d9227ffb6fda975081a7c36a Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 28 Feb 2020 16:57:46 -0800 Subject: [PATCH 7/8] bump 8.0.0 --- .travis.yml | 12 ++++++------ README.md | 4 ++-- go.mod | 2 +- go.sum | 15 --------------- main.go | 2 +- src/cli/cli.go | 10 +++++----- src/croc/croc.go | 14 +++++++------- src/croc/croc_test.go | 2 +- src/install/default.txt | 2 +- src/message/message.go | 6 +++--- src/message/message_test.go | 4 ++-- src/tcp/tcp.go | 6 +++--- 12 files changed, 32 insertions(+), 47 deletions(-) diff --git a/.travis.yml b/.travis.yml index a8877c4..f13d9f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,12 +10,12 @@ install: true script: - env GO111MODULE=on go build -v - - env GO111MODULE=on go test -v -cover github.com/schollz/croc/v6/src/compress - - env GO111MODULE=on go test -v -cover github.com/schollz/croc/v6/src/croc - - env GO111MODULE=on go test -v -cover github.com/schollz/croc/v6/src/crypt - - env GO111MODULE=on go test -v -cover github.com/schollz/croc/v6/src/tcp - - env GO111MODULE=on go test -v -cover github.com/schollz/croc/v6/src/utils - - env GO111MODULE=on go test -v -cover github.com/schollz/croc/v6/src/comm + - env GO111MODULE=on go test -v -cover github.com/schollz/croc/v8/src/compress + - env GO111MODULE=on go test -v -cover github.com/schollz/croc/v8/src/croc + - env GO111MODULE=on go test -v -cover github.com/schollz/croc/v8/src/crypt + - env GO111MODULE=on go test -v -cover github.com/schollz/croc/v8/src/tcp + - env GO111MODULE=on go test -v -cover github.com/schollz/croc/v8/src/utils + - env GO111MODULE=on go test -v -cover github.com/schollz/croc/v8/src/comm branches: except: diff --git a/README.md b/README.md index e74d7d6..77eab0c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ src="https://user-images.githubusercontent.com/6550035/46709024-9b23ad00-cbf6-11e8-9fb2-ca8b20b7dbec.jpg" width="408px" border="0" alt="croc">
-Version +Version Coverage Build
@@ -69,7 +69,7 @@ $ snap install croc
 Or, you can [install Go](https://golang.org/dl/) and build from source (requires Go 1.12+): 
 
 ```
-$ GO111MODULE=on go get -v github.com/schollz/croc/v6
+$ GO111MODULE=on go get -v github.com/schollz/croc/v8
 ```
 
 
diff --git a/go.mod b/go.mod
index cb98ebf..cb8030b 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module github.com/schollz/croc/v6
+module github.com/schollz/croc/v8
 
 go 1.13
 
diff --git a/go.sum b/go.sum
index 3522ee2..d62723e 100644
--- a/go.sum
+++ b/go.sum
@@ -1,12 +1,9 @@
-github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
-github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
 github.com/OneOfOne/xxhash v1.2.5 h1:zl/OfRA6nftbBK9qTohYBJ5xvw6C/oNKizR7cZGl3cI=
 github.com/OneOfOne/xxhash v1.2.5/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q=
 github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
 github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
-github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
 github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
 github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
 github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
@@ -24,13 +21,10 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
 github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
 github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
-github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
 github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
 github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
 github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
-github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
 github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
-github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
 github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
 github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
 github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
@@ -56,16 +50,13 @@ github.com/schollz/spinner v0.0.0-20180925172146-6bbc5f7804f9 h1:y08o5oQ/slxXE/F
 github.com/schollz/spinner v0.0.0-20180925172146-6bbc5f7804f9/go.mod h1:kCMoQsqzx4MzGJWaALr6tKyCnlrY0kILGLkA1FOiLF4=
 github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
 github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
-github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
 github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
 github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
 github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
 github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
-github.com/tscholl2/siec v0.0.0-20180721101609-21667da05937 h1:lhssCpSe3TjKcbvUoPzFMuv9oUyZDgI3Cmgolfw2C90=
 github.com/tscholl2/siec v0.0.0-20180721101609-21667da05937/go.mod h1:KL9+ubr1JZdaKjgAaHr+tCytEncXBa1pR6FjbTsOJnw=
 github.com/tscholl2/siec v0.0.0-20191122224205-8da93652b094 h1:tZWtuLE+LbUwT4OP1oWBSB9zXA8qmQ5qEm4kV9R72oo=
 github.com/tscholl2/siec v0.0.0-20191122224205-8da93652b094/go.mod h1:KL9+ubr1JZdaKjgAaHr+tCytEncXBa1pR6FjbTsOJnw=
@@ -75,33 +66,27 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
 golang.org/x/crypto v0.0.0-20190907121410-71b5226ff739/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw=
 golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa h1:F+8P+gmewFQYRk6JoLQLwjBCTu3mcIURZfNkVweuRKA=
 golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=
 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200117145432-59e60aa80a0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
 golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
-golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e h1:FDhOuMEY4JVRztM/gsbk+IKUQ8kj74bxZrgw87eMMVc=
 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/tylerb/is.v1 v1.1.2 h1:AB/MANFml2ySf+adwcinvajyHvsYltAOD+rb/8njfSU=
 gopkg.in/tylerb/is.v1 v1.1.2/go.mod h1:9yQB2tyIhZ5oph6Kk5Sq7cJMd9c5Jpa1p3hr9kxzPqo=
-gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
 gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/main.go b/main.go
index 004a864..f1d9237 100644
--- a/main.go
+++ b/main.go
@@ -8,7 +8,7 @@ package main
 import (
 	Date: Fri, 28 Feb 2020 17:05:03 -0800 Subject: [PATCH 8/8] throw error when submitting bad passphrase to relay --- src/crypt/crypt.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/crypt/crypt.go b/src/crypt/crypt.go index b864d46..462865d 100644 --- a/src/crypt/crypt.go +++ b/src/crypt/crypt.go @@ -50,6 +50,10 @@ func Encrypt(plaintext []byte, key []byte) (encrypted []byte, err error) { // Decrypt using the pre-generated key func Decrypt(encrypted []byte, key []byte) (plaintext []byte, err error) { + if len(encrypted) < 13 { + err = fmt.Errorf("incorrect passphrase") + return + } b, err := aes.NewCipher(key) if err != nil { return