Add fuzz tests for obfuscated2

This commit is contained in:
9seconds
2022-03-18 14:58:03 +03:00
parent cbe5b8c94e
commit 9375552180
5 changed files with 183 additions and 48 deletions
@@ -0,0 +1,32 @@
package obfuscated2
import (
"bytes"
"testing"
"github.com/stretchr/testify/require"
)
var FuzzClientHandshakeSecret = []byte{1,2,3}
func FuzzClientHandshake(f *testing.F) {
f.Add([]byte{1,2,3})
f.Fuzz(func(t *testing.T, frame []byte) {
data := bytes.NewReader(frame)
if _, _, _, err := ClientHandshake(FuzzClientHandshakeSecret, data); err != nil {
return
}
handshake := clientHandhakeFrame{}
require.Len(t, frame, handshakeFrameLen)
copy(handshake.data[:], frame)
decryptor := handshake.decryptor(FuzzClientHandshakeSecret)
decryptor.XORKeyStream(handshake.data[:], handshake.data[:])
require.Equal(t, handshakeConnectionType, handshake.connectionType())
})
}