Skip to content

Commit fcedb8d

Browse files
committed
Refactored how program was finding configs
1 parent 2c783f8 commit fcedb8d

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

searchsploit.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,20 @@ def scrapeRC():
3434
"""
3535
divider = []
3636

37-
try:
38-
settingsFile = open("/etc/.searchsploit_rc", "r")
39-
except:
40-
try:
41-
settingsFile = open(os.path.expanduser("~/.searchsploit_rc"), "r")
42-
except:
43-
settingsFile = open(os.path.abspath(
44-
os.sys.path[0] + "/.searchsploit_rc"), "r")
45-
# Checks for config in home directory
46-
47-
settings = settingsFile.read().split("\n")
48-
settingsFile.close()
49-
37+
paths = [
38+
"/etc/.searchsploit_rc",
39+
os.path.expanduser("~/.searchsploit_rc"),
40+
os.path.expanduser("~/.local/.searchsploit_rc"),
41+
os.path.abspath(os.path.join(os.sys.path[0], "/.searchsploit_rc"))
42+
]
43+
44+
for p in paths:
45+
if os.path.exists(p):
46+
with open(p, "r") as settingsFile:
47+
settings = settingsFile.read().split("\n")
48+
settingsFile.close()
49+
break
50+
5051
for i in settings:
5152
if(i == "" or i[0] == "#"):
5253
continue # Ignores lines that are empty or are just comments

0 commit comments

Comments
 (0)