지니언 EDR 로그에서 WMI 프로세스 생성, 원격 접속용 계정 준비, 방화벽 개방이 정찰과 함께 한 단말에서 나타나는 Mallox 랜섬웨어 내부 확산 준비를 탐지합니다.
Overview
Query
1table duration=30m EDR_GENIAN
2| search (_schema == "genian-edr-file" and in(event_subtype, "FileCreate", "FileMove"))
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 ((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",
14 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "(?:new-pssession|enter-pssession)\\b[\\s\\S]*-computername\\b|invoke-command\\b[\\s\\S]*-(?:computername|session)\\b")) or (proc == "winrs.exe" and match(cmd_l, "[-/]r(?:emote)?:"))), "winrm",
15 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (((proc == "net.exe" or (proc == "net1.exe" and par != "net.exe")) and match(cmd_l, "\\bnet1?(?:\\.exe)?\"?\\s+user\\s+\\S+[\\s\\S]*\\s/add\\b") and not(match(cmd_l, "/do(?:m|ma|mai|main)?\\b"))) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "new-localuser\\b|\\[adsi\\][\\s\\S]*winnt://[\\s\\S]*create\\(\\s*['\"]user"))), "localacct",
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, "\\bnet1?(?:\\.exe)?\"?\\s+localgroup\\b")) or (proc == "wmic.exe" and match(cmd_l, "\\bgroup\\b[\\s\\S]*\\b(?:get|list)\\b")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "get-localgroup(?:member)?\\b|add-localgroupmember\\b|win32_group\\b"))), "localgroup",
17 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((proc == "netsh.exe" and match(cmd_l, "\\b(?:advfirewall\\s+(?:firewall\\s+(?:add|set)\\s+rule|set\\s+\\w+profile\\s+state\\s+off)|firewall\\s+(?:add|set)\\s+(?:allowedprogram|portopening|opmode\\s+(?:mode=)?disable))")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "new-netfirewallrule\\b|set-netfirewallprofile\\b[\\s\\S]*-enabled\\s+\\W?(?:false|0)\\b|set-netfirewallrule\\b[\\s\\S]*-action\\s+allow|hnetcfg\\.fwpolicy2"))), "firewall",
18 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "ipconfig.exe", "nbtstat.exe", "getmac.exe") or (proc == "route.exe" and match(cmd_l, "\\bprint\\b")) or (proc == "arp.exe" and match(cmd_l, "\\s-[ag]\\b")) or (proc == "netsh.exe" and match(cmd_l, "\\b(?:interface\\s+(?:ip|ipv4)?\\s*show|wlan\\s+show|(?:advfirewall\\s+(?:firewall\\s+)?|firewall\\s+)show|ip\\s+show\\s+config)\\b")) or (proc == "wmic.exe" and match(cmd_l, "\\b(?:nicconfig|nic|win32_networkadapterconfiguration|win32_ip4routetable)\\b[\\s\\S]*\\b(?:get|list)\\b")) or (proc == "nltest.exe" and match(cmd_l, "[/-]dsgetdc\\b"))), "netconf",
19 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (proc == "netstat.exe" or ((proc == "net.exe" or (proc == "net1.exe" and par != "net.exe")) and match(cmd_l, "\\bnet1?(?:\\.exe)?\"?\\s+(?:session|sessions|use)\\s*$")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "get-nettcpconnection\\b|get-netudpendpoint\\b|get-smbsession\\b"))), "netconn",
20 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "systeminfo.exe", "hostname.exe") or (proc == "wmic.exe" and match(cmd_l, "\\b(?:os|computersystem|bios|qfe|csproduct|path\\s+win32_(?:operatingsystem|bios|baseboard|computersystemproduct))\\b[\\s\\S]*\\b(?:get|list)\\b")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "getnativesysteminfo|getsysteminfo\\b|get-computerinfo|win32_operatingsystem|\\.partofdomain\\b|dllimport[\\s\\S]*\\b(?:getlogicaldrivestringsw?|getdrivetypew?|getlogicaldrives)\\b"))), "sysinfo",
21 _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",
22 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "getlocaleinfo|getgeoinfo|getusergeoid|get-winhomelocation|ipinfo\\.io|ip-api\\.com|ipapi\\.co|geoplugin|ipwho\\.is|freegeoip")), "geo",
23 _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",
24 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "isdebuggerpresent|checkremotedebuggerpresent|ntqueryinformationprocess|outputdebugstring|debugger\\]::isattached")), "antidebug",
25 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "add-type[\\s\\S]*dllimport|dllimport[\\s\\S]*add-type")), "nativeapi",
26 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((proc == "vssadmin.exe" and match(cmd_l, "\\bdelete\\s+shadows\\b|\\bresize\\s+shadowstorage\\b")) or (proc == "wmic.exe" and match(cmd_l, "shadowcopy[\\s\\S]*\\bdelete\\b")) or (proc == "bcdedit.exe" and match(cmd_l, "recoveryenabled\\s+no|bootstatuspolicy\\s+ignoreallfailures")) or (proc == "wbadmin.exe" and match(cmd_l, "\\bdelete\\s+(?:catalog|systemstatebackup|backup)\\b")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "win32_shadowcopy[\\s\\S]*(?:\\.delete\\(\\)|remove-(?:cim|wmi)(?:instance|object))|remove-(?:cim|wmi)(?:instance|object)[\\s\\S]*win32_shadowcopy|vssadmin[^\\r\\n]*delete\\s+shadows"))), "shadow",
27 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((proc == "wevtutil.exe" and match(cmd_l, "\\s(?:cl|clear-log)\\s")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "clear-eventlog\\b|remove-eventlog\\b|\\.clearlog\\(|wevtutil(?:\\.exe)?\\s+(?:cl|clear-log)\\s"))), "logclear",
28 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (((proc == "reg.exe" and match(cmd_l, "\\s(?:add|delete|import)\\s")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "(?:set|new)-itemproperty\\b|\\bsp\\s+-path|remove-itemproperty\\b"))) and match(ps_text, "policies\\\\microsoft\\\\windows defender|control panel\\\\desktop[\\s\\S]*wallpaper|policies\\\\system\\b|image file execution options|control\\\\lsa\\b|securityproviders\\\\wdigest|terminal server[\\s\\S]*fdenytsconnections|safeboot|currentversion\\\\winlogon")), "regmod",
29 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((proc == "reg.exe" and match(cmd_l, "\\bquery\\b") and match(cmd_l, "securityproviders\\\\wdigest|control\\\\lsa\\b|winlogon|terminal server|simontatham\\\\putty|martin prikryl|realvnc|tightvnc|control\\\\systemstartoptions|/v\\s+systemstartoptions")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "get-item(?:property)?(?:value)?\\b|\\bgp\\b|\\bgpv\\b|regread|opensubkey") and match(ps_text, "securityproviders\\\\wdigest|control\\\\lsa\\b|winlogon\\b[\\s\\S]*(?:defaultpassword|autoadminlogon)|terminal server\\\\(?:winstations|fdenytsconnections)|simontatham\\\\putty|systemstartoptions"))), "regquery",
30 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((proc == "ftp.exe" and match(cmd_l, "\\s-s:")) or (proc == "tftp.exe" and match(cmd_l, "\\bput\\b")) or (proc == "curl.exe" and match(cmd_l, "(?:s?ftp|scp|smb)://") and match(cmd_l, "(?:^|\\s)(?:-t|--upload-file)\\s")) or in(proc, "pscp.exe", "psftp.exe", "rclone.exe", "megacmd.exe", "winscp.com") or (match(cmd_l, "\\s(?:copy|sync|move|copyto|moveto)\\s") and match(cmd_l, "\\s[a-z0-9_-]{2,}:[^\\\\\\s]") and match(cmd_l, "--(?:s3-|no-check-certificate|transfers|checkers|low-level-retries|bwlimit|ignore-existing|multi-thread)")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "ftpwebrequest|uploadfile\\(\\s*['\"]?ftp://|webclient[\\s\\S]*ftp://|rclone_config_[a-z0-9_]+_type|rclone_s3_(?:access_key_id|secret_access_key)"))), "exfil",
31 _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",
32 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (((proc == "certutil.exe" or (proc == "cmd.exe" and match(cmd_l, "/[ck]\\s+(?:.*&\\s*)?\"?certutil(?:\\.exe)?\"?\\s"))) and match(cmd_l, "(?:^|\\s)[-/]decode(?:hex)?\\s+\\S+\\s+\\S+")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "frombase64string[\\s\\S]*(?:writeallbytes|set-content|out-file)"))), "decode",
33 _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",
34 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "getuserdefaultlcid|getsystemdefaultlcid|getuserdefaultlocalename|getsystemdefaultlocalename|getuserdefaultuilanguage|getsystemdefaultuilanguage|getkeyboardlayoutlist|get-winsystemlocale|get-winuserlanguagelist")) or (proc == "reg.exe" and match(cmd_l, "\\bquery\\b[\\s\\S]*(?:\\\\nls\\\\language|\\\\keyboard layout)"))), "language")
35| search isnotnull(grp)
36| eval tech = case(grp == "wmiexec", "T1047", grp == "winrm", "T1021.006", grp == "localacct", "T1136.001", grp == "localgroup", "T1069.001", grp == "firewall", "T1686", grp == "netconf", "T1016", grp == "netconn", "T1049", grp == "sysinfo", "T1082", grp == "user", "T1033", grp == "geo", "T1614", grp == "drop", "T1105", grp == "antidebug", "T1622", grp == "nativeapi", "T1106", grp == "shadow", "T1490", grp == "logclear", "T1685.005", grp == "regmod", "T1112", grp == "regquery", "T1012", grp == "exfil", "T1048", grp == "wipe", "T1070.004", grp == "decode", "T1140", grp == "encrypt", "T1486", grp == "language", "T1614.001")
37| eval anchor_g = if(in(grp, "wmiexec", "winrm", "localacct", "localgroup", "firewall"), grp, null), disc_g = if(in(grp, "netconf", "netconn", "sysinfo", "user", "geo"), grp, null)
38| stats dc(grp) as grp_cnt, dc(anchor_g) as anchor_cnt, dc(disc_g) as disc_cnt, values(grp) as groups, values(tech) as techs, min(_time) as first_seen, max(_time) as last_seen by hostname, host_ip
39| search anchor_cnt >= 2 and disc_cnt >= 2 and grp_cnt >= 6
40| eval groups = strjoin(", ", groups), techs = strjoin(", ", techs),
41 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)를 집계합니다. WMI 프로세스 생성·PowerShell 원격 세션·로컬 계정 생성·관리자와 원격 데스크톱 그룹 추가·방화벽 허용 규칙 추가 중 2개 이상이 있고(필수 행위군), 네트워크 설정·네트워크 연결·시스템 정보·사용자·국가 확인 정찰 행위군이 2개 이상(disc_cnt)이며, 서로 다른 행위군이 6개 이상이면 탐지합니다. 탐지 결과에는 관찰된 행위군 목록(groups)과 기법 목록(techs), 첫 발생 시각(first_seen)과 마지막 발생 시각(last_seen)을 함께 제공합니다.
Threat analysis
로컬 계정을 만들어 관리자·원격 데스크톱 그룹에 추가하고 3389 포트 방화벽 허용 규칙을 추가하는 것은 공격자가 재접속 경로를 확보하는 행위입니다. WMI 프로세스 생성과 PowerShell 원격 세션은 다른 단말에서 명령을 실행하는 수단이며, 섀도 복사본·이벤트 로그 삭제가 함께 관찰되면 암호화가 임박한 것으로 판단합니다.
False positives
원격 지원 환경을 구성하는 관리 작업에서 계정 생성, 그룹 추가, 방화벽 규칙 추가가 함께 발생할 수 있습니다. 정찰 행위군과 행위군 6개가 함께 요구되어 관리 작업만으로는 탐지되기 어렵지만, 구성 관리 도구가 동작하는 단말은 실행 주체 기준으로 예외 조건을 추가합니다.
Response actions
생성된 계정과 그룹 변경, 추가된 방화벽 규칙을 확인하여 승인된 작업인지 확인합니다. WMI·원격 세션의 대상 단말을 확인하고 그 단말에서 같은 행위가 있는지 조회합니다. 정탐으로 확인되면 계정을 삭제하고 방화벽 규칙을 원래 상태로 복구한 뒤 단말을 격리하며, Windows Temp에 반입된 파일을 확보합니다.