Skip to content

Commit d67fb5c

Browse files
committed
fix: #3; move deque to list; remove unused emunerate
#3
1 parent b545ec1 commit d67fb5c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/pnk/core.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def parse_hostname(self, hostname):
2626
log.debug(f"{host=}")
2727
if host:
2828
_domain = re.search(
29-
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)$",
29+
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)$",
3030
host,
3131
)
3232
log.debug(f"{_domain=}")
@@ -110,10 +110,10 @@ def run(self):
110110
print(".".join(_s) + "." + d)
111111
_s[index] = j
112112
if self.args.cartesian:
113-
_deque = deque()
113+
_deque = []
114114
subs_list = []
115115
pattern = re.compile('((?<!\d)\d{1,2}(?!\d))')
116-
for index, _s in enumerate(s):
116+
for _s in s:
117117
log.debug(_s)
118118
_list = pattern.split(_s)
119119
if len(_list) == 1:
@@ -122,8 +122,12 @@ def run(self):
122122
else:
123123
for x in _list:
124124
try:
125-
if type(int(x)) == int:
126-
_deque.append([str(i).zfill(len(x)) for i in range(10 if len(x) < 2 else 100)])
125+
if int(x) or x in ("0", "00"):
126+
x_lenght = len(x)
127+
if x_lenght <= 2:
128+
_deque.append([str(i).zfill(x_lenght) for i in range(10 if x_lenght == 1 else 100)])
129+
else:
130+
_deque.append([x])
127131
except ValueError:
128132
# filter out empty str
129133
if x != "":
@@ -136,15 +140,14 @@ def run(self):
136140

137141
for p in itertools.product(*subs_list):
138142
log.debug(p)
139-
log.debug(self.join_product_tuples(p))
140143
print(self.join_product_tuples(p) + "." + d)
141144

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

145148
def produce_wordlist(self):
146149
"""TODO: see https://github.com/storenth/pnk/issues/1
147-
Read the wordlist and returns lines generator
150+
Read the wordlist and return lines generator
148151
"""
149152
wordlist = self.args.wordlist if self.args.wordlist else pathlib.Path(__file__).parent / 'wordlist.txt'
150153
with open(wordlist, 'r', encoding='UTF-8') as file:

0 commit comments

Comments
 (0)