지니언 EDR 로그에서 Git 자격 증명·개인 키 수집, 저장소 복제, rclone 유출이 한 단말에서 이어지는 Lapsus$형 소스 저장소 탈취를 탐지합니다.
개요
쿼리
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 (in(proc, "gitleaks.exe", "trufflehog.exe", "detect-secrets.exe", "ggshield.exe", "noseyparker.exe") or match(cmd_l, "(?:gitleaks|trufflehog)[^\\s]*(?:\\.exe)?\"?\\s+(?:detect|protect|git|filesystem|dir)\\b") or (proc == "git.exe" and match(cmd_l, "\\scredential\\s+fill\\b")) or (proc == "cmdkey.exe" and match(cmd_l, "/generic:\"?git:") and match(cmd_l, "/pass:")) or (proc == "findstr.exe" and match(cmd_l, "\\s/s") and match(cmd_l, "pass(?:word|wd)?|secret|token|api[_-]?key|credential")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "gitleaks(?:\\.exe)?\"?\\s+detect|\\sdetect\\s+--source\\b[^\\r\\n]*--report-(?:path|format)|git\\s+credential\\s+fill|select-string\\b[^\\r\\n]*-pattern\\s+['\"]?[^'\"\\r\\n]*(?:password|passwd|secret|api[_-]?key|aws_secret)"))), "secrets",
14 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "['\"]\\*\\.(?:pem|key|pfx|p12)['\"][\\s,]*['\"]\\*\\.(?:pem|key|pfx|p12|cer|crt)['\"]|(?:get-childitem|gci|dir|ls)\\b[^\\r\\n|]*-(?:filter|include)\\s+['\"]?\\*\\.(?:pfx|p12|pem|key)\\b|cert:\\\\[\\s\\S]*\\.hasprivatekey|export-pfxcertificate")) or (proc == "certutil.exe" and match(cmd_l, "[-/]exportpfx\\b")) or (in(proc, "cmd.exe", "where.exe") and match(cmd_l, "(?:dir|where)\\b[^\\r\\n]*(?:/s|/r)\\b[^\\r\\n]*\\*\\.(?:pfx|p12|pem|key)\\b"))), "privkey",
15 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((proc == "git.exe" and match(ipath, "(?:c:\\\\users\\\\public|c:\\\\perflogs|c:\\\\programdata|c:\\\\windows\\\\temp|\\\\appdata\\\\local\\\\temp|\\\\appdata\\\\roaming|\\\\downloads)\\\\") and match(cmd_l, "\\s(?:clone|fetch|pull|remote\\s+add|ls-remote)\\b")) or (proc == "git.exe" and match(cmd_l, "\\sclone\\s+(?:--mirror|--bare)\\b|\\sclone\\s[^\\r\\n]*https?://[^\\s/@:]+(?::[^\\s/@]+)?@")) or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "api\\.github\\.com/(?:user|orgs/[^/\\s'\"]+)/repos|/api/v4/projects|git\\s+clone\\s+(?:--mirror\\s+)?\\$|https://\\$\\(?\\$[a-z_.]+(?:\\.password)?\\)?@"))), "coderepo",
16 _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",
17 _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",
18 _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",
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-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",
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-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",
23 _schema == "genian-edr-process" and event_subtype == "ProcessStart" and ((proc == "rundll32.exe" and match(cmd_l, "comsvcs(?:\\.dll)?[\\s\\S]*minidump|#\\+?24\\b")) or (in(proc, "procdump.exe", "procdump64.exe", "procdump64a.exe") and match(cmd_l, "\\s-m[ap]\\b[\\s\\S]*lsass|lsass[\\s\\S]*\\s-m[ap]\\b")) or in(proc, "mimikatz.exe", "nanodump.exe", "pypykatz.exe") or (in(proc, "powershell.exe", "pwsh.exe") and match(ps_text, "invoke-mimikatz|sekurlsa::|lsadump::|comsvcs(?:\\.dll)?[\\s\\S]*minidump|minidumpwritedump|out-minidump"))), "lsass")
24| search isnotnull(grp)
25| eval tech = case(grp == "secrets", "T1552.001", grp == "privkey", "T1552.004", grp == "coderepo", "T1213.003", grp == "exfil", "T1048", grp == "filedisc", "T1083", grp == "sysinfo", "T1082", grp == "drop", "T1105", grp == "psbypass", "T1059.001", grp == "exec", "T1204", grp == "wipe", "T1070.004", grp == "lsass", "T1003.001")
26| eval anchor_g = if(in(grp, "secrets", "privkey", "coderepo", "exfil"), grp, null), disc_g = if(in(grp, "filedisc", "sysinfo"), grp, null)
27| 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
28| search anchor_cnt >= 3 and disc_cnt >= 1 and grp_cnt >= 6
29| eval groups = strjoin(", ", groups), techs = strjoin(", ", techs),
30 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)를 집계합니다. 시크릿 스캐너 실행·Git 자격 증명 추출, 인증서·개인 키 파일 수집, Git 저장소 원격 작업·저장소 목록 조회, rclone 클라우드 유출 중 3개 이상이 있고(필수 행위군), 파일 탐색·시스템 정보 정찰 행위군이 1개 이상(disc_cnt)이며, 서로 다른 행위군이 6개 이상이면 탐지합니다. 탐지 결과에는 관찰된 행위군 목록(groups)과 기법 목록(techs), 첫 발생 시각(first_seen)과 마지막 발생 시각(last_seen)을 함께 제공합니다.
위협 분석
소스 저장소와 코드 서명 인증서는 유출 시 공급망 공격과 악성코드 서명에 악용될 수 있는 자산입니다. 시크릿 스캐너로 저장소의 토큰을 검색하고 git credential fill로 저장된 토큰을 추출한 뒤 저장소를 복제하는 것은 소스 코드 탈취 단계입니다. 이름을 바꾼 rclone 실행은 외부 클라우드로의 대량 유출을 의미합니다.
오탐 유형
개발자 단말에서는 Git 원격 작업과 시크릿 스캐너 실행이 일상적으로 발생합니다. 개인 키 수집이나 rclone 유출까지 겹쳐야 탐지 조건을 충족하지만, 백업 용도로 rclone을 쓰는 개발 단말이 있으면 실행 경로와 목적지 기준으로 예외 조건을 추가하여 조정합니다.
대응 방안
추출된 Git 토큰과 수집된 개인 키·인증서를 식별하여 즉시 폐기·재발급합니다. rclone의 목적지와 전송량을 확인하고, 저장소 서버의 접근 로그에서 해당 토큰의 복제 이력을 조회합니다. 정탐으로 확인되면 단말을 격리하고 유출된 저장소의 시크릿을 전부 교체합니다.