An open API service indexing awesome lists of open source software.

https://github.com/root4loot/nsfinder

DNS resolver discovery
https://github.com/root4loot/nsfinder

discovery dns nameserver osint reconnaissance

Last synced: 16 days ago
JSON representation

DNS resolver discovery

Awesome Lists containing this project

README

          

# nsfinder

[![CI](https://github.com/root4loot/nsfinder/actions/workflows/ci.yml/badge.svg)](https://github.com/root4loot/nsfinder/actions/workflows/ci.yml)

A tool to find DNS resolvers for a target (domain or IP) using:

- WHOIS nameserver extraction
- NS record traversal
- ASN-based IP range scanning
- Port 53 scanning (UDP/TCP)
- Curated public DNS resolvers

## Quick Start

```bash
go get github.com/root4loot/nsfinder/pkg/nsfinder
```

```go
package main

import (
"fmt"
"time"
"github.com/root4loot/nsfinder/pkg/nsfinder"
)

func main() {
finder := nsfinder.NewFinder(&nsfinder.Options{
EnableWhois: true,
EnableNSLookup: true,
EnablePortScan: false, // Can be slow
Concurrency: 10,
Timeout: 30 * time.Second,
})

go func() {
for result := range finder.Results {
if result.Error == nil {
fmt.Printf("Found: %s from %s (target: %s)\n",
result.Resolver, result.Source, result.Target)
}
}
}()

finder.FindStream("example.com", "test.com")
}
```

## Configuration Options

```go
type Options struct {
EnableWhois bool // Extract nameservers from whois data
EnableNSLookup bool // Follow NS record chains
EnablePortScan bool // Scan for port 53 services
EnableASNLookup bool // Use ASN data for IP range finding
EnableDNSGrab bool // Use existing dnsgrab functionality
Timeout time.Duration // Timeout for operations
Concurrency int // Number of concurrent workers
Verbose bool // Verbose logging
}
```

## Core Types

```go
type Finder struct {
Options *Options
Results chan Result
}

type Result struct {
Resolver string // The found DNS resolver
Source string // Finding method (whois, ns-records, etc.)
Target string // Original target
Error error // Any error encountered
}
```

## Example Usage

```go
package main

import (
"fmt"
"log"
"time"

"github.com/root4loot/nsfinder/pkg/nsfinder"
)

func main() {
finder := nsfinder.NewFinder(&nsfinder.Options{
EnableWhois: true,
EnableNSLookup: true,
EnablePortScan: false,
EnableASNLookup: false,
EnableDNSGrab: false,
EnablePublicResolvers: true,
Concurrency: 10,
Timeout: 30 * time.Second,
Verbose: true,
})

fmt.Println("Stream")
go func() {
for result := range finder.Results {
if result.Error != nil {
log.Printf("Error: %s - %v", result.Target, result.Error)
} else {
fmt.Printf("Found: %s from %s (target: %s)\n",
result.Resolver, result.Source, result.Target)
}
}
}()

finder.FindStream("example.com", "hackerone.com")
time.Sleep(10 * time.Second)
}

// Found: a.ns.hackerone.com:53 from whois (target: hackerone.com)
// Found: b.ns.hackerone.com:53 from whois (target: hackerone.com)
// Found: a.ns.hackerone.com:53 from ns-records (target: hackerone.com)
// Found: 162.159.0.31:53 from ns-records (target: hackerone.com)
// Found: [2400:cb00:2049:1::a29f:1f]:53 from ns-records (target: hackerone.com)
// ...
```

## Contributing

1. Fork the repository
2. Create a feature branch
3. Add tests for new functionality
4. Ensure all tests pass
5. Submit a pull request

## License

MIT License - see LICENSE file for details.