지니언 EDR 로그에서 BITS 내려받기, Defender 예외 추가, 포트 스캔, RDP 접속이 WMI 정찰과 함께 한 단말에서 나타나는 Medusa 랜섬웨어 내부 확산 준비를 탐지합니다.
개요
쿼리
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 ((proc == "bitsadmin.exe" and match(cmd_l, "[/-](?:transfer|addfile|create|setnotifycmdline|resume)\\b")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "start-bitstransfer\\b[^\\r\\n]*-source\\s+['\"]?https?://|bitsadmin(?:\\.exe)?\\s+[/-](?:transfer|addfile)"))), "bits",
14 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "wfreerdp.exe", "wfreerdp_win64.exe", "xfreerdp.exe", "sdl-freerdp.exe") or match(cmd_l, "freerdp[^\\s]*\\.exe\"?\\s+/v:") or (proc == "mstsc.exe" and match(cmd_l, "/v:")) or (proc == "cmdkey.exe" and match(cmd_l, "/(?:generic|add):\"?termsrv/"))), "rdp",
15 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "nmap.exe", "masscan.exe", "portqry.exe", "advanced_ip_scanner.exe", "netscan.exe", "ipscan.exe") or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "test-netconnection[\\s\\S]*-port\\b|\\btnc\\b[\\s\\S]*-port\\b|net\\.sockets\\.tcpclient[\\s\\S]*\\.(?:connect|beginconnect|connectasync)\\("))), "portscan",
16 _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",
17 _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",
18 _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",
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 _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|users|accounts)\\b") and not(match(cmd_l, "/(?:add|del|delete|do|dom|doma|domai|domain)\\b"))) or (proc == "wmic.exe" and match(cmd_l, "\\buseraccount\\b[\\s\\S]*\\b(?:get|list)\\b")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "get-localuser\\b|get-aduser\\b|win32_useraccount\\b"))), "acct",
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, "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",
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 (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",
25 _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",
26 _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",
27 _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")
28| search isnotnull(grp)
29| eval tech = case(grp == "bits", "T1197", grp == "rdp", "T1021.001", grp == "portscan", "T1046", grp == "defimpair", "T1685", grp == "sysinfo", "T1082", grp == "proclist", "T1057", grp == "filedisc", "T1083", grp == "acct", "T1087", grp == "user", "T1033", grp == "netconf", "T1016", grp == "drop", "T1105", grp == "exec", "T1204", grp == "shadow", "T1490", grp == "nativeapi", "T1106", grp == "wipe", "T1070.004")
30| eval anchor_g = if(in(grp, "bits", "rdp", "portscan", "defimpair"), grp, null), disc_g = if(in(grp, "sysinfo", "proclist", "filedisc", "acct", "user", "netconf"), grp, null)
31| 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
32| search anchor_cnt >= 2 and disc_cnt >= 3 and grp_cnt >= 7
33| eval groups = strjoin(", ", groups), techs = strjoin(", ", techs),
34 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)를 집계합니다. BITS 작업 내려받기·명령줄 RDP 클라이언트 접속·포트 스캔·Defender 예외 추가 중 2개 이상이 있고(필수 행위군), 시스템·프로세스·파일·계정·사용자·네트워크 정찰 행위군이 3개 이상(disc_cnt)이며, 서로 다른 행위군이 7개 이상이면 탐지합니다. 탐지 결과에는 관찰된 행위군 목록(groups)과 기법 목록(techs), 첫 발생 시각(first_seen)과 마지막 발생 시각(last_seen)을 함께 제공합니다.
위협 분석
bitsadmin으로 도구를 내려받고 Defender 예외 경로를 추가하는 것은 보안 제품의 검사를 피해 공격 도구를 반입하는 준비 단계입니다. 이어서 포트 스캔과 명령줄 RDP 클라이언트 접속이 나타나면 내부의 다른 서버로 이동을 시도하는 것으로 판단합니다. 섀도 복사본 삭제가 함께 관찰되면 암호화가 임박한 상태입니다.
오탐 유형
네트워크 관리자가 포트 스캔 도구로 점검하거나 소프트웨어 업데이트가 BITS 작업을 사용하는 경우 필수 행위군 일부가 관찰될 수 있습니다. 점검용 단말은 hostname 기준으로, 업데이트 프로그램은 BITS 작업의 내려받기 주소 기준으로 예외 조건을 추가합니다.
대응 방안
추가된 Defender 예외 경로와 BITS 작업이 내려받은 주소·파일을 확인합니다. 포트 스캔 대상 대역과 RDP 접속 대상 서버를 확인하고, 그 서버의 로그온 이력을 조회합니다. 정탐으로 확인되면 Defender 예외를 제거하고 단말을 격리하며, 접속에 쓰인 계정의 암호를 변경합니다.