Skip to content

Commit 4b910ae

Browse files
Merge pull request #2365 from projectdiscovery/dev
httpx v1.8.0
2 parents 8b2e65a + e3c6ba3 commit 4b910ae

30 files changed

Lines changed: 2708 additions & 177 deletions

.github/workflows/build-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
lint:
1212
name: Lint Test
13-
if: "${{ !endsWith(github.actor, '[bot]') }}"
13+
if: ${{ !endsWith(github.actor, '[bot]') }}
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4

README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ Usage:
9292

9393
Flags:
9494
INPUT:
95-
-l, -list string input file containing list of hosts to process
96-
-rr, -request string file containing raw request
97-
-u, -target string[] input target host(s) to probe
95+
-l, -list string input file containing list of hosts to process
96+
-rr, -request string file containing raw request
97+
-u, -target string[] input target host(s) to probe
98+
-im, -input-mode string mode of input file (burp)
9899

99100
PROBES:
100101
-sc, -status-code display response status-code
@@ -110,9 +111,11 @@ PROBES:
110111
-title display page title
111112
-bp, -body-preview display first N characters of response body (default 100)
112113
-server, -web-server display server name
113-
-td, -tech-detect display technology in use based on wappalyzer dataset
114+
-td, -tech-detect display technology in use based on wappalyzer dataset
114115
-cff, -custom-fingerprint-file string path to a custom fingerprint file for technology detection
115-
-method display http request method
116+
-cpe display CPE (Common Platform Enumeration) based on awesome-search-queries
117+
-wp, -wordpress display WordPress plugins and themes
118+
-method display http request method
116119
-ws, -websocket display server using websocket
117120
-ip display host ip
118121
-cname display host cname
@@ -231,6 +234,7 @@ CONFIGURATIONS:
231234
-tlsi, -tls-impersonate enable experimental client hello (ja3) tls randomization
232235
-no-stdin Disable Stdin processing
233236
-hae, -http-api-endpoint string experimental http api endpoint
237+
-sf, -secret-file string path to secret file for authentication
234238

235239
DEBUG:
236240
-health-check, -hc run diagnostic check up
@@ -277,9 +281,28 @@ For details about running httpx, see https://docs.projectdiscovery.io/tools/http
277281
# Notes
278282

