projectdiscovery / subfinder

Fast passive subdomain enumeration tool.
https://projectdiscovery.io
MIT License
9.68k stars 1.22k forks source link

Subdomain Comparison to last runs #33

Closed codingo closed 4 years ago

codingo commented 6 years ago

Identifying new and old subdomains would be valuable and having a flag to pass in a previous scan of a domain to compare results against would prove valuable.

Essentially - I scan subdomain x into output x.txt on day y

On day z I rescan x, but I pass the flag --dif x.txt and it compares the results of scan z against my previous scan and lets me know what has changed.

This not only may help identify new techniques for takeovers but will also help identify potential development or pre-production hosts.

Ice3man543 commented 6 years ago

In theory, this could work for single output files but what about multiple output files? @codingo

codingo commented 6 years ago

I think we focus on 1:1 for now between two files. I'm still giving some further thought to the best way to approach multiple files and will raise a new issue / merge once we've tackled it.

Ice3man543 commented 6 years ago

Sure. :+1:

ehsandeep commented 6 years ago

Awesome idea @codingo!

Ice3man543 commented 6 years ago

Guys, this is how this should work. I am a little busy, so i can't add it now. If anyone can do it now, it would be cool. Else, i will do it someday.



func SliceExists(slice interface{}, item interface{}) bool {
    s := reflect.ValueOf(slice)

    if s.Kind() != reflect.Slice {
        panic("SliceExists() given a non-slice type")
    }

    for i := 0; i < s.Len(); i++ {
        if s.Index(i).Interface() == item {
            return true
        }
    }

    return false
}

....

var outputSubs []string
// Here, we perform checks for newly added subdomains
if oldList != "" {
    var oldSubs []string

    file, err := os.Open(oldList)

    if err != nil {
        fmt.Fprintf(os.Stderr, "\nerror: %v\n", err)
        os.Exit(1)
    }

    defer file.Close()

    scanner := bufio.NewScanner(file)

    for scanner.Scan() {
        oldSubs = append(oldSubs, scanner.Text())
    }

    // Check each subdomain found and if not in old list,
    // add them to the correct array
    for _, sub := range subsReturned {
        if SliceExists(oldSubs, sub) != true {
            outputSubs = append(outputSubs, sub)
        }
    }
} else {
    outputSubs = append(outputSubs, subsReturned...)
}

_ = WriteOutputText(outputSubs)
Attackerpentest commented 5 years ago

Hello there, Need some help here. How can I add this? Regard. @panchocosil

Ice3man543 commented 5 years ago

I gave an example above. If you have futhur questions, please comment!

Ice3man543 commented 4 years ago

Closing this as its outside scope of subfinder!