C.W.K.
Stream
Lesson 14 of 14 · published

사고 대응

~18 min · incident, compromise, forensics, recovery

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

"침해" 가 어떻게 보이는지

대부분 home-fleet 침해가 우연히 잡혀 — top 위의 설명 안 되는 프로세스, authorized_keys 의 이상한 항목, 가본 적 없는 IP 의 4 AM 로그인. 기술이 패턴 일찍 인식. 아래 목록이 스캔할 거; 대응 섹션이 뭐 잘못됐다 의심하면 할 일.

스캔할 red flag

  • authorized_keys 의 모르는 키 — 모르는 키, 특히 운영 안 하는 username 이나 host 참조하는 comment.
  • 이상한 시간 또는 IP 의 로그인 — 가본 적 없는 나라의 3 AM.
  • 예상 못한 프로세스 — crypto miner, reverse shell, 설치 안 한 데몬. top + ps aux + lsof -i.
  • 수정된 시스템 파일/etc/ssh/, crontab, /etc/passwd, /etc/sudoers.
  • 새 user 계정/etc/passwd 의 모르는 계정.
  • Outbound 연결 — 사용에 말 안 되는 IP 로의 수립된 세션.

Code

빠른 triage 명령·bash
# 1. authorized_keys audit on every fleet machine
ssh-keygen -l -f ~/.ssh/authorized_keys

# 2. Recent logins
last -50
lastb -20      # failed (Linux, sudo)
w

# 3. Unusual processes
ps -ef | grep -v "$(whoami)\|root" | head -30
ps aux --sort=-%cpu | head
lsof -i -P -n | grep ESTABLISHED

# 4. Crontab inventory
crontab -l
sudo ls -la /etc/cron.* 2>/dev/null
sudo find /var/spool/cron 2>/dev/null

# 5. New users
cut -d: -f1,3 /etc/passwd | grep -v 'nologin\|false'

# 6. Suspicious files modified recently
sudo find /etc -mtime -7 -type f
sudo find /usr/local/bin -mtime -30 -type f

# 7. Outbound connections summary
netstat -an | awk '/ESTABLISHED/ {print $5}' | sort | uniq -c | sort -rn
침해 확인됐을 때·bash
# 1. ISOLATE — disconnect from the network
sudo ifconfig en0 down                  # macOS
sudo systemctl stop NetworkManager      # Linux (or `ifconfig eth0 down`)

# 2. Snapshot for forensics — disk image, log copies
# (out of scope for this lesson — but do it before any recovery)

# 3. Rotate ALL keys — not just on this machine
#    Assume agent forwarding may have spread the compromise

# 4. Audit authorized_keys on every server in the fleet
for host in $(cat ~/.fleet/all.txt); do
    echo "=== $host ==="
    ssh "$host" 'cat ~/.ssh/authorized_keys'
done

# 5. Review logs for the suspected timeframe
sudo grep sshd /var/log/auth.log | grep 'Accepted'

# 6. If you can't determine scope — wipe and rebuild
#    Better than "clean" with hidden persistence

External links

Exercise

오늘, 모든 거 fine 한 동안 모든 fleet 머신에 풀 triage block 실행. 출력 bookmark. 그게 baseline — fleet 의 "normal" 모양. 다음에 뭐 이상 느껴지면 이 baseline 과 diff. Baseline 없이 anomaly detection 은 그냥 추측; 있으면 tractable.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.