• No results found

Fighting malware on your own

N/A
N/A
Protected

Academic year: 2021

Share "Fighting malware on your own"

Copied!
47
0
0

Loading.... (view fulltext now)

Full text

(1)

Fighting

Fighting malware malware on your own on your own

Vitaliy Kamlyuk

Senior Virus Analyst Kaspersky Lab

[email protected]

(2)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Why fight malware on your own?

Why fight malware on your own?

5 reasons:

1. Touch 100% of protection yourself 2. Be prepared for attacks

3. Maintain confidentiality

4. Restore system here and now

5. Time matters

(3)

What is available in

What is available in W W indows indows XP? XP?

™System tools:

¾Explorer, Task manager, Regedit, SigVerif,…

¾Console utils: netstat,tasklist,reg,expand…

¾Interpreters: Batch, JS/VBS

¾Text editors: notepad,wordpad,edit,edlin,…

¾Binary editing tool: debug

¾Symbolic debugger: ntsd

¾OLE repository

(4)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Email

Email - - Worm.Win32.Warezov Worm.Win32.Warezov

™Detected on 15

th

August, 2006

™430 modifications (~25000 of files)

™All application data is encrypted

™Code mutates very often (server-side polymorphic engine)

™Downloads additional modules from the Internet

™Hides its modules from Task Manager

(5)

Warezov: Infecting the system

Warezov: Infecting the system

(6)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Warezov: Installing KAV 6.0

Warezov: Installing KAV 6.0

(7)

Warezov: What really happened?

Warezov: What really happened?

(8)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Warezov: Inspecting the system

Warezov: Inspecting the system

(9)

Warezov: Manual removal

Warezov: Manual removal

(10)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Warezov: Resistance

Warezov: Resistance to to manual manual removal

removal

(11)

Analysis Analysis

1. Malware restores registry values when the application terminates (seems to be when malicious dll is unloaded)

2. There is a set of processes running/closing from time to time. So the routine is called

several times.

3. The value is restored only if it doesn’t exist.

4. Looks like the malware uses one of the

following functions: strstr/wcsstr/CString::Find, strtok or its own substring find routine

We can hack the malware removal

resistance mechanism!

(12)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Warezov: Hacking the resistance to Warezov: Hacking the resistance to

manual removal

manual removal

(13)

Trojan.Win32.Agent.ach Trojan.Win32.Agent.ach

™ Detected on 12

th

December, 2006

™ Made in Japan

™ Silently removes itself after being run

™ Suspends running destructive functionality until the following Friday, and after that:

¾ Disables pressing Ctrl-Alt-Delete

¾ Disables running any executable file from shell

¾ Disables system shutdown/reboot

¾ If you try hard-reboot, it disables loading the system in any available mode

(14)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Agent.ach

Agent.ach : Infecting the system : Infecting the system

(15)

Agent.ach

Agent.ach : Infection symptoms : Infection symptoms

(16)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Hard reset result

Hard reset result - - time matters! time matters!

(17)

Agent.ach

Agent.ach : Inspecting the system : Inspecting the system

(18)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Agent.ach

Agent.ach : Removing the malware : Removing the malware

(19)

Agent.ach

Agent.ach : Control check : Control check

(20)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Virus.Win32.Saburex.a Virus.Win32.Saburex.a

™ Detected on 10

th

December, 2006

™ The virus infects executable files located on a hard disk partition which is selected at random

™ Injects own DLL into every process that has visible window

™ Injected DLL makes screenshots of active

windows on the victim machine, encrypts them,

and publishes them on a website

(21)

Saburex

Saburex : Getting the code : Getting the code

(22)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Saburex

Saburex : Code listing : Code listing

push ebp mov ebp,esp sub esp,0x318 push ebx push esi push edi push 0x100 lea eax,[ebp-0x204]

push eax push 0x0 call dword ptr [kernel32!GetModuleFileNameA (7c80b357)]

push 0x0 push 0x0 push 0x3 push 0x0 push 0x3 push 0x80000000 lea ecx,[ebp-0x204]

push ecx call dword ptr [kernel32!CreateFileA (7c801a24)]

mov [ebp-0x318],eax push 0x2

push 0x0 push 0xf8

mov edx,[ebp-0x318]

push edx

call dword ptr [kernel32!SetFilePointer (7c810da6)]

push 0x0 lea eax,[ebp-0x314]

push eax push 0x8 lea ecx,[ebp-0x310]

push ecx mov edx,[ebp-0x318]

push edx call dword ptr [kernel32!ReadFile (7c80180e)]

