MYSQL 로그 수집

다음에서 지원:

이 문서에서는 Bindplane을 사용하여 Google Security Operations에 MYSQL 로그를 처리하는 방법을 설명합니다. 파서는 먼저 grok를 사용하여 MySQL SYSLOG 메시지에서 공통 필드를 추출합니다. 그런 다음 조건부 브랜치 (if, else if) 및 정규식 일치를 사용하여 로그 메시지 내에서 특정 이벤트 유형을 식별하고 관련 정보를 추출하여 통합 데이터 모델 (UDM) 스키마에 매핑합니다.

시작하기 전에

다음 기본 요건이 충족되었는지 확인합니다.

  • Google SecOps 인스턴스
  • Windows 2016 이상 또는 systemd가 있는 Linux 호스트
  • 프록시 뒤에서 실행되는 경우 방화벽 포트가 열려 있습니다.
  • MySQL 호스트에 대한 권한이 있는 액세스
  • MySQL DB 및 Rsyslog 설치

Google SecOps 처리 인증 파일 가져오기

  1. Google SecOps 콘솔에 로그인합니다.
  2. SIEM 설정 > 수집 에이전트로 이동합니다.
  3. 처리 인증 파일을 다운로드합니다. Bindplane가 설치될 시스템에 파일을 안전하게 저장합니다.

Google SecOps 고객 ID 가져오기

  1. Google SecOps 콘솔에 로그인합니다.
  2. SIEM 설정 > 프로필로 이동합니다.
  3. 조직 세부정보 섹션에서 고객 ID를 복사하여 저장합니다.

Bindlane 에이전트 설치

Windows 설치

  1. 관리자 권한으로 명령 프롬프트 또는 PowerShell을 엽니다.
  2. 다음 명령어를 실행합니다.

    msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
    

Linux 설치

  1. 루트 또는 sudo 권한으로 터미널을 엽니다.
  2. 다음 명령어를 실행합니다.

    sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
    

추가 설치 리소스

추가 설치 옵션은 설치 가이드를 참고하세요.

Syslog를 수집하고 Google SecOps로 전송하도록 Bindplane 에이전트 구성

  1. 구성 파일에 액세스합니다.
    • config.yaml 파일을 찾습니다. 일반적으로 Linux의 /etc/bindplane-agent/ 디렉터리 또는 Windows의 설치 디렉터리에 있습니다.
    • 텍스트 편집기 (예: nano, vi, 메모장)를 사용하여 파일을 엽니다.
  2. 다음과 같이 config.yaml 파일을 수정합니다.

    receivers:
        udplog:
            # Replace the port and IP address as required
            listen_address: "0.0.0.0:514"
    
    exporters:
        chronicle/chronicle_w_labels:
            compression: gzip
            # Adjust the path to the credentials file you downloaded in Step 1
            creds: '/path/to/ingestion-authentication-file.json'
            # Replace with your actual customer ID from Step 2
            customer_id: <customer_id>
            endpoint: malachiteingestion-pa.googleapis.com
            # Add optional ingestion labels for better organization
            ingestion_labels:
                log_type: 'MYSQL'
                raw_log_field: body
    
    service:
        pipelines:
            logs/source0__chronicle_w_labels-0:
                receivers:
                    - udplog
                exporters:
                    - chronicle/chronicle_w_labels
    
  3. 인프라에서 필요에 따라 포트와 IP 주소를 바꿉니다.

  4. <customer_id>를 실제 고객 ID로 바꿉니다.

  5. /path/to/ingestion-authentication-file.jsonGoogle SecOps 처리 인증 파일 가져오기 섹션에서 인증 파일이 저장된 경로로 업데이트합니다.

