Skip to content

Commit fa920e4

Browse files
committed
Added handler for HTTP2/PRI
1 parent 8fd9401 commit fa920e4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

protocols/protocols.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func MapTCPProtocolHandlers(log interfaces.Logger, h interfaces.Honeypot) map[st
7575
return nil
7676
}
7777
// poor mans check for HTTP request
78-
httpMap := map[string]bool{"GET ": true, "POST": true, "HEAD": true, "OPTI": true, "CONN": true}
78+
httpMap := map[string]bool{"GET ": true, "POST": true, "HEAD": true, "OPTI": true, "CONN": true,"PRI": true}
7979
if _, ok := httpMap[strings.ToUpper(string(snip))]; ok {
8080
return tcp.HandleHTTP(ctx, bufConn, md, log, h)
8181
}

protocols/tcp/http.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,15 @@ func HandleHTTP(ctx context.Context, conn net.Conn, md connection.Metadata, logg
123123
logger.Error("Failed to close the HTTP connection", producer.ErrAttr(err))
124124
}
125125
}()
126-
126+
127+
reader := bufio.NewReader(conn)
128+
preface,err := reader.Peek(24)
129+
if err==nil && bytes.Equal(preface, []byte("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n")){
130+
settingsFrame := []byte("\x00\x00\x00\x04\x00\x00\x00\x00\x00")
131+
_,_ = conn.Write(settingsFrame)
132+
return conn.Close()
133+
}
134+
127135
req, err := http.ReadRequest(bufio.NewReader(conn))
128136
if err != nil {
129137
return fmt.Errorf("failed to read the HTTP request: %w", err)

0 commit comments

Comments
 (0)