mirror of https://github.com/daffainfo/nuclei.git
implementing requested changes
parent
0a6b84639b
commit
7251a2ef60
|
@ -3,6 +3,7 @@ package engine
|
|||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-rod/rod"
|
||||
|
@ -11,11 +12,12 @@ import (
|
|||
|
||||
// Page is a single page in an isolated browser instance
|
||||
type Page struct {
|
||||
page *rod.Page
|
||||
rules []requestRule
|
||||
instance *Instance
|
||||
router *rod.HijackRouter
|
||||
History []HistoryData
|
||||
page *rod.Page
|
||||
rules []requestRule
|
||||
instance *Instance
|
||||
router *rod.HijackRouter
|
||||
historyMutex sync.RWMutex
|
||||
History []HistoryData
|
||||
}
|
||||
|
||||
// HistoryData contains the page request/response pairs
|
||||
|
@ -92,6 +94,9 @@ func (p *Page) URL() string {
|
|||
|
||||
// DumpHistory returns the full page navigation history
|
||||
func (p *Page) DumpHistory() string {
|
||||
p.historyMutex.RLock()
|
||||
defer p.historyMutex.RUnlock()
|
||||
|
||||
var historyDump strings.Builder
|
||||
for _, historyData := range p.History {
|
||||
historyDump.WriteString(historyData.RawRequest)
|
||||
|
@ -99,3 +104,11 @@ func (p *Page) DumpHistory() string {
|
|||
}
|
||||
return historyDump.String()
|
||||
}
|
||||
|
||||
// addToHistory adds a request/response pair to the page history
|
||||
func (p *Page) addToHistory(historyData HistoryData) {
|
||||
p.historyMutex.Lock()
|
||||
defer p.historyMutex.Unlock()
|
||||
|
||||
p.History = append(p.History, historyData)
|
||||
}
|
||||
|
|
|
@ -64,9 +64,11 @@ func (p *Page) routingRuleHandler(ctx *rod.Hijack) {
|
|||
var rawResp strings.Builder
|
||||
respPayloads := ctx.Response.Payload()
|
||||
if respPayloads != nil {
|
||||
rawResp.WriteString(fmt.Sprintf("HTTP/1.1 %d %s\n", respPayloads.ResponseCode, respPayloads.ResponsePhrase))
|
||||
rawResp.WriteString("HTTP/1.1 ")
|
||||
rawResp.WriteString(fmt.Sprint(respPayloads.ResponseCode))
|
||||
rawResp.WriteString(" " + respPayloads.ResponsePhrase + "+\n")
|
||||
for _, header := range respPayloads.ResponseHeaders {
|
||||
rawResp.WriteString(fmt.Sprintf("%s: %s\n", header.Name, header.Value))
|
||||
rawResp.WriteString(header.Name + ": " + header.Value + "\n")
|
||||
}
|
||||
rawResp.WriteString("\n")
|
||||
rawResp.WriteString(ctx.Response.Body())
|
||||
|
@ -77,5 +79,5 @@ func (p *Page) routingRuleHandler(ctx *rod.Hijack) {
|
|||
RawRequest: rawReq,
|
||||
RawResponse: rawResp.String(),
|
||||
}
|
||||
p.History = append(p.History, historyData)
|
||||
p.addToHistory(historyData)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue