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

init mars stealer module #1

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

init mars stealer module #1

wants to merge 1 commit into from

Conversation

lbpierre
Copy link
Collaborator

@lbpierre lbpierre commented Apr 6, 2022

Initial version of the Mars Stealer C2 configuration extractor.

@lbpierre lbpierre added the enhancement New feature or request label Apr 6, 2022
@lbpierre lbpierre self-assigned this Apr 6, 2022
@lbpierre lbpierre requested a review from qbourgue April 6, 2022 08:13
Copy link

@qbourgue qbourgue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code seems good to me from my non-developer eyes. The code is clear to distinguish every obfuscation methods.
Perhaps you could add a regex to check if the URL is correctly built?

Section = namedtuple("Section",
["name", "id", "paddr", "size",
"vaddr", "vsize", "perm"])
HAVE_CSPARSER = True

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constant name is odd (probably the result of a copy-paste ?)

Comment on lines +22 to +41
def unxor(string: List[Any], key: List[Any]) -> str:
"""Method to unxor obfuscated data from llcppc section"""

unxored = ""

for c1, c2 in zip(string, key):
unxored += chr(c1 ^ c2)

return unxored


def decrypt_rc4(key: bytes, ciphertext: bytes) -> bytes:
"""Decrypt RC4 encrypt data"""

algorithm = algorithms.ARC4(key)
cipher = Cipher(algorithm, mode=None)
decryptor = cipher.decryptor()
cleartext = decryptor.update(ciphertext)

return cleartext

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI you can probably find equivalent functions and more in malduck to speed up module development


class MarsStealerC2Extractor(ProcessingModule):

name: str = "mars_stealer_c2"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: str = "mars_stealer_c2"
name: str = "mars_stealer"

When there is a match, the name of the module is added as a tag so it is a convention to give the module the name of what it is able to recognize.

class MarsStealerC2Extractor(ProcessingModule):

name: str = "mars_stealer_c2"
description: str = "Mars Stealer command and control configuration extractor"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should probably be an acts_on property here to specify the type of file needed.

It may also need a triggered_by property if this should not be run automatically on all executables.

try:
c2 = self.get_c2(r2, sections)
except Exception as err:
print(f"Error getting c2: {err}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use self.log instead of print every time you would like to have the information directly in the logs on the analysis page

self.add_ioc(dest, ["marsstealer", "c2"])
self.add_ioc(c2_url, ["marsstealer", "c2"])

self.add_tag("marsstealer")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned earlier, this is done automatically if this is the module's name. You should probably replace it by self.add_probable_name("Mars Stealer")

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

Successfully merging this pull request may close these issues.

3 participants