지니언 EDR 로그에서 자격 증명 덤프 도구와 PsExec 반입, 도메인 계정 조회, PsExec 측면 이동이 한 단말에서 이어지는 LockBit형 침투를 탐지합니다.
개요
쿼리
1table duration=30m EDR_GENIAN
2| search (_schema == "genian-edr-file" and in(event_subtype, "FileCreate", "FileMove"))
3 or (_schema == "genian-edr-network" and event_subtype == "NetworkConnect")
4 or (_schema == "genian-edr-process" and event_subtype == "ProcessStart")
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 grp = case(
14 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((proc == "sc.exe" and match(cmd_l, "\\s(?:create|config)\\s[\\s\\S]*binpath=\\s*\"?[^\"]*(?:cmd|powershell|pwsh|mshta|rundll32|regsvr32|wscript|cscript)(?:\\.exe)?\\b")) or in(proc, "psexec.exe", "psexec64.exe", "paexec.exe", "psexesvc.exe", "csexec.exe", "remcom.exe") or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "new-service\\b[\\s\\S]*-binarypathname\\s+['\"]?[^'\"]*(?:cmd|powershell|pwsh|mshta|rundll32|regsvr32)(?:\\.exe)?\\b|psexe(?:c|c64)(?:\\.exe)?['\"]?\\s[^\\r\\n]*-accepteula"))), "psexec",
15 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "lazagne.exe", "secretsdump.exe", "pwdump.exe", "fgdump.exe", "gsecdump.exe", "wce.exe") or match(cmd_l, "\\blazagne(?:\\.exe|\\.py)?\"?\\s+(?:all|browsers|windows|sysadmin|wifi|mails|chats|databases|memory)\\b") or (proc == "reg.exe" and match(cmd_l, "\\b(?:save|export)\\s+\"?(?:hklm|hkey_local_machine)\\\\(?:sam|security|system)\"?\\s")) or (proc == "ntdsutil.exe" and match(cmd_l, "\\bifm\\b|ac(?:tivate)?\\s+i(?:nstance)?\\s+ntds"))), "credump",
16 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (((proc == "net.exe" or (proc == "net1.exe" and par != "net.exe")) and match(cmd_l, "\\s(?:group|groups|user|users)\\b[^/]*\\s/do(?:m|ma|mai|main)?\\b") and not(match(cmd_l, "/(?:add|del|delete)\\b"))) or (proc == "dsquery.exe" and match(cmd_l, "dsquery(?:\\.exe)?\"?\\s+group\\b")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "get-adgroup(?:member)?\\b|get-domaingroup\\b|\\bnet(?:\\.exe)?\\s+(?:user|users|group|groups)\\b[^\\r\\n|;]*\\s/do(?:m|ma|mai|main)?\\b"))), "domacct",
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 (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",
19 _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",
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 (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",
22 _schema == "genian-edr-file" and in(event_subtype, "FileCreate", "FileMove") and (match(fpath, "\\.(?:conti|vanhelsing|vanlocker|locked|lockbit|encrypted|crypted|ryk|babyk|akira|royal|basta|hive|clop|medusa|rhysida|8base|phobos|makop|djvu)$") or match(fpath, "\\\\(?:how[_-]?to[_-]?(?:decrypt|restore|recover)|restore[_-]?(?:my[_-]?)?files|decrypt[_-]?(?:my[_-]?)?files|readme[_-]?(?:for[_-]?)?decrypt|_readme_|ransom)[^\\\\]*\\.(?:txt|html?|hta)$")), "encrypt")
23| search isnotnull(grp)
24| eval tech = case(grp == "psexec", "T1569.002", grp == "credump", "T1003", grp == "domacct", "T1069.002", grp == "drop", "T1105", grp == "psbypass", "T1059.001", grp == "webc2", "T1071.001", grp == "wipe", "T1070.004", grp == "exec", "T1204", grp == "encrypt", "T1486")
25| eval anchor_g = if(in(grp, "psexec", "credump", "domacct"), grp, null), has_drop_v = if(grp == "drop", 1, 0)
26| stats dc(grp) as grp_cnt, dc(anchor_g) as anchor_cnt, 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
27| search anchor_cnt >= 2 and has_drop == 1 and grp_cnt >= 4
28| eval groups = strjoin(", ", groups), techs = strjoin(", ", techs),
29 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)를 집계합니다. PsExec 측면 이동·자격 증명 덤프 도구 실행·도메인 계정 그룹 조회 중 2개 이상이 있고(필수 행위군), 공용 폴더 등 사용자 쓰기 위치의 실행 파일 반입이 반드시 있으며, 서로 다른 행위군이 4개 이상이면 탐지합니다. 탐지 결과에는 관찰된 행위군 목록(groups)과 기법 목록(techs), 첫 발생 시각(first_seen)과 마지막 발생 시각(last_seen)을 함께 제공합니다.
위협 분석
공용 폴더에 자격 증명 덤프 도구와 PsExec를 반입한 뒤 덤프 결과에서 얻은 계정의 도메인 관리자 그룹 소속을 확인하는 것은 측면 이동에 쓸 계정을 고르는 과정입니다. 그 계정으로 PsExec를 실행하면 파일·DB 서버로 이동해 랜섬웨어를 배포할 수 있습니다. 도메인 관리자 계정이 노출됐다면 도메인 전체가 위험합니다.
오탐 유형
시스템 관리자가 PsExec로 원격 작업을 하고 도메인 계정을 조회하는 경우 필수 행위군이 관찰될 수 있습니다. 관리 단말에서 반복 탐지되면 hostname과 실행 계정 기준으로 예외 조건을 추가하되, 덤프 도구 실행이 포함된 탐지는 예외로 두지 않습니다.
대응 방안
PsExec의 대상 서버와 사용 계정을 확인하고, 대상 서버에서 PSEXESVC 서비스 생성 이력과 이후 실행된 프로세스를 조회합니다. 덤프 도구가 실행됐다면 해당 단말에 로그온한 모든 계정의 암호를 변경합니다. 정탐으로 확인되면 출발지와 대상 단말을 함께 격리합니다.