Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit a1c41d9

Browse files
author
byt3bl33d3r
committed
Fixed incorrect error handling when database wasn't created
(part of issue #93)
1 parent cd98987 commit a1c41d9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

crackmapexec.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,18 @@
138138
logger.error("I'm sorry {}, I'm afraid I can't let you do that".format(getpass.getuser()))
139139
sys.exit(1)
140140

141+
if not os.path.exists('data/cme.db'):
142+
logger.error('Could not find CME database, did you run the setup_database.py script?')
143+
sys.exit(1)
144+
141145
if not args.server_port:
142146
args.server_port = server_port_dict[args.server]
143147

144-
try:
145-
# set the database connection to autocommit w/ isolation level
146-
db_connection = sqlite3.connect('data/cme.db', check_same_thread=False)
147-
db_connection.text_factory = str
148-
db_connection.isolation_level = None
149-
db = CMEDatabase(db_connection)
150-
except Exception as e:
151-
logger.error("Could not connect to CME database: {}".format(e))
152-
sys.exit(1)
148+
# set the database connection to autocommit w/ isolation level
149+
db_connection = sqlite3.connect('data/cme.db', check_same_thread=False)
150+
db_connection.text_factory = str
151+
db_connection.isolation_level = None
152+
db = CMEDatabase(db_connection)
153153

154154
if args.cred_id:
155155
try:

0 commit comments

Comments
 (0)