Seperated wildcard detection
This commit is contained in:
parent
a0c4349018
commit
158e202ed8
1
TODO.md
1
TODO.md
@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
- [ ] Clean up CLI
|
- [ ] Clean up CLI
|
||||||
- [ ] Fix logger levels
|
- [ ] Fix logger levels
|
||||||
- [ ] Move wildcard to separate function
|
|
||||||
- [ ] Complete all options (ENT, verify etc)
|
- [ ] Complete all options (ENT, verify etc)
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"slices"
|
"slices"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.supernets.org/perp/blink/v1/internal/bar"
|
"git.supernets.org/perp/blink/v1/internal/bar"
|
||||||
@ -30,6 +31,7 @@ var opts runner.Options
|
|||||||
var (
|
var (
|
||||||
wordlist string
|
wordlist string
|
||||||
resolvers string
|
resolvers string
|
||||||
|
wildcard bool
|
||||||
verbose bool
|
verbose bool
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -94,22 +96,13 @@ var rootCmd = &cobra.Command{
|
|||||||
// Create bar
|
// Create bar
|
||||||
pb := bar.New(tasks)
|
pb := bar.New(tasks)
|
||||||
|
|
||||||
// Store shown
|
|
||||||
// var shown bool
|
|
||||||
|
|
||||||
// Handle results
|
// Handle results
|
||||||
opts.OnResult = func(result *dns.Result) {
|
opts.OnResult = func(result *dns.Result) {
|
||||||
|
// Render bar
|
||||||
defer pb.RenderBlank()
|
defer pb.RenderBlank()
|
||||||
pb.Add(1)
|
pb.Add(1)
|
||||||
pb.Clear()
|
pb.Clear()
|
||||||
|
|
||||||
//if !shown {
|
|
||||||
// if result.Wildcard {
|
|
||||||
// log.Warn().Str("domain", result.Domain).Msg("Wildcard detected")
|
|
||||||
// shown = true
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Error found
|
// Error found
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
// Verbose enabled
|
// Verbose enabled
|
||||||
@ -149,10 +142,28 @@ var rootCmd = &cobra.Command{
|
|||||||
|
|
||||||
// Create runner
|
// Create runner
|
||||||
run := runner.New(&opts)
|
run := runner.New(&opts)
|
||||||
run.Bruteforce()
|
|
||||||
|
// Wildcard enabled
|
||||||
|
if wildcard {
|
||||||
|
// Go through domains
|
||||||
|
for _, domain := range opts.Domains {
|
||||||
|
// Check wildcard
|
||||||
|
found := run.Wildcard(domain)
|
||||||
|
|
||||||
|
// Print detection
|
||||||
|
log.Info().
|
||||||
|
Str("domain", domain).
|
||||||
|
Str("detected", strconv.FormatBool(found)).
|
||||||
|
Msg("Wildcard detection")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start runner
|
||||||
|
run.Start()
|
||||||
|
|
||||||
// Go through domains
|
// Go through domains
|
||||||
for domain, count := range domains {
|
for domain, count := range domains {
|
||||||
|
// Print count
|
||||||
log.Info().Str("subdomains", fmt.Sprintf("%d", count)).Msg(domain)
|
log.Info().Str("subdomains", fmt.Sprintf("%d", count)).Msg(domain)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -164,7 +175,7 @@ func init() {
|
|||||||
rootCmd.Flags().StringVarP(&resolvers, "resolvers", "r", "", "Path to resolvers")
|
rootCmd.Flags().StringVarP(&resolvers, "resolvers", "r", "", "Path to resolvers")
|
||||||
rootCmd.Flags().BoolVarP(&opts.UDP, "udp", "u", false, "Query using UDP")
|
rootCmd.Flags().BoolVarP(&opts.UDP, "udp", "u", false, "Query using UDP")
|
||||||
rootCmd.Flags().BoolVarP(&opts.IPv6, "ipv6", "i", false, "Query for IPv6")
|
rootCmd.Flags().BoolVarP(&opts.IPv6, "ipv6", "i", false, "Query for IPv6")
|
||||||
rootCmd.Flags().BoolVarP(&opts.Wildcard, "wildcard", "c", false, "Query for wildcard")
|
rootCmd.Flags().BoolVarP(&wildcard, "wildcard", "c", false, "Query for wildcard")
|
||||||
rootCmd.Flags().IntVarP(&opts.Timeout, "timeout", "d", 5, "Query timeout")
|
rootCmd.Flags().IntVarP(&opts.Timeout, "timeout", "d", 5, "Query timeout")
|
||||||
rootCmd.Flags().IntVarP(&opts.Threads, "threads", "t", 1, "Concurrent threads")
|
rootCmd.Flags().IntVarP(&opts.Threads, "threads", "t", 1, "Concurrent threads")
|
||||||
rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Verbose logging")
|
rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Verbose logging")
|
||||||
@ -174,7 +185,10 @@ func init() {
|
|||||||
rootCmd.MarkFlagRequired("wordlist")
|
rootCmd.MarkFlagRequired("wordlist")
|
||||||
|
|
||||||
// Setup logger
|
// Setup logger
|
||||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, PartsExclude: []string{"time"}})
|
log.Logger = log.Output(zerolog.ConsoleWriter{
|
||||||
|
Out: os.Stderr,
|
||||||
|
PartsExclude: []string{"time"},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -21,7 +21,6 @@ type Query struct {
|
|||||||
type Result struct {
|
type Result struct {
|
||||||
Domain string // Target domain
|
Domain string // Target domain
|
||||||
Subdomain string // Target subdomain
|
Subdomain string // Target subdomain
|
||||||
Wildcard bool // Wildcard detect
|
|
||||||
IPv4 []net.IP // IPv4 hosts
|
IPv4 []net.IP // IPv4 hosts
|
||||||
IPv6 []net.IP // IPv6 hosts
|
IPv6 []net.IP // IPv6 hosts
|
||||||
Error error // Error response
|
Error error // Error response
|
||||||
|
@ -12,9 +12,8 @@ type Options struct {
|
|||||||
Wordlist []string // Target wordlist
|
Wordlist []string // Target wordlist
|
||||||
Resolvers []string // Target resolvers
|
Resolvers []string // Target resolvers
|
||||||
// ENT bool // Query for ENT
|
// ENT bool // Query for ENT
|
||||||
UDP bool // Query using UDP
|
UDP bool // Query using UDP
|
||||||
IPv6 bool // Query for IPv6
|
IPv6 bool // Query for IPv6
|
||||||
Wildcard bool // Detect wildcard
|
|
||||||
// Verify bool // Verify query
|
// Verify bool // Verify query
|
||||||
Timeout int // Query timeout
|
Timeout int // Query timeout
|
||||||
Threads int // Concurrent threads
|
Threads int // Concurrent threads
|
||||||
|
@ -10,11 +10,10 @@ import (
|
|||||||
|
|
||||||
// Bruteforce runner
|
// Bruteforce runner
|
||||||
type Runner struct {
|
type Runner struct {
|
||||||
options *Options // CLI options
|
options *Options // CLI options
|
||||||
client *mdns.Client // DNS client
|
client *mdns.Client // DNS client
|
||||||
pool *ants.Pool // Goroutine pool
|
pool *ants.Pool // Goroutine pool
|
||||||
results chan *dns.Result // Results channel
|
results chan *dns.Result // Results channel
|
||||||
wildcards map[string]bool // Domain wildcards
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a new Runner
|
// Return a new Runner
|
||||||
@ -45,25 +44,17 @@ func New(options *Options) *Runner {
|
|||||||
// Create channel
|
// Create channel
|
||||||
results := make(chan *dns.Result, tasks)
|
results := make(chan *dns.Result, tasks)
|
||||||
|
|
||||||
// Create wildcards
|
|
||||||
wildcards := make(map[string]bool)
|
|
||||||
|
|
||||||
return &Runner{
|
return &Runner{
|
||||||
options: options,
|
options: options,
|
||||||
client: client,
|
client: client,
|
||||||
pool: pool,
|
pool: pool,
|
||||||
results: results,
|
results: results,
|
||||||
wildcards: wildcards,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect wildcard
|
// Detect wildcard
|
||||||
func (r *Runner) Detect() {
|
func (r *Runner) Wildcard(domain string) bool {
|
||||||
// Go through domains
|
return dns.Wildcard(r.client, r.options.Resolvers, domain)
|
||||||
for _, domain := range r.options.Domains {
|
|
||||||
// Get wildcard status
|
|
||||||
r.wildcards[domain] = dns.Wildcard(r.client, r.options.Resolvers, domain)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submit tasks into pool
|
// Submit tasks into pool
|
||||||
@ -103,27 +94,14 @@ func (r *Runner) Receive() {
|
|||||||
for range tasks {
|
for range tasks {
|
||||||
select {
|
select {
|
||||||
case result := <-r.results:
|
case result := <-r.results:
|
||||||
// Go through domains
|
|
||||||
for domain, wildcard := range r.wildcards {
|
|
||||||
// Domain found
|
|
||||||
if result.Domain == domain {
|
|
||||||
// Set wildcard
|
|
||||||
result.Wildcard = wildcard
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send result
|
// Send result
|
||||||
r.options.OnResult(result)
|
r.options.OnResult(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start bruteforcing
|
// Start runner
|
||||||
func (r *Runner) Bruteforce() {
|
func (r *Runner) Start() {
|
||||||
if r.options.Wildcard {
|
|
||||||
r.Detect()
|
|
||||||
}
|
|
||||||
|
|
||||||
go r.Submit()
|
go r.Submit()
|
||||||
r.Receive()
|
r.Receive()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user