Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WsTrust server returned error in RSTR #11

Open
quentinhardy opened this issue Aug 5, 2022 · 1 comment
Open

WsTrust server returned error in RSTR #11

quentinhardy opened this issue Aug 5, 2022 · 1 comment

Comments

@quentinhardy
Copy link

Hello,

I have used:

python3.10 spray365.py generate normal -ep ex-plan.s365 -d dom.de -u users.txt -pf pwds.txt

It is a fresh install.

python3.10 spray365.py spray -ep ex-plan.s365                                                    

███████╗██████╗ ██████╗  █████╗ ██╗   ██╗██████╗  ██████╗ ███████╗
██╔════╝██╔══██╗██╔══██╗██╔══██╗╚██╗ ██╔╝╚════██╗██╔════╝ ██╔════╝                                                                                                                                                                           
███████╗██████╔╝██████╔╝███████║ ╚████╔╝  █████╔╝███████╗ ███████╗                                                                                                                                                                           
╚════██║██╔═══╝ ██╔══██╗██╔══██║  ╚██╔╝   ╚═══██╗██╔═══██╗╚════██║                                                                                                                                                                           
███████║██║     ██║  ██║██║  ██║   ██║   ██████╔╝ ██████╔╝███████║                                                                                                                                                                           
╚══════╝╚═╝     ╚═╝  ╚═╝╚═╝  ╚═╝   ╚═╝   ╚═════╝  ╚═════╝ ╚══════╝                                                                                                                                                                           
                         By MarkoH17 (https://github.com/MarkoH17)                                                                                                                                                                           
                                               Version: 0.2.2-beta                                                                                                                                                                           
                                                                                                                                                                                                                                             
[2022-08-05 06:37:15 - INFO]: Processing execution plan 'ex-plan.s365'
[2022-08-05 06:37:15 - INFO]: Identified 18650 credentials in the provided execution plan
[2022-08-05 06:37:15 - INFO]: Password spraying will take at least 559500 seconds, and should finish around 2022-08-11 18:02:15
[2022-08-05 06:37:15 - INFO]: Lockout threshold is set to 10 accounts
[2022-08-05 06:37:15 - INFO]: Starting to spray credentials
An exception was raised: RuntimeError650] (win_ie11_win8->webshellsuite->outlook): testaccount / thepassword (waiting...)
Stack trace from most recent exception:
Traceback (most recent call last):
  File "/home/myaccount/tools/Spray365/modules/spray/spray_exception_wrapper.py", line 13, in invoke
    return super(SprayExceptionWrapper, self).invoke(ctx)
  File "/home/myaccount/.local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/myaccount/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/myaccount/tools/Spray365/modules/spray/spray.py", line 159, in command
    auth_result = helpers.authenticate_credential(cred, proxy, insecure)
  File "/home/myaccount/tools/Spray365/modules/spray/helpers.py", line 52, in authenticate_credential
    raw_result = auth_app.acquire_token_by_username_password(
  File "/home/myaccount/.local/lib/python3.10/site-packages/msal/application.py", line 1420, in acquire_token_by_username_password
    response = _clean_up(self._acquire_token_by_username_password_federated(
  File "/home/myaccount/.local/lib/python3.10/site-packages/msal/application.py", line 1447, in _acquire_token_by_username_password_federated
    wstrust_result = wst_send_request(
  File "/home/myaccount/.local/lib/python3.10/site-packages/msal/wstrust_request.py", line 60, in send_request
    return parse_response(resp.text)
  File "/home/myaccount/.local/lib/python3.10/site-packages/msal/wstrust_response.py", line 49, in parse_response
    raise RuntimeError("WsTrust server returned error in RSTR: %s" % (error or body))
RuntimeError: WsTrust server returned error in RSTR: {'reason': 'ID3242: The security token could not be authenticated or authorized.', 'code': 'a:FailedAuthentication'}
[2022-08-05 06:37:16 - INFO]: Authentication results saved to file 'spray365_results_2022-08-05_06-37-16.json'

It seems the msal library has been modified. I think authentication now requires a UPN, an not a username only.

Best regard,

@puzzlepeaches
Copy link

Seeing similar behavior on my end, but only in specific situations. I believe this is not related to UPN specification, but instead redirects caused by federated identity providers such as Okta, ADFS, OneLogin, etc. I have also seen this happen when a GSuite account accidentally makes its way into my spraying list. When attempting to log in with your "testaccount" above via a browser, are you redirected to an alternate login portal?

Let me know if not, and I can try to make some code modifications to specify a UPN to share here.

Regardless, we need to work on error handling in spray_exception_wrapper.py. It needs some work to better pass on/handle more fringe errors produced by msal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants