Reverse Engineering and Applications to
Anti-Malware
Nguyen Minh Hai
Ho Chi Minh City University of Technology (HCMUT)
November 2015
Agenda
1. Introduction
2. Anti-Research Techniques
1. Indirect Jump
2. Overlapping Instruction
3. Self-modifying Code
4. Encryption
5. Structured Exception Handler
6. Anti-Debugging
7. Anti-Emulation
3. Conclusions
1
Introduction
2
Reverse Engineering
• Reverse engineering (RE) is the process of
inferring the insight knowledge from anything man
made.
• The Goal of RE is to obtain missing knowledge,
ideas and design philosophy when such information
is unavailable.
Demo
5a4d903040ffff0b8
00040000000000000
00000a801f0eebab4
00cd09b8214c0121c
d6854736970206f72
72676d6163206e616
f6e2074656272206e
756920206e4f44205
36f6d6564d2ea0d24
000175ddb1d761...
0x1000: addl $0x2a, %eax
0x1003: cmpl $0x0, %eax
0x1006: jae 0x100f
0x1008: movl $0x5, %ebx
0x100d: jmp 0x1017
0x100f: subl $0x7, %eax
0x1012: movl $0x3, %ebx
0x1017: addl %ebx, %eax
0x1019: ret
Magic word (ZM)
Entry point address
Instructions
Disassembly
Problems
• Indirect Jump
• Overlapping Block/Function/Instruction
• SEH
• Encryption/Decryption
• Anti-Research Techniques
Applications
• Software Maintenance
• Source Code and Documentation Engineering
• Virus Analysis: to extract the Virus Signature
Virus Signature
Signature of Stoned Virus:
0400 B801 020E 07BB 0002 33C9 8BD1 419C
Anti-Research Techniques
4
Motivation
• Multi-layer Malware
Motivation (cont.)
• Obfuscation techniques are used in software for
protecting against cracking, reverse engineering.
• Obfuscation techniques are used in malware for
protecting against automatic detection and analysis
of malicious code.
• Our goal: build a tool for handling most of
obfuscation techniques: Indirect Jump, Self-
modifying code, SEH, Encryption, Anti-Debugging,
Anti-Emulation.
5
Indirect Jump
• Idea: store the target address of JUMP instruction in
register or memory location
• Require simulation of executing x86 instructions
and Windows API
JMP EAX ?????
6
Indirect Jump (cont.)
• Virus.Win32.Aztec
00401057 . B8 00100000 MOV EAX,1000
0040105C . 05 00004000 ADD EAX, 00400000
00401061 . FFE0 JMP EAX
BE-PUM
IDA Pro
7
Indirect Jump (cont.)
• Virus.Win32.Aztec: look for base address of
kernel32 and store address of API in memory
location.
8
Indirect Jump
• Demo
Overlapping Instruction
HLLW.Rolog.f
•Junk code modifies the return address.
00437002 E8 03000000 CALL 0043700A
00437007 E9 EB045D45 JMP 45A074F7
00437002 CALL 0043700A
0043700D RETN
0043700A POP EBP
0043700B INC EBP
0043700C PUSH EBP
Code
11
Demo
BE-PUM
IDA Pro
12
Self-Modifying Code
• Virus.Win32.Seppuku.1606 : Self-Modifying Code
00401646 E8 B5F9FFFF CALL 00401000
EDI = 401067
004010E5 MOV EAX,DWORD PTR SS:[EBP+401489]
004010EB STOS DWORD PTR ES:[EDI]
00401646 E8 00000000 CALL 0040164B
13
Decryption
• Email-Worm.Win32.Kickin.d : Self-decryption
00609223 pop ebp
00609224 push 3d
00609226 mov byte ptr ds:[esi+9cccd0e5],dh
0060922C retn 8d9e
0060922F pxor mm5,mm3
00609232 dec ecx
00609233 fiadd word ptr ds:[ecx+80a6b31]
Decryption loop
ecx was set to 0CAh0060933A mov ecx,0ca
00609345 lods byte ptr ds:[esi]
00609346 xor al,ah
00609348 inc ah
0060934A rol ah,2
0060934D add ah,90
00609350 stos byte ptr es:[edi]
00609351 loopd 00609345
00609223 call 00609228
00609228 mov ebx, [ebp+402705]
0060922E add ebx,28
00609231 pop eax
00609232 sub eax,ebx
00609234 mov [ebp+40270d],eax
14
Demo
BE-PUM
IDA Pro
15
SEH
• SEH - Structured Exception Handler
• Used to handle error in running code
• Malware uses this method to intentionally cause a
change in the execution flow
push offset SEH_Handler
push dword ptr fs:[0]
mov fs:[0],esp
16
SEH (cont.)
004011FE xor edx, edx
00401200 push dword ptr [edx]
00401203 mov dword ptr [edx], esp
00401206 inc dword ptr [edx]
00401209 lea esi,dword ptr [ebp+401943]
edx = 0
Set up SEH
Exception occurs!
17
SEH (cont.)
• Demo
BE-PUM
IDA Pro
18
• Dead code insertion
push %ebx
pop %ebx
• Instruction substitution
mov $0, %eax -> xor %eax, %eax
• Variable renaming & register reassignment
mov $0, %eax -> mov $0, %ebx
• Code reordering
Change syntactic order of the code
Semantic execution path remains unchange
Anti-debugging
• Use NtGlobalFlag field which exists at offset 0x68 in the PEB
(Process Environemnt Block)
• PEB is a structure created in process initialization
• PEB contains data necessary to the execution of a process.
• Used by ExeCryptor
1: mov eax, fs:[30h] ;PEB
;check NtGlobalFlag
2: cmp byte [eax+68h], 70h
3: jne being_debugged
4: jmp real_code
being_debugged:
5: call ExitProcess
19
Anti-debugging (cont.)
• Use the process default heap to find presence of
debugging artifacts
1: mov eax, fs:[30h] ;PEB
;get process heap base
2: mov eax, [eax+18h]
3: mov eax, [eax+0ch] ;Flags
4: dec eax
5: dec eax
6: jne being_debugged
7: jmp real_code
being_debugged:
8: call ExitProcess
20
Special APIs
• The kernel32 IsDebuggerPresent() function was
introduced in Windows 95.
• It returns TRUE if a debugger is present
1: call IsDebuggerPresent
2: test al, al
3: jne being_debugged
4: jmp real_code
being_debugged:
5: call ExitProcess
21
Special APIs (cont.)
• Use kernel32 CheckRemoteDebuggerPresent() function
1: push eax
2: push esp
3: push -1 ;GetCurrentProcess()
4: call CheckRemoteDebuggerPresent
5: pop eax
6: test eax, eax
7: jne being_debugged
8: jmp real_code
being_debugged:
9: call ExitProcess
22
Time Attack
• Malware target on specific date.
E.g. CodeRed malware use Windows API
GetSystemTime
• Solution: On-Demand Symbolic Execution for
Windows API
The return value is symbol value (instead of real
execution with JNA)
Demo
• Win32.Voltage
1: lea eax,[ebp + SYSTEMTIME]
2: push eax
3: call [ebp + GetLocalTime]
4: cmp word ptr [ebp+wMonth],12
5: jne NoPayLoad
6: cmp word ptr [ebp +wDay],29
7: jne NoPayLoad
8: push eax
9: push eax
10: push 0h
11: call [ebp + MessageBox]
NoPayLoad:
12: Call ExitProcess
Execution Timing
• Based on an idea: there is a significant delay between the
executions of the individual instructions in debugger mode
compared to normal execution.
1: call GetTickCount
2: xchg ebx, eax
3: call GetTickCount
4: sub eax, ebx
5: cmp eax, 1
6: jnb being_debugged
7: jmp real_code
being_debugged:
8: call ExitProcess
24
Exception
• Using exceptions to alter the value of eip
• An effective anti-debugging technique
• Used by packer PECompact
1: xor eax, eax
2: push offset l3
3: push dw fs:[eax]
4: mov fs:[eax], esp
l1:
5: call l1
l2:
6: jmp l3
l3:
7: pop eax
25
Exception (cont.)
• Used in packer Telock
00407A1B PUSHAD
00407A1C CALL 00407A27
00407A27 PUSH DWORD PTR FS:[0]
00407A2D MOV DWORD PTR FS:[0],ESP
00407A33 PUSHFD
00407A34 OR DWORD PTR SS:[ESP],100
00407A3B POPFD
00407A3C CLC
00407A3D JNB SHORT 00407A1B
26
Stalling Code
• The main idea is to delay the execution of malicious
activity in very long time.
• Stalling code make automated analysis systems to
give up on a sample.
27
Stalling Code (cont.)
0x00406016: movl %ecx, $0x1951<UINT32>
0x0040601b: movl %eax, %ecx
0x0040601d: clc
0x0040601e: jae 0x00406022
0x00406022: addl %esi, $0x33<UINT8>
0x00406025: leal %eax, 0x67(%ecx,
%eax,4)
0x00406029: call 0x00406030
0x00406030: xorb (%esi), %al
0x00406032: incl %esi
0x00406033: popl %edx
0x00406034: jmp 0x00406037
0x00406037: aam $0x9<UINT8>
0x00406039: decl %ecx
0x0040603a: jg 0x00406025
28
Anti-Emulation
• Invalid API parameters: Attacker will intentionally
pass known invalid parameters to the function, and
expecting an error code to be returned
push 1
push 1
call Beep
call GetLastError
;ERROR_INVALID_PARAMET
ER (0x57)
push 5 ;sizeof(l2)
pop ecx
xchg edx, eax
mov esi, offset l2
mov edi, esi
l1: lodsb
xor al, dl
stosb
loop l1
...
l2: db 3fh, 32h,
3bh, 3bh, 38h
;secret message
29
GetProcAddress
• Attacker will intentionally pass known invalid
parameters to the function, and expecting no
function address to be returned.
• Any emulator that returns an address in such a
situation will be revealed
push offset l1
push 12345678h ;illegal value
call GetProcAddress
test eax, eax
jne being_debugged
...
l1: db "myfunction", 0
30
Undocumented instructions
• An anti-malware emulator might fail to support
undocumented instructions or undocumented
encodings of documented instructions
• Solution: Capstone disassembly
(http://www.capstone-engine.org/)
0040F0D0 > $ 0F6FE0 MOVQ MM4,MM0
0040F0D3 . E8 06000000 CALL 0040F0DE
31
Other Techniques
• Check Parent process for explore.exe
• Checksumming for detecting tampering
• Stolen bytes technique using
VirtualAlloc API.
Other Techniques (cont.)
• Prevent reverser from controlling the debugger with
user32!BlockInput()
• Debugger blocker by spawning a process which
becomes a debugger for the packed code
• API redirection with LoadLibrary and GetProcAddress
Packer
Self-modifying Code + SEH +
Encryption + Anti-Debugging +
Anti-Emulation + ...
•Bullet-proof jacket for software (and malware also):
Against Cracks
Against KeyGens
Against Stolen serial number
Against Unauthorized use
Packer
32
Antivirus Is Dead
Antivirus Isn't Dead, It Just Can't Keep Up
Advanced Persistent Threat
• W32.Stuxnet is discovered in 2009.
A compute worm targets to industrial control
systems for equipment made by Siement.
These systems are used in Iran for uranium
enrichment.
“the Most Menacing Malware in History”
• Flame is discovered in 2010
“most complex malware ever found” – main
component is ~6MB
Kaspersky researchers found chunks of code
from a 2009 Stuxnet variant inside Flame
My Current Research
2
BE-PUM
• BE-PUM - Binary Emulation for Pushdown Model
• Apply pushdown model generation of binary code
Apply concolic testing (dynamic symbolic execution) to
handle indirect jump
Apply on-the-fly model generation for handling self-
modifying code
Focus on obfuscation techniques which are used in
malware and packer tools.
3
Architecture
Frontiers
Single-step
Symbolic Execution
Instr(Env,m)
Jakstab 0.8.3
Feasibility check
SMT: Z3 4.3
Control
instructions
Data
instructions
Yes
No
Binary Emulation
Controlled
Sandbox
Stack
Memory
Register
Flag
(k, asmk,ψk)
(k, asmk,ψk) : New region?
〈 (k, asmk),ε 〉 ↪ 〈 (m, asm), (m’, asm’) 〉 : New rule?
Pushdown Model
〈 (k, asmk),ε 〉 ↪ 〈 (m, asm), (m’, asm’) 〉
Symbolic states
(k, asmk,ψk )
Stub of API
System call
(pre-condition)
Java API
(Output)
CFG Storage
〈 (k, asmk) 〉
Conclusion
• RE is very important in the fight for malware.
• It needs to evolve to keep up with the new types of
APT malwares.
• How ???
36
References
• “The Art of Unpacking”. Mark Vincent Yason.
• “Reversing: Secrets of Reverse Engineering”. Eldad
Eilam.
• “An Anti-Reverse Engineering Guide”. Josh_Jackson.
• “Anti-unpacker Tricks”. Peter Ferrie.
36
Q&A

Reverse engineering20151112

  • 1.
    Reverse Engineering andApplications to Anti-Malware Nguyen Minh Hai Ho Chi Minh City University of Technology (HCMUT) November 2015
  • 2.
    Agenda 1. Introduction 2. Anti-ResearchTechniques 1. Indirect Jump 2. Overlapping Instruction 3. Self-modifying Code 4. Encryption 5. Structured Exception Handler 6. Anti-Debugging 7. Anti-Emulation 3. Conclusions 1
  • 3.
  • 4.
    Reverse Engineering • Reverseengineering (RE) is the process of inferring the insight knowledge from anything man made. • The Goal of RE is to obtain missing knowledge, ideas and design philosophy when such information is unavailable.
  • 5.
    Demo 5a4d903040ffff0b8 00040000000000000 00000a801f0eebab4 00cd09b8214c0121c d6854736970206f72 72676d6163206e616 f6e2074656272206e 756920206e4f44205 36f6d6564d2ea0d24 000175ddb1d761... 0x1000: addl $0x2a,%eax 0x1003: cmpl $0x0, %eax 0x1006: jae 0x100f 0x1008: movl $0x5, %ebx 0x100d: jmp 0x1017 0x100f: subl $0x7, %eax 0x1012: movl $0x3, %ebx 0x1017: addl %ebx, %eax 0x1019: ret Magic word (ZM) Entry point address Instructions Disassembly
  • 7.
    Problems • Indirect Jump •Overlapping Block/Function/Instruction • SEH • Encryption/Decryption • Anti-Research Techniques
  • 8.
    Applications • Software Maintenance •Source Code and Documentation Engineering • Virus Analysis: to extract the Virus Signature
  • 9.
    Virus Signature Signature ofStoned Virus: 0400 B801 020E 07BB 0002 33C9 8BD1 419C
  • 10.
  • 11.
  • 12.
    Motivation (cont.) • Obfuscationtechniques are used in software for protecting against cracking, reverse engineering. • Obfuscation techniques are used in malware for protecting against automatic detection and analysis of malicious code. • Our goal: build a tool for handling most of obfuscation techniques: Indirect Jump, Self- modifying code, SEH, Encryption, Anti-Debugging, Anti-Emulation. 5
  • 13.
    Indirect Jump • Idea:store the target address of JUMP instruction in register or memory location • Require simulation of executing x86 instructions and Windows API JMP EAX ????? 6
  • 14.
    Indirect Jump (cont.) •Virus.Win32.Aztec 00401057 . B8 00100000 MOV EAX,1000 0040105C . 05 00004000 ADD EAX, 00400000 00401061 . FFE0 JMP EAX BE-PUM IDA Pro 7
  • 15.
    Indirect Jump (cont.) •Virus.Win32.Aztec: look for base address of kernel32 and store address of API in memory location. 8
  • 16.
  • 17.
    Overlapping Instruction HLLW.Rolog.f •Junk codemodifies the return address. 00437002 E8 03000000 CALL 0043700A 00437007 E9 EB045D45 JMP 45A074F7 00437002 CALL 0043700A 0043700D RETN 0043700A POP EBP 0043700B INC EBP 0043700C PUSH EBP Code 11
  • 18.
  • 19.
    Self-Modifying Code • Virus.Win32.Seppuku.1606: Self-Modifying Code 00401646 E8 B5F9FFFF CALL 00401000 EDI = 401067 004010E5 MOV EAX,DWORD PTR SS:[EBP+401489] 004010EB STOS DWORD PTR ES:[EDI] 00401646 E8 00000000 CALL 0040164B 13
  • 20.
    Decryption • Email-Worm.Win32.Kickin.d :Self-decryption 00609223 pop ebp 00609224 push 3d 00609226 mov byte ptr ds:[esi+9cccd0e5],dh 0060922C retn 8d9e 0060922F pxor mm5,mm3 00609232 dec ecx 00609233 fiadd word ptr ds:[ecx+80a6b31] Decryption loop ecx was set to 0CAh0060933A mov ecx,0ca 00609345 lods byte ptr ds:[esi] 00609346 xor al,ah 00609348 inc ah 0060934A rol ah,2 0060934D add ah,90 00609350 stos byte ptr es:[edi] 00609351 loopd 00609345 00609223 call 00609228 00609228 mov ebx, [ebp+402705] 0060922E add ebx,28 00609231 pop eax 00609232 sub eax,ebx 00609234 mov [ebp+40270d],eax 14
  • 21.
  • 22.
    SEH • SEH -Structured Exception Handler • Used to handle error in running code • Malware uses this method to intentionally cause a change in the execution flow push offset SEH_Handler push dword ptr fs:[0] mov fs:[0],esp 16
  • 23.
    SEH (cont.) 004011FE xoredx, edx 00401200 push dword ptr [edx] 00401203 mov dword ptr [edx], esp 00401206 inc dword ptr [edx] 00401209 lea esi,dword ptr [ebp+401943] edx = 0 Set up SEH Exception occurs! 17
  • 24.
  • 25.
    • Dead codeinsertion push %ebx pop %ebx • Instruction substitution mov $0, %eax -> xor %eax, %eax • Variable renaming & register reassignment mov $0, %eax -> mov $0, %ebx • Code reordering Change syntactic order of the code Semantic execution path remains unchange
  • 26.
    Anti-debugging • Use NtGlobalFlagfield which exists at offset 0x68 in the PEB (Process Environemnt Block) • PEB is a structure created in process initialization • PEB contains data necessary to the execution of a process. • Used by ExeCryptor 1: mov eax, fs:[30h] ;PEB ;check NtGlobalFlag 2: cmp byte [eax+68h], 70h 3: jne being_debugged 4: jmp real_code being_debugged: 5: call ExitProcess 19
  • 27.
    Anti-debugging (cont.) • Usethe process default heap to find presence of debugging artifacts 1: mov eax, fs:[30h] ;PEB ;get process heap base 2: mov eax, [eax+18h] 3: mov eax, [eax+0ch] ;Flags 4: dec eax 5: dec eax 6: jne being_debugged 7: jmp real_code being_debugged: 8: call ExitProcess 20
  • 28.
    Special APIs • Thekernel32 IsDebuggerPresent() function was introduced in Windows 95. • It returns TRUE if a debugger is present 1: call IsDebuggerPresent 2: test al, al 3: jne being_debugged 4: jmp real_code being_debugged: 5: call ExitProcess 21
  • 29.
    Special APIs (cont.) •Use kernel32 CheckRemoteDebuggerPresent() function 1: push eax 2: push esp 3: push -1 ;GetCurrentProcess() 4: call CheckRemoteDebuggerPresent 5: pop eax 6: test eax, eax 7: jne being_debugged 8: jmp real_code being_debugged: 9: call ExitProcess 22
  • 30.
    Time Attack • Malwaretarget on specific date. E.g. CodeRed malware use Windows API GetSystemTime • Solution: On-Demand Symbolic Execution for Windows API The return value is symbol value (instead of real execution with JNA)
  • 31.
    Demo • Win32.Voltage 1: leaeax,[ebp + SYSTEMTIME] 2: push eax 3: call [ebp + GetLocalTime] 4: cmp word ptr [ebp+wMonth],12 5: jne NoPayLoad 6: cmp word ptr [ebp +wDay],29 7: jne NoPayLoad 8: push eax 9: push eax 10: push 0h 11: call [ebp + MessageBox] NoPayLoad: 12: Call ExitProcess
  • 32.
    Execution Timing • Basedon an idea: there is a significant delay between the executions of the individual instructions in debugger mode compared to normal execution. 1: call GetTickCount 2: xchg ebx, eax 3: call GetTickCount 4: sub eax, ebx 5: cmp eax, 1 6: jnb being_debugged 7: jmp real_code being_debugged: 8: call ExitProcess 24
  • 33.
    Exception • Using exceptionsto alter the value of eip • An effective anti-debugging technique • Used by packer PECompact 1: xor eax, eax 2: push offset l3 3: push dw fs:[eax] 4: mov fs:[eax], esp l1: 5: call l1 l2: 6: jmp l3 l3: 7: pop eax 25
  • 34.
    Exception (cont.) • Usedin packer Telock 00407A1B PUSHAD 00407A1C CALL 00407A27 00407A27 PUSH DWORD PTR FS:[0] 00407A2D MOV DWORD PTR FS:[0],ESP 00407A33 PUSHFD 00407A34 OR DWORD PTR SS:[ESP],100 00407A3B POPFD 00407A3C CLC 00407A3D JNB SHORT 00407A1B 26
  • 35.
    Stalling Code • Themain idea is to delay the execution of malicious activity in very long time. • Stalling code make automated analysis systems to give up on a sample. 27
  • 36.
    Stalling Code (cont.) 0x00406016:movl %ecx, $0x1951<UINT32> 0x0040601b: movl %eax, %ecx 0x0040601d: clc 0x0040601e: jae 0x00406022 0x00406022: addl %esi, $0x33<UINT8> 0x00406025: leal %eax, 0x67(%ecx, %eax,4) 0x00406029: call 0x00406030 0x00406030: xorb (%esi), %al 0x00406032: incl %esi 0x00406033: popl %edx 0x00406034: jmp 0x00406037 0x00406037: aam $0x9<UINT8> 0x00406039: decl %ecx 0x0040603a: jg 0x00406025 28
  • 37.
    Anti-Emulation • Invalid APIparameters: Attacker will intentionally pass known invalid parameters to the function, and expecting an error code to be returned push 1 push 1 call Beep call GetLastError ;ERROR_INVALID_PARAMET ER (0x57) push 5 ;sizeof(l2) pop ecx xchg edx, eax mov esi, offset l2 mov edi, esi l1: lodsb xor al, dl stosb loop l1 ... l2: db 3fh, 32h, 3bh, 3bh, 38h ;secret message 29
  • 38.
    GetProcAddress • Attacker willintentionally pass known invalid parameters to the function, and expecting no function address to be returned. • Any emulator that returns an address in such a situation will be revealed push offset l1 push 12345678h ;illegal value call GetProcAddress test eax, eax jne being_debugged ... l1: db "myfunction", 0 30
  • 39.
    Undocumented instructions • Ananti-malware emulator might fail to support undocumented instructions or undocumented encodings of documented instructions • Solution: Capstone disassembly (http://www.capstone-engine.org/) 0040F0D0 > $ 0F6FE0 MOVQ MM4,MM0 0040F0D3 . E8 06000000 CALL 0040F0DE 31
  • 40.
    Other Techniques • CheckParent process for explore.exe • Checksumming for detecting tampering • Stolen bytes technique using VirtualAlloc API.
  • 41.
    Other Techniques (cont.) •Prevent reverser from controlling the debugger with user32!BlockInput() • Debugger blocker by spawning a process which becomes a debugger for the packed code • API redirection with LoadLibrary and GetProcAddress
  • 42.
    Packer Self-modifying Code +SEH + Encryption + Anti-Debugging + Anti-Emulation + ... •Bullet-proof jacket for software (and malware also): Against Cracks Against KeyGens Against Stolen serial number Against Unauthorized use Packer 32
  • 44.
  • 45.
    Antivirus Isn't Dead,It Just Can't Keep Up
  • 46.
    Advanced Persistent Threat •W32.Stuxnet is discovered in 2009. A compute worm targets to industrial control systems for equipment made by Siement. These systems are used in Iran for uranium enrichment. “the Most Menacing Malware in History” • Flame is discovered in 2010 “most complex malware ever found” – main component is ~6MB Kaspersky researchers found chunks of code from a 2009 Stuxnet variant inside Flame
  • 47.
  • 48.
    BE-PUM • BE-PUM -Binary Emulation for Pushdown Model • Apply pushdown model generation of binary code Apply concolic testing (dynamic symbolic execution) to handle indirect jump Apply on-the-fly model generation for handling self- modifying code Focus on obfuscation techniques which are used in malware and packer tools. 3
  • 49.
    Architecture Frontiers Single-step Symbolic Execution Instr(Env,m) Jakstab 0.8.3 Feasibilitycheck SMT: Z3 4.3 Control instructions Data instructions Yes No Binary Emulation Controlled Sandbox Stack Memory Register Flag (k, asmk,ψk) (k, asmk,ψk) : New region? 〈 (k, asmk),ε 〉 ↪ 〈 (m, asm), (m’, asm’) 〉 : New rule? Pushdown Model 〈 (k, asmk),ε 〉 ↪ 〈 (m, asm), (m’, asm’) 〉 Symbolic states (k, asmk,ψk ) Stub of API System call (pre-condition) Java API (Output) CFG Storage 〈 (k, asmk) 〉
  • 50.
    Conclusion • RE isvery important in the fight for malware. • It needs to evolve to keep up with the new types of APT malwares. • How ??? 36
  • 51.
    References • “The Artof Unpacking”. Mark Vincent Yason. • “Reversing: Secrets of Reverse Engineering”. Eldad Eilam. • “An Anti-Reverse Engineering Guide”. Josh_Jackson. • “Anti-unpacker Tricks”. Peter Ferrie. 36
  • 52.

Editor's Notes

  • #2 Anti-research
  • #10 https://en.wikipedia.org/wiki/Stoned_(computer_virus) Stoned is the name of a boot sector computer virus created in 1987. One of the very first viruses, it is thought to have been written by a university student in Wellington, New Zealand.[1][2] By 1989 it had spread widely in New Zealand and Australia,[3] and variants became very common worldwide in the early 1990s.[4] A computer infected with the original version had a one in eight probability[5][6] that the screen would declare: &amp;quot;Your PC is now Stoned!&amp;quot;, a phrase found in infected boot sectors of infected floppy disks and master boot records of infected hard disks, along with the phrase &amp;quot;Legalise Marijuana&amp;quot;. Later variants produced a range of other messages.
  • #13 In software development, obfuscation is the deliberate act of creating obfuscated code, i.e. source or machine code that is difficult for humans to understand. Programmers may deliberately obfuscate code to conceal its purpose (security through obscurity) or its logic, in order to prevent tampering, deter reverse engineering, or as a puzzle or recreational challenge for someone reading the source code. Programs known as obfuscators transform readable code into obfuscated code using various techniques.
  • #23 Eva.a : exception occurrence is obfuscated. As Windows standard, fs:[0] initially points to the system exception handler. New frame pushed at 00401012 and modified at 00401015. At 00401018, access violation (inc at 00000000). Win32 PE executables can set up a so-called SEH (Structured Exception Handler). Most runtime code, and several viruses use this method to trap errors, but it can also be used to intentionally cause a change in the execution flow. Viruses insert their SEH and create a fault condition, causing the exception handler to be run instead. The first virus really in ‘in-the-wild’ installing multiple exception handlers was W32/Magistr.A to confuse AV emulators.
  • #27 What is PEB: Process Environment Block Simulate PEB structure using symbolic execution value
  • #28 Solution: Simulate PEB structure using symbolic execution value
  • #29 Solution: On-demand Symbolic Execution for APIs
  • #30 Other APIs: NtQueryInformationProcess, NtQuerySystemInformation, NtQueryObject, SetInformationThread... Determines whether the specified process is being debugged. Solution: On-demand Symbolic Execution for APIs
  • #33 Solution: On-demand Symbolic Execution for APIs
  • #35 Stack overflow
  • #38 This leads to a vulnerability, whereby an attacker will intentionally pass known invalid parameters to the function, and expecting an error code to be returned. In some cases, this error code is used as a key for decryption. Any emulator that fails to return the error code will not be able to decrypt the data. Solution: On-demand Symbolic Execution for APIs
  • #39 Solution: Simulate Windows APIs