mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2024-12-22 22:36:53 +00:00
fix: client hello
This commit is contained in:
parent
6b0547b431
commit
852b789ac3
48
proxy/client_hello.go
Normal file
48
proxy/client_hello.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package proxy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
const headerLen = 5
|
||||||
|
|
||||||
|
type ClientHello struct {
|
||||||
|
Header ClientHelloHeader
|
||||||
|
Raw []byte //Header + Payload
|
||||||
|
RawHeader []byte
|
||||||
|
RawPayload []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientHelloHeader struct {
|
||||||
|
Type byte
|
||||||
|
ProtoVersion uint16
|
||||||
|
PayloadLen uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReadClientHello(r io.Reader) (*ClientHello, error) {
|
||||||
|
var rawHeader [5]byte
|
||||||
|
_, err := io.ReadFull(r, rawHeader[:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
header := ClientHelloHeader{
|
||||||
|
Type: rawHeader[0],
|
||||||
|
ProtoVersion: binary.BigEndian.Uint16(rawHeader[1:3]),
|
||||||
|
PayloadLen: binary.BigEndian.Uint16(rawHeader[3:5]),
|
||||||
|
}
|
||||||
|
raw := make([]byte, header.PayloadLen+headerLen)
|
||||||
|
copy(raw[0:headerLen], rawHeader[:])
|
||||||
|
_, err = io.ReadFull(r, raw[headerLen:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
hello := &ClientHello{
|
||||||
|
Header: header,
|
||||||
|
Raw: raw,
|
||||||
|
}
|
||||||
|
hello.RawHeader = hello.Raw[:headerLen]
|
||||||
|
hello.RawPayload = hello.Raw[headerLen:]
|
||||||
|
return hello, nil
|
||||||
|
}
|
@ -45,12 +45,12 @@ func (pxy *Proxy) handleHttps(lConn *net.TCPConn, exploit bool, initPkt *packet.
|
|||||||
log.Debug("[HTTPS] Sent 200 Connection Estabalished to ", lConn.RemoteAddr())
|
log.Debug("[HTTPS] Sent 200 Connection Estabalished to ", lConn.RemoteAddr())
|
||||||
|
|
||||||
// Read client hello
|
// Read client hello
|
||||||
tmpBuffer := make([]byte, 4096)
|
hello, err := ReadClientHello(lConn)
|
||||||
clientHello, err := ReadBytes(lConn, tmpBuffer)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("[HTTPS] Error reading client hello from the client", err)
|
log.Debug("[HTTPS] Error reading client hello from the client", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
clientHello := hello.Raw
|
||||||
|
|
||||||
log.Debug("[HTTPS] Client sent hello ", len(clientHello), "bytes")
|
log.Debug("[HTTPS] Client sent hello ", len(clientHello), "bytes")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user