이번 글에서는 Sigma CLI (sigma-cli) 설치부터 첫 변환까지 완벽한 실습 가이드를 드리겠습니다.
SigmaHQ 공식 문서에 따르면 sigma-cli는 pySigma 라이브러리를 기반으로 하며, pip3 install sigma-cli 한 줄로 설치 후 백엔드 플러그인을 추가해 변환하는 방식입니다.
복잡해 보이지 않으시죠? Kali Linux에서도 기본 패키지로 지원되며, 10분이면 첫 쿼리가 나옵니다.
◎ 왜 sigma-cli를 써야 하는가
기존 sigmac은 legacy 도구로, 이제 pySigma 기반의 sigma-cli가 표준입니다.
이 도구는 백엔드 플러그인 시스템을 통해 Splunk, Elastic, QRadar 등 30+ SIEM을 지원하며, 파이프라인으로 필드 매핑까지 자동화합니다.
실무에서 Detection as Code 파이프라인을 구축할 때 필수로, GitHub Actions와 연동해 CI/CD까지 구현 가능합니다.
- 1단계: 환경 준비 (2분)
- Python 3.9+ 확인:
| python3 --version pip3 --version |
- 가상환경 생성 (권장):
| mkdir sigma_lab && cd sigma_lab python3 -m venv sigma_env source sigma_env/bin/activate # Windows: sigma_env\Scripts\activate |
- 2단계: sigma-cli 설치 (1분)
- pipx 사용 (추천):
| python3 -m pipx install sigma-cli pipx ensurepath source ~/.bashrc # 또는 재로그인 |
- 또는 pip:
| pip3 install sigma-cli |
- 소스 빌드 (고급):
| git clone https://github.com/SigmaHQ/sigma-cli.git cd sigma-cli poetry install && poetry shell |
- 설치 확인:
| sigma version |
- 출력: sigma-cli 1.x.x.
- 3단계: 백엔드 플러그인 설치 (2분)
- 사용 가능 플러그인 목록:
| sigma plugin list |
- 출력 예:
| +----------------------+----------+---------+--------------------------------------------------------------+ | Identifier | Type | State | Description | +----------------------+----------+---------+--------------------------------------------------------------+ | splunk | backend | stable | Splunk backend | | elasticsearch | backend | stable | Elasticsearch backend | | ibm-qradar-aql | backend | stable | IBM QRadar AQL backend | +----------------------+----------+---------+--------------------------------------------------------------+ |
- 설치:
| sigma plugin install splunk sigma plugin install elasticsearch sigma plugin install ibm-qradar-aql # QRadar |
- 확인:
| sigma list targets sigma list pipelines |
- Splunk: splunk-windows, Elastic: winlogbeat 등 출력.
- 4단계: Sigma 규칙 준비 (3분)
- SigmaHQ 클론:
| git clone https://github.com/SigmaHQ/sigma.git cd sigma/rules/windows/process_creation # 예시 디렉토리 |
- 테스트 규칙 생성 (powershell.yml):
| title: Suspicious PowerShell Execution id: test-powershell-001 status: stable description: Detects PowerShell with suspicious arguments author: Your Team logsource: category: process_creation product: windows detection: selection: Image|endswith: '\powershell.exe' CommandLine|contains: - 'Invoke-WebRequest' - 'DownloadString' - '-EncodedCommand' filter_legit: CommandLine|contains: 'WindowsUpdate' condition: selection and not filter_legit level: high tags: - attack.execution - attack.t1059.001 |
- 5단계: 첫 변환 실습 (3분)
- Splunk 변환:
| sigma convert powershell.yml --target splunk --pipeline splunk-windows |
- 출력:
| index=* sourcetype="WinEventLog:Security" EventCode="4688" New_Process_Name="*powershell.exe" CommandLine="*Invoke-WebRequest*" OR CommandLine="*DownloadString*" OR CommandLine="*-EncodedCommand*" NOT CommandLine="*WindowsUpdate*" |
- Elastic 변환:
| sigma convert powershell.yml --target elasticsearch --pipeline winlogbeat |
- 출력:
| event.code : "4688" and process.name : "powershell.exe" and (process.command_line : "*Invoke-WebRequest*" or process.command_line : "*DownloadString*" or process.command_line : "*-EncodedCommand*") and not process.command_line : "*WindowsUpdate*" |
- QRadar 변환:
| sigma convert powershell.yml --target ibm-qradar-aql |
- 출력:
| SELECT * FROM events WHERE eventname="4688" AND process_name ENDSWITH "powershell.exe" AND (CommandLine CONTAINS "Invoke-WebRequest" OR ...) |
- 여러 파일 변환:
| sigma convert sigma/rules/windows/process_creation/*.yml --target splunk --pipeline splunk-windows > splunk_rules.txt |
- 6단계: 고급 변환 옵션 (5분)
- 출력 형식 지정:
| # Splunk savedsearches.conf sigma convert powershell.yml --target splunk --pipeline splunk-windows --format savedsearches -o savedsearches.conf |
- 백엔드 옵션:
| sigma convert --target splunk -O sourcetype=sysmon_windows -O index=security --pipeline sysmon |
- 파이프라인 커스텀 (pipelines/my_pipeline.yml 생성 후):
| sigma convert --pipeline pipelines/my_pipeline.yml --target elasticsearch powershell.yml |
- 유효성 검사:
| sigma validate powershell.yml sigma check sigma/rules/windows/process_creation/ |
- 7단계: CI/CD 파이프라인 구축 (5분)
- GitHub Actions 예시 (.github/workflows/convert.yml):
| name: Convert Sigma Rules on: [push] jobs: convert: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Python uses: actions/setup-python@v4 with: python-version: '3.11' - run: pip install sigma-cli - run: sigma plugin install splunk elasticsearch - run: sigma convert rules/*.yml --target splunk --pipeline splunk-windows -o splunk_queries/ - name: Upload Queries uses: actions/upload-artifact@v3 with: name: splunk-queries path: splunk_queries/ |
- push 후: Splunk 쿼리 자동 생성·아티팩트 다운로드.
◎ 트러블슈팅 가이드
- 오류 1: "Backend not found":
| sigma plugin install |
- 오류 2: "Pipeline not found":
| sigma list pipelines # 확인 후 --pipeline splunk-windows 등 |
- 오류 3: 필드 매핑 실패:
| --pipeline winlogbeat # 또는 커스텀 파이프라인 |
- Windows 사용자:
| py -3 -m pip install sigma-cli sigma.exe convert ... |
반응형
'IT > Sigma Rule' 카테고리의 다른 글
| [Sigma Rule] 제9화: Elastic 및 MS Sentinel 환경에서 Sigma 활용하기 (0) | 2026.04.30 |
|---|---|
| [Sigma Rule] 제8화: Splunk 사용자를 위한 Sigma 가이드: SPL 변환 실습 (0) | 2026.04.29 |
| [Sigma Rule] 제6화: 정규표현식보다 쉽다? Value Modifier를 활용한 정밀 패턴 매칭 (0) | 2026.04.27 |
| [Sigma Rule] 제5화: "And? Or?" 탐지 로직의 뼈대, Selection과 Condition 완벽 가이드 (0) | 2026.04.26 |
| [Sigma Rule] 제4화: 로그 소스(Logsource) 정의하기: 윈도우 이벤트부터 클라우드 로그, 네트워크 장비까지 (0) | 2026.04.25 |
