Skip to content

Commit

Permalink
Updated README.md and fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
gnebbia committed Jul 25, 2019
1 parent bebcfec commit 72fa505
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ We can save the output in a text file by doing:
pdlist example.com -o example-list.txt
```

Notice that by default pdlist will also output hostnames which may not really
be proper subdomains of the specified domains, and this happens because those
subdomains are still related to the specified domains.

If we want to only output proper subdomains we can enable the strict mode by
doing:
```shs
pdlist example.com --strict
```

A usage example in the gif below:
![](img/pdlist_demo.gif)



## NOTES

Expand Down
Binary file added img/pdlist_demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 13 additions & 7 deletions pdlist/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import pdlist.source.dnsdumpster as dd
import pdlist.source.certspotter as cs
import pdlist.source.hackertarget as ht
from pdlist.utils import polish_subdomain_strings, remove_unrelated_domains


__all__ = ('main',)
Expand All @@ -37,13 +38,6 @@ def show_banner():
Developed by gnc
""")


def polish_subdomain_strings(subdomains):
subdomains = [item.strip() for item in subdomains]
subdomains = [item.rstrip('\.') for item in subdomains]
subdomains = [re.sub("^.* ", "", item) for item in subdomains]
subdomains = [re.sub("^[\.\*]\.", "", item) for item in subdomains]
return subdomains


def main():
Expand All @@ -59,6 +53,14 @@ def main():
type=str,
nargs='+',
)
parser.add_argument(
"-s","--strict",
dest='is_strict',
action='store_true',
help="Enables strict mode, where only proper (and not also related)\
subdomains will be saved",
default=False,
)
parser.add_argument(
"-o","--output",
dest='outputfile',
Expand Down Expand Up @@ -98,6 +100,10 @@ def main():


subdomains = polish_subdomain_strings(subdomains)

if args.is_strict:
subdomains = remove_unrelated_domains(subdomains, domains)

subdomains = list(set(subdomains))
print()
print()
Expand Down
31 changes: 22 additions & 9 deletions pdlist/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,30 @@
:Copyright: © 2019, Giuseppe Nebbione.
:License: BSD (see /LICENSE).
"""
import re


def remove_unrelated_domains(subdomains, domains):
subdomains = [s for s in subdomains if s.endswith(tuple(domains))]
return subdomains


def polish_subdomain_strings(subdomains):
subdomains = [item.strip() for item in subdomains]
subdomains = [item.rstrip('\.') for item in subdomains]
subdomains = [re.sub("^.* ", "", item) for item in subdomains]
subdomains = [re.sub("^[\.\*]\.", "", item) for item in subdomains]
return subdomains

def find(key, dictionary):
for k, v in dictionary.items():
if k == key:
yield v
elif isinstance(v, dict):
for result in find(key, v):
yield result
elif isinstance(v, list):
for d in v:
for result in find(key, d):
if isinstance(dictionary, dict):
for k, v in dictionary.items():
if k == key:
yield v
elif isinstance(v, dict):
for result in find(key, v):
yield result
elif isinstance(v, list):
for d in v:
for result in find(key, d):
yield result

0 comments on commit 72fa505

Please sign in to comment.