epinna/weevely3

python trace if executed without arguements

Closed this issue · 1 comments

If weevely is executed without arguments, it will print following python trace:

Traceback (most recent call last):
  File "/tmp/weevely3-4.0.2/./weevely.py", line 104, in <module>
    arguments = parser.parse_args()
  File "/usr/lib/python3.10/argparse.py", line 1845, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python3.10/argparse.py", line 1878, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python3.10/argparse.py", line 2094, in _parse_known_args
    stop_index = consume_positionals(start_index)
  File "/usr/lib/python3.10/argparse.py", line 2050, in consume_positionals
    take_action(action, args)
  File "/usr/lib/python3.10/argparse.py", line 1955, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib/python3.10/argparse.py", line 1233, in __call__
    subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)
  File "/usr/lib/python3.10/argparse.py", line 1878, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python3.10/argparse.py", line 2119, in _parse_known_args
    self.error(_('the following arguments are required: %s') %
  File "/tmp/weevely3-4.0.2/core/argparsers.py", line 56, in error
    raise ArgparseError(message)
core.weexceptions.ArgparseError: the following arguments are required: url, password

If required arguments are provided, then weevely works.
Tested with python 3.10.12 and 3.11.8

Possible fix (from line 104):

parser.set_default_subparser('terminal')

try:
    arguments = parser.parse_args()
except:
    sys.exit(1)

try:
    main(arguments)
except (KeyboardInterrupt, EOFError):
    log.info('Exiting.')
except FatalException as e:
    log.critical('Exiting: %s' % e)

Fixed by e5f892d.