279283
- As default, `httpx` probe with **HTTPS** scheme and fall-back to **HTTP** only if **HTTPS** is not reachable.
284+
- Burp Suite XML exports can be used as input with `-l burp-export.xml -im burp`
280285
- The `-no-fallback` flag can be used to probe and display both **HTTP** and **HTTPS** result.
281286
- Custom scheme for ports can be defined, for example `-ports http:443,http:80,https:8443`
282287
- Custom resolver supports multiple protocol (**doh|tcp|udp**) in form of `protocol:resolver:port` (e.g. `udp:127.0.0.1:53`)
288+
- Secret files can be used for domain-based authentication via `-sf secrets.yaml`. Supported auth types: `BasicAuth`, `BearerToken`, `Header`, `Cookie`, `Query`. Example:
289+
```yaml
290+
id: example-auth
291+
info:
292+
name: Example Auth Config
293+
static:
294+
- type: Header
295+
domains:
296+
- api.example.com
297+
headers:
298+
- key: X-API-Key
299+
value: secret-key-here
300+
- type: BasicAuth
301+
domains-regex:
302+
- ".*\\.internal\\.com$"
303+
username: admin
304+
password: secret
305+
```
283306
- The following flags should be used for specific use cases instead of running them as default with other probes:
284307
- `-ports`
285308
- `-path`
@@ -307,4 +330,4 @@ Probing feature is inspired by [@tomnomnom/httprobe](https://github.com/tomnomno
307330

308331
<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>
309332

310-
</div>
333+
</div>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package authx
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/projectdiscovery/retryablehttp-go"
7+
)
8+
9+
var (
10+
_ AuthStrategy = &BasicAuthStrategy{}
11+
)
12+
13+
// BasicAuthStrategy is a strategy for basic auth
14+
type BasicAuthStrategy struct {
15+
Data *Secret
16+
}
17+
18+
// NewBasicAuthStrategy creates a new basic auth strategy
19+
func NewBasicAuthStrategy(data *Secret) *BasicAuthStrategy {
20+
return &BasicAuthStrategy{Data: data}
21+
}
22+
23+
// Apply applies the basic auth strategy to the request
24+
func (s *BasicAuthStrategy) Apply(req *http.Request) {
25+
req.SetBasicAuth(s.Data.Username, s.Data.Password)
26+
}
27+
28+
// ApplyOnRR applies the basic auth strategy to the retryable request
29+
func (s *BasicAuthStrategy) ApplyOnRR(req *retryablehttp.Request) {
30+
req.SetBasicAuth(s.Data.Username, s.Data.Password)
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package authx
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/projectdiscovery/retryablehttp-go"
7+
)
8+
9+
var (
10+
_ AuthStrategy = &BearerTokenAuthStrategy{}
11+
)
12+
13+
// BearerTokenAuthStrategy is a strategy for bearer token auth
14+
type BearerTokenAuthStrategy struct {
15+
Data *Secret
16+
}
17+
18+
// NewBearerTokenAuthStrategy creates a new bearer token auth strategy
19+
func NewBearerTokenAuthStrategy(data *Secret) *BearerTokenAuthStrategy {
20+
return &BearerTokenAuthStrategy{Data: data}
21+
}
22+
23+
// Apply applies the bearer token auth strategy to the request
24+
func (s *BearerTokenAuthStrategy) Apply(req *http.Request) {
25+
req.Header.Set("Authorization", "Bearer "+s.Data.Token)
26+
}
27+
28+
// ApplyOnRR applies the bearer token auth strategy to the retryable request
29+
func (s *BearerTokenAuthStrategy) ApplyOnRR(req *retryablehttp.Request) {
30+
req.Header.Set("Authorization", "Bearer "+s.Data.Token)
31+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package authx
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/projectdiscovery/retryablehttp-go"
7+
)
8+
9+
var (
10+
_ AuthStrategy = &CookiesAuthStrategy{}
11+
)
12+
13+
// CookiesAuthStrategy is a strategy for cookies auth
14+
type CookiesAuthStrategy struct {
15+
Data *Secret
16+
}
17+
18+
// NewCookiesAuthStrategy creates a new cookies auth strategy
19+
func NewCookiesAuthStrategy(data *Secret) *CookiesAuthStrategy {
20+
return &CookiesAuthStrategy{Data: data}
21+
}
22+
23+
// Apply applies the cookies auth strategy to the request
24+
func (s *CookiesAuthStrategy) Apply(req *http.Request) {
25+
for _, cookie := range s.Data.Cookies {
26+
req.AddCookie(&http.Cookie{
27+
Name: cookie.Key,
28+
Value: cookie.Value,
29+
})
30+
}
31+
}
32+
33+
// ApplyOnRR applies the cookies auth strategy to the retryable request
34+
func (s *CookiesAuthStrategy) ApplyOnRR(req *retryablehttp.Request) {
35+
// Build a set of cookie names to replace
36+
newCookieNames := make(map[string]struct{}, len(s.Data.Cookies))
37+
for _, cookie := range s.Data.Cookies {
38+
newCookieNames[cookie.Key] = struct{}{}
39+
}
40+
41+
// Filter existing cookies, keeping only those not being replaced
42+
existingCookies := req.Cookies()
43+
filteredCookies := make([]*http.Cookie, 0, len(existingCookies))
44+
for _, cookie := range existingCookies {
45+
if _, shouldReplace := newCookieNames[cookie.Name]; !shouldReplace {
46+
filteredCookies = append(filteredCookies, cookie)
47+
}
48+
}
49+
50+
// Clear and reset cookies
51+
req.Header.Del("Cookie")
52+
for _, cookie := range filteredCookies {
53+
req.AddCookie(cookie)
54+
}
55+
// Add new cookies
56+
for _, cookie := range s.Data.Cookies {
57+
req.AddCookie(&http.Cookie{
58+
Name: cookie.Key,
59+
Value: cookie.Value,
60+
})
61+
}
62+
}

0 commit comments

Comments
 (0)