Skip to content

Commit 67ad370

Browse files
committed
Using default wordlist
1 parent 8910ee3 commit 67ad370

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/helpers/wordlist_helper.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
import sys
2+
import os
3+
from lib.helpers.file_helper import get_combined_word_lists
4+
5+
DEFAULT_WORDLIST_FILE = os.path.join(
6+
os.path.dirname(os.path.abspath(__file__)),
7+
'../..',
8+
'wordlists',
9+
'virtual-host-scanning.txt'
10+
)
211

312

413
class WordList:
514
def get_stdin_wordlist(self):
615
return list(line for line in sys.stdin.read().splitlines()) if not sys.stdin.isatty() else []
16+
17+
def get_wordlist(self, wordlist_files=None):
18+
wordlist = []
19+
stdin_words = self.get_stdin_wordlist()
20+
if stdin_words:
21+
wordlist.extend(stdin_words)
22+
combined = get_combined_word_lists(wordlist_files or DEFAULT_WORDLIST_FILE)
23+
wordlist.extend(combined['words'])
24+
return wordlist

tests/helpers/test_wordlist_helper.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,24 @@
33
from mock import patch
44

55
from lib.helpers.wordlist_helper import WordList
6+
from lib.helpers.wordlist_helper import DEFAULT_WORDLIST_FILE
67

78

89
class TestWordList(unittest.TestCase):
910
def setUp(self):
1011
self.wordlist = WordList()
12+
with open(DEFAULT_WORDLIST_FILE, 'r') as word_file:
13+
self.default_wordlist = list(word_file.read().splitlines())
1114

1215
def test_get_wordlist_from_stdin(self):
1316
stdin_list = ['keyword1', 'keyword1']
17+
expected_wordlist = []
18+
expected_wordlist.extend(stdin_list)
19+
expected_wordlist.extend(self.default_wordlist)
1420
with patch('sys.stdin') as mock_stdin:
1521
mock_stdin.read = Mock(return_value='\n'.join(stdin_list))
1622
mock_stdin.isatty = Mock(return_value=False)
17-
self.assertEqual(self.wordlist.get_stdin_wordlist(), stdin_list)
23+
self.assertEqual(self.wordlist.get_wordlist(), expected_wordlist)
24+
25+
def test_using_default_wordlist(self):
26+
self.assertEqual(self.wordlist.get_wordlist(), self.default_wordlist)

0 commit comments

Comments
 (0)