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

Working Persistence Module #496

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

Conversation

kapla0011
Copy link

For now the rrp library has been removed from the module. This is the usage of each of the techniques:

add_user: This methods adds a new user to the admin group

image

We can also specify some input credentials:

image
Checking if the credentials are valid:

image

file_upload:

This is just an upload function for file transfer purposes

image

malicious_binary

This technique involves copying a binary from a specified path to the user's startup folder.

image

proof:

image

registry_run:

This technique involves modifying the registry's Run key. Any executable path listed in the Run key will be executed when a user logs into the machine.

image

proof:

image

logon_scripts:

This techinique works by adding to the Logon Registry value the path of a .bat file with some custom commands inside.

image

proof:

image

scheduled_task:

creates a scheduled task that starts at every logon:

image

query the task:

image

win_logon_userinit:

the module adds to the UserInit value of winlogon the path of the malware:

image

query the registry:

image

@NeffIsBack
Copy link
Contributor

Thanks for the PR! Having screenshots while reviewing definitely helps a lot :)

Comment on lines +28 to +31
self.BINARY = "Do_not_execute"
self.user = "kapla2"
self.password = "Join_The_0xH3xSec_Community!"
self.file = "Do_not_execute"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Set these to empty strings

Created by Lorenzo Meacci @kapla founder of the 0xH3xSec community!
"""

name = 'persistence'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use double quotes


name = 'persistence'
description = "Implements techniques for persistence used by malicious actors"
supported_protocols = ['smb']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use double quotes

Comment on lines +33 to +42
if 'USER' in module_options:
self.user = module_options['USER']
if 'PASS' in module_options:
self.password = module_options['PASS']
if 'BINARY' in module_options:
self.BINARY = module_options['BINARY']
if 'FILE' in module_options:
self.file = module_options['FILE']
if 'FILE_NAME' in module_options:
self.file_name = module_options['FILE_NAME']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use double quotes

Comment on lines +85 to +86
if self.user == "kapla2" and self.password == "Join_The_0xH3xSec_Community!":
context.log.highlight("No credentials were submitted!!! Using default user and default password!!!")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would remove these, set the defaults to blank, and then if after initialization they are still blank, throw an error right away.


def logon_script(self , context , connection):
"""
Setup's one of the registry value to the specified .bat file
Copy link
Collaborator

Choose a reason for hiding this comment

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

Incorrect grammar. Should rephrase to "Sets the user logon script regkey to specified bat file"

Comment on lines +123 to +124
command = f'schtasks /create /sc onlogon /tn UpDater2.0 /tr "{self.BINARY}"'
context.log.highlight(f'Creating the logon task with the path : {self.BINARY}')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use double quotes

"""
Created a task that triggers at logon
"""
command = f'schtasks /create /sc onlogon /tn UpDater2.0 /tr "{self.BINARY}"'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add the ability to pass in the scheduled task name? Otherwise it should probably default to the binary name.

Comment on lines +129 to +130
command = fr'reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /V "UserInit" /T REG_SZ /D "C:\Windows\system32\userinit.exe,{self.BINARY}" /F'
context.log.highlight(fr'Modifying the WinLogon UserInit value to : C:\Windows\system32\userinit.exe , {self.BINARY}')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use double quotes

Comment on lines +139 to +140
if self.file == "Do_not_execute" and self.file_name == "":
context.log.error("You need to specify the file path FILE= and how you want to save the file on the system FILE_NAME")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just default to blank script name and then check on initialization if its still blank.

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

Successfully merging this pull request may close these issues.

3 participants