push 0x2 push 0x0 mov eax,0xfffffff8 sub eax,[ebp-0x310]

push eax

mov ecx,[ebp-0x318]

push ecx

call dword ptr [kernel32!SetFilePointer (7c810da6)]

mov edx,[ebp-0x310]

push edx push 0x0

call dword ptr [kernel32!LocalAlloc (7c8099bd)]

mov [ebp-0x4],eax mov eax,[ebp-0x30c]

push eax push 0x0

call dword ptr [kernel32!LocalAlloc (7c8099bd)]

mov [ebp-0x308],eax push 0x0

lea ecx,[ebp-0x314]

push ecx

mov edx,[ebp-0x310]

push edx mov eax,[ebp-0x4]

push eax

mov ecx,[ebp-0x318]

push ecx

call dword ptr [kernel32!SetFilePointer (7c810da6)]

mov edx,[ebp-0x4]

mov dword ptr [edx],0x4643534d mov eax,[ebp-0x310]

push eax

mov edx,[ebp-0x308]

mov ecx,[ebp-0x4]

call KODAKIMG+0x1060 (00401060) Subroutine_1 lea ecx,[ebp-0x104]

push ecx push 0x100

call dword ptr [kernel32!GetTempPathA (7c8221cf)]

lea edx,[ebp-0x304]

push edx push 0x0 push 0x401434 lea eax,[ebp-0x104]

push eax

call dword ptr [kernel32!GetTempFileNameA (7c8606df)]

push 0x0 push 0x0 push 0x2 push 0x0 push 0x2 push 0x40000000 lea ecx,[ebp-0x304]

push ecx

call dword ptr [kernel32!CreateFileA (7c801a24)]

mov [ebp-0x318],eax push 0x0

lea edx,[ebp-0x314]

push edx

mov eax,[ebp-0x30c]

push eax

mov ecx,[ebp-0x308]

push ecx

mov edx,[ebp-0x318]

push edx

call dword ptr [kernel32!WriteFile (7c810f9f)]

mov eax,[ebp-0x318]

push eax

call dword ptr [kernel32!CloseHandle (7c809b77)]

mov edi,0x401054 lea edx,[ebp-0x304]

or ecx,0xffffffff xor eax,eax repne scasb not ecx sub edi,ecx mov esi,edi mov ebx,ecx mov edi,edx or ecx,0xffffffff xor eax,eax repne scasb add edi,0xffffffff mov ecx,ebx shr ecx,0x2 rep movsd mov ecx,ebx and ecx,0x3 rep movsb lea edi,[ebp-0x204]

lea edx,[ebp-0x304]

or ecx,0xffffffff xor eax,eax repne scasb not ecx sub edi,ecx mov esi,edi

mov ebx,ecx mov edi,edx or ecx,0xffffffff xor eax,eax repne scasb add edi,0xffffffff mov ecx,ebx shr ecx,0x2 rep movsd mov ecx,ebx and ecx,0x3 rep movsb push 0x0 push 0x0 lea eax,[ebp-0x304]

push eax push 0x401048 push 0x0 push 0x0

call dword ptr [SHELL32!ShellExecuteA (7ca40e80)]

pop edi pop esi pop ebx mov esp,ebp pop ebp ret

(23)

Saburex

Saburex : Analysis : Analysis

Src PE Header

Src Sections

Virus PE Header

Src Sections Virus Section

Compressed chunk of src file

Source File Infected File

Src PE Header

Src Sections Cured File

compress

decompress

(24)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Simple PE Structure

Simple PE Structure

(25)

Saburex

Saburex : Curing tool in machine code : Curing tool in machine code

(26)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Saburex

Saburex : Applying the tool : Applying the tool

(27)

System evolution System evolution

1. MS DOS

1970th 1980

2. Windows NT

Unix

3. Windows 9x/ME

4. Windows 2000

5. Windows XP

1990

2000

2001

2007

(28)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Microsoft.NET

Microsoft.NET in the wild in the wild

(29)

Sniffing malware communication Sniffing malware communication

Methods:

™ Analysis of Windows network monitor

™ Catching DNS requests (server emulation)

™ Catching HTTP request (server emulation)

™ Implementing IP packet filter

(30)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Trojan

Trojan - - Downloader.Win32.Small.eup Downloader.Win32.Small.eup

(31)

Packet Filtering Explained

Packet Filtering Explained

(32)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Backdoor.Win32.IRCBot.ach

Backdoor.Win32.IRCBot.ach

(33)

Advanced techniques Advanced techniques

™ Viewing PE header

™ Ways of terminating a process

™ Dumping loaded executable image

