WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit e455249

Browse files
authored
Merge pull request #692 from projectdiscovery/dev
v1.2.3 Release
2 parents ba6220d + 0857cac commit e455249

File tree

22 files changed

+452
-214
lines changed

22 files changed

+452
-214
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727
go test -coverprofile=./cov.out ./...
2828
2929
- name: Run Gosec Security Scanner
30-
run: |
31-
go install github.com/securego/gosec/cmd/gosec@latest
32-
gosec -no-fail -fmt=sonarqube -out report.json ./...
30+
uses: securego/gosec@master
31+
with:
32+
args: '-no-fail -fmt=sonarqube -out report.json ./...'
3333

3434
- name: SonarCloud Scan
3535
uses: SonarSource/sonarcloud-github-action@master

README.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,12 @@ MATCHERS:
116116
-mfc, -match-favicon string[] match response with specified favicon hash (-mfc 1494302000)
117117
-ms, -match-string string match response with specified string (-ms admin)
118118
-mr, -match-regex string match response with specified regex (-mr admin)
119-
-mcdn, -match-cdn string[] match host with specified cdn provider (google, azure, cloudflare, cloudfront, fastly, incapsula, oracle, akamai, sucuri, leaseweb)
119+
-mcdn, -match-cdn string[] match host with specified cdn provider (azure, cloudflare, cloudfront, fastly, incapsula, oracle, google, akamai, sucuri, leaseweb)
120120
-mrt, -match-response-time string match response with specified response time in seconds (-mrt '< 1')
121121

122122
EXTRACTOR:
123-
-er, -extract-regex string display response content for specified regex
123+
-er, -extract-regex string[] Display response content with matched regex
124+
-ep, -extract-preset string[] Display response content with matched preset regex
124125

125126
FILTERS:
126127
-fc, -filter-code string filter response with specified status code (-fc 403,401)
@@ -130,7 +131,7 @@ FILTERS:
130131
-ffc, -filter-favicon string[] filter response with specified favicon hash (-mfc 1494302000)
131132
-fs, -filter-string string filter response with specified string (-fs admin)
132133
-fe, -filter-regex string filter response with specified regex (-fe admin)
133-
-fcdn, -filter-cdn string[] filter host with specified cdn provider (google, azure, cloudflare, cloudfront, fastly, incapsula, oracle, akamai, sucuri, leaseweb)
134+
-fcdn, -filter-cdn string[] filter host with specified cdn provider (azure, cloudflare, cloudfront, fastly, incapsula, oracle, google, akamai, sucuri, leaseweb)
134135
-frt, -filter-response-time string filter response with specified response time in seconds (-frt '> 1')
135136

