enowars / enochecker

Checker library for ENOWARS
MIT License
7 stars 9 forks source link

Why is search_flag not available in other methods? #123

Open DanielHabenicht opened 3 years ago

DanielHabenicht commented 3 years ago

I would like to use self.search_flag(fileRequest.text) in the getflag method but it throws the error:

Unhandled checker error occurred: Traceback (most recent call last):
 File \"/home/dnhb/.local/lib/python3.8/site-packages/enochecker/enochecker.py\", line 321, in run
    ret = self._run_method(method)
  File \"/home/dnhb/.local/lib/python3.8/site-packages/enochecker/enochecker.py\", line 307, in _run_method
    return getattr(self, snake_caseify(method.value))()
  File \"/home/dnhb/code/enowars5-service-file-share/checker/src/checker.py\", line 153, in getflag
    self.search_flag(fileRequest.text)
  File \"/home/dnhb/.local/lib/python3.8/site-packages/enochecker/enochecker.py\", line 513, in search_flag
    for flag in self._flag_regex.findall(data):
AttributeError: 'FileShareChecker' object has no attribute '_flag_regex'

 excp: Traceback (most recent call last):
  File \"/home/dnhb/.local/lib/python3.8/site-packages/enochecker/enochecker.py\", line 321, in run
    ret = self._run_method(method)
  File \"/home/dnhb/.local/lib/python3.8/site-packages/enochecker/enochecker.py\", line 307, in _run_method
    return getattr(self, snake_caseify(method.value))()
  File \"/home/dnhb/code/enowars5-service-file-share/checker/src/checker.py\", line 153, in getflag
    self.search_flag(fileRequest.text)
  File \"/home/dnhb/.local/lib/python3.8/site-packages/enochecker/enochecker.py\", line 513, in search_flag
    for flag in self._flag_regex.findall(data):
AttributeError: 'FileShareChecker' object has no attribute '_flag_regex'
domenukk commented 3 years ago

Why do you need it? You have the actual flag in getflag, use this instead.

DanielHabenicht commented 3 years ago

Well, the content where I get the flag from isn't actually well-formed, so I thought using the search function would be less hassle.

domenukk commented 3 years ago

How about if self.flag in file_request.text?

DanielHabenicht commented 3 years ago

yep that what I use now... But the function could be working too :) Otherwise you could also use it in the exploit function, right?

ldruschk commented 3 years ago

yep that what I use now... But the function could be working too :)

I agree that it might be nice to have a consistent interface, and only use self.flag in ... if self.flag is available

Otherwise you could also use it in the exploit function, right?

This was needed in the first place because self.flag is not available in the exploit method and search_flag was supposed to be a replacement for self.flag in ... which can be used in other methods

DanielHabenicht commented 3 years ago

So maybe that comes back to the general question, of "would you rather have an extra exploiter checker"?