Viruses and Anti-Viruses

50

Transcript of Viruses and Anti-Viruses

Page 1: Viruses and Anti-Viruses
Page 2: Viruses and Anti-Viruses

Plan of talkKinds of malwareAnti-Virus TechnologiesAnti-Anti-Virus TechniquesExample Timid VirusCode Explanation

2

Page 3: Viruses and Anti-Viruses

Kinds of malwareWorms SpywareTrojan horsesAdware

Page 4: Viruses and Anti-Viruses

WormsA computer worm is a self-replicating

computer program. It uses a network to send copies of itself to other nodes (computer terminals on the network) and it may do so without any user intervention. Unlike a virus, it does not need to attach itself to an existing program. Worms always harm the network (if only by consuming bandwidth), whereas viruses always infect or corrupt files on a targeted computer.

Page 5: Viruses and Anti-Viruses

Worm Propagation

Leverage Network Connectivity 5

Page 6: Viruses and Anti-Viruses

Spyware Spyware is computer software that collects personal

information about users without their informed consent. The term Spyware, is often used interchangeably with adware and malware.

Personal information is secretly recorded with a variety of techniques, including logging keystrokes, recording Internet web browsing history, and scanning documents on the computer's hard disk. It can cause theft of passwords and financial details to the merely annoying recording Internet search history for targeted advertising .Spyware may collect different types of information. Some variants attempt to track the websites a user visits and then send this information to an advertising agency. More malicious variants attempt to intercept passwords or credit card numbers as a user enters them into a web form or other applications.

Page 7: Viruses and Anti-Viruses

Trojan horsesA Trojan horse is a program that unlike a

virus contains or installs a malicious program (sometimes called the payload or 'trojan'). The term is derived from the classical myth of the Trojan Horse. Trojan horses may appear to be useful or interesting programs (or at the very least harmless) to an unsuspecting user, but are actually harmful when executed.

The famous usage in hacking.

Page 8: Viruses and Anti-Viruses

Trojan

Leverages gullible users 8

Page 9: Viruses and Anti-Viruses

AdwareAdware or advertising-supported

software is any software package which automatically plays, displays, or downloads advertising material to a computer after the software is installed on it or while the application is being used.

Page 10: Viruses and Anti-Viruses

The functional logic of a virus Search for a file to infect. Open the file to see if it is infected. If infected, search for another file. Else, infect the file. Return control to the host program.

Page 11: Viruses and Anti-Viruses

Virus

V

Virus – Needs a host

11

Page 12: Viruses and Anti-Viruses

Virus Propagation

Leverage User Connectivity12

Page 13: Viruses and Anti-Viruses

13

Page 14: Viruses and Anti-Viruses

Detection TechnologiesStatic Anti-Virus (AV) Scanners

Signature-based Strings Regular expressions

Static behavior analyzerDynamic AV Scanners

Behavior Monitors

14

Page 15: Viruses and Anti-Viruses

Virus (Malware) Identification

Anti-VirusSignature

Virus

Form - A Antivirus scanners use extracted patterns, or “signatures” to identify known malware.

Signature

15

Page 16: Viruses and Anti-Viruses

Static SignatureHex strings from virus variants

67 33 74 20 73 38 6D 35 20 76 37 6167 36 74 20 73 32 6D 37 20 76 38 6167 39 74 20 73 37 6D 33 20 76 36 61

Hex string for detecting virus67 ?? 74 20 73 ?? 6D ?? 20 76 ?? 61?? = wildcard

16

Page 17: Viruses and Anti-Viruses

Static Signature Ex-:

8BEF 33C0 BF?? ???? ??03 FDB9 ??0A 0000 8A85 ???? ???? 3007 47E2 FBEB 17

Page 18: Viruses and Anti-Viruses

Dynamic Signature

Monitor a running program to detect malicious behavior

For example, if an application opens another executable for write access, the blocker might display a warning asking for the user's permission to grant the write access , we will discuss the anti of that anti virus later.

18

Page 19: Viruses and Anti-Viruses

19

Page 20: Viruses and Anti-Viruses

Attacking Integrity CheckersIntercept open() system call

