Skip to content

Commit

Permalink
Merge pull request #64 from tracertea/@tracertea/feature/extract-loca…
Browse files Browse the repository at this point in the history
…tion-header

Extracted location header into Result json to allow for additional da…
  • Loading branch information
ehsandeep authored Aug 12, 2020
2 parents 5a60c9e + ab6ee60 commit 84dc1e9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmd/httpx/httpx.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func main() {
scanopts.VHost = options.VHost
scanopts.OutputTitle = options.ExtractTitle
scanopts.OutputStatusCode = options.StatusCode
scanopts.OutputLocation = options.Location
scanopts.OutputContentLength = options.ContentLength
scanopts.StoreResponse = options.StoreResponse
scanopts.StoreResponseDirectory = options.StoreResponseDir
Expand Down Expand Up @@ -236,6 +237,7 @@ type scanOptions struct {
VHost bool
OutputTitle bool
OutputStatusCode bool
OutputLocation bool
OutputContentLength bool
StoreResponse bool
StoreResponseDirectory string
Expand Down Expand Up @@ -311,6 +313,16 @@ retry:
builder.WriteRune(']')
}

if scanopts.OutputLocation {
builder.WriteString(" [")
if !scanopts.OutputWithNoColor {
builder.WriteString(aurora.Magenta(resp.GetHeaderPart("Location", ";")).String())
} else {
builder.WriteString(resp.GetHeaderPart("Location", ";"))
}
builder.WriteRune(']')
}

if scanopts.OutputContentLength {
builder.WriteString(" [")
if !scanopts.OutputWithNoColor {
Expand Down Expand Up @@ -381,6 +393,7 @@ retry:
URL: fullURL,
ContentLength: resp.ContentLength,
StatusCode: resp.StatusCode,
Location: resp.GetHeaderPart("Location", ";"),
ContentType: resp.GetHeaderPart("Content-Type", ";"),
Title: title,
str: builder.String(),
Expand All @@ -397,6 +410,7 @@ type Result struct {
URL string `json:"url"`
ContentLength int `json:"content-length"`
StatusCode int `json:"status-code"`
Location string `json:"location"`
Title string `json:"title"`
str string
err error
Expand Down Expand Up @@ -424,6 +438,7 @@ type Options struct {
Smuggling bool
ExtractTitle bool
StatusCode bool
Location bool
ContentLength bool
Retries int
Threads int
Expand Down Expand Up @@ -471,6 +486,7 @@ func ParseOptions() *Options {
flag.BoolVar(&options.VHost, "vhost", false, "Check for VHOSTs")
flag.BoolVar(&options.ExtractTitle, "title", false, "Extracts title")
flag.BoolVar(&options.StatusCode, "status-code", false, "Extracts status code")
flag.BoolVar(&options.Location, "location", false, "Extracts location header")
flag.Var(&options.CustomHeaders, "H", "Custom Header")
flag.Var(&options.CustomPorts, "ports", "ports range (nmap syntax: eg 1,2-10,11)")
flag.BoolVar(&options.ContentLength, "content-length", false, "Extracts content length")
Expand Down

0 comments on commit 84dc1e9

Please sign in to comment.