akde/infosec

Information security is ultimately about managing risk


SID Security Identifiers

All ele­ments have attrib­ut­es. They are iden­ti­fied via a Secu­ri­ty Iden­ti­fi­er SID. The struc­ture of a SID:

  • A‑B-C‑D
    • A is always S, which here indi­cates a secu­ri­ty identifier.
    • B is the revision/version. It is 1 on most cases.
    • C is the ID of the author­i­ty who cre­at­ed the ID with all sub authorities. 
      • When it is 5, it is the NT Author­i­ty, which indi­cates that this is an ID of the local sys­tem. Behind that are fol­low­ing fur­ther rel­a­tive iden­ti­fiers.
    • D is the rel­a­tive identifier.

Exam­ple:

  • S‑1–5‑21–466546139-763938477–1796994327-1001
    • A = S (secu­rit identifier)
    • B = 1 (ver­sion)
    • C = 5 (domain identifier)
    • D = 21–466546139-763938477–1796994327-1001 (rel­a­tive identifier)

The Domain Iden­ti­fi­er ist the SID with­out the last RID part.

Exam­ples for well-known SIDs:

  • S‑1–0‑0 Nobody
  • S‑1–1‑0 Every­body
  • S‑1–5‑11 Authen­ti­cat­ed Users
  • S‑1–5‑18 Local System
  • S‑1–5-$domainidentifier-500 Admin­is­tra­tor

Basic Windows security access control

Security context

  1. When a user logs in, Win­dows cre­ates an access token for the user. 
    • This token defines the secu­ri­ty con­text. The secu­ri­ty con­text defines what a user can do. It con­sists of the user’s SID and the groups of which the user is a mem­ber of and it’s privileges.
  2. When Win­dows cre­ates a new process / thread, it is assigned to a token, which defines the capa­bil­i­ties of this process / thread, espe­cial­ly regard­ing access­ing oth­er process­es / threats or sys­tem ressources. 
    • This token can also be an imper­son­ation token. This is a token with dif­fer­ent secu­ri­ty capa­bil­i­ties, e.g. when a user exe­cutes a process under anoth­er user, the own­er of a process may be user1, but the secu­ri­ty con­text is then from user2.

Mandatory Integrity Control and integrity levels

Win­dows (from Vista on) has five integri­ty levels:

  1. Sys­tem (SYSTEM)
  2. High (ele­vat­ed users)
  3. Medi­um (nor­mal users)
  4. Low
  5. Untrust­ed

For each process, Win­dows assignes a integri­ty lev­el depend­ing of the caller. If a user with integri­ty lev­el Medi­um starts a process, the process has the lev­el Medi­um as well, except the exe­cute­able file has a low­er integri­ty lev­el. In this case, the process has the low­er secu­ri­ty lev­el. A process has can­not access process­es with high­er secu­ri­ty levels.

Note: The integri­ty lev­els can be shown in the TaskManager.

UAC User Account Control

  • UAC was intro­duced in Vista and Serv­er 2008.
  • It requires to con­firm tasks which can affect the system.
  • Users has to con­firm the action with their pass­word, admins with a con­fir­ma­tion dialog.
  • Even as admin­is­tra­tor, some sys­tem com­mands does not work with­out UAC confirmation.
  • Exam­ple:
    • Try to change the pass­word as admin­is­tra­tor
      net user admin Ev!lpass
    • It doesn’t work “Access is denied”
    • Switch to a high­er integri­ty lev­el with
      powershell.exe Start-Process cmd.exe -Verb runAs
    • Repeat the com­mand. Now it will work.

Separation of Kernel space

There are two access modes in Windows:

  • Ker­nel mode runs in ring 0 and allows access to core os ele­ments or drivers
  • User mode runs in ring 3 and is the default mode where appli­ca­tions run.

From the user mode, appli­ca­tions can go to functions/components in the ker­nel mode via secu­ri­ty gates. These gates are imple­ment­ed in ntdll.dll. This is the glob­al entry point for appli­ca­tions from the user­land to access ker­nel func­tions. The nor­mal way is via exposed OS-APIs. These APIs are exposed and doc­u­ment­ed. When an appli­ca­tion calls one, then these APIs will prob­a­bly go through oth­er func­tions until they call some­thing in ntdll. The calls in ntdll usu­al­ly require more para­me­ters than the easy-to-use high-lev­el API func­tions. A devel­op­er can also access the exposed func­tions in ntdll direct­ly which could pro­vide more pos­si­bil­i­ties for attacks.

Linking and loading

In com­par­i­son to Lin­ux, Win­dows uses oth­er terms.

Lin­uxWin­dowsPur­pose
GOT/PLT (Glob­al Off­set Table/Procedure Link­ing Table)IAT/EAT (Import Address Table/Export Address Table)Ref­er­enc­ing the posi­tion of func­tions in the memory.
ELF (Exe­cutable and Link­ing Format)PE/COFF (Portable Executeable/Common Object File Format)Struc­ture for exe­cute­able files.

Leave a Reply

About

Personal collection of some infosec stuff. Primary purpose of this site is to collect and organize for myself.

Note: Some content is not publicly visible due to copyright issues. Therefore, some links could be broken.

Checklists

Categories

Checklists: Ports

python -c 'import pty;pty.spawn("/bin/bash")';

python3 -c 'import pty;pty.spawn("/bin/bash")';