Add file manager, storing extracted files

This commit is contained in:
2020-01-08 16:34:31 +01:00
parent cd01dc7664
commit 1217153e78
4 changed files with 24 additions and 1 deletions

View File

@@ -3,10 +3,12 @@ package http
import (
"bufio"
"fmt"
"git.darknebu.la/maride/pancap/output"
"github.com/google/gopacket"
"github.com/google/gopacket/tcpassembly"
"github.com/google/gopacket/tcpassembly/tcpreader"
"io"
"io/ioutil"
"net/http"
)
@@ -48,9 +50,12 @@ func (h *httpResponseStream) run() {
// Ignore, because it may be a request
} else {
// Try to process assembled request
tcpreader.DiscardBytesToEOF(resp.Body)
fileBytes, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
// Register file in filemanager
output.RegisterFile("", fileBytes, "HTTP response")
// Build summary
line := fmt.Sprintf("Response %s, Type %s, Size %d bytes", resp.Status, resp.Header.Get("Content-Type"), resp.ContentLength)
responseSummaryLines = append(responseSummaryLines, line)