지니언 EDR 로그에서 DLL 사이드로딩 실행, 백신 차단 점검, C2 POST 전송, 예약 작업 등록이 한 단말에서 이어지는 Mustang Panda형 침투를 탐지합니다.
개요
쿼리
1table duration=30m EDR_GENIAN
2| search (_schema == "genian-edr-file" and in(event_subtype, "FileCreate", "FileDelete"))
3 or (_schema == "genian-edr-module" and event_subtype == "ModuleLoad")
4 or (_schema == "genian-edr-network" and event_subtype == "NetworkConnect")
5 or (_schema == "genian-edr-process" and event_subtype == "ProcessStart")
6| search len(trim(hostname)) > 0
7| eval psrc = if(len(trim(image_path)) > 0, trim(image_path), trim(image))
8| eval proc = lower(substr(psrc, lastindexof(psrc, "\\") + 1)), ipath = lower(psrc), cmd_l = lower(nvl(cmd_line, "")),
9 i_dir = if(lastindexof(psrc, "\\") >= 0, lower(substr(psrc, 0, lastindexof(psrc, "\\"))), ""),
10 par = lower(nvl(substr(parent_image, lastindexof(parent_image, "\\") + 1), "")), hostname = lower(trim(hostname))
11| 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)
12| 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)
13| eval fpath = lower(nvl(file_path, "")), f_dir = if(lastindexof(file_path, "\\") >= 0, lower(substr(file_path, 0, lastindexof(file_path, "\\"))), "")
14| eval grp = case(
15 _schema == "genian-edr-module" and event_subtype == "ModuleLoad" and (f_dir == i_dir and match(fpath, "(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\programdata|c:\\\\windows\\\\temp|\\\\appdata\\\\local\\\\temp|\\\\appdata\\\\roaming|\\\\downloads)\\\\") and match(fpath, "\\.dll$") and not(match(fpath, "\\\\(?:python[0-9]*|msys-[^\\\\]+|cyg[^\\\\]+|lib[^\\\\]+|zlib[^\\\\]*|vcruntime[^\\\\]*|msvc[pr][^\\\\]*|ucrtbase|api-ms-win-[^\\\\]+|concrt[^\\\\]*|qt[0-9][^\\\\]*)\\.dll$"))), "sideload",
16 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and (in(proc, "powershell.exe", "pwsh.exe", "cmd.exe") and (match(ps_text, "\\b(?:copy|copy-item|cp|cpi|move|move-item|xcopy)\\s[^\\r\\n]*c:\\\\windows\\\\system32\\\\[\\s\\S]*(?:get-filehash|certutil[^\\r\\n]*-hashfile)") or match(ps_text, "\\b(?:copy|copy-item|cp|cpi|xcopy)\\s[^\\r\\n]*(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\programdata|c:\\\\windows\\\\temp|\\\\appdata\\\\local\\\\temp|\\\\appdata\\\\roaming|\\\\downloads)\\\\[\\s\\S]*(?:get-filehash|certutil[^\\r\\n]*-hashfile)[\\s\\S]*(?:get-filehash|certutil[^\\r\\n]*-hashfile)[\\s\\S]*-eq\\b"))), "avcheck",
17 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "(?:invoke-(?:webrequest|restmethod)|\\biwr\\b|\\birm\\b)[\\s\\S]*-method\\s+['\"]?(?:post|put)\\b[\\s\\S]*-(?:infile|body)\\b|(?:invoke-(?:webrequest|restmethod)|\\biwr\\b|\\birm\\b)[\\s\\S]*-(?:infile|body)\\b[\\s\\S]*-method\\s+['\"]?(?:post|put)\\b|\\.upload(?:file|data|string)(?:async)?\\s*\\(")) or (proc == "curl.exe" and match(cmd_l, "(?:^|\\s)(?:-t|--upload-file)\\s+\\S|(?:^|\\s)(?:-f|--form)\\s+['\"]?[^\\s'\"]*=@|(?:^|\\s)(?:--data-binary|-d|--data)\\s+['\"]?@")) or (proc == "bitsadmin.exe" and match(cmd_l, "/transfer\\b[\\s\\S]*/upload\\b"))), "c2post",
18 _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",
19 _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",
20 _schema == "genian-edr-file" and event_subtype == "FileCreate" and (match(fpath, "\\.(?:zip|7z|rar)$") and (indexof(fpath, "c:\\users\\public\\") == 0 or indexof(fpath, "c:\\perflogs\\") == 0 or in(f_dir, "c:\\programdata", "c:\\windows\\temp")) and not(in(proc, "msiexec.exe", "trustedinstaller.exe", "tiworker.exe", "mpsigstub.exe", "mpcmdrun.exe", "msmpeng.exe", "dismhost.exe", "system", "svchost.exe"))), "archdrop",
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-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",
23 _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",
24 _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",
25 _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",
26 _schema == "genian-edr-file" and event_subtype == "FileDelete" and (match(proc, "^(?:msmpeng|mssense|sentinelagent|csfalconservice|cylancesvc|mcshield|bdservicehost|savservice|sophos|ekrn|avp\\.exe|ntrtscan|tmbmsrv|cbdefense|repmgr|xagt|elastic-endpoint|vsserv|ccsvchst|avastsvc|v3svc|ayagent)") and match(fpath, "(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\programdata|c:\\\\windows\\\\temp|\\\\appdata\\\\local\\\\temp|\\\\appdata\\\\roaming|\\\\downloads)\\\\") and match(fpath, "\\.(?:exe|dll|scr|com|pif|cpl|sys|swf|jar|js|jse|vbs|vbe|wsf|hta|ps1|bat|cmd|lnk|docm|xlsm|zip|rar|7z|iso|img|txt)$") and not(match(fpath, "^c:\\\\programdata\\\\microsoft\\\\"))), "avquar",
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 _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")
29| search isnotnull(grp)
30| eval tech = case(grp == "sideload", "T1574.001", grp == "avcheck", "T1497", grp == "c2post", "T1041", grp == "schtask", "T1053.005", grp == "drop", "T1105", grp == "archdrop", "T1105", grp == "exec", "T1204", grp == "webc2", "T1071.001", grp == "user", "T1033", grp == "procdisc", "T1057", grp == "sysinfo", "T1082", grp == "avquar", "T1587.001", grp == "wipe", "T1070.004", grp == "psbypass", "T1059.001")
31| eval anchor_g = if(in(grp, "sideload", "avcheck", "c2post", "schtask"), grp, null)
32| 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
33| search anchor_cnt >= 3 and grp_cnt >= 6
34| eval groups = strjoin(", ", groups), techs = strjoin(", ", techs),
35 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 로드(사이드로딩)·사본 해시 비교(백신 차단 점검)·PowerShell POST 전송·예약 작업 등록 중 3개 이상이 있고(필수 행위군), 서로 다른 행위군이 6개 이상이면 탐지합니다. 탐지 결과에는 관찰된 행위군 목록(groups)과 기법 목록(techs), 첫 발생 시각(first_seen)과 마지막 발생 시각(last_seen)을 함께 제공합니다.
위협 분석
압축 파일에 정상 실행 파일과 악성 DLL을 함께 넣어 보내고 사용자가 실행 파일을 열면 DLL이 로드되게 하는 방식은 Mustang Panda의 대표적인 유입 형태입니다. SYSTEM 예약 작업으로 지속성을 확보하고 사용자 정보·OS 시리얼·시스템 정보를 PowerShell POST로 전송하는 것은 감염 단말을 C2에 등록하는 과정입니다.
오탐 유형
관리 스크립트가 PowerShell로 자산 정보를 내부 서버에 POST로 전송하고 예약 작업으로 등록돼 있는 경우 필수 행위군 2개가 관찰될 수 있습니다. 사이드로딩이나 백신 점검이 겹쳐야 탐지 조건을 충족하며, 확인된 자산 수집 스크립트는 전송 목적지 기준으로 예외 조건을 추가합니다.
대응 방안
POST 전송의 목적지와 전송된 정보를 확인하고, 사이드로딩에 쓰인 실행 파일·DLL과 원본 압축 파일을 확보합니다. 등록된 예약 작업의 실행 대상을 확인합니다. 정탐으로 확인되면 예약 작업을 삭제하고 단말을 격리하며, 목적지 주소를 차단하고 같은 주소와 통신한 단말을 조회합니다.