Professional Documents
Culture Documents
Asqwe PDF
Asqwe PDF
다형성 바이러스 분석 방법
㈜ AhnLab / ASEC
한창규 선임 연구원
목차
Ⅰ. 바이러스 개요
Ⅱ. 바이러스 분석
Ⅲ. 다형성 바이러스
Ⅳ. Case Study
Ⅴ. 결 론
2
Ⅰ. 바이러스 개요
1. 바이러스 정의
2. 바이러스 분류
3. 바이러스 발전 단계
4. 감염 기법
3
1.바이러스 정의
악성코드 정의
9 The Malware (for "malicious software") is any program
or file that is harmful to a computer user.
Thus, malware includes computer Viruses, Worms,
Trojan horses, and also SpyWare, programming that
gathers information about a computer user without
permission. (영문 Terms)
바이러스 정의
9 We define a computer ‘virus’ as a program can
‘infect’ other programs by modifying them to include
a possibly evolved copy of itself. ( Fred Cohen 1984 ]
4
2.바이러스 분류
바이러스 분류
기준 세부내용
■ 부트바이러스 (부트 섹터 감염, Brain, Monkey, Anti-CMOS )
■ 파일 바이러스 (COM, EXE 실행파일 감염, 예루살렘, Sunday, Scorpion, Crow )
감염 대상
■ 부트/파일 바이러스 (부트섹터, 파일 모두 감염, Invader(1990), 안락사(Euthanasia))
■ 매크로 바이러스 (XM/Laroux)
5
3.바이러스 발전 단계
제
제 11세대
세대
• 단순한 구조, 분석 용이
(Primitive)
(Primitive)
• Stoned Virus, Jerusalem Virus
제제 22세대
세대
(Encryption)
(Encryption) • 암호화 기법 사용
• Cascade Virus, Slow Virus
제
제 33세대
세대
(Stealth) • 은폐 기법 사용
(Stealth)
• Joshi Virus, Wanderer Virus
제
제 44세대
세대
(Armour) • 분석 방해 (Polymorphic, EPO 기법)
(Armour)
• Whale Virus
6
4.감염 기법 (1/4)
Entry Point를 수정하는 방법
감염전 프로그램 크기
감염전 프로그램
Entry Point
감염후 프로그램 크기
Entry Point
7
4.감염 기법 (2/4)
Entry Point 부분의 코드를 수정하는 방법
감염전 프로그램 크기
감염전 프로그램
Entry Point
11
8
4.감염 기법 (3/4)
EPO (Entry Point Obscuring) 기법
감염전 프로그램 크기
감염전 프로그램
Entry Point
11
감염후 프 로 그 램 바이러스
22
Entry Point
9
4.감염 기법 (4/4)
EPO (Entry Point Obscuring) 기법
[감염전 코드]
코드]
[감염후 코드]
코드]
10
Ⅱ. 바이러스 분석
1. 사전 지식
2. 분석 과정
3. 진단법
11
1.사전 지식(1/14)
분석
분석 도구
도구 운영체제
운영체제 // 통신
통신 분석
분석 기본
기본 지식
지식
12
1.사전 지식(2/14)
StartUp Code
[메인 덧셈 프로그램]
프로그램] [StartUp Code]
13
1.사전 지식(3/14)
실행파일 구조
14
1.사전 지식(4/14)
실행파일 구조 (Import Directory Table)
15
1.사전 지식(5/14)
실행파일 구조 (Export Directory Table)
16
1.사전 지식(6/14)
실행 압축 (분석지연, AV 진단우회, 다양한 변형 제작)
[실행압축 종류]
종류]
17
1.사전 지식(7/14)
실행 압축 (OEP)
[실행압축 이전 OEP]
[실행압축 이후 OEP]
18
1.사전 지식(8/14)
DLL Injection 기법 1
레지스트리 등록 기법
- user32.dll 를 사용하는 프로그램에 Injection (NT 계열)
- user32.dll 이 다른 프로세스에 attach 될때 레지스트리에 등록된 dll를 로드하여 attach
시켜줌
[HKLM\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Windows]
"AppInit_DLLs"="d:\Work\Test\Debug\Test.dll “
19
1.사전 지식(9/14)
DLL Injection 기법 2
원본 : ws2_32.dll Î ws2_32_org.dll
Hook : hook.dll Î ws2_32.dll
Remote Thread 기법
- 타 프로세스에 Thread를 생성하는 API 이용 (NT 계열)
- DLL Injection를 사용하는 최근 악성코드의 대부분이 이 기법 사용
- CreateRemoteThread, WriteProcessMemory API 사용
20
1.사전 지식(10/14)
[Win32/Korgo.worm DLL Injection]
21
1.사전 지식(11/14)
Stealth 기법
9 사용자가 악성코드의 설치/ 감염 여부를 확인 못하도록 함
9 악성 코드 진단 회피
고전적 기법
최신 기법
22
1.사전 지식(12/14)
Stealth 기법 (SSDT 후킹)
23
1.사전 지식(13/14)
WFP (Windows File Protection)
9 A mechanism that protects system files from being modified or deleted
9 시스템 안정성 (Stability) 확보
9 시스템 무결성 (Integrity] 확보
9 DLL HELL 문제 해결
SFC.DLL SFCFILES.DLL
System
System File
File
SFC_OS.DLL Checker SFC.EXE
Checker
24
1.사전 지식(14/14)
WFP (Windows File Protection) 무력화 기법
25
2.분석 과정(1/2)
기초
기초 분석 (외형 분석
분석(외형 분석,, 증상
증상 분석
분석,, 자료 분석)) Î
자료 분석 Î 상세분석
상세분석
외형 분석 증상 분석 자료 분석 상세 분석 엔진 반영
분 석 과 정
26
2.분석 과정(2/2)
바이러스 분석 과정
1. 기본 외형 분석
2. 샘플 셋 생성 및 기본 증상 확인
3. 바이러스의 감염 유형 파악(전위형, 후위형)
4. 디버깅을 통한 바이러스의 전반적인 기능 확인
(감염 대상, 감염 조건, 감염 기법 등등)
5. 호스트 프로그램 실행 부분 분석
6. 바이러스 특징 분석 (일반, 암호화, 다형성 등등)
7. 진단명 명명
8. 진단 문자열 추출
9. 치료 데이터 작성 및 검증 작업
27
3.진단법 (1/3)
바이러스 진단법
1. Signature 기반 진단법
- 진단 위치 (Entry Point / 프로그램의 전체 크기)
- Signature (특정 영역 / 특정 코드)
- 특정 위치 진단법 (by Ahnlab)
2. Non-Signature 기반 진단법
- 전용진단 함수 제작
선행조건 검사
악성코드 각각의 특징을 검사
3. 행위 기반 진단법
- 악성코드 행위에 대한 진단
파일 이름, 인젝션, 파일 Drop, 통신 포트 오픈 등등
28
3.진단법 (2/3)
Signature 기반 진단법
[특정 영역 Signature]
[특정 OP 코드]
코드]
29
3.진단법 (3/3)
Non-Signature 기반 진단법
[전용 진단 함수]
함수]
30
Ⅲ. 다형성 바이러스
1. 다형성 바이러스 개요
2. 변형 기법
3. 다형성 바이러스 진단
31
1.다형성 바이러스 개요 (1/6)
암호화 바이러스
1. 암호화 Key
- 동일한 Decryption 루틴 Encryption
Encryption
- 가변 Key 값 Key
Key
2. Decoding Buffer
- Overwritting hello $#!!%
- Stack Memory
- Allocated Memory
Key
Key
3. 암호화 기법 Substitution
Substitution Table
Table
- Linear / Non-Linear
- Multiple Layer
- RDA
32
1.다형성 바이러스 개요 (2/6)
암호화 바이러스
[감염 상태]
상태]
EP
Host
11
Program
Decoding Routine
22
Encoded Virus
Body
33
1.다형성 바이러스 개요 (3/6)
Polymorphic Virus
[Polymorphic Virus]
[Encrypted Virus]
EP
EP
Encoded Virus
Decoding Routine MtE , TPE , … Body
22
Encoded Virus Mutation
Body Engine
34
1.다형성 바이러스 개요 (4/6)
Polymorphic Virus
[MtE]
35
1.다형성 바이러스 개요 (5/6)
Metamorphic Virus
G1
G1 *#!^ G1
%
•
Encoding G2 •
•
G2
G2
&*^
•
%#
Virus Virus Metamorphic G3 •
원본
• 원본
•
• •
• •
Decoding
• G4
Gn
Gn ~!#$
^ Gn
36
1.다형성 바이러스 개요 (6/6)
Metamorphic Virus
[ZMIST]
37
2.변형 기법 (1/4)
사용 명령어 변경
EE :: ModR/M
ModR/M follows
follows the
the opcode
opcode and
and specifies
specifies the
the operand.
operand.
G
G :: The
The reg
reg field
field of
of ModR/M
ModR/M select
select aa general
general register.
register.
38
2.변형 기법 (2/4)
Garbage 명령 삽입
39
2.변형 기법 (3/4)
사용 Register 변경
40
2.변형 기법 (4/4)
Permutation
V1 V2
22
11
V2 V5
Permutation
V3 V1 44
V4 V4
33
V5 V3
41
3.다형성 바이러스 진단 (1/3)
다형성 바이러스 진단
1. Signature 기반 진단
- 다형성 엔진에 대한 시그니쳐 진단
- 오진 / 비정상 치료
2. 전용진단 함수
- 선행 조건
- 사용된 명령어 패턴 기반 진단
3. Emulation
- Emulation 시작 위치 ( EPO )
- Emulation 종료
- 진단 속도 / 예외 처리
- Anti-Emulation 기법에 대한 대비
42
3.다형성 바이러스 진단 (2/3)
전용 진단 함수 (명령어 패턴)
[Win32/Zmist]
43
3.다형성 바이러스 진단 (3/3)
Anti-Emulation Technique
5. Use of API
44
Ⅳ. Case Study
1. Win32/Polip 분석
2. 진단
3. 치료
45
3.Win32/Polip 분석 (1/9)
Win32/Polip Virus
EP
1. EPO 기법 사용 EP
PE Header
3. 섹션 빈 공간에 코드 추가 .text
4. NULL 섹션 추가 Virus
Virus
.data
5. 파일 크기 증가 (60 ~ 70 KB)
.null
6. Win32.Polipos 1.2 by Joseph
.rsrc
46
3.Win32/Polip 분석 (2/9)
Polymorphic Engine - EPO (Entry Point Obscruing)
[Pinball.exe 감염]
감염] [Msn6.exe 감염]
감염]
47
3.Win32/Polip 분석 (3/9)
Polymorphic Engine – Random Memory Access
48
3.Win32/Polip 분석 (4/9)
Polymorphic Engine – Garbage 명령 삽입
[Pinball.exe 감염]
감염] [Msn6.exe 감염]
감염]
49
3.Win32/Polip 분석 (5/9)
Polymorphic Engine – Random Code Execution
50
3.Win32/Polip 분석 (6/9)
XTEA (eXtended Tiny Encryption Algorithm) 원형
51
3.Win32/Polip 분석 (7/9)
XTEA (eXtended Tiny Encryption Algorithm) 변형
52
3.Win32/Polip 분석 (8/9)
XTEA (eXtended Tiny Encryption Algorithm) 변형
53
3.Win32/Polip 분석 (9/9)
Win32/Polip XTEA – Decoding 루틴 구조
54
2.Win32/Polip 진단 (1/2)
Emulation ( Pre-Condition 체크 )
55
2.Win32/Polip 진단 (2/2)
진단문자열 ( Virus Body )
56
3.Win32/Polip 치료 (1/2)
치료 정보
V1
V2
0x7554
0x7554 치료
치료 데이터
데이터
V3
06 FF 25 84 11 00 01
V4
0x759E
0x759E 치료
치료 위치
위치
02 AB 63 00 00
V5
BC C1 01 00
V6
57
3.Win32/Polip 치료 (2/2)
치료 ( Entry Point 치료 Vs 원본 파일에 가깝게 )
EP
EP
PE Header
EP
EP
Section Table PE Header
Section Table
.text
Virus 치료 .text
Virus
.data
.data
.null
.rsrc
.rsrc
58
Ⅴ. 결 론
59
결론
3. Scanning Speed
60
참고 문헌
http://www.ahnlab.com
http://www.ncsc.go.kr
http://www.kisa.or.kr
http://www.sysinternals.com
http://www.rootkit.com
http://www.microsoft.com/korea/technet/security
http://msdn.microsoft.com/default.aspx
http://vx.netlux.org/lib/vmd03.html
http://www.bitdefender.com/VIRUS-1000066-en--Win32.Polip.A.html
http://secunia.com/virus_information
http://www.virusbtn.com/index
The Windows 2000 Device Driver Book
Inside Microsoft Windows2000 Third Edition (Mark E. Russinovich)
Programming Applications for Microsoft Windows Fourth Edition (Jeffrey Ritcher)
Subverting The Windows Kernel Rootkits (Greg Hoglund)
Programming the Microsoft Windows Driver Model (Walter Oney)
The Art of Computer Virus Research and Defender (Peter Szor)
Hacker Dissembling Uncovered (Kris Kaspersky)
61
Q/A
62