136137
RATE-LIMIT:
@@ -180,6 +181,7 @@ CONFIGURATIONS:
180181
-ldp, -leave-default-ports leave default http/https ports in host header (eg. http://host:80 - https//host:443
181182

182183
DEBUG:
184+
-health-check, -hc run diagnostic check up
183185
-debug display request/response content in cli
184186
-debug-req display request content in cli
185187
-debug-resp display response content in cli
@@ -395,7 +397,7 @@ https://api.hackerone.com [AS13335, CLOUDFLARENET, US, 104.16.96.0/20]
395397
```
396398

397399

398-
### Path Probe
400+
### File/Path Bruteforce
399401

400402

401403
```console
@@ -451,8 +453,47 @@ https://docs.hackerone.com
451453
https://support.hackerone.com
452454
```
453455

456+
### Using httpx as a library
457+
`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:
458+
459+
```go
460+
package main
461+
462+
import (
463+
"log"
464+
"os"
465+
466+
"github.com/projectdiscovery/httpx/runner"
467+
)
468+
469+
func main() {
470+
inputFile := "test.txt"
471+
err := os.WriteFile(inputFile, []byte("scanme.sh"), 0644)
472+
if err != nil {
473+
log.Fatal(err)
474+
}
475+
defer os.RemoveAll(inputFile)
476+
477+
options := runner.Options{
478+
Methods: "GET",
479+
InputFile: inputFile,
480+
}
481+
if err := options.ValidateOptions(); err != nil {
482+
log.Fatal(err)
483+
}
484+
485+
httpxRunner, err := runner.New(&options)
486+
if err != nil {
487+
log.Fatal()
488+
}
489+
defer httpxRunner.Close()
490+
491+
httpxRunner.RunEnumeration()
492+
}
493+
```
494+
454495

455-
# 📋 Notes
496+
# Notes
456497

457498
- As default, **httpx** checks for `HTTPS` probe and fall-back to `HTTP` only if `HTTPS` is not reachable.
458499
- For printing both HTTP/HTTPS results, `no-fallback` flag can be used.

cmd/functional-test/run.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ echo "::group::Building functional-test binary"
1111
go build -o functional-test$extension
1212
echo "::endgroup::"
1313

14-
echo "::group::Building dnsx binary from current branch"
14+
echo "::group::Building httpx binary from current branch"
1515
go build -o httpx_dev$extension ../httpx
1616
echo "::endgroup::"
1717

18-
echo "::group::Building latest release of dnsx"
18+
echo "::group::Building latest release of httpx"
1919
go build -o httpx$extension -v github.com/projectdiscovery/httpx/cmd/httpx
2020
echo "::endgroup::"
2121

22-
echo 'Starting dnsx functional test'
22+
echo 'Starting httpx functional test'
2323
./functional-test$extension -main ./httpx$extension -dev ./httpx_dev$extension -testcases testcases.txt
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://www.example.com
1+
https://scanme.sh

cmd/functional-test/testcases.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
www.example.com {{binary}} -silent
2-
www.example.com {{binary}} -silent -l test-data/request.txt
3-
www.example.com {{binary}} -silent -request test-data/raw-request.txt
4-
www.example.com {{binary}} -silent -title
5-
www.example.com {{binary}} -silent -sc
6-
www.example.com {{binary}} -silent -td
7-
www.example.com {{binary}} -silent -probe
8-
www.example.com {{binary}} -silent -no-fallback
9-
www.example.com {{binary}} -silent -cl
10-
www.example.com {{binary}} -silent -server
11-
www.example.com {{binary}} -silent -ip
12-
www.example.com {{binary}} -silent -tls-grab
13-
www.example.com {{binary}} -silent -unsafe
14-
www.example.com {{binary}} -silent -x all
15-
www.example.com {{binary}} -silent -body 'a=b'
16-
www.example.com {{binary}} -silent -exclude-cdn
1+
scanme.sh {{binary}} -silent
2+
scanme.sh {{binary}} -silent -l test-data/request.txt
3+
scanme.sh {{binary}} -silent -request test-data/raw-request.txt
4+
scanme.sh {{binary}} -silent -title
5+
scanme.sh {{binary}} -silent -sc
6+
scanme.sh {{binary}} -silent -td
7+
scanme.sh {{binary}} -silent -probe
8+
scanme.sh {{binary}} -silent -no-fallback
9+
scanme.sh {{binary}} -silent -cl
10+
scanme.sh {{binary}} -silent -server
11+
scanme.sh {{binary}} -silent -ip
12+
scanme.sh {{binary}} -silent -tls-grab
13+
scanme.sh {{binary}} -silent -unsafe
14+
scanme.sh {{binary}} -silent -x all
15+
scanme.sh {{binary}} -silent -body 'a=b'
16+
scanme.sh {{binary}} -silent -exclude-cdn

cmd/integration-test/integration-test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ func main() {
2222
failed := aurora.Red("[✘]").String()
2323

2424
tests := map[string]map[string]testutils.TestCase{
25-
"http": httpTestcases,
25+
"http": httpTestcases,
26+
"library": libraryTestcases,
2627
}
2728
for proto, tests := range tests {
2829
if protocol == "" || protocol == proto {

cmd/integration-test/library.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package main
2+
3+
import (
4+
"os"
5+
6+
"github.com/projectdiscovery/httpx/internal/testutils"
7+
"github.com/projectdiscovery/httpx/runner"
8+
)
9+
10+
var libraryTestcases = map[string]testutils.TestCase{
11+
"Httpx as library": &httpxLibrary{},
12+
}
13+
14+
type httpxLibrary struct {
15+
}
16+
17+
func (h *httpxLibrary) Execute() error {
18+
testFile := "test.txt"
19+
err := os.WriteFile(testFile, []byte("scanme.sh"), 0644)
20+
if err != nil {
21+
return err
22+
}
23+
defer os.RemoveAll(testFile)
24+
25+
options := runner.Options{
26+
Methods: "GET",
27+
InputFile: testFile,
28+
}
29+
if err := options.ValidateOptions(); err != nil {
30+
return err
31+
}
32+
33+
httpxRunner, err := runner.New(&options)
34+
if err != nil {
35+
return err
36+
}
37+
defer httpxRunner.Close()
38+
39+
httpxRunner.RunEnumeration()
40+
return nil
41+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package customextract
2+
3+
import "regexp"
4+
5+
var ExtractPresets = map[string]*regexp.Regexp{
6+
"url": regexp.MustCompile("^(http(s)?:\\/\\/)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:[0-9]{1,5})?[-a-zA-Z0-9()@:%_\\\\\\+\\.~#?&//=]*$"), //nolint
7+
"ip": regexp.MustCompile("((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})(\\.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})){3}"), //nolint
8+
"mail": regexp.MustCompile("^([A-Za-z0-9_\\-\\.\u4e00-\u9fa5])+\\@([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,8})$"), //nolint
9+
}

common/customextract/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package customextract

common/customports/customport.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package customport
22

33
import (
4+
"fmt"
45
"strconv"
56
"strings"
67

@@ -28,6 +29,36 @@ func (c *CustomPorts) String() string {
2829
return "Custom Ports"
2930
}
3031

32+
// ValidateCustomPorts to validate the custom port range
33+
func ValidateCustomPorts(value string) error {
34+
potentialRange := strings.Split(value, "-")
35+
if len(potentialRange) < portRangeParts {
36+
if _, err := strconv.Atoi(value); err != nil {
37+
return fmt.Errorf("Could not cast port to integer from your value: %s. Resulting error: %s.\n", value, err.Error())
38+
}
39+
} else {
40+
part1 := potentialRange[0]
41+
part2 := potentialRange[1]
42+
lowP, err := strconv.Atoi(part1)
43+
if err != nil {
44+
return fmt.Errorf("Could not cast first port of your range(%s) to integer from your value: %s. Resulting error: %s.\n",
45+
value, part1, err.Error())
46+
}
47+
highP, err := strconv.Atoi(part2)
48+
if err != nil {
49+
return fmt.Errorf("Could not cast last port of your port range(%s) to integer from "+
50+
"your value: %s. Resulting error %s.\n",
51+
value, part2, err.Error())
52+
}
53+
if lowP > highP {
54+
return fmt.Errorf("First value of port range should be lower than the last port "+
55+
"from your range: [%d, %d].\n",
56+
lowP, highP)
57+
}
58+
}
59+
return nil
60+
}
61+
3162
// Set a port range
3263
func (c *CustomPorts) Set(value string) error {
3364
// ports can be like nmap -p [https|http:]start-end,[https|http:]port1,[https|http:]port2,[https|http:]port3

0 commit comments

Comments
 (0)