Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved json output #295

Merged
merged 11 commits into from
Aug 23, 2020
Merged

Improved json output #295

merged 11 commits into from
Aug 23, 2020

Conversation

vzamanillo
Copy link
Contributor

Implement #245

@ehsandeep
Copy link
Member

Hi @vzamanillo,

Thank you for the PR and working on this, I see this PR adds sources Information in JSON output which is really useful, apart from that, I also noticed somehow this breaks nW flag.

./subfinder -d hackerone.com -oJ -nW -o test.txt

This doesn't add host information in the JSON output like the previous version, ignore this comment if you still working on this PR for other issues listed in #245

@vzamanillo
Copy link
Contributor Author

vzamanillo commented Aug 16, 2020

Hey, don't worry I will take a look to solve it, maybe I am missing something.

@vzamanillo
Copy link
Contributor Author

vzamanillo commented Aug 16, 2020

Sorry, I am a little bit confused with the actual behaviour

// Write the output to the file depending upon user requirement
if r.options.HostIP {
  err = WriteHostIPOutput(foundResults, file)
} else if r.options.JSON {
  err = WriteJSONOutput(foundResults, file)
} else {
  if r.options.RemoveWildcard {
    err = WriteHostOutputNoWildcard(foundResults, file)
  } else {
    err = WriteHostOutput(uniqueMap, file)
  }
}
  • if r.options.HostIP writes Host + IP in plain text (no JSON):
sb.WriteString(host)
sb.WriteString(",")
sb.WriteString(ip)
sb.WriteString("\n")
  • else if r.options.JSON writes Host + IP in JSON:
data.Host = host
data.IP = ip
err := encoder.Encode(&data)
  • else if r.options.RemoveWildcard writes Host only in plain text (no JSON)
sb.WriteString(host)
sb.WriteString("\n")
  • else writes Host only in plain text (no JSON)

My approach

  • If you ask for HostIP writes Host + IP (JSON / Plain text)
  • If you ask for RemoveWildcard writes Host only (JSON / Plain text)
  • Else writes Host (JSON / Plain text)

Why the existing master branch writes Host + IP in all cases if -oJ is specified even if the user don't ask for IP?

@Ice3man543
Copy link
Member

@vzamanillo so, regarding your question, the behaviour is as follows -

  1. If user asks for Host as well as IP, write the host->IP in plain text. (Expects nW flag is provided)
  2. If user asks for JSON, write host->IP in json format. (Expects nW flag is provided)
  3. Else, if user asks for removing wildcards, write only hosts that are not wildcard to plain text file. Otherwise, write normal output (only hosts) to file.

@Ice3man543 Ice3man543 marked this pull request as draft August 17, 2020 08:40
@vzamanillo
Copy link
Contributor Author

I think this is ready to merge.

This is the final behaviour:

  • You can always ask for JSON output (-oJ), it is fully compatible with all options.
  • You can set an absolute path for output (-o) file on single domain enumeration (intermediate dirs are created).
  • If you ask for HostIP (-oI) writes Host + IP (JSON / Plain text)
  • If you ask for RemoveWildcard (-nW) writes Host only (JSON / Plain text)
  • Else writes Host (JSON / Plain text)

Check it and tell me impressions / improvements / flaws.

@Ice3man543 Ice3man543 marked this pull request as ready for review August 23, 2020 14:46
Copy link
Member

@Ice3man543 Ice3man543 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Merging now! Great work as always.

@Ice3man543 Ice3man543 merged commit eea72d3 into projectdiscovery:master Aug 23, 2020
@vzamanillo vzamanillo deleted the improved-json-output branch August 25, 2020 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants