Skip to content

Commit 5f806a8

Browse files
authored
Merge pull request #1849 from projectdiscovery/dev
httpx - v1.6.7 (UI Dashboard)
2 parents 7fd3fb1 + 56f4474 commit 5f806a8

File tree

12 files changed

+591
-200
lines changed

12 files changed

+591
-200
lines changed

README.md

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ MATCHERS:
134134
-mfc, -match-favicon string[] match response with specified favicon hash (-mfc 1494302000)
135135
-ms, -match-string string[] match response with specified string (-ms admin)
136136
-mr, -match-regex string[] match response with specified regex (-mr admin)
137-
-mcdn, -match-cdn string[] match host with specified cdn provider (leaseweb, stackpath, cloudfront, fastly, google)
137+
-mcdn, -match-cdn string[] match host with specified cdn provider (google, cloudfront, fastly)
138138
-mrt, -match-response-time string match response with specified response time in seconds (-mrt '< 1')
139139
-mdc, -match-condition string match response with dsl expression condition
140140

141141
EXTRACTOR:
142142
-er, -extract-regex string[] display response content with matched regex
143-
-ep, -extract-preset string[] display response content matched by a pre-defined regex (url,ipv4,mail)
143+
-ep, -extract-preset string[] display response content matched by a pre-defined regex (ipv4,mail,url)
144144

145145
FILTERS:
146146
-fc, -filter-code string filter response with specified status code (-fc 403,401)
@@ -151,7 +151,7 @@ FILTERS:
151151
-ffc, -filter-favicon string[] filter response with specified favicon hash (-ffc 1494302000)
152152
-fs, -filter-string string[] filter response with specified string (-fs admin)
153153
-fe, -filter-regex string[] filter response with specified regex (-fe admin)
154-
-fcdn, -filter-cdn string[] filter host with specified cdn provider (leaseweb, stackpath, cloudfront, fastly, google)
154+
-fcdn, -filter-cdn string[] filter host with specified cdn provider (google, cloudfront, fastly)
155155
-frt, -filter-response-time string filter response with specified response time in seconds (-frt '> 1')
156156
-fdc, -filter-condition string filter response with dsl expression condition
157157
-strip strips all tags in response. supported formats: html,xml (default html)
@@ -178,25 +178,25 @@ UPDATE:
178178
-duc, -disable-update-check disable automatic httpx update check
179179

180180
OUTPUT:
181-
-o, -output string file to write output results
182-
-oa, -output-all filename to write output results in all formats
183-
-sr, -store-response store http response to output directory
184-
-srd, -store-response-dir string store http response to custom directory
185-
-ob, -omit-body omit response body in output
186-
-csv store output in csv format
187-
-csvo, -csv-output-encoding string define output encoding
188-
-j, -json store output in JSONL(ines) format
189-
-irh, -include-response-header include http response (headers) in JSON output (-json only)
190-
-irr, -include-response include http request/response (headers + body) in JSON output (-json only)
191-
-irrb, -include-response-base64 include base64 encoded http request/response in JSON output (-json only)
192-
-include-chain include redirect http chain in JSON output (-json only)
193-
-store-chain include http redirect chain in responses (-sr only)
194-
-svrc, -store-vision-recon-cluster include visual recon clusters (-ss and -sr only)
195-
-pr, -protocol string protocol to use (unknown, http11)
181+
-o, -output string file to write output results
182+
-oa, -output-all filename to write output results in all formats
183+
-sr, -store-response store http response to output directory
184+
-srd, -store-response-dir string store http response to custom directory
185+
-ob, -omit-body omit response body in output
186+
-csv store output in csv format
187+
-csvo, -csv-output-encoding string define output encoding
188+
-j, -json store output in JSONL(ines) format
189+
-irh, -include-response-header include http response (headers) in JSON output (-json only)
190+
-irr, -include-response include http request/response (headers + body) in JSON output (-json only)
191+
-irrb, -include-response-base64 include base64 encoded http request/response in JSON output (-json only)
192+
-include-chain include redirect http chain in JSON output (-json only)
193+
-store-chain include http redirect chain in responses (-sr only)
194+
-svrc, -store-vision-recon-cluster include visual recon clusters (-ss and -sr only)
195+
-pr, -protocol string protocol to use (unknown, http11)
196+
-fepp, -filter-error-page-path string path to store filtered error pages (default "filtered_error_page.json")
196197

197198
CONFIGURATIONS:
198199
-config string path to the httpx configuration file (default $HOME/.config/httpx/config.yaml)
199-
-auth configure projectdiscovery cloud (pdcp) api key (default true)
200200
-r, -resolvers string[] list of custom resolver (file or comma separated)
201201
-allow string[] allowed list of IP/CIDR's to process (file or comma separated)
202202
-deny string[] denied list of IP/CIDR's to process (file or comma separated)
@@ -237,14 +237,21 @@ DEBUG:
237237

238238
OPTIMIZATIONS:
239239
-nf, -no-fallback display both probed protocol (HTTPS and HTTP)
240-
-nfs, -no-fallback-scheme probe with protocol scheme specified in input
240+
-nfs, -no-fallback-scheme probe with protocol scheme specified in input
241241
-maxhr, -max-host-error int max error count per host before skipping remaining path/s (default 30)
242242
-e, -exclude string[] exclude host matching specified filter ('cdn', 'private-ips', cidr, ip, regex)
243243
-retries int number of retries
244244
-timeout int timeout in seconds (default 10)
245245
-delay value duration between each http request (eg: 200ms, 1s) (default -1ns)
246246
-rsts, -response-size-to-save int max response size to save in bytes (default 2147483647)
247247
-rstr, -response-size-to-read int max response size to read in bytes (default 2147483647)
248+
249+
CLOUD:
250+
-auth configure projectdiscovery cloud (pdcp) api key (default true)
251+
-pd, -dashboard upload / view output in projectdiscovery cloud (pdcp) UI dashboard
252+
-aid, -asset-id string upload new assets to existing asset id (optional)
253+
-aname, -asset-name string assets group name to set (optional)
254+
-pdu, -dashboard-upload string upload httpx output file (jsonl) in projectdiscovery cloud (pdcp) UI dashboard
248255
```
249256

250257
# Running httpx

cmd/httpx/httpx.go

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
package main
22

33
import (
4+
"context"
5+
"encoding/json"
46
"os"
57
"os/signal"
68
"runtime"
79
"runtime/pprof"
810

11+
"github.com/logrusorgru/aurora"
912
"github.com/projectdiscovery/gologger"
13+
"github.com/projectdiscovery/httpx/internal/pdcp"
1014
"github.com/projectdiscovery/httpx/runner"
11-
errorutil "github.com/projectdiscovery/utils/errors"
15+
pdcpauth "github.com/projectdiscovery/utils/auth/pdcp"
16+
_ "github.com/projectdiscovery/utils/pprof"
1217
)
1318

1419
func main() {
@@ -33,6 +38,30 @@ func main() {
3338
}()
3439
}
3540

41+
// validation for local results file upload
42+
if options.AssetFileUpload != "" {
43+
_ = setupOptionalAssetUpload(options)
44+
file, err := os.Open(options.AssetFileUpload)
45+
if err != nil {
46+
gologger.Fatal().Msgf("Could not open file: %s\n", err)
47+
}
48+
defer file.Close()
49+
dec := json.NewDecoder(file)
50+
for dec.More() {
51+
var r runner.Result
52+
err := dec.Decode(&r)
53+
if err != nil {
54+
gologger.Fatal().Msgf("Could not decode jsonl file: %s\n", err)
55+
}
56+
options.OnResult(r)
57+
}
58+
options.OnClose()
59+
return
60+
}
61+
62+
// setup optional asset upload
63+
_ = setupOptionalAssetUpload(options)
64+
3665
httpxRunner, err := runner.New(options)
3766
if err != nil {
3867
gologger.Fatal().Msgf("Could not create runner: %s\n", err)
@@ -60,8 +89,54 @@ func main() {
6089
httpxRunner.Close()
6190
}
6291

63-
func init() {
64-
if os.Getenv("DEBUG") != "" {
65-
errorutil.ShowStackTrace = true
92+
// setupOptionalAssetUpload is used to setup optional asset upload
93+
// this is optional and only initialized when explicitly enabled
94+
func setupOptionalAssetUpload(opts *runner.Options) *pdcp.UploadWriter {
95+
var mustEnable bool
96+
// enable on multiple conditions
97+
if opts.AssetUpload || opts.AssetID != "" || opts.AssetName != "" || pdcp.EnableCloudUpload {
98+
mustEnable = true
99+
}
100+
a := aurora.NewAurora(!opts.NoColor)
101+
if !mustEnable {
102+
if !pdcp.HideAutoSaveMsg {
103+
gologger.Print().Msgf("[%s] UI Dashboard is disabled, Use -dashboard option to enable", a.BrightYellow("WRN"))
104+
}
105+
return nil
106+
}
107+
if opts.Screenshot {
108+
gologger.Fatal().Msgf("Screenshot option is not supported for dashboard upload yet")
109+
}
110+
gologger.Info().Msgf("To view results in UI dashboard, visit https://cloud.projectdiscovery.io/assets upon completion.")
111+
h := &pdcpauth.PDCPCredHandler{}
112+
creds, err := h.GetCreds()
113+
if err != nil {
114+
if err != pdcpauth.ErrNoCreds && !pdcp.HideAutoSaveMsg {
115+
gologger.Verbose().Msgf("Could not get credentials for cloud upload: %s\n", err)
116+
}
117+
pdcpauth.CheckNValidateCredentials("httpx")
118+
return nil
119+
}
120+
writer, err := pdcp.NewUploadWriterCallback(context.Background(), creds)
121+
if err != nil {
122+
gologger.Error().Msgf("failed to setup UI dashboard: %s", err)
123+
return nil
124+
}
125+
if writer == nil {
126+
gologger.Error().Msgf("something went wrong, could not setup UI dashboard")
127+
}
128+
opts.OnResult = writer.GetWriterCallback()
129+
opts.OnClose = func() {
130+
writer.Close()
131+
}
132+
// add additional metadata
133+
if opts.AssetID != "" {
134+
// silently ignore
135+
_ = writer.SetAssetID(opts.AssetID)
136+
}
137+
if opts.AssetName != "" {
138+
// silently ignore
139+
writer.SetAssetGroupName(opts.AssetName)
66140
}
141+
return writer
67142
}

go.mod

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.21
55
require (
66
github.com/Mzack9999/gcache v0.0.0-20230410081825-519e28eab057
77
github.com/PuerkitoBio/goquery v1.8.1
8-
github.com/akrylysov/pogreb v0.10.1 // indirect
8+
github.com/akrylysov/pogreb v0.10.2 // indirect
99
github.com/corona10/goimagehash v1.1.0
1010
github.com/go-faker/faker/v4 v4.1.1
1111
github.com/go-rod/rod v0.114.0
@@ -17,41 +17,41 @@ require (
1717
github.com/logrusorgru/aurora v2.0.3+incompatible
1818
github.com/mfonda/simhash v0.0.0-20151007195837-79f94a1100d6
1919
github.com/microcosm-cc/bluemonday v1.0.26
20-
github.com/miekg/dns v1.1.56 // indirect
20+
github.com/miekg/dns v1.1.59 // indirect
2121
github.com/mitchellh/mapstructure v1.5.0
2222
github.com/pkg/errors v0.9.1
2323
github.com/projectdiscovery/asnmap v1.1.1
2424
github.com/projectdiscovery/cdncheck v1.1.0
2525
github.com/projectdiscovery/clistats v0.0.20
26-
github.com/projectdiscovery/dsl v0.1.2
27-
github.com/projectdiscovery/fastdialer v0.1.5
26+
github.com/projectdiscovery/dsl v0.1.7
27+
github.com/projectdiscovery/fastdialer v0.2.1
2828
github.com/projectdiscovery/fdmax v0.0.4
2929
github.com/projectdiscovery/goconfig v0.0.1
30-
github.com/projectdiscovery/goflags v0.1.56
31-
github.com/projectdiscovery/gologger v1.1.12
32-
github.com/projectdiscovery/hmap v0.0.48
30+
github.com/projectdiscovery/goflags v0.1.60
31+
github.com/projectdiscovery/gologger v1.1.17
32+
github.com/projectdiscovery/hmap v0.0.51
3333
github.com/projectdiscovery/mapcidr v1.1.34
3434
github.com/projectdiscovery/networkpolicy v0.0.9
35-
github.com/projectdiscovery/ratelimit v0.0.45
36-
github.com/projectdiscovery/rawhttp v0.1.55
37-
github.com/projectdiscovery/retryablehttp-go v1.0.65
35+
github.com/projectdiscovery/ratelimit v0.0.49
36+
github.com/projectdiscovery/rawhttp v0.1.57
37+
github.com/projectdiscovery/retryablehttp-go v1.0.71
3838
github.com/projectdiscovery/tlsx v1.1.6
39-
github.com/projectdiscovery/useragent v0.0.57
40-
github.com/projectdiscovery/utils v0.1.5
41-
github.com/projectdiscovery/wappalyzergo v0.1.8
39+
github.com/projectdiscovery/useragent v0.0.60
40+
github.com/projectdiscovery/utils v0.2.3
41+
github.com/projectdiscovery/wappalyzergo v0.1.12
4242
github.com/rs/xid v1.5.0
4343
github.com/spaolacci/murmur3 v1.1.0
4444
github.com/stretchr/testify v1.9.0
45-
github.com/zmap/zcrypto v0.0.0-20230422215203-9a665e1e9968
46-
go.etcd.io/bbolt v1.3.7 // indirect
45+
github.com/zmap/zcrypto v0.0.0-20240512203510-0fef58d9a9db
46+
go.etcd.io/bbolt v1.3.10 // indirect
4747
go.uber.org/multierr v1.11.0
48-
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad
48+
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
4949
golang.org/x/net v0.26.0
5050
golang.org/x/sys v0.21.0 // indirect
5151
golang.org/x/text v0.16.0
5252
)
5353

54-
require github.com/weppos/publicsuffix-go v0.30.1
54+
require github.com/weppos/publicsuffix-go v0.30.2
5555

5656
require (
5757
aead.dev/minisign v0.2.0 // indirect
@@ -60,7 +60,7 @@ require (
6060
github.com/Mzack9999/go-http-digest-auth-client v0.6.1-0.20220414142836-eb8883508809 // indirect
6161
github.com/VividCortex/ewma v1.2.0 // indirect
6262
github.com/alecthomas/chroma v0.10.0 // indirect
63-
github.com/andybalholm/brotli v1.0.6 // indirect
63+
github.com/andybalholm/brotli v1.1.0 // indirect
6464
github.com/andybalholm/cascadia v1.3.2 // indirect
6565
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
6666
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
@@ -69,35 +69,34 @@ require (
6969
github.com/charmbracelet/glamour v0.6.0 // indirect
7070
github.com/cheggaaa/pb/v3 v3.1.4 // indirect
7171
github.com/cloudflare/cfssl v1.6.4 // indirect
72-
github.com/cloudflare/circl v1.3.7 // indirect
72+
github.com/cloudflare/circl v1.3.8 // indirect
7373
github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 // indirect
7474
github.com/davecgh/go-spew v1.1.1 // indirect
7575
github.com/dimchansky/utfbom v1.1.1 // indirect
76-
github.com/dlclark/regexp2 v1.8.1 // indirect
76+
github.com/dlclark/regexp2 v1.11.0 // indirect
7777
github.com/docker/go-units v0.5.0 // indirect
7878
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
79-
github.com/fatih/color v1.15.0 // indirect
79+
github.com/fatih/color v1.16.0 // indirect
8080
github.com/gaissmai/bart v0.9.5 // indirect
81-
github.com/gaukas/godicttls v0.0.4 // indirect
8281
github.com/go-ole/go-ole v1.2.6 // indirect
83-
github.com/golang/protobuf v1.5.3 // indirect
82+
github.com/golang/protobuf v1.5.4 // indirect
8483
github.com/google/certificate-transparency-go v1.1.4 // indirect
8584
github.com/google/go-github/v30 v30.1.0 // indirect
8685
github.com/google/go-querystring v1.1.0 // indirect
8786
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
88-
github.com/google/uuid v1.3.1 // indirect
89-
github.com/gorilla/css v1.0.0 // indirect
87+
github.com/google/uuid v1.6.0 // indirect
88+
github.com/gorilla/css v1.0.1 // indirect
9089
github.com/hashicorp/go-version v1.6.0 // indirect
9190
github.com/json-iterator/go v1.1.12 // indirect
92-
github.com/kataras/jwt v0.1.8 // indirect
93-
github.com/klauspost/compress v1.16.7 // indirect
94-
github.com/klauspost/pgzip v1.2.5 // indirect
91+
github.com/kataras/jwt v0.1.10 // indirect
92+
github.com/klauspost/compress v1.17.8 // indirect
93+
github.com/klauspost/pgzip v1.2.6 // indirect
9594
github.com/kljensen/snowball v0.8.0 // indirect
9695
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
9796
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
9897
github.com/mattn/go-colorable v0.1.13 // indirect
99-
github.com/mattn/go-isatty v0.0.19 // indirect
100-
github.com/mattn/go-runewidth v0.0.14 // indirect
98+
github.com/mattn/go-isatty v0.0.20 // indirect
99+
github.com/mattn/go-runewidth v0.0.15 // indirect
101100
github.com/mholt/archiver/v3 v3.5.1 // indirect
102101
github.com/minio/selfupdate v0.6.1-0.20230907112617-f11e74f84ca7 // indirect
103102
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@@ -107,35 +106,34 @@ require (
107106
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
108107
github.com/nwaples/rardecode v1.1.3 // indirect
109108
github.com/olekukonko/tablewriter v0.0.5 // indirect
110-
github.com/pierrec/lz4/v4 v4.1.2 // indirect
109+
github.com/pierrec/lz4/v4 v4.1.21 // indirect
111110
github.com/pmezard/go-difflib v1.0.0 // indirect
112111
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
113112
github.com/projectdiscovery/blackrock v0.0.1 // indirect
114113
github.com/projectdiscovery/freeport v0.0.5 // indirect
115114
github.com/projectdiscovery/gostruct v0.0.2 // indirect
116115
github.com/projectdiscovery/machineid v0.0.0-20240226150047-2e2c51e35983 // indirect
117-
github.com/projectdiscovery/retryabledns v1.0.65 // indirect
118-
github.com/quic-go/quic-go v0.42.0 // indirect
119-
github.com/refraction-networking/utls v1.5.4 // indirect
116+
github.com/projectdiscovery/retryabledns v1.0.68 // indirect
117+
github.com/refraction-networking/utls v1.6.7 // indirect
120118
github.com/rivo/uniseg v0.4.4 // indirect
121119
github.com/rogpeppe/go-internal v1.12.0 // indirect
122120
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
123-
github.com/sashabaranov/go-openai v1.14.2 // indirect
124-
github.com/shirou/gopsutil/v3 v3.23.7 // indirect
121+
github.com/sashabaranov/go-openai v1.15.3 // indirect
122+
github.com/shirou/gopsutil/v3 v3.24.2 // indirect
125123
github.com/shoenig/go-m1cpu v0.1.6 // indirect
126124
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
127125
github.com/syndtr/goleveldb v1.0.0 // indirect
128-
github.com/tidwall/btree v1.6.0 // indirect
129-
github.com/tidwall/buntdb v1.3.0 // indirect
130-
github.com/tidwall/gjson v1.14.4 // indirect
126+
github.com/tidwall/btree v1.7.0 // indirect
127+
github.com/tidwall/buntdb v1.3.1 // indirect
128+
github.com/tidwall/gjson v1.17.1 // indirect
131129
github.com/tidwall/grect v0.1.4 // indirect
132130
github.com/tidwall/match v1.1.1 // indirect
133131
github.com/tidwall/pretty v1.2.1 // indirect
134132
github.com/tidwall/rtred v0.1.2 // indirect
135133
github.com/tidwall/tinyqueue v0.1.1 // indirect
136134
github.com/tklauser/go-sysconf v0.3.12 // indirect
137135
github.com/tklauser/numcpus v0.6.1 // indirect
138-
github.com/ulikunitz/xz v0.5.11 // indirect
136+
github.com/ulikunitz/xz v0.5.12 // indirect
139137
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
140138
github.com/ysmood/fetchup v0.2.3 // indirect
141139
github.com/ysmood/goob v0.4.0 // indirect
@@ -149,12 +147,12 @@ require (
149147
github.com/zmap/rc2 v0.0.0-20190804163417-abaa70531248 // indirect
150148
golang.org/x/crypto v0.24.0 // indirect
151149
golang.org/x/mod v0.17.0 // indirect
152-
golang.org/x/oauth2 v0.11.0 // indirect
150+
golang.org/x/oauth2 v0.18.0 // indirect
153151
golang.org/x/sync v0.7.0 // indirect
154152
golang.org/x/term v0.21.0 // indirect
155153
golang.org/x/time v0.5.0 // indirect
156154
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
157-
google.golang.org/appengine v1.6.7 // indirect
155+
google.golang.org/appengine v1.6.8 // indirect
158156
google.golang.org/protobuf v1.33.0 // indirect
159157
gopkg.in/djherbis/times.v1 v1.3.0 // indirect
160158
gopkg.in/ini.v1 v1.67.0 // indirect

0 commit comments

Comments
 (0)