Skip to content

Commit ed4a3aa

Browse files
committed
Reworked wordlist building for prefix and suffix code, added IP address validation
1 parent 2de7519 commit ed4a3aa

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

lib/helpers/wordlist_helper.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,45 @@ def get_wordlist(self, wordlist_files=None, wordlist_prefix=False, wordlist_suff
3737

3838
# Apply prefixes
3939
if wordlist_prefix:
40-
prefixed = [wordlist_prefix + word for word in self.wordlist]
41-
self.wordlist = self.wordlist + prefixed
40+
prefixed = []
41+
for word in self.wordlist:
42+
if(word == '%s'):
43+
continue
44+
elif(self.valid_ip(word)):
45+
continue
46+
else:
47+
prefixed.append(wordlist_prefix + word)
4248

43-
#if wordlist_suffix:
44-
49+
if len(prefixed) > 0:
50+
self.wordlist = self.wordlist + prefixed
4551

52+
if wordlist_suffix:
53+
suffixed = []
54+
for word in self.wordlist:
55+
if(word == '%s'):
56+
continue
57+
elif(self.valid_ip(word)):
58+
continue
59+
elif(".%s" in word):
60+
split = word.split(".")
61+
suffixed.append(split[0] + wordlist_suffix + ".%s")
62+
else:
63+
suffixed.append(word + wordlist_suffix)
64+
65+
if len(suffixed) > 0:
66+
self.wordlist = self.wordlist + suffixed
67+
4668
return self.wordlist, self.wordlist_types
4769

4870
def set_words(self, words_type, words):
4971
self.wordlist_types.append(words_type)
5072
self.wordlist.extend(words)
73+
74+
def valid_ip(self, address):
75+
try:
76+
host_bytes = address.split('.')
77+
valid = [int(b) for b in host_bytes]
78+
valid = [b for b in valid if b >= 0 and b<=255]
79+
return len(host_bytes) == 4 and len(valid) == 4
80+
except:
81+
return False

0 commit comments

Comments
 (0)