elceef / dnstwist

Domain name permutation engine for detecting homograph phishing attacks, typo squatting, and brand impersonation
https://dnstwist.it
Apache License 2.0
4.81k stars 764 forks source link

Chained arguements #97

Closed HullaBrian closed 4 years ago

HullaBrian commented 4 years ago

I am attempting to retrieve a list of registered results off of a scan. I want to put it in idle format as I am using that list in another tool. However, if I want to do something such as: $dnstwist -r domain.com --format idle This returns just idle format of a non registered scan or so it seems. I have run a registered scan using: $dnstwist -r domain.com this returns some reachable websites.

All I am saying is that chaining arguments together doesn't seem to work.

elceef commented 4 years ago

Format idle just prints domain permutations and does not run any active scans so it can't tell which are registered. I suggest to use CSV format and pipe it through cut like this:

$ dnstwist --format csv --registered domain.com | cut -d, -f2

I will update the documentation and the argument parser to make sure chaining --format idle with other options won't be possible.

HullaBrian commented 4 years ago

Alright. I will see if that works.

HullaBrian commented 4 years ago

It doesn’t seem to work in the way that I want to use it. It works in the command line, but doesn’t work with what I want to use it with which is the subprocess.run() Command. When I run it, I get the following error:

Error: Unrecognized arguments: | cut\n
elceef commented 4 years ago

Can you paste full console output?

HullaBrian commented 4 years ago

Sure...

CompletedProcess(args=['dnstwist', '--format', 'csv', '--registered', 'domain.name', '|', 'cut', '-d,', '-f2'], returncode=2, stdout='', stderr="usage: /home/#####/.local/bin/dnstwist [OPTION]... DOMAIN\ndnstwist: error: argument -f/--format: invalid choice: '2' (choose from 'cli', 'csv', 'json', 'idle')\n")

I am getting a different error now because i changed the command from "-f2" to "--format idle". But i changed it back because that didnt work

elceef commented 4 years ago

I think I have full picture now. Pipes do not work with subprocess so you need to figure out some other way to parse the output. How about running it with --format json and then use json.loads() to convert it into a dictionary?

HullaBrian commented 4 years ago

I managed to make it work. Thanks so much!