Skip to content

Commit

Permalink
Merge pull request #63 from stulzq/master
Browse files Browse the repository at this point in the history
  • Loading branch information
withlin authored Nov 5, 2020
2 parents 72ff485 + 98f8bee commit b7c5331
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
# vendor/

.vscode
.idea
.idea

vendor
34 changes: 34 additions & 0 deletions client/security_util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package client

import (
"crypto/sha1"
"encoding/hex"
)

func Scramble411(data *[]byte,seed *[]byte) []byte {
crypt := sha1.New()

//stage1
crypt.Write(*data)
stage1 := crypt.Sum(nil)

//stage2
crypt.Reset()
crypt.Write(stage1)
stage2 := crypt.Sum(nil)

//stage3
crypt.Reset()
crypt.Write(*seed)
crypt.Write(stage2)
stage3 := crypt.Sum(nil)
for i := range stage3 {
stage3[i] ^= stage1[i]
}

return stage3
}

func ByteSliceToHexString(data []byte) string {
return hex.EncodeToString(data)
}
4 changes: 3 additions & 1 deletion client/simple_canal_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ func (c SimpleCanalConnector) doConnect() error {
}

handshake := &pb.Handshake{}
seed := &handshake.Seeds
err = proto.Unmarshal(p.GetBody(), handshake)
if err != nil {
return err
}
pas := []byte(c.PassWord)
bytePas :=[]byte(c.PassWord)
pas := []byte(ByteSliceToHexString(Scramble411(&bytePas,seed)))
ca := &pb.ClientAuth{
Username: c.UserName,
Password: pas,
Expand Down

0 comments on commit b7c5331

Please sign in to comment.