Open a non-infected backup of the file insteadRestore system to original state after attackInfect system before checksums are

computed

20

Page 21: Viruses and Anti-Viruses

Attacking static signature - Metamorphism

Virus

Form - CM M

VirusVirus

Form - A Form - B

•Metamorphic malware change as it propagates

•Creates multiple variants of itself

21

Page 22: Viruses and Anti-Viruses

Metamorphism Example

mov [ebp - 3], eax

push ecxmov ecx,ebpadd ecx,33push esimov esi,ecxsub esi,34mov [esi-2],eaxpop esipop ecx

push ecxmov ecx, ebppush eaxmov eax, 33add ecx, eaxpop eax

push esimov esi, ecxpush edx

mov edx, 34sub esi, edxpop edxmov [esi - 2], eaxpop esipop ecx

push ecxmov ecx, [ebp + 10]mov ecx, ebppush eaxadd eax, 2342mov eax, 33add ecx, eaxpop eaxmov eax, esipush eaxmov esi, ecxpush edxxor edx, 778fmov edx, 34sub esi, edxpop edxmov [esi-2], eaxpop esipop ecx

push ecxmov ecx,ebpadd ecx,33mov [ecx-36],eaxpop ecx

22

Page 23: Viruses and Anti-Viruses

Attacking static signature- Metamorphism

Anti-VirusSignature

Virus

Form - CM M

VirusVirus

Form - A Form - B

Too many signatures challenge the AV Scanner

Using different signatures for most variants cannot scale.

23

Page 24: Viruses and Anti-Viruses

Attacking Behavior MonitorsSome viruses can wait patiently until write

access to the object is granted. These viruses are called slow infectors. Such viruses typically wait until the user makes a copy of an executable object; the virus (which is already loaded in memory) will be able to infect the target in the file cache before the file is created on the disk. Slow infectors attack behavior blockers effectively

24

Page 25: Viruses and Anti-Viruses

25

Page 26: Viruses and Anti-Viruses

“Undo” Metamorphism

mov [ebp - 3], eax

push ecxmov ecx,ebpadd ecx,33push esimov esi,ecxsub esi,34mov [esi-2],eaxpop esipop ecx

push ecxmov ecx, ebppush eaxmov eax, 33add ecx, eaxpop eax

push esimov esi, ecxpush edx

mov edx, 34sub esi, edxpop edxmov [esi - 2], eaxpop esipop ecx

push ecxmov ecx, [ebp + 10]mov ecx, ebppush eaxadd eax, 2342mov eax, 33add ecx, eaxpop eaxmov eax, esipush eaxmov esi, ecxpush edxxor edx, 778fmov edx, 34sub esi, edxpop edxmov [esi-2], eaxpop esipop ecx

push ecxmov ecx,ebpadd ecx,33mov [ecx-36],eaxpop ecx

26

Page 27: Viruses and Anti-Viruses

Detecting Metamorphism

Behavior MonitorsRun suspect program in an emulator (

code emulation) Analyze behavior while running

Look for changes in file structure Some viruses modify files in a consistent way

Disassemble and look for virus-like instructions

27

Page 28: Viruses and Anti-Viruses

Code EmulationCode emulation is an extremely powerful

virus detection technique. A virtual machine is implemented to simulate the CPU and memory management systems to mimic the code execution. Thus malicious code is simulated in the virtual machine of the scanner, and no actual virus code is executed by the real processor.

28

Page 29: Viruses and Anti-Viruses

Virus Phylogeny

W32.Beagle.J@mm

W32/Bagle.j@mm

W32.Klez.I@mm

W32/Klez.i@MM

W32/NetSky.B

W32.Beagle.AO@mm

W32.Beagle.U@mm

W32.Beagle.A@mm

W32.Klez.F@mm

W32/Bagle.a@mm

[email protected]

W32/Klez.f@MM

W32/Bagle.ao@mm

W32/Bagle.u@mm

W32/Klez.e@MM

W32.NetSky.D

W32.NetSky.B

W32.NetSky.A

W32/Bugbear.17916intd

W32/NetSky.A

??

