지니언 EDR 로그에서 UAC 우회, RunOnceEx 등록, 반사형 DLL 주입, Kerberoasting이 한 단말에서 이어지는 다단계 침투를 탐지합니다.
개요
쿼리
1table duration=30m EDR_GENIAN
2| search (_schema == "genian-edr-file" and event_subtype == "FileCreate")
3 or (_schema == "genian-edr-module" and event_subtype == "DllInjected")
4 or (_schema == "genian-edr-network" and event_subtype == "NetworkConnect")
5 or (_schema == "genian-edr-process" and event_subtype == "ProcessStart")
6 or (_schema == "genian-edr-reg" and event_subtype == "RegSetValue")
7| search len(trim(hostname)) > 0
8| eval psrc = if(len(trim(image_path)) > 0, trim(image_path), trim(image))
9| eval proc = lower(substr(psrc, lastindexof(psrc, "\\") + 1)), ipath = lower(psrc), cmd_l = lower(nvl(cmd_line, "")),
10 i_dir = if(lastindexof(psrc, "\\") >= 0, lower(substr(psrc, 0, lastindexof(psrc, "\\"))), ""),
11 par = lower(nvl(substr(parent_image, lastindexof(parent_image, "\\") + 1), "")), hostname = lower(trim(hostname))
12| 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)
13| 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)
14| eval fpath = lower(nvl(file_path, "")), f_dir = if(lastindexof(file_path, "\\") >= 0, lower(substr(file_path, 0, lastindexof(file_path, "\\"))), "")
15| eval rkey = lower(nvl(reg_key_path, "")), vname = lower(nvl(reg_value_name, "")), rval = lower(nvl(reg_value, ""))
16| eval grp = case(
17 _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",
18 _schema == "genian-edr-reg" and event_subtype == "RegSetValue" and (match(rkey, "\\\\software\\\\(?:wow6432node\\\\)?microsoft\\\\windows\\\\currentversion\\\\(?:run|runonce|runonceex|runservices|runservicesonce|policies\\\\explorer\\\\run)$") and match(rval, "c:\\\\users\\\\public\\\\|c:\\\\perflogs\\\\|\\\\windows\\\\temp\\\\|\\\\appdata\\\\local\\\\temp\\\\|%temp%|%public%|https?://|(?:^|\\\\|\")(?:powershell|pwsh|mshta|wscript|cscript|rundll32|regsvr32)(?:\\.exe)?\"?\\s")), "runkey",
19 _schema == "genian-edr-reg" and event_subtype == "RegSetValue" and (match(rkey, "\\\\software\\\\(?:wow6432node\\\\)?microsoft\\\\windows\\\\currentversion\\\\runonceex\\\\[^\\\\]+\\\\depend$")), "runkey",
20 _schema == "genian-edr-module" and event_subtype == "DllInjected" and (match(fpath, "(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\programdata|c:\\\\windows\\\\temp|\\\\appdata\\\\local\\\\temp|\\\\appdata\\\\roaming|\\\\downloads)\\\\") and match(fpath, "\\.dll$")), "reflect",
21 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (proc == "rubeus.exe" or match(cmd_l, "\\b(?:kerberoast(?:ing)?|asreproast(?:ing)?)\\b") or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "invoke-kerberoast|invoke-rubeus|kerberosrequestorsecuritytoken|\\b(?:kerberoast(?:ing)?|asreproast(?:ing)?)\\b"))), "kerberoast",
22 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((proc == "wmic.exe" and match(cmd_l, "\\bprocess\\b[\\s\\S]*\\bcall\\s+create\\b")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "invoke-(?:wmi|cim)method\\b[\\s\\S]*win32_process\\b[\\s\\S]*create|win32_process\\b[\\s\\S]*invoke-(?:wmi|cim)method\\b[\\s\\S]*create|\\[wmiclass\\][\\s\\S]*win32_process[\\s\\S]*\\.create\\("))), "wmiexec",
23 _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",
24 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((proc == "rundll32.exe" and match(cmd_l, "comsvcs(?:\\.dll)?[\\s\\S]*minidump|#\\+?24\\b")) or (in(proc, "procdump.exe", "procdump64.exe", "procdump64a.exe") and match(cmd_l, "\\s-m[ap]\\b[\\s\\S]*lsass|lsass[\\s\\S]*\\s-m[ap]\\b")) or in(proc, "mimikatz.exe", "nanodump.exe", "pypykatz.exe") or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "invoke-mimikatz|sekurlsa::|lsadump::|comsvcs(?:\\.dll)?[\\s\\S]*minidump|minidumpwritedump|out-minidump"))), "lsass",
25 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "cmd.exe", "powershell.exe", "pwsh.exe", "where.exe", "tree.com", "wmic.exe") and match(ps_text, "\\b(?:cim_datafile|cim_directory|win32_directory)\\b[\\s\\S]*\\bget\\b|\\bdir\\b[^|&\\r\\n]*\\s/s\\b|\\btree(?:\\.com)?\\b[^|&\\r\\n]*\\s/f\\b|\\bwhere(?:\\.exe)?\\s+/r\\s|get-childitem[^|\\r\\n]*-recurse|\\bgci\\b[^|\\r\\n]*-recurse|dllimport[\\s\\S]*\\bfind(?:first|next)filew?\\b")), "filedisc",
26 _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)"))), "procdisc",
27 _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",
28 _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",
29 _schema == "genian-edr-network" and event_subtype == "NetworkConnect" and (in(proc, "powershell.exe", "pwsh.exe", "mshta.exe", "wscript.exe", "cscript.exe", "rundll32.exe", "regsvr32.exe", "certutil.exe", "bitsadmin.exe") and isnotnull(remote_ip) and not(match(remote_ip, "^(?:10\\.|127\\.|192\\.168\\.|172\\.(?:1[6-9]|2\\d|3[01])\\.|169\\.254\\.|0\\.|::1|fe80)"))), "webc2",
30 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "powershell.exe", "pwsh.exe") and match(cmd_line, "(?i)(?:^|\\s)\"?-(?:ep|ex|exe|exec|execu|execut|executi|executio|execution|executionp|executionpo|executionpol|executionpoli|executionpolic|executionpolicy)\"?\\s+\"?bypass\"?(?:\\s|$)") and (isnotnull(b64) or match(cmd_l, "(?:^|\\s)\"?-(?:f|fi|fil|file)\"?\\s+\"?(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\windows\\\\temp|c:\\\\programdata|c:\\\\users\\\\[^\\\\]+\\\\appdata\\\\local\\\\temp)\\\\"))), "psbypass")
31| search isnotnull(grp)
32| eval tech = case(grp == "uacbypass", "T1548.002", grp == "runkey", "T1547.001/T1547.001", grp == "reflect", "T1620", grp == "kerberoast", "T1558.003", grp == "wmiexec", "T1047", grp == "schtask", "T1053.005", grp == "lsass", "T1003.001", grp == "filedisc", "T1083", grp == "procdisc", "T1057", grp == "user", "T1033", grp == "drop", "T1105", grp == "webc2", "T1071.001", grp == "psbypass", "T1059.001")
33| eval anchor_g = if(in(grp, "uacbypass", "runkey", "reflect", "kerberoast"), grp, null)
34| 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
35| search anchor_cnt >= 3 and grp_cnt >= 6
36| eval groups = strjoin(", ", groups), techs = strjoin(", ", techs),
37 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)를 집계합니다. 자동 상승 프로그램 셸 명령 키 변조(UAC 우회)·Run 계열 키의 사용자 쓰기 위치 실행 또는 RunOnceEx Depend 등록·사용자 쓰기 위치 DLL의 다른 프로세스 주입·Kerberoasting 중 3개 이상이 있고(필수 행위군), 서로 다른 행위군이 6개 이상이면 탐지합니다. 탐지 결과에는 관찰된 행위군 목록(groups)과 기법 목록(techs), 첫 발생 시각(first_seen)과 마지막 발생 시각(last_seen)을 함께 제공합니다.
위협 분석
공격 자동화 프레임워크는 지속성 확보, 권한 상승, 방어 회피, 자격 증명 접근을 정해진 순서로 실행합니다. RunOnceEx Depend 값은 로그온 시 DLL을 로드하게 하는 드문 지속성 수단이고, fodhelper 셸 명령 키 변조는 UAC 창 없이 관리자 권한을 얻는 방법입니다. 이 단계들이 30분 안에 겹치면 자동화된 침투 도구가 동작 중인 것으로 판단합니다.
오탐 유형
승인된 모의 침투나 레드팀 훈련에서 같은 프레임워크를 사용하는 경우 탐지됩니다. 훈련 일정과 대상 단말을 확인하고, 훈련 기간에는 대상 hostname을 예외 조건으로 추가하여 조정합니다.
대응 방안
변조된 셸 명령 키와 RunOnceEx 값을 확인하여 원래 상태로 복구하고, 주입 대상 프로세스와 에이전트의 C2 주소를 확인합니다. Kerberoasting이 있었다면 대상 서비스 계정의 암호를 변경합니다. 정탐으로 확인되면 단말을 격리하고 C2 주소와 통신한 다른 단말을 조회합니다.