™ Extracting string data from binary images

(34)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Viewing PE header Viewing PE header

How to view PE header of target PE file in Windows:

1. Run: ntsd <path to target PE file>

2. Locate image base of the loaded module

3. !dh <image base>

(35)

Ways of terminating a process Ways of terminating a process

™ Task manager

™ tasklist + taskkill console apps (starting from WinXP Pro)

™ WMI (starting from WinXP) using:

¾ Windows Scripting Host

¾ WbemTest Application

™ ntsd (starting from NT4)

™ own pskill-like utility with PID received from:

¾ Qprocess

(36)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Kill

Kill Process:tasklist+taskkill Process:tasklist+taskkill

(37)

Kill

Kill Process:WMI+WSH Process:WMI+WSH

(38)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Kill

Kill Process:WMI+WbemTest Process:WMI+WbemTest

(39)

Kill

Kill Process:ntsd Process:ntsd

(40)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Kill Process: Own tool in machine code Kill Process: Own tool in machine code

User code for pskill.exe:

f 1600 1700 90

e 1600 ff,15,04,10,40,00 ,68,00,15,40,00 ,83,c0,04 ,50 e 1610 ff,15,20,10,40,00 ,83,c0,04 ,6a,0a ,6a,00 ,ff,30 e 1620 ff,15,30,10,40,00 ,8B,D8 ,ff,15,08,10,40,00, 3b,c3 e 1630 74,3E ,53 ,6a,00 ,6a,01 ,ff,15,0c,10,40,00 ,6a,00 ,50 e 1640 ff,15,10,10,40,00 ,eb,38

e 1670 33,c0

e 1680 50 ,ff,15,00,10,40,00

Usage:

Pskill.exe <Target Process Id>

Getting Process Id using:

¾ Qprocess

¾ Msinfo32

¾ Performance monitor

(41)

Kill

Kill Process:Getting Process:Getting PID PID

(42)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Dumping a process

Dumping a process

(43)

Extracting string data Extracting string data

var fso=new ActiveXObject("Scripting.FileSystemObject");

var fi=fso.OpenTextFile(WScript.Arguments(0), 1, 0);

var fo=fso.CreateTextFile(WScript.Arguments(1), 1);

var pdb="";

while(!fi.AtEndOfStream) { var db=fi.Read(1);

if(pdb.length>0) {

if((db.charCodeAt(0)>=32 && db.charCodeAt(0)<=127)) pdb+=db;

else {

if(pdb.length>4) fo.Write(pdb+"\n");

pdb="";

continue;

} }

else if((db.charCodeAt(0)>=32 && db.charCodeAt(0)<=127)) pdb=db;

}

Grab all sequences of bytes from given file that form a string

consisting of 3 or more ASCII characters.

The idea: JScript implementation:

(44)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Krotten: Bypassing system policies

Krotten: Bypassing system policies

(45)

Fight malware on your own Fight malware on your own ! !

Results:

1. You can touch 100% of protection 2. You are ready for being attacked

3. You can preserve your confidentiality

4. You can restore system here and now

5. You know why time matters

(46)

DefCon 15 , August 3-5, 2007, Las Vegas, NV, USA

Questions?

Questions?

(47)

May the force be with you!

May the force be with you!

Vitaliy

Vitaliy Kamlyuk Kamlyuk

Senior Virus Analyst Kaspersky Lab [email protected]

Fighting malware on your own

Fighting malware on your own

References

Related documents

Disclaimer: The IES Working Papers is an online paper series for works by the faculty and students of the Institute of Economic Studies, Faculty of Social

Hasil penelitian menunjukkan bahwa struktur frase endosentris bahasa Kaili dialek Unde terdiri atas: (1) frase endosentris multihulu, meliputi: (A) frase koordinatif yang terdiri

By using this E-Book (Sore to the Core - Ab Guide) you agree to hold harmless Alexa Brown, Alexa Jean Fitness, www.alexajeanbrown.com and Lex Brown LLC from any li- ability or

Rajesh Chakrabarti and Barry Scholnick argue in the paper “The Mechanics of Price Adjustment: New Evidence on the (Un)importance of Menu Costs” that if menu cost is the main cause

Additionally, there is also a spatial aspect to the conflict, which is most intense in the mid and far western regions of Nepal, which are economically the most disadvantaged in

The loss in the value of the investment opportunity for the non-pre-emptive leader relative to that of a monopolist at the pre-emptive leader’s optimal entry threshold price

The purpose of this study is to evaluate the outcomes of brand equity on consumer responses by investigating the effects of the overall brand equity on consumer