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

fix 'checked_flags' variable in Parser module #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

0xyy66
Copy link

@0xyy66 0xyy66 commented Oct 28, 2023

Brief description

When running an Adversary Ability with a custom PowerShell command, the command runs successfully, but the Ability status is incorrectly set to "failed." This issue is caused by a logic problem in the atomic_powershell.py module.

Details:

  • The module checks for the presence of the header FullyQualifiedErrorId in the response, but the logic is flawed.
  • The module's logic involves splitting the FullyQualifiedErrorId string into individual letters and checking each letter against the headers.

Description in depth

Ability output.

002
003

The following is the Caldera output.

001

This problem is caused by the module atomic_powershell.py which, from what I understand, should check if the header FullyQualifiedErrorId is present.

It is declared a list called checked_flags that splits the 'FullyQualifiedErrorId' string letter by letter.

checked_flags = list('FullyQualifiedErrorId')

The function parse, in the same module, is meant to check the response headers.
The code checks every header (blob variable) against every single letter contained in the checked_flags list. If the letter is present in the header string, it throws the error showed upon. The following is the code snippet that causes the error.

def parse(self, blob):
        # for every header (blob string is splitted by newline)
        for ex_line in self.line(blob):
            if any(x in ex_line for x in self.checked_flags):
                # ...
                log.warning('This ability failed for some reason. Manually updating the link to report a failed state.')

Proposed Fix

The issue with the checked_flags variable is addressed by changing the line:

checked_flags = list('FullyQualifiedErrorId')

to:

checked_flags = ['FullyQualifiedErrorId']

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

Successfully merging this pull request may close these issues.

None yet

1 participant