Skip to content

Commit

Permalink
feat: use wordlist to mixed up with subdomains #1
Browse files Browse the repository at this point in the history
  • Loading branch information
storenth committed Feb 29, 2024
1 parent 8402c47 commit ef31a6f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 18 deletions.
6 changes: 6 additions & 0 deletions src/pnk/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
48 changes: 33 additions & 15 deletions src/pnk/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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()
42 changes: 39 additions & 3 deletions src/pnk/wordlist.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ef31a6f

Please sign in to comment.