지니언 EDR 로그에서 사용자 쓰기 위치에 반입한 드라이버를 서비스로 등록하고 서비스 상태를 조회하는 BYOVD 커널 권한 상승 준비 흐름을 탐지합니다.
Overview
Query
1table duration=30m EDR_GENIAN
2| search (_schema == "genian-edr-file" and event_subtype == "FileCreate")
3 or (_schema == "genian-edr-process" and event_subtype == "ProcessStart")
4 or (_schema == "genian-edr-reg" and event_subtype == "RegSetValue")
5| search len(trim(hostname)) > 0
6| eval psrc = if(len(trim(image_path)) > 0, trim(image_path), trim(image))
7| eval proc = lower(substr(psrc, lastindexof(psrc, "\\") + 1)), ipath = lower(psrc), cmd_l = lower(nvl(cmd_line, "")),
8 i_dir = if(lastindexof(psrc, "\\") >= 0, lower(substr(psrc, 0, lastindexof(psrc, "\\"))), ""),
9 par = lower(nvl(substr(parent_image, lastindexof(parent_image, "\\") + 1), "")), hostname = lower(trim(hostname))
10| eval b64 = if(in(proc, "powershell.exe", "pwsh.exe"), valueof(groups(cmd_line, "(?i)(?:^|\\s)\"?-(?:e|ec|en|enc|enco|encod|encode|encoded|encodedc|encodedco|encodedcom|encodedcomm|encodedcomma|encodedcomman|encodedcommand)\"?\\s+\"?([a-z0-9+/]{20,}={0,2})\"?(?:\\s|$)"), 0), null)
11| eval ps_text = if(in(proc, "powershell.exe", "pwsh.exe"), lower(concat(cmd_line, " ", nvl(decode(frombase64(substr(b64, 0, len(b64) - mod(len(b64), 4))), "UTF-16LE"), ""))), cmd_l)
12| eval fpath = lower(nvl(file_path, "")), f_dir = if(lastindexof(file_path, "\\") >= 0, lower(substr(file_path, 0, lastindexof(file_path, "\\"))), "")
13| eval rkey = lower(nvl(reg_key_path, "")), vname = lower(nvl(reg_value_name, "")), rval = lower(nvl(reg_value, ""))
14| eval grp = case(
15 _schema == "genian-edr-reg" and event_subtype == "RegSetValue" and (match(rkey, "^hkey_local_machine\\\\system\\\\(?:currentcontrolset|controlset\\d{3})\\\\services\\\\[^\\\\]+$") and vname == "imagepath" and match(rval, "(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\programdata|c:\\\\windows\\\\temp|\\\\appdata\\\\local\\\\temp|\\\\appdata\\\\roaming|\\\\downloads)\\\\[^\"]*\\.sys\"?$") and not(match(rval, "c:\\\\programdata\\\\microsoft\\\\windows defender\\\\(?:platform|definition updates)\\\\"))), "drvsvc",
16 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((proc == "sc.exe" and match(cmd_l, "\\s(?:query|queryex|qc|qdescription|enumdepend)\\b")) or (proc == "tasklist.exe" and match(cmd_l, "\\s/svc\\b")) or ((proc == "net.exe" or (proc == "net1.exe" and par != "net.exe")) and match(cmd_l, "\\bnet1?(?:\\.exe)?\"?\\s+start\\s*$")) or (proc == "wmic.exe" and match(cmd_l, "\\bservice\\b[\\s\\S]*\\b(?:get|list)\\b")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "get-service\\b|win32_service\\b"))), "svcdisc",
17 _schema == "genian-edr-file" and event_subtype == "FileCreate" and ((match(fpath, "\\.(?:exe|dll|sys|scr|cpl|bat|cmd|ps1|vbs|vbe|js|jse|wsf|hta)$") or (nvl(file_type, "") == "PE" and not(match(fpath, "\\.[a-z0-9]{2,4}$")))) and (indexof(fpath, "c:\\users\\public\\") == 0 or indexof(fpath, "c:\\perflogs\\") == 0 or in(f_dir, "c:\\programdata", "c:\\windows\\temp")) and not(match(fpath, "\\\\__psscriptpolicytest_[^\\\\]+\\.ps1$")) and not(in(proc, "msiexec.exe", "trustedinstaller.exe", "tiworker.exe", "mpsigstub.exe", "mpcmdrun.exe", "msmpeng.exe", "dismhost.exe", "system"))), "drop",
18 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (match(ipath, "\\.(?:exe|scr|com|pif)$") and (indexof(ipath, "c:\\users\\public\\") == 0 or indexof(ipath, "c:\\perflogs\\") == 0 or in(i_dir, "c:\\programdata", "c:\\windows\\temp"))), "exec",
19 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "whoami.exe", "quser.exe") or (proc == "query.exe" and match(cmd_l, "\\bquery(?:\\.exe)?\"?\\s+(?:user|session)\\b")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "windowsidentity\\]::getcurrent\\(\\)[\\s\\S]*isinrole|isinrole\\([\\s\\S]*administrator")) or (in(proc, "wmic.exe", "powershell.exe", "pwsh.exe") and match(ps_text, "\\b(?:win32_logonsession|win32_loggedonuser)\\b"))), "user",
20 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "remove-item|\\bdel\\b|\\bri\\b|\\brm\\b") and match(ps_text, "(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\windows\\\\temp|c:\\\\programdata)\\\\[^\\r\\n\"']*\\.(?:exe|dll|sys|ps1|bat|cmd|vbs|js|jse|hta|cs|bin|zip|7z|rar)\\b")) or (proc == "cmd.exe" and match(cmd_l, "\\b(?:del|erase)\\b[^&|]*(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\windows\\\\temp|c:\\\\programdata|%temp%|\\\\appdata\\\\local\\\\temp)\\\\[^&|\"]*\\.(?:exe|dll|sys|ps1|bat|cmd|vbs|js|jse|hta|bin)\\b")) or in(proc, "sdelete.exe", "sdelete64.exe")), "wipe",
21 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "set-mppreference[\\s\\S]*-disable(?:realtimemonitoring|behaviormonitoring|ioavprotection|scriptscanning|blockatfirstseen|intrusionpreventionsystem|archivescanning)\\s+\\W?(?:true|1)\\b|add-mppreference[\\s\\S]*-exclusion(?:path|process|extension)\\b")) or (proc == "reg.exe" and match(cmd_l, "\\badd\\b[\\s\\S]*windows defender[\\s\\S]*/v\\s+\"?disable(?:antispyware|antivirus|realtimemonitoring|behaviormonitoring|onaccessprotection|scanonrealtimeenable|ioavprotection)\"?[\\s\\S]*/d\\s+\"?1\\b")) or (in(proc, "sc.exe", "net.exe", "net1.exe") and match(cmd_l, "\\b(?:stop|delete|config)\\s+\"?(?:windefend|sense|wdnissvc|wdboot|wdfilter|wscsvc|securityhealthservice)\\b")) or (proc == "taskkill.exe" and match(cmd_l, "(?:msmpeng|mssense|sentinelagent|csfalconservice|cylancesvc|mcshield|bdservicehost|savservice|sophos|ekrn|avp\\.exe|ntrtscan|tmbmsrv|cbdefense|repmgr|xagt|elastic-endpoint|vsserv|ccsvchst|avastsvc|v3svc|ayagent)"))), "defimpair",
22 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((proc == "schtasks.exe" and match(cmd_l, "[/-]create\\b") and match(cmd_l, "(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\programdata|c:\\\\windows\\\\temp|\\\\appdata\\\\local\\\\temp|\\\\appdata\\\\roaming|\\\\downloads)\\\\|%(?:temp|tmp|appdata|public|programdata)%|/tr\\s+\"?[^/]*(?:powershell|pwsh|mshta|wscript|cscript|rundll32|regsvr32|cmd)(?:\\.exe)?\\b|/ru\\s+\"?(?:system|nt authority)")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "(?:^|[^a-z])register-scheduledtask") and match(ps_text, "(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\programdata|c:\\\\windows\\\\temp|\\\\appdata\\\\local\\\\temp|\\\\appdata\\\\roaming|\\\\downloads)\\\\|-execute\\s+['\"]?[^'\"\\s]*(?:powershell|pwsh|mshta|wscript|cscript|rundll32|regsvr32|cmd)(?:\\.exe)?\\b|-user(?:id)?\\s+['\"]?(?:system|nt authority)"))), "schtask",
23 _schema == "genian-edr-reg" and event_subtype == "RegSetValue" and (match(rkey, "(?:^hkey_users\\\\[^\\\\]+_classes|\\\\software\\\\classes)\\\\(?:ms-settings|mscfile|folder|exefile|launcher\\.systemsettings|appx[0-9a-z]{20,})\\\\shell\\\\open\\\\command$") and ((in(vname, "", "(default)") and len(trim(rval)) > 0) or vname == "delegateexecute") and not(in(proc, "explorer.exe", "systemsettings.exe", "svchost.exe")) and not(match(rval, "^\\{[0-9a-f-]{36}\\}$"))), "uacbypass",
24 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((in(proc, "tasklist.exe", "qprocess.exe") and not(contains(cmd_line, "/?"))) or (proc == "query.exe" and match(cmd_l, "\\bquery(?:\\.exe)?\"?\\s+process\\b")) or (proc == "wmic.exe" and match(cmd_l, "\\bprocess\\b[\\s\\S]*\\b(?:get|list)\\b") and not(match(cmd_l, "\\bcall\\b"))) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "get-process|\\bgps\\b") and match(ps_text, "(?:msmpeng|mssense|sentinelagent|csfalconservice|cylancesvc|mcshield|bdservicehost|savservice|sophos|ekrn|avp\\.exe|ntrtscan|tmbmsrv|cbdefense|repmgr|xagt|elastic-endpoint|vsserv|ccsvchst|avastsvc|v3svc|ayagent)[\\s\\S]*(?:msmpeng|mssense|sentinelagent|csfalconservice|cylancesvc|mcshield|bdservicehost|savservice|sophos|ekrn|avp\\.exe|ntrtscan|tmbmsrv|cbdefense|repmgr|xagt|elastic-endpoint|vsserv|ccsvchst|avastsvc|v3svc|ayagent)"))), "proclist")
25| search isnotnull(grp)
26| eval tech = case(grp == "drvsvc", "T1574.009", grp == "svcdisc", "T1007", grp == "drop", "T1105", grp == "exec", "T1204", grp == "user", "T1033", grp == "wipe", "T1070.004", grp == "defimpair", "T1685", grp == "schtask", "T1053.005", grp == "uacbypass", "T1548.002", grp == "proclist", "T1057")
27| eval anchor_g = if(in(grp, "drvsvc", "svcdisc"), grp, null)
28| stats dc(grp) as grp_cnt, dc(anchor_g) as anchor_cnt, values(grp) as groups, values(tech) as techs, min(_time) as first_seen, max(_time) as last_seen by hostname, host_ip
29| search anchor_cnt >= 2 and grp_cnt >= 4
30| eval groups = strjoin(", ", groups), techs = strjoin(", ", techs),
31 first_seen = string(first_seen, "yyyy-MM-dd HH:mm:ss"), last_seen = string(last_seen, "yyyy-MM-dd HH:mm:ss")
10분마다 직전 30분의 지니언 EDR 프로세스·파일·레지스트리 로그를 조회하여, 각 이벤트를 조건에 따라 행위군(grp)으로 분류하고 해당하는 MITRE 기법 번호(tech)를 붙입니다. 이후 hostname·host_ip별로 서로 다른 행위군 수(grp_cnt)와 필수 행위군 수(anchor_cnt)를 집계합니다. 사용자 쓰기 위치 실행 파일·드라이버의 서비스 등록과 서비스 상태 조회가 모두 있고(필수 행위군 2개), 서로 다른 행위군이 4개 이상이면 탐지합니다. 탐지 결과에는 관찰된 행위군 목록(groups)과 기법 목록(techs), 첫 발생 시각(first_seen)과 마지막 발생 시각(last_seen)을 함께 제공합니다.
Threat analysis
공용 폴더 등 사용자 쓰기 위치의 .sys 파일을 서비스로 등록하는 것은 취약한 커널 드라이버를 로드해 SYSTEM·커널 권한을 얻으려는 BYOVD 공격의 핵심 단계입니다. 등록 직후 sc query로 상태를 확인하고 익스플로잇 실행 파일을 실행한 뒤 드라이버와 실행 파일을 삭제하는 흐름이 함께 관찰되면 권한 상승이 시도된 것으로 판단합니다.
False positives
하드웨어 진단 도구나 드라이버 설치 프로그램이 Temp 경로에 드라이버를 생성해 서비스로 등록하고 상태를 확인하는 경우 탐지될 수 있습니다. 확인된 설치 프로그램은 드라이버 경로나 서명자를 기준으로 예외 조건을 추가하여 조정합니다.
Response actions
등록된 서비스의 이름과 드라이버 경로·해시·서명을 확인하고 취약 드라이버 목록과 대조합니다. 등록 주체 프로세스와 그 이후 SYSTEM 권한으로 실행된 프로세스를 조회합니다. 정탐으로 확인되면 단말을 격리하고 드라이버 서비스를 제거하며, 취약 드라이버 차단 목록을 적용합니다.