File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 1
1
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
+ )
2
11
3
12
4
13
class WordList :
5
14
def get_stdin_wordlist (self ):
6
15
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
Original file line number Diff line number Diff line change 3
3
from mock import patch
4
4
5
5
from lib .helpers .wordlist_helper import WordList
6
+ from lib .helpers .wordlist_helper import DEFAULT_WORDLIST_FILE
6
7
7
8
8
9
class TestWordList (unittest .TestCase ):
9
10
def setUp (self ):
10
11
self .wordlist = WordList ()
12
+ with open (DEFAULT_WORDLIST_FILE , 'r' ) as word_file :
13
+ self .default_wordlist = list (word_file .read ().splitlines ())
11
14
12
15
def test_get_wordlist_from_stdin (self ):
13
16
stdin_list = ['keyword1' , 'keyword1' ]
17
+ expected_wordlist = []
18
+ expected_wordlist .extend (stdin_list )
19
+ expected_wordlist .extend (self .default_wordlist )
14
20
with patch ('sys.stdin' ) as mock_stdin :
15
21
mock_stdin .read = Mock (return_value = '\n ' .join (stdin_list ))
16
22
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 )
You can’t perform that action at this time.
0 commit comments