2015-08-05 18:36:39 +00:00
|
|
|
from lib.common import helpers
|
|
|
|
|
|
|
|
class Module:
|
|
|
|
|
|
|
|
def __init__(self, mainMenu, params=[]):
|
|
|
|
|
|
|
|
self.info = {
|
|
|
|
'Name': 'User-to-SID',
|
|
|
|
|
|
|
|
'Author': ['@harmj0y'],
|
|
|
|
|
|
|
|
'Description': ("Converts a specified domain\\user to a domain sid."),
|
|
|
|
|
|
|
|
'Background' : False,
|
|
|
|
|
|
|
|
'OutputExtension' : None,
|
|
|
|
|
|
|
|
'NeedsAdmin' : False,
|
|
|
|
|
|
|
|
'OpsecSafe' : True,
|
|
|
|
|
2016-09-23 18:04:35 +00:00
|
|
|
'Language' : 'powershell',
|
|
|
|
|
|
|
|
'MinLanguageVersion' : '2',
|
2015-08-05 18:36:39 +00:00
|
|
|
|
|
|
|
'Comments': []
|
|
|
|
}
|
|
|
|
|
|
|
|
# any options needed by the module, settable during runtime
|
|
|
|
self.options = {
|
|
|
|
# format:
|
|
|
|
# value_name : {description, required, default_value}
|
|
|
|
'Agent' : {
|
|
|
|
'Description' : 'Agent to run module on.',
|
|
|
|
'Required' : True,
|
|
|
|
'Value' : ''
|
|
|
|
},
|
|
|
|
'Domain' : {
|
|
|
|
'Description' : 'Domain name for translation.',
|
|
|
|
'Required' : True,
|
|
|
|
'Value' : ''
|
|
|
|
},
|
|
|
|
'User' : {
|
|
|
|
'Description' : 'Username for translation.',
|
|
|
|
'Required' : True,
|
|
|
|
'Value' : ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# save off a copy of the mainMenu object to access external functionality
|
|
|
|
# like listeners/agent handlers/etc.
|
|
|
|
self.mainMenu = mainMenu
|
|
|
|
|
|
|
|
for param in params:
|
|
|
|
# parameter format is [Name, Value]
|
|
|
|
option, value = param
|
|
|
|
if option in self.options:
|
|
|
|
self.options[option]['Value'] = value
|
|
|
|
|
|
|
|
|
2017-03-11 23:35:17 +00:00
|
|
|
def generate(self, obfuscate=False, obfuscationCommand=""):
|
2015-08-05 18:36:39 +00:00
|
|
|
|
|
|
|
script = "(New-Object System.Security.Principal.NTAccount(\"%s\",\"%s\")).Translate([System.Security.Principal.SecurityIdentifier]).Value" %(self.options['Domain']['Value'], self.options['User']['Value'])
|
|
|
|
|
2017-03-11 23:35:17 +00:00
|
|
|
if obfuscate:
|
2017-04-23 01:17:28 +00:00
|
|
|
script = helpers.obfuscate(psScript=script, obfuscationCommand=obfuscationCommand)
|
2015-08-05 18:36:39 +00:00
|
|
|
return script
|