mirror of
https://github.com/projectdiscovery/httpx.git
synced 2024-09-11 17:46:08 +03:00
- Callback for every result, even it contains error - User can handle it using Result.Err
42 lines
972 B
Go
42 lines
972 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
|
|
"github.com/projectdiscovery/goflags"
|
|
"github.com/projectdiscovery/gologger"
|
|
"github.com/projectdiscovery/gologger/levels"
|
|
"github.com/projectdiscovery/httpx/runner"
|
|
)
|
|
|
|
func main() {
|
|
gologger.DefaultLogger.SetMaxLevel(levels.LevelVerbose) // increase the verbosity (optional)
|
|
|
|
options := runner.Options{
|
|
Methods: "GET",
|
|
InputTargetHost: goflags.StringSlice{"scanme.sh", "projectdiscovery.io", "localhost"},
|
|
//InputFile: "./targetDomains.txt", // path to file containing the target domains list
|
|
OnResult: func(r runner.Result) {
|
|
// handle error
|
|
if r.Err != nil {
|
|
fmt.Printf("[Err] %s: %s\n", r.Input, r.Err)
|
|
return
|
|
}
|
|
fmt.Printf("%s %s %d\n", r.Input, r.Host, r.StatusCode)
|
|
},
|
|
}
|
|
|
|
if err := options.ValidateOptions(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
httpxRunner, err := runner.New(&options)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer httpxRunner.Close()
|
|
|
|
httpxRunner.RunEnumeration()
|
|
}
|