From ef31a6f0f4e7f67d15482ae3de28798b24573d72 Mon Sep 17 00:00:00 2001 From: Kirill Zhdanov Date: Thu, 29 Feb 2024 22:27:30 +0700 Subject: [PATCH] feat: use wordlist to mixed up with subdomains #1 --- src/pnk/__main__.py | 6 ++++++ src/pnk/core.py | 48 ++++++++++++++++++++++++++++++-------------- src/pnk/wordlist.txt | 42 +++++++++++++++++++++++++++++++++++--- 3 files changed, 78 insertions(+), 18 deletions(-) diff --git a/src/pnk/__main__.py b/src/pnk/__main__.py index 474b1a0..c1677a8 100755 --- a/src/pnk/__main__.py +++ b/src/pnk/__main__.py @@ -44,6 +44,12 @@ def setup_argparse(): default="", help="target domain to find subs for (which will not be processed)", ) + parser.add_argument( + "-w", + "--wordlist", + type=argparse.FileType('r', encoding='UTF-8'), + help="mixed subdomains with wordlist", + ) # positional argument parser.add_argument( "file", diff --git a/src/pnk/core.py b/src/pnk/core.py index 69ac635..bc1fe10 100755 --- a/src/pnk/core.py +++ b/src/pnk/core.py @@ -160,17 +160,18 @@ def crtsn(self, subdomains): else: return () - def join_product_tuples(self, tuples): + def join_product_tuples(self, tuples, delimeter=None): """Convert a list of tuples into a string input: (('1', '_', 'n', '-', '0', '_', 'test1'), ('s2', '-', 'v')) output: 1_n-0_test.s2-v """ + dlmtr = delimeter if delimeter else "." _len = len(tuples) log.debug(_len) log.debug(tuples) if _len == 1: return "".join(*tuples) - return "".join(tuples[0]) + "." + self.join_product_tuples(tuples[1:]) + return "".join(tuples[0]) + dlmtr + self.join_product_tuples(tuples[1:]) def add_template(self, items): log.debug(items) @@ -182,6 +183,19 @@ def add_template(self, items): _list.extend(self.add_template(items[1:])) return _list + def produce_wordlist(self, subdomains): + """TODO: see https://github.com/storenth/pnk/issues/1 + Read the wordlist and return lines generator + """ + wordlist = ( + self.args.wordlist + if self.args.wordlist + else pathlib.Path(__file__).parent / "wordlist.txt" + ) + for word in wordlist: + log.debug(f"{word.strip()=}") + yield self.pnk([word.strip(), *subdomains]) + def run(self): """Compose functions on files with hostname lines""" for lines in self.file: @@ -223,21 +237,25 @@ def run(self): ".".join(filter(None, [self.join_product_tuples(x), d])) ) + if self.args.wordlist: + for word_subs_permutations in self.produce_wordlist(s): + for p in word_subs_permutations: + log.debug(p) + print( + ".".join( + filter(None, [self.join_product_tuples(p), d]) + ) + ) + print( + ".".join( + filter( + None, [self.join_product_tuples(p, "-"), d] + ) + ) + ) + # region operations by default for p in self.pnk(s): log.debug(p) print(".".join(filter(None, [".".join(p), d]))) # endregion - - def produce_wordlist(self): - """TODO: see https://github.com/storenth/pnk/issues/1 - Read the wordlist and return lines generator - """ - wordlist = ( - self.args.wordlist - if self.args.wordlist - else pathlib.Path(__file__).parent / "wordlist.txt" - ) - with open(wordlist, "r", encoding="UTF-8") as file: - for line in file: - yield line.strip() diff --git a/src/pnk/wordlist.txt b/src/pnk/wordlist.txt index f52486b..5f99385 100644 --- a/src/pnk/wordlist.txt +++ b/src/pnk/wordlist.txt @@ -1,7 +1,43 @@ +acc +acceptance +account +admin +administer +administrator alpha +api +area +backend beta -test -stage +betaprod +bill +box +cd +ci +client +demo +dev +devqa +devteam +hub +login +node preprod +private prod -area +prvt +qa +st +stage +staging +support +system +team +test +testadmin +testlogin +testnode +testprod +testuser +try +web