Bindplane 에이전트를 다시 시작하여 변경사항 적용

  • Linux에서 Bindplane 에이전트를 다시 시작하려면 다음 명령어를 실행합니다.

    sudo systemctl restart bindplane-agent
    
  • Windows에서 Bindplane 에이전트를 다시 시작하려면 서비스 콘솔을 사용하거나 다음 명령어를 입력하면 됩니다.

    net stop BindPlaneAgent && net start BindPlaneAgent
    

MySQL에서 Syslog 구성

  1. SSH를 사용하여 MySQL 호스트에 로그인합니다.

  2. MySQL 데이터베이스에 연결합니다.

    mysql -u root -p
    
  3. server_audit.so 감사 플러그인을 확인합니다.

    show variables like 'plugin_dir';
    
  4. 플러그인 디렉터리 내에 플러그인 파일이 없으면 다음 명령어를 사용하여 플러그인을 설치합니다.

    install plugin server_audit soname 'server_audit.so';
    
  5. 플러그인이 설치되고 사용 설정되어 있는지 확인합니다.

    show plugins;
    
  6. vi를 사용하여 /etc/my.cnf 파일을 수정하고 다음을 사용 설정한 다음 파일을 저장합니다.

    server_audit_events='CONNECT,QUERY,TABLE'
    server_audit_file_path=server_audit.log
    server_audit_logging=ON
    server_audit_output_type=SYSLOG
    server_audit_syslog_facility=LOG_LOCAL6
    
  7. 다음 명령어를 사용하여 감사 변수를 확인합니다.

    show global variables like "server_audit%";
    
  8. 다음 명령어를 사용하여 감사가 사용 설정되어 있는지 확인합니다.

    Show global status like 'server_audit%';
    
  9. vi를 사용하여 /etc/rsyslog.conf 파일을 수정하여 UDP 사용을 사용 설정하고 파일을 저장합니다.

    *.* @@<bindplane-agent-ip>:<bindplane-agent-port>
    
  10. <bindplane-agent-ip><bindplane-agent-port>를 Bindplane 에이전트 구성으로 바꿉니다.

  11. MySQL 서비스를 다시 시작하고 MySQL 데이터베이스에 연결합니다.

    /etc/init.d/mysqld restart
    

UDM 매핑 표

로그 필드 UDM 매핑 논리
action read_only_udm.metadata.event_type 값이 Created이면 FILE_CREATION, 값이 Deleted이면 FILE_DELETION, 그 외의 경우에는 변경되지 않습니다.
데이터베이스 read_only_udm.target.resource.parent
db_hostname read_only_udm.target.hostname
db_user read_only_udm.target.user.userid
description read_only_udm.security_result.description
error_details 임시 변수이므로 무시하세요.
error_level read_only_udm.security_result.severity 값이 error이면 ERROR, warning이면 MEDIUM, note이면 INFORMATIONAL, 그 외의 경우에는 변경되지 않습니다.
error_message read_only_udm.security_result.summary
file_path read_only_udm.target.file.full_path
file_size read_only_udm.target.file.size
호스트 이름 read_only_udm.principal.hostname
inner_message read_only_udm.security_result.description
요약 read_only_udm.metadata.product_event_type
테이블 read_only_udm.target.resource.name
table_not_found 임시 변수이므로 무시하세요.
타임스탬프 read_only_udm.metadata.event_timestamp
read_only_udm.extensions.auth.type 정적 값 - MACHINE
read_only_udm.metadata.event_type 정적 값 - USER_LOGIN, GENERIC_EVENT, STATUS_UPDATE, FILE_CREATION, FILE_DELETION
read_only_udm.metadata.log_type 정적 값 - MYSQL
read_only_udm.metadata.product_name 정적 값 - MySQL
read_only_udm.metadata.vendor_name 정적 값 - Oracle Corporation
read_only_udm.security_result.action 정적 값 - BLOCK
read_only_udm.target.resource.resource_type 정적 값 - DATABASE, TABLE

도움이 더 필요하신가요? 커뮤니티 회원 및 Google SecOps 전문가의 답변을 받아 보세요.