Skip to content

Commit 525aeb0

Browse files
authored
Merge pull request #928 from projectdiscovery/dev
httpx v1.2.6
2 parents 42fd260 + 95ca203 commit 525aeb0

32 files changed

+606
-348
lines changed

.github/workflows/build-test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: 🔨 Build Test
22

33
on:
4-
push:
54
pull_request:
65
workflow_dispatch:
76

@@ -16,7 +15,7 @@ jobs:
1615
- name: Set up Go
1716
uses: actions/setup-go@v3
1817
with:
19-
go-version: 1.18
18+
go-version: 1.19
2019

2120
- name: Check out code
2221
uses: actions/checkout@v3

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: 🚨 CodeQL Analysis
22

33
on:
44
workflow_dispatch:
5-
push:
65
pull_request:
76
branches:
87
- dev

.github/workflows/functional-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: 🧪 Functional Test
2+
23
on:
3-
push:
44
pull_request:
55
workflow_dispatch:
66

@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Go
1616
uses: actions/setup-go@v3
1717
with:
18-
go-version: 1.18
18+
go-version: 1.19
1919

2020
- name: Check out code
2121
uses: actions/checkout@v3

.github/workflows/lint-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: 🙏🏻 Lint Test
2+
23
on:
3-
push:
44
pull_request:
55
workflow_dispatch:
66

@@ -12,11 +12,11 @@ jobs:
1212
- name: Set up Go
1313
uses: actions/setup-go@v3
1414
with:
15-
go-version: 1.18
15+
go-version: 1.19
1616
- name: Checkout code
1717
uses: actions/checkout@v3
1818
- name: Run golangci-lint
19-
uses: golangci/golangci-lint-action@v3.3.0
19+
uses: golangci/golangci-lint-action@v3.3.1
2020
with:
2121
version: latest
2222
args: --timeout 5m

.github/workflows/release-binary.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: 🎉 Release Binary
2+
23
on:
3-
create:
4+
push:
45
tags:
5-
- v*
6+
- '*'
67
workflow_dispatch:
78

89
jobs:
@@ -17,14 +18,16 @@ jobs:
1718
- name: "Set up Go"
1819
uses: actions/setup-go@v3
1920
with:
20-
go-version: 1.18
21+
go-version: 1.19
2122

2223
- name: "Create release on GitHub"
23-
uses: goreleaser/goreleaser-action@v3
24+
uses: goreleaser/goreleaser-action@v4
2425
with:
2526
args: "release --rm-dist"
2627
version: latest
2728
workdir: .
2829
env:
2930
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
3031
SLACK_WEBHOOK: "${{ secrets.RELEASE_SLACK_WEBHOOK }}"
32+
DISCORD_WEBHOOK_ID: "${{ secrets.DISCORD_WEBHOOK_ID }}"
33+
DISCORD_WEBHOOK_TOKEN: "${{ secrets.DISCORD_WEBHOOK_TOKEN }}"

.github/workflows/sonarcloud.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
name: 👮🏼‍♂️ Sonarcloud
2+
23
on:
3-
push:
4-
branches:
5-
- master
6-
- dev
74
pull_request:
8-
types: [opened, synchronize, reopened]
95
workflow_dispatch:
106

117
jobs:
@@ -20,7 +16,7 @@ jobs:
2016
- name: "Set up Go"
2117
uses: actions/setup-go@v3
2218
with:
23-
go-version: 1.18
19+
go-version: 1.19
2420

2521
- name: Run unit Tests
2622
run: |

.goreleaser.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@ announce:
3939
enabled: true
4040
channel: '#release'
4141
username: GoReleaser
42-
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
42+
message_template: 'New Release: {{ .ProjectName }} {{ .Tag }} is published! Check it out at {{ .ReleaseURL }}'
43+
44+
discord:
45+
enabled: true
46+
message_template: '**New Release: {{ .ProjectName }} {{.Tag}}** is published! Check it out at {{ .ReleaseURL }}'

Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
FROM golang:1.19.2-alpine AS builder
2-
RUN apk add --no-cache git
3-
RUN go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
1+
FROM golang:1.19.4-alpine AS builder
2+
ARG BUILD_SOURCE_TAG=latest
3+
RUN apk add --no-cache git build-base gcc musl-dev
4+
RUN go install -v github.com/projectdiscovery/httpx/cmd/httpx@${BUILD_SOURCE_TAG}
45

5-
FROM alpine:3.16.2
6+
FROM alpine:3.17.0
67
RUN apk -U upgrade --no-cache \
78
&& apk add --no-cache bind-tools ca-certificates
89
COPY --from=builder /go/bin/httpx /usr/local/bin/

