Skip to content

Commit

Permalink
fix: use command in console mode use absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
13ph03nix committed Nov 22, 2022
1 parent 098e355 commit 4c551b9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pocsuite3/lib/core/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,24 +324,31 @@ def command_use(self, module_path, *args, **kwargs):

module_ext = ''
module_path_found = False
for module_ext in ['.py', '.yaml']:
for module_ext in ['', '.py', '.yaml']:
if os.path.exists(module_path + module_ext):
module_path_found = True
module_path = module_path + module_ext
break
elif os.path.exists(os.path.join(self.module_parent_directory, module_path + module_ext)):
module_path_found = True
module_path = os.path.join(self.module_parent_directory, module_path + module_ext)
break

if not module_path_found:
errMsg = "No such file: '{0}'".format(module_path)
logger.error(errMsg)
err_msg = "No such file: '{0}'".format(module_path)
logger.error(err_msg)
return

if module_ext == '':
if module_path.endswith('.py'):
module_ext = '.py'
elif module_path.endswith('.yaml'):
module_ext = '.yaml'
try:
load_file_to_module(module_path)
self.current_module = kb.current_poc
self.current_module.pocsuite3_module_path = ltrim(rtrim(module_path, module_ext), self.module_parent_directory)
self.current_module.pocsuite3_module_path = ltrim(rtrim(module_path, module_ext),
self.module_parent_directory)
except Exception as err:
logger.error(str(err))

Expand Down

0 comments on commit 4c551b9

Please sign in to comment.