13
13
import lib .output
14
14
import lib .banner
15
15
16
+ CUR_DIR = "{}" .format (os .getcwd ())
16
17
17
18
# path to the file containing all the discovered hosts
18
- HOST_FILE = "{}/hosts.txt" .format (os . getcwd () )
19
+ HOST_FILE = "{}/hosts.txt" .format (CUR_DIR )
19
20
20
21
# path to the folder containing all the JSON exploit modules
21
- EXPLOIT_FILES_PATH = "{}/etc/json" .format (os . getcwd () )
22
+ EXPLOIT_FILES_PATH = "{}/etc/json" .format (CUR_DIR )
22
23
23
24
# path to the usage and legal file
24
- USAGE_AND_LEGAL_PATH = "{}/etc/text_files/general" .format (os . getcwd () )
25
+ USAGE_AND_LEGAL_PATH = "{}/etc/text_files/general" .format (CUR_DIR )
25
26
26
27
# path to the bash script to stack the PostgreSQL service
27
- START_POSTGRESQL_PATH = "{}/etc/scripts/start_postgre.sh" .format (os . getcwd () )
28
+ START_POSTGRESQL_PATH = "{}/etc/scripts/start_postgre.sh" .format (CUR_DIR )
28
29
29
30
# path to the bash script to start the Apache service
30
- START_APACHE_PATH = "{}/etc/scripts/start_apache.sh" .format (os . getcwd () )
31
+ START_APACHE_PATH = "{}/etc/scripts/start_apache.sh" .format (CUR_DIR )
31
32
32
33
# path to the file that will contain our query
33
34
QUERY_FILE_PATH = tempfile .NamedTemporaryFile (delete = False ).name
45
46
46
47
# all the paths to the API tokens
47
48
API_KEYS = {
48
- "censys" : ("{}/etc/tokens/censys.key" .format (os . getcwd ()) , "{}/etc/tokens/censys.id" .format (os . getcwd () )),
49
- "shodan" : ("{}/etc/tokens/shodan.key" .format (os . getcwd () ), )
49
+ "censys" : ("{}/etc/tokens/censys.key" .format (CUR_DIR ) , "{}/etc/tokens/censys.id" .format (CUR_DIR )),
50
+ "shodan" : ("{}/etc/tokens/shodan.key" .format (CUR_DIR ), )
50
51
}
51
52
52
53
# all the URLs that we will use while doing the searching
@@ -80,8 +81,7 @@ def validate_ip_addr(provided):
80
81
return True
81
82
except :
82
83
return False
83
- else :
84
- return False
84
+ return False
85
85
86
86
87
87
def check_services (service_name ):
@@ -109,11 +109,8 @@ def write_to_file(data_to_write, filename, mode="a+"):
109
109
is_append = lib .output .prompt ("would you like to (a)ppend or (o)verwrite the file" )
110
110
if is_append == "o" :
111
111
mode = "w"
112
- elif is_append == "a" :
113
- mode = "a+"
114
- else :
112
+ elif is_append != "a" :
115
113
lib .output .warning ("invalid input provided ('{}'), appending to file" .format (is_append ))
116
- mode = "a+"
117
114
with open (filename , mode ) as log :
118
115
if isinstance (data_to_write , (tuple , set , list )):
119
116
for item in list (data_to_write ):
@@ -124,20 +121,18 @@ def write_to_file(data_to_write, filename, mode="a+"):
124
121
return filename
125
122
126
123
127
- def load_api_keys (path = "{}/etc/tokens" .format (os . getcwd () )):
124
+ def load_api_keys (path = "{}/etc/tokens" .format (CUR_DIR )):
128
125
129
126
"""
130
127
load the API keys from their .key files
131
128
"""
132
129
133
- def makedir (dir ):
134
- """
135
- make the directory if it does not exist
136
- """
137
- if not os .path .exists (dir ):
138
- os .mkdir (dir )
130
+ """
131
+ make the directory if it does not exist
132
+ """
133
+ if not os .path .exists (path ):
134
+ os .mkdir (path )
139
135
140
- makedir (path )
141
136
for key in API_KEYS .keys ():
142
137
if not os .path .isfile (API_KEYS [key ][0 ]):
143
138
access_token = lib .output .prompt ("enter your {} API token" .format (key .title ()), lowercase = False )
@@ -179,10 +174,7 @@ def check_for_msf():
179
174
"""
180
175
check the ENV PATH for msfconsole
181
176
"""
182
- in_env = os .getenv ("msfconsole" , False )
183
- if not in_env :
184
- return False
185
-
177
+ return os .getenv ("msfconsole" , False )
186
178
187
179
def logo ():
188
180
"""
@@ -200,8 +192,10 @@ def animation(text):
200
192
global stop_animation
201
193
i = 0
202
194
while not stop_animation :
195
+ """
203
196
if stop_animation is True:
204
197
print("\n ")
198
+ """
205
199
temp_text = list (text )
206
200
if i >= len (temp_text ):
207
201
i = 0
@@ -236,13 +230,12 @@ def close(warning, status=1):
236
230
lib .output .error (warning )
237
231
sys .exit (status )
238
232
239
-
240
233
def grab_random_agent ():
241
234
"""
242
235
get a random HTTP User-Agent
243
236
"""
244
237
user_agent_path = "{}/etc/text_files/agents.txt"
245
- with open (user_agent_path .format (os . getcwd () )) as agents :
238
+ with open (user_agent_path .format (CUR_DIR )) as agents :
246
239
return random .choice (agents .readlines ()).strip ()
247
240
248
241
0 commit comments