16 Win. Priv. esc. Leveraging Windows Services Flashcards

1
Q

What is a Windows service ? What is similar in linux world ?

A

A Windows Service is a long-running background executable or application managed by the Service Control Manager and is similar to the concept of daemons on Unix systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can be managed a windows service ? (3)

A

Windows services can be managed by the Services snap-in, PowerShell, or the sc.exe command line tool. Windows uses the LocalSystem (includes the SIDs of NT AUTHORITY\SYSTEM and BUILTIN\Administrators in its token), Network Service, and Local Service user accounts to run its own services. Users or programs creating a service can choose either one of those accounts, a domain user, or a local user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What windows service are important for priv. esc. ?

A

Windows services are one of the main areas to analyze when searching for privilege escalation vectors. In this Learning Unit, we’ll review three different ways to elevate our privileges by abusing services.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Service Binary Hijacking ?

A

Each Windows service has an associated binary file.

A scenario in which a software developer creates a program and installs an application as a Windows service. During the installation, the developer does not secure the permissions of the program, allowing full Read and Write access to all members of the Users group. As a result, a lower-privileged user could replace the program with a malicious one. To execute the replaced binary, the user can restart the service or, in case the service is configured to start automatically, reboot the machine. Once the service is restarted, the malicious binary will be executed with the privileges of the service, such as LocalSystem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How get a list of all installed Windows services ? What are the interesting information (3)

A

Get-Service
Get-CimInstance

Get-CimInstance -ClassName win32service | Select Name,State,PathName | Where-Object {$.State -like ‘Running’}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Two XAMPP services Apache2.4 and mysql stand out as the binaries are located in the C:\xampp\ directory instead of C:\Windows\System32. This means the service is user-installed and the software developer is in charge of the directory structure as well as permissions of the software. These circumstances make it potentially prone to service binary hijacking.

How enumerate the permissions on both service binaries ?

A

We can choose between the traditional icacls Windows utility or the PowerShell Cmdlet Get-ACL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Listing permisions with icals, what are the most useful flag ?

A

Mask:
F => Full access
M => Modify access
RX => Read and execute access
R => Read-only access
W => Write-only access

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How list permissions of binary file “C:\xampp\apache\bin\httpd.exe” ?

How interpret the results :
1.
C:\xampp\apache\bin\httpd.exe BUILTIN\Administrators:(F)
NT AUTHORITY\SYSTEM:(F)
BUILTIN\Users:(RX)
NT AUTHORITY\Authenticated Users:(RX)

Successfully processed 1 files; Failed processing 0 files

2.
XXXX> “C:\xampp\mysql\bin\mysqld.exe”
C:\xampp\mysql\bin\mysqld.exe NT AUTHORITY\SYSTEM:(F)
BUILTIN\Administrators:(F)
BUILTIN\Users:(F)

A

icacls “C:\xampp\apache\bin\httpd.exe”

  1. As member of the built-in Users group, dave only has Read and Execute (RX) rights on httpd.exe, meaning we cannot replace the file with a malicious binary.
  2. The output of listing shows that members of the Users group have the Full Access (F) permission, allowing us to write to and modify the binary and therefore, replace it. Due to the missing indicator (I) preceding this permission, we know that it was set on purpose and not inherited by the parent directory.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Latest read paraph for next time

A

16.2.1 Service Binary Hijacking

The output of Listing 43 shows that members of the Users group have the Full Access (F) permission, allowing us to write to and modify the binary and therefore, replace it. Due to the missing indicator (I) preceding this permission, we know that it was set on purpose and not inherited by the parent directory. Administrators often set Full Access permissions when they configure a service and are not entirely sure about the required permissions. Setting it to Full Access avoids most permission problems, but creates a security risk as we’ll show in this example.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly