Merge pull request #211 from projectdiscovery/single-file-output-fix
Fixed single file outputmaster
commit
4a6d839154
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
// EnumerateSingleDomain performs subdomain enumeration against a single domain
|
||||
func (r *Runner) EnumerateSingleDomain(domain, output string) error {
|
||||
func (r *Runner) EnumerateSingleDomain(domain, output string, append bool) error {
|
||||
log.Infof("Enumerating subdomains for %s\n", domain)
|
||||
|
||||
// Get the API keys for sources from the configuration
|
||||
|
@ -127,7 +127,13 @@ func (r *Runner) EnumerateSingleDomain(domain, output string) error {
|
|||
}
|
||||
}
|
||||
|
||||
file, err := os.Create(output)
|
||||
var file *os.File
|
||||
var err error
|
||||
if append {
|
||||
file, err = os.OpenFile(output, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
} else {
|
||||
file, err = os.Create(output)
|
||||
}
|
||||
if err != nil {
|
||||
log.Errorf("Could not create file %s for %s: %s\n", output, domain, err)
|
||||
return err
|
||||
|
|
|
@ -40,7 +40,7 @@ func NewRunner(options *Options) (*Runner, error) {
|
|||
func (r *Runner) RunEnumeration() error {
|
||||
// Check if only a single domain is sent as input. Process the domain now.
|
||||
if r.options.Domain != "" {
|
||||
return r.EnumerateSingleDomain(r.options.Domain, r.options.Output)
|
||||
return r.EnumerateSingleDomain(r.options.Domain, r.options.Output, false)
|
||||
}
|
||||
|
||||
// If we have multiple domains as input,
|
||||
|
@ -71,8 +71,16 @@ func (r *Runner) EnumerateMultipleDomains(reader io.Reader) error {
|
|||
continue
|
||||
}
|
||||
|
||||
var err error
|
||||
// If the user has specifed an output file, use that output file instead
|
||||
// of creating a new output file for each domain. Else create a new file
|
||||
// for each domain in the directory.
|
||||
if r.options.Output != "" {
|
||||
err = r.EnumerateSingleDomain(domain, r.options.Output, true)
|
||||
} else {
|
||||
outputFile := path.Join(r.options.OutputDirectory, domain)
|
||||
err := r.EnumerateSingleDomain(domain, outputFile)
|
||||
err = r.EnumerateSingleDomain(domain, outputFile, false)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue