지니언 EDR 로그에서 UAC·가상화 환경 확인 뒤 사용자 쓰기 위치의 DLL 주입 도구가 실행되고 실행형 파일 반입·실행·흔적 삭제가 한 단말에서 함께 나타나는 방어 회피 공격을 탐지합니다.
개요
쿼리
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| search len(trim(hostname)) > 0
5| eval psrc = if(len(trim(image_path)) > 0, trim(image_path), trim(image))
6| eval proc = lower(substr(psrc, lastindexof(psrc, "\\") + 1)), ipath = lower(psrc), cmd_l = lower(nvl(cmd_line, "")),
7 i_dir = if(lastindexof(psrc, "\\") >= 0, lower(substr(psrc, 0, lastindexof(psrc, "\\"))), ""),
8 par = lower(nvl(substr(parent_image, lastindexof(parent_image, "\\") + 1), "")), hostname = lower(trim(hostname))
9| 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)
10| 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)
11| eval fpath = lower(nvl(file_path, "")), f_dir = if(lastindexof(file_path, "\\") >= 0, lower(substr(file_path, 0, lastindexof(file_path, "\\"))), "")
12| eval grp = case(
13 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (match(ipath, "\\.exe$") and match(ipath, "(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\programdata|c:\\\\windows\\\\temp|\\\\appdata\\\\local\\\\temp|\\\\appdata\\\\roaming|\\\\downloads)\\\\") and match(cmd_l, "(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\programdata|c:\\\\windows\\\\temp|\\\\appdata\\\\local\\\\temp|\\\\appdata\\\\roaming|\\\\downloads)\\\\[^\"\\s]*\\.dll\\b")), "inject",
14 _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",
15 _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",
16 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "powershell.exe", "pwsh.exe", "cmd.exe", "reg.exe", "wmic.exe") and match(ps_text, "(?:win32_computersystem|win32_bios|win32_diskdrive|win32_baseboard|win32_videocontroller|systemmanufacturer|systemproductname|\\\\hardware\\\\description\\\\system)[\\s\\S]*(?:vmware|virtualbox|vbox|qemu|xen|kvm|hyper-v|parallels|bochs)|(?:vmware|virtualbox|vbox|qemu|xen|kvm|parallels|bochs)[\\s\\S]*(?:win32_computersystem|win32_bios|win32_diskdrive|win32_baseboard|systemmanufacturer|systemproductname)|sbiedll|cuckoo|\\\\policies\\\\system[\\s\\S]*(?:enablelua|consentpromptbehavioradmin)")), "envcheck",
17 _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",
18 _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",
19 _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")
20| search isnotnull(grp)
21| eval tech = case(grp == "inject", "T1055.001", grp == "exec", "T1204", grp == "drop", "T1105", grp == "envcheck", "T1497.001", grp == "wipe", "T1070.004", grp == "user", "T1033", grp == "filedisc", "T1083")
22| eval anchor_g = if(in(grp, "inject", "envcheck"), grp, null), has_exec_v = if(grp == "exec", 1, 0), has_drop_v = if(grp == "drop", 1, 0)
23| stats dc(grp) as grp_cnt, dc(anchor_g) as anchor_cnt, max(has_exec_v) as has_exec, max(has_drop_v) as has_drop, values(grp) as groups, values(tech) as techs, min(_time) as first_seen, max(_time) as last_seen by hostname, host_ip
24| search anchor_cnt >= 2 and (has_exec == 1 or has_drop == 1) and grp_cnt >= 4
25| eval groups = strjoin(", ", groups), techs = strjoin(", ", techs),
26 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)를 집계합니다. DLL 주입 도구 실행과 UAC·가상화 환경 확인이 모두 있고(필수 행위군 2개), 사용자 쓰기 위치 실행 파일 실행 또는 실행형 파일 반입이 있으며, 서로 다른 행위군이 4개 이상이면 탐지합니다. 탐지 결과에는 관찰된 행위군 목록(groups)과 기법 목록(techs), 첫 발생 시각(first_seen)과 마지막 발생 시각(last_seen)을 함께 제공합니다.
위협 분석
사용자 쓰기 위치의 실행 파일이 같은 계열 위치의 DLL을 인자로 받아 실행되는 것은 정상 프로세스에 악성 DLL을 넣어 보안 제품의 탐지를 피하려는 주입 도구의 전형적인 형태입니다. 실행 전에 UAC 설정과 가상화 환경을 확인하는 것은 분석 환경을 피하려는 사전 점검이며, 이어지는 파일 삭제는 흔적을 지우려는 행위입니다. 이 행위들이 30분 안에 겹치면 주입이 실제로 시도됐을 가능성이 높으므로 우선 조사합니다.
오탐 유형
사내 개발·보안 점검 부서가 공용 폴더나 Temp 경로에서 주입 시험 도구를 실행하는 경우 탐지될 수 있습니다. 설치 프로그램이 Temp에 생성한 실행 파일이 DLL 경로를 인자로 받는 경우도 있으므로, 확인된 정상 도구는 실행 파일 경로나 서명 기준으로 예외 조건을 추가하여 조정합니다.
대응 방안
groups와 first_seen·last_seen 구간으로 해당 단말의 프로세스 로그를 조회하여 주입 도구의 경로, 인자로 넘긴 DLL, 대상 프로세스를 확인합니다. 반입된 파일의 해시로 평판을 조회하고, 삭제된 파일은 파일 이벤트에서 생성 주체를 확인합니다. 정탐으로 확인되면 단말을 네트워크에서 격리하고 주입 대상 프로세스의 이후 행위(네트워크 연결·자식 프로세스)를 조사합니다.