Page 30: Viruses and Anti-Viruses

Virus Phylogeny

[email protected]@mm

[email protected]@mm

[email protected]@mm

W32/Bagle.a@mmW32/Bagle.j@mm

[email protected]

W32/Klez.i@MMW32/Klez.f@MM

W32/Bagle.aq@mmW32/Bagle.u@mm

W32/Klez.e@MM

W32.NetSky.DW32.NetSky.BW32.NetSky.A

W32/Bugbear.17916intdW32/NetSky.BW32/NetSky.A

Symantec McAfee

??

??

Page 31: Viruses and Anti-Viruses

Deobfuscator of CallsNORMAL CALL

L0: call L5L1: …L2: …L3: …L4: …L5: <proc>L6: …

OBFUSCATED CALL

L0a: push L1L0b: push L5L0c: retL1: …L2: …L3: …L4: …L5: <proc>L6: …

Call Obfsucations to prevent static analysis

31

Page 32: Viruses and Anti-Viruses

DOC: Deobfuscator of Calls

32

Page 33: Viruses and Anti-Viruses

33

Page 34: Viruses and Anti-Viruses

Timid

Our example of malware

34

Page 35: Viruses and Anti-Viruses

What Timid Virus do Timid is a file infecting virus. It does not become memory

resident. It infects .COM files, including COMMAND.COM. Timid appears to be an escaped research virus, and is now found in the public domain.

Each time a file infected with Timid is executed, the Timid virus infects the first uninfected .COM file in the current directory. If no uninfected .COM files exist in the current directory, a system hang occurs.

The string "VI", is located in the fourth and fifth byte of infected files. Together with a jump (E9h) instruction located at the beginning of the infected file, it forms the infection marker used by the virus to determine if the file was previously infected.

35

Page 36: Viruses and Anti-Viruses

Overwriting Viruses

Page 37: Viruses and Anti-Viruses

Overwriting Viruses

Page 38: Viruses and Anti-Viruses

Overwriting Viruses

Page 39: Viruses and Anti-Viruses

Overwriting Viruses

Page 40: Viruses and Anti-Viruses

Difference Between .COM and .EXE files

A.COM file is a direct image of how the program will look in main memory, A .COM file is limited to 64K or 100H for all segments combined, but a .EXE file can have as many segments as your linker will handle and be as large as RAM can take.

The actual file extension doesn't matter.

In EXE files we create the stack segment , but in the COM files it creates the stack automatically .

40

Page 41: Viruses and Anti-Viruses

Difference Between .COM and .EXE files

Page 42: Viruses and Anti-Viruses

How to Write a .COM programProgram Size

maximum 64K (including 256-byte PSP)data, stack, and code in one (64k) segmentstack segment in a COM program is automatically

GeneratedInitialization for COM Program

All four segment registers are automatically initialized with PSP address

Addressing begins at address 100H after .CODE directive, need the directive:

ORG 100H

Page 43: Viruses and Anti-Viruses

How to assemble it

Page 44: Viruses and Anti-Viruses

Example of .COM codeMAIN SEGMENT BYTE

ASSUME CS:MAIN,DS:MAIN,SS:NOTHINGORG 100H

START:FINISH:

mov ah,4CHmov al,0int 21H

MAIN ENDSEND START

Page 45: Viruses and Anti-Viruses

A.BAT fileA .BAT file is a file that contains a

sequence, or batch, of commands . Batch files are useful for storing sets of commands that are always executed together because you can simply enter the name of the batch file instead of entering each command individually.

Page 46: Viruses and Anti-Viruses
Page 47: Viruses and Anti-Viruses

TIMIDTIMID The Host of our Virus

Page 48: Viruses and Anti-Viruses

labels

Page 49: Viruses and Anti-Viruses

63

Page 50: Viruses and Anti-Viruses

SummaryMalware kinds

Virus, worms, Trojans, adware, spyware, etc.Anti-Virus Technologies

Static, Dynamic ScannersAV Process

Anti-AV TechniquesTransform, Hide

Research ResultsUndo transformationDetect obfuscationCreate phylogeny

Code explanation

64