Skip to content

Commit

Permalink
fix: #3; move deque to list; remove unused emunerate
Browse files Browse the repository at this point in the history
  • Loading branch information
storenth committed Jan 28, 2024
1 parent b545ec1 commit d67fb5c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/pnk/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def parse_hostname(self, hostname):
log.debug(f"{host=}")
if host:
_domain = re.search(
r"[\w-]+[.](com|co.uk|ru|org|co|in|ai|sh|io|jp|com.cn|cn|cz|de|net|fr|it|au|ca|ir|br|com.br|co.kr|gov|uk|kz|tech|shop|moscow|store|me)$",
r"[\w-]+[.](рф|com|co.uk|ru|org|co|in|ai|sh|io|jp|com.cn|cn|cz|de|net|fr|it|au|ca|ir|br|com.br|co.kr|gov|uk|kz|tech|shop|moscow|store|me)$",
host,
)
log.debug(f"{_domain=}")
Expand Down Expand Up @@ -110,10 +110,10 @@ def run(self):
print(".".join(_s) + "." + d)
_s[index] = j
if self.args.cartesian:
_deque = deque()
_deque = []
subs_list = []
pattern = re.compile('((?<!\d)\d{1,2}(?!\d))')
for index, _s in enumerate(s):
for _s in s:
log.debug(_s)
_list = pattern.split(_s)
if len(_list) == 1:
Expand All @@ -122,8 +122,12 @@ def run(self):
else:
for x in _list:
try:
if type(int(x)) == int:
_deque.append([str(i).zfill(len(x)) for i in range(10 if len(x) < 2 else 100)])
if int(x) or x in ("0", "00"):
x_lenght = len(x)
if x_lenght <= 2:
_deque.append([str(i).zfill(x_lenght) for i in range(10 if x_lenght == 1 else 100)])
else:
_deque.append([x])
except ValueError:
# filter out empty str
if x != "":
Expand All @@ -136,15 +140,14 @@ def run(self):

for p in itertools.product(*subs_list):
log.debug(p)
log.debug(self.join_product_tuples(p))
print(self.join_product_tuples(p) + "." + d)

for p in self.pnk(s):
print(".".join(p) + "." + d)

def produce_wordlist(self):
"""TODO: see https://github.com/storenth/pnk/issues/1
Read the wordlist and returns lines generator
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:
Expand Down

0 comments on commit d67fb5c

Please sign in to comment.