README.md

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h1 align="center">
2-
<img src="static/httpx-logo.png" alt="httpx" width="200px"></a>
2+
<img src="static/httpx-logo.png" alt="httpx" width="200px">
33
<br>
44
</h1>
55

@@ -24,12 +24,12 @@
2424
</p>
2525

2626

27-
httpx is a fast and multi-purpose HTTP toolkit that allows running multiple probes using the [retryablehttp](https://github.com/projectdiscovery/retryablehttp-go) library. It is designed to maintain result reliability with an increased number of threads.
27+
`httpx` is a fast and multi-purpose HTTP toolkit that allows running multiple probes using the [retryablehttp](https://github.com/projectdiscovery/retryablehttp-go) library. It is designed to maintain result reliability with an increased number of threads.
2828

2929
# Features
3030

3131
<h1 align="center">
32-
<img src="https://user-images.githubusercontent.com/8293321/135731750-4c1d38b1-bd2a-40f9-88e9-3c4b9f6da378.png" alt="httpx" width="700px"></a>
32+
<img src="https://user-images.githubusercontent.com/8293321/135731750-4c1d38b1-bd2a-40f9-88e9-3c4b9f6da378.png" alt="httpx" width="700px">
3333
<br>
3434
</h1>
3535

@@ -40,7 +40,7 @@ httpx is a fast and multi-purpose HTTP toolkit that allows running multiple prob
4040
- Supports hosts, URLs and CIDR as input.
4141
- Handles edge cases doing retries, backoffs etc for handling WAFs.
4242

43-
### Supported probes:-
43+
### Supported probes
4444

4545
| Probes | Default check | Probes | Default check |
4646
|-----------------|---------------|----------------|---------------|
@@ -62,7 +62,7 @@ httpx is a fast and multi-purpose HTTP toolkit that allows running multiple prob
6262

6363
# Installation Instructions
6464

65-
httpx requires **go1.17** to install successfully. Run the following command to get the repo -
65+
`httpx` requires **go1.19** to install successfully. Run the following command to get the repo:
6666

6767
```sh
6868
go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
@@ -117,7 +117,7 @@ MATCHERS:
117117
-mfc, -match-favicon string[] match response with specified favicon hash (-mfc 1494302000)
118118
-ms, -match-string string match response with specified string (-ms admin)
119119
-mr, -match-regex string match response with specified regex (-mr admin)
120-
-mcdn, -match-cdn string[] match host with specified cdn provider (fastly, incapsula, oracle, google, azure, cloudflare, cloudfront, sucuri, leaseweb, akamai)
120+
-mcdn, -match-cdn string[] match host with specified cdn provider (oracle, google, azure, cloudflare, cloudfront, fastly, incapsula, leaseweb, akamai, sucuri)
121121
-mrt, -match-response-time string match response with specified response time in seconds (-mrt '< 1')
122122
-mdc, -match-condition string match response with dsl expression condition
123123

@@ -133,7 +133,7 @@ FILTERS:
133133
-ffc, -filter-favicon string[] filter response with specified favicon hash (-mfc 1494302000)
134134
-fs, -filter-string string filter response with specified string (-fs admin)
135135
-fe, -filter-regex string filter response with specified regex (-fe admin)
136-
-fcdn, -filter-cdn string[] filter host with specified cdn provider (fastly, incapsula, oracle, google, azure, cloudflare, cloudfront, sucuri, leaseweb, akamai)
136+
-fcdn, -filter-cdn string[] filter host with specified cdn provider (oracle, google, azure, cloudflare, cloudfront, fastly, incapsula, leaseweb, akamai, sucuri)
137137
-frt, -filter-response-time string filter response with specified response time in seconds (-frt '> 1')
138138
-fdc, -filter-condition string filter response with dsl expression condition
139139

@@ -155,14 +155,16 @@ MISCELLANEOUS:
155155
-ldv, -list-dsl-variables list json output field keys name that support dsl matcher/filter
156156

157157
OUTPUT:
158-
-o, -output string file to write output results
159-
-sr, -store-response store http response to output directory
160-
-srd, -store-response-dir string store http response to custom directory
161-
-csv store output in csv format
162-
-json store output in JSONL(ines) format
163-
-irr, -include-response include http request/response in JSON output (-json only)
164-
-include-chain include redirect http chain in JSON output (-json only)
165-
-store-chain include http redirect chain in responses (-sr only)
158+
-o, -output string file to write output results
159+
-sr, -store-response store http response to output directory
160+
-srd, -store-response-dir string store http response to custom directory
161+
-csv store output in csv format
162+
-csvo, -csv-output-encoding string define output encoding
163+
-json store output in JSONL(ines) format
164+
-irr, -include-response include http request/response in JSON output (-json only)
165+
-irrb, -include-response-base64 include base64 encoded http request/response in JSON output (-json only)
166+
-include-chain include redirect http chain in JSON output (-json only)
167+
-store-chain include http redirect chain in responses (-sr only)
166168

167169
CONFIGURATIONS:
168170
-r, -resolvers string[] list of custom resolver (file or comma separated)
@@ -183,6 +185,7 @@ CONFIGURATIONS:
183185
-s, -stream stream mode - start elaborating input targets without sorting
184186
-sd, -skip-dedupe disable dedupe input items (only used with stream mode)
185187
-ldp, -leave-default-ports leave default http/https ports in host header (eg. http://host:80 - https//host:443
188+
-ztls use ztls library with autofallback to standard one for tls13
186189

187190
DEBUG:
188191
-health-check, -hc run diagnostic check up
@@ -204,6 +207,7 @@ OPTIMIZATIONS:
204207
-ec, -exclude-cdn skip full port scans for CDNs (only checks for 80,443)
205208
-retries int number of retries
206209
-timeout int timeout in seconds (default 5)
210+
-delay duration duration between each http request (eg: 200ms, 1s) (default -1ns)
207211
-rsts, -response-size-to-save int max response size to save in bytes (default 2147483647)
208212
-rstr, -response-size-to-read int max response size to read in bytes (default 2147483647)
209213
```
@@ -241,7 +245,7 @@ https://support.hackerone.com
241245

242246
### File Input
243247

244-
This will run the tool with the `probe` flag against all of the hosts in **hosts.txt** and return URLs with probed status.
248+
This will run the tool with the `-probe` flag against all the hosts in **hosts.txt** and return URLs with probed status.
245249

246250
```console
247251
httpx -list hosts.txt -silent -probe
@@ -467,31 +471,30 @@ https://docs.hackerone.com
467471
https://support.hackerone.com
468472
```
469473

470-
### Using httpx as a library
471-
`httpx` can be used as a library by creating an instance of the `Option` struct and populating it with the same options that would be specified via CLI. Once validated, the struct should be passed to a runner instance (to close at the end of the program) and the `RunEnumeration` method should be called. Here follows a minimal example of how to do it:
474+
### Using `httpx` as a library
475+
`httpx` can be used as a library by creating an instance of the `Option` struct and populating it with the same options that would be specified via CLI. Once validated, the struct should be passed to a runner instance (to be closed at the end of the program) and the `RunEnumeration` method should be called. Here follows a minimal example of how to do it:
472476

473477
```go
474478
package main
475479

476480
import (
477481
"log"
478-
"os"
479482

483+
"github.com/projectdiscovery/goflags"
484+
"github.com/projectdiscovery/gologger"
485+
"github.com/projectdiscovery/gologger/levels"
480486
"github.com/projectdiscovery/httpx/runner"
481487
)
482488

483489
func main() {
484-
inputFile := "test.txt"
485-
err := os.WriteFile(inputFile, []byte("scanme.sh"), 0644)
486-
if err != nil {
487-
log.Fatal(err)
488-
}
489-
defer os.RemoveAll(inputFile)
490+
gologger.DefaultLogger.SetMaxLevel(levels.LevelVerbose) // increase the verbosity (optional)
490491

491492
options := runner.Options{
492-
Methods: "GET",
493-
InputFile: inputFile,
493+
Methods: "GET",
494+
InputTargetHost: goflags.StringSlice{"scanme.sh", "projectdiscovery.io"},
495+
//InputFile: "./targetDomains.txt", // path to file containing the target domains list
494496
}
497+
495498
if err := options.ValidateOptions(); err != nil {
496499
log.Fatal(err)
497500
}
@@ -509,17 +512,27 @@ func main() {
509512

510513
# Notes
511514

512-
- As default, **httpx** checks for `HTTPS` probe and fall-back to `HTTP` only if `HTTPS` is not reachable.
513-
- For printing both HTTP/HTTPS results, `no-fallback` flag can be used.
515+
- As default, `httpx` checks for **HTTPS** probe and fall-back to **HTTP** only if **HTTPS** is not reachable.
516+
- The `-no-fallback` flag can be used to display both **HTTP** and **HTTPS** results
514517
- Custom scheme for ports can be defined, for example `-ports http:443,http:80,https:8443`
515-
- `favicon`,`vhost`, `http2`, `pipeline`, `ports`, `csp-probe`, `tls-probe` and `path` are unique flag with different probes.
516-
- Unique flags should be used for specific use cases instead of running them as default with other probes.
517-
- When using `json` flag, all the information (default probes) included in the JSON output.
518-
- Custom resolver supports multiple protocol (**doh|tcp|udp**) in form of `protocol:resolver:port` (eg **udp:127.0.0.1:53**)
518+
- The following flags should be used for specific use cases instead of running them as default with other probes:
519+
* `-favicon`,`-vhost`, `-http2`, `-pipeline`, `-ports`, `-csp-probe`, `-tls-probe`, `-path`
520+
- When using the `-json` flag, all the default probe results are included in the JSON output.
521+
- Custom resolver supports multiple protocol (**doh|tcp|udp**) in form of `protocol:resolver:port` (e.g. `udp:127.0.0.1:53`)
519522
- Invalid custom resolvers/files are ignored.
520523

521524
# Acknowledgement
522525

523-
httpx is made with 🖤 by the [projectdiscovery](https://projectdiscovery.io) team. Community contributions have made the project what it is. See the **[Thanks.md](https://github.com/projectdiscovery/httpx/blob/master/THANKS.md)** file for more details. Do also check out these similar awesome projects that may fit in your workflow:
526+
Probing feature is inspired by [@tomnomnom/httprobe](https://github.com/tomnomnom/httprobe) work ❤️
527+
528+
529+
--------
530+
531+
<div align="center">
532+
533+
`httpx` is made with 💙 by the [projectdiscovery](https://projectdiscovery.io) team and distributed under [MIT License](LICENSE.md).
534+
535+
536+
<a href="https://discord.gg/projectdiscovery"><img src="https://raw.githubusercontent.com/projectdiscovery/nuclei-burp-plugin/main/static/join-discord.png" width="300" alt="Join Discord"></a>
524537

525-
Probing feature is inspired by [@tomnomnom/httprobe](https://github.com/tomnomnom/httprobe) work :heart:
538+
</div>

cmd/functional-test/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var (
2222

2323
mainHttpxBinary = flag.String("main", "", "Main Branch Httpx Binary")
2424
devHttpxBinary = flag.String("dev", "", "Dev Branch Httpx Binary")
25-
testcases = flag.String("testcases", "", "Test cases file for Httpx functional tests")
25+
testcases = flag.String("testcases", "", "Test cases file for Httpx functional tests")
2626
)
2727

2828
func main() {

cmd/functional-test/testcases.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ scanme.sh {{binary}} -silent -unsafe
1414
scanme.sh {{binary}} -silent -x all
1515
scanme.sh {{binary}} -silent -body 'a=b'
1616
scanme.sh {{binary}} -silent -exclude-cdn
17-
scanme.sh {{binary}} -silent -ports https:443
17+
scanme.sh {{binary}} -silent -ports https:443
18+
scanme.sh {{binary}} -silent -ztls
19+
https://scanme.sh?a=1*1 {{binary}} -silent

cmd/integration-test/http.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (h *standardHttpGet) Execute() error {
8383
}
8484

8585
if h.expectedOutput != "" && !strings.EqualFold(results[0], h.expectedOutput) {
86-
return errIncorrectResult(results[0], h.expectedOutput)
86+
return errIncorrectResult(h.expectedOutput, results[0])
8787
}
8888

8989
return nil
@@ -115,7 +115,7 @@ func (h *issue276) Execute() error {
115115
// title
116116
expected := ts.URL + "/redirect" + " [302] [Object moved]"
117117
if !strings.EqualFold(results[0], expected) {
118-
return errIncorrectResult(results[0], expected)
118+
return errIncorrectResult(expected, results[0])
119119
}
120120
return nil
121121
}
@@ -146,7 +146,7 @@ func (h *issue277) Execute() error {
146146
// title
147147
expected := ts.URL + uripath
148148
if !strings.EqualFold(results[0], expected) {
149-
return errIncorrectResult(results[0], expected)
149+
return errIncorrectResult(expected, results[0])
150150
}
151151
return nil
152152
}
@@ -175,7 +175,7 @@ func (h *issue303) Execute() error {
175175
// full url with port
176176
expected := ts.URL
177177
if !strings.EqualFold(results[0], expected) {
178-
return errIncorrectResult(results[0], expected)
178+
return errIncorrectResult(expected, results[0])
179179
}
180180
return nil
181181
}
@@ -249,7 +249,7 @@ func (h *issue414) Execute() error {
249249
}
250250
expected := ts.URL + uripath
251251
if !strings.EqualFold(results[0], expected) {
252-
return errIncorrectResult(results[0], expected)
252+
return errIncorrectResult(expected, results[0])
253253
}
254254
return nil
255255
}

0 commit comments

Comments
 (0)