Support obfuscated2

This commit is contained in:
9seconds
2021-03-18 13:42:14 +03:00
parent 657a74a5c2
commit 58335b3e59
7 changed files with 225 additions and 7 deletions
+33
View File
@@ -0,0 +1,33 @@
package obfuscated2
import (
"crypto/cipher"
"net"
)
type Conn struct {
net.Conn
Encryptor cipher.Stream
Decryptor cipher.Stream
writeBuf []byte
}
func (c *Conn) Read(p []byte) (int, error) {
n, err := c.Conn.Read(p)
if err != nil {
return n, err // nolint: wrapcheck
}
c.Decryptor.XORKeyStream(p, p[:n])
return n, nil
}
func (c *Conn) Write(p []byte) (int, error) {
c.writeBuf = append(c.writeBuf[:0], p...)
c.Encryptor.XORKeyStream(c.writeBuf, c.writeBuf)
return c.Conn.Write(c.writeBuf)
}