elceef / dnstwist

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

Don't print ANSI escape sequences to file on exit #125

Closed apinkney97 closed 3 years ago

apinkney97 commented 3 years ago

Before this change, when using -o <filename> you end up with \x1b[39m\x1b[0m appended to the end of your file.

There is logic to avoid this elsewhere (by setting FG_RST, ST_RST etc to empty string) but this happens at module level before the CLI arguments are parsed.

_exit is also defined (and used) before the arguments are parsed, which means we can't check args.output.

We can safely use sys.stdout.isatty() because by the time the _exit(0) is called at the end, sys.stdout has been overwritten to be the file specified in the -o arg, and won't be a tty any more.

elceef commented 3 years ago

Commit 89fee065aeaf18c2b360d6f0ac4682c91b2263bf. Thank you for your contribution!