-
Notifications
You must be signed in to change notification settings - Fork 875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Adding new status flag #323
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ cat test.txt | go run . -status
https://www.aaaaahackerone.com [failure]
https://www.hackerone.com [success]
$ cat test.txt | go run . -status -json
{"timestamp":"2021-07-20T10:46:33.001886+02:00","url":"https://www.aaaaahackerone.com","original-input":"www.aaaaahackerone.com","error":"could not resolve host","failed":true}
{"timestamp":"2021-07-20T10:46:33.731353+02:00","scheme":"https","port":"443","path":"/","body-sha256":"76b917579934ae32852d184485702b0b5140c8c6a2199d06bbf7fdf09957430b","header-sha256":"edcc859af1819c9b648e0600647e85346bb691418957e923710a2c6df64d3c63","a":["104.16.99.52","104.16.100.52"],"url":"https://www.hackerone.com","title":"HackerOne | Hacker-Powered Security, Bug Bounties, \u0026 Pentests","webserver":"cloudflare","content-type":"text/html","method":"GET","host":"104.16.99.52","content-length":56234,"status-code":200,"csp":{"domains":["*.mktoutil.com","s3.amazonaws.com","fonts.gstatic.com","*.youtube.com","*.bidr.io","*.twimg.com","*.cloudflare.com","via.placeholder.com","https://*.bred4tula.com","https://*.googletagmanager.com","*.ads-twitter.com","*.demandbase.com","fonts.googleapis.com","https://errors.hackerone.net/api/30/csp-report/?sentry_key=61c1e2f50d21487c97a071737701f598","js.driftt.com","*.google-analytics.com","*.stripe.com","embedwistia-a.akamaihd.net","cdn.bizibly.com","cdn.ttgtmedia.com","munchkin.marketo.net","*.6sc.co","cdn.bizible.com","id.rlcdn.com","*.6sense.com","secure.adnxs.com","stats.g.doubleclick.net","*.company-target.com","*.wistia.com","api.lever.co","*.google.com","*.linkedin.com","snap.licdn.com","unpkg.com","*.typekit.net","*.twitter.com","my.pima.app","*.adsymptotic.com","*.techtarget.com","cdn.syndication.twimg.com","t.co","*.youtube-nocookie.com","*.marketo.com","*.litix.io","*.mktoresp.com","hackerone.com","fast.wistia.com","embed-fastly.wistia.com","checkout.stripe.com"]},"response-time":"910.864343ms"}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other flags are not working when using status
flag.
chaos -d hackerone.com | ./httpx -status -title
https://mta-sts.forwarding.hackerone.com [success]
https://mta-sts.managed.hackerone.com [success]
https://docs.hackerone.com [success]
https://mta-sts.hackerone.com [success]
https://ns.hackerone.com [failed]
https://a.ns.hackerone.com [failed]
https://support.hackerone.com [success]
As per feature request, |
Adding colored output along with no-color support will be useful, for example, red for failed, and green for success. |
runner/runner.go
Outdated
@@ -903,6 +952,7 @@ retry: | |||
HeaderSHA256: headersSha, | |||
raw: resp.Raw, | |||
URL: fullURL, | |||
OriginalInput: domain, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OriginalInput => Input
runner/runner.go
Outdated
@@ -944,10 +994,12 @@ type Result struct { | |||
CNAMEs []string `json:"cnames,omitempty"` | |||
raw string | |||
URL string `json:"url,omitempty"` | |||
OriginalInput string `json:"input,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OriginalInput => Input
@@ -605,6 +606,54 @@ retry: | |||
} | |||
|
|||
resp, err := hp.Do(req) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-status
should work along with other options, unfortunately in this position we are unable to perform retries from https
to http
. I would refactor it as follows:
resp, err := hp.Do(req)
fullURL := req.URL.String()
builder := &strings.Builder{}
builder.WriteString(stringz.RemoveURLDefaultPort(fullURL))
if r.options.Status {
builder.WriteString(" [")
outputStatus := "success"
if err != nil {
outputStatus = "failure"
}
switch {
case !scanopts.OutputWithNoColor && err != nil:
builder.WriteString(aurora.Red(outputStatus).String())
case !scanopts.OutputWithNoColor && err == nil:
builder.WriteString(aurora.Green(outputStatus).String())
default:
builder.WriteString(outputStatus)
}
builder.WriteRune(']')
}
errString := ""
if err != nil {
errString = err.Error()
splitErr := strings.Split(errString, ":")
errString = strings.TrimSpace(splitErr[len(splitErr)-1])
}
if err != nil {
if !retried && origProtocol == httpx.HTTPorHTTPS {
if protocol == httpx.HTTPS {
protocol = httpx.HTTP
} else {
protocol = httpx.HTTPS
}
retried = true
goto retry
}
return Result{URL: URL.String(), Input: domain, Timestamp: time.Now(), err: err, Failed: err != nil, Error: errString, str: builder.String()}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
$ cat test.txt | go run . -title -status -silent
https://www.hackerone.com [success] [HackerOne | Hacker-Powered Security, Bug Bounties, & Pentests]
http://www.aaaaahackerone.com [failure]
No description provided.