Vulnerabilities: Malicious Code Class 10 P&P: Ch 3.3, 3.4 1 - - PowerPoint PPT Presentation

vulnerabilities malicious code
SMART_READER_LITE
LIVE PREVIEW

Vulnerabilities: Malicious Code Class 10 P&P: Ch 3.3, 3.4 1 - - PowerPoint PPT Presentation

Vulnerabilities: Malicious Code Class 10 P&P: Ch 3.3, 3.4 1 CIS-5372: 9.Nov.2011 Announcement Presence sheet Solution to Homework 2 is out Grades will follow 2 CIS-5372: 9.Nov.2011 What Did We Cover Before ?


slide-1
SLIDE 1

CIS-5372: 9.Nov.2011

1 Class 10

Vulnerabilities: Malicious Code

P&P: Ch 3.3, 3.4

slide-2
SLIDE 2

CIS-5372: 9.Nov.2011

2

  • Presence sheet
  • Solution to Homework 2 is out
  • Grades will follow …

Announcement

slide-3
SLIDE 3

CIS-5372: 9.Nov.2011

3

  • Nonmalicious Program Errors
  • Buffer Overflows
  • Incomplete Mediation
  • TOCTTOU
  • Introduction to Malicious Code

What Did We Cover Before ?

slide-4
SLIDE 4

CIS-5372: 9.Nov.2011

4

  • Viruses
  • How they attach
  • How they gain control
  • Where they are stored
  • Detection …
  • Worms
  • Web Bugs
  • Trapdoors

In this lecture

slide-5
SLIDE 5

CIS-5372: 9.Nov.2011

5

  • Program that can infect other programs by

modifying them to include a, possibly evolved, version of itself

  • Fred Cohen 1983

What is a Virus ?

slide-6
SLIDE 6

CIS-5372: 9.Nov.2011

6

  • Hard to detect
  • Not easily destroyed or deactivated
  • Spreads widely
  • Can re-infect home program/other programs
  • Easy to create
  • Machine/OS independent

Qualities of Virus

slide-7
SLIDE 7

CIS-5372: 9.Nov.2011

7

How Viruses Attach

1. Virus is on CD

  • When executed, the virus can
  • Install on hard drive
  • Attach to any executing program in memory

2. E-mail virus

  • The attacker convince victim to open attachment
  • Executable file
  • Graphics, photos …
slide-8
SLIDE 8

CIS-5372: 9.Nov.2011

8

How Viruses Attach (cont’d)

  • Appending
  • Surrounding
  • Integrated
  • Overwriting
slide-9
SLIDE 9

CIS-5372: 9.Nov.2011

9

Targeted Executable Virus Original Program Virus

Apending Virus

  • Add to beginning of target
  • First instruction of new program

Virus writer doesn’t need to know target program

slide-10
SLIDE 10

CIS-5372: 9.Nov.2011

10

Targeted Executable Virus

Surrounding Virus

Virus B Original Program Virus A

  • Add to beginning and end of target
  • Control before and after target program
slide-11
SLIDE 11

CIS-5372: 9.Nov.2011

11

Surrounding Virus - Example

  • Prevent user from detecting virus
  • Using file name and size during ls/dir command
  • Virus attaches to ls/dir command
  • When ls/dir completes, virus takes control
  • Eliminate entry from listing
  • Distribute space among other programs to hide size
slide-12
SLIDE 12

CIS-5372: 9.Nov.2011

12

Targeted Executable Virus Infected host Executable Virus

Integrated Virus

  • Replace some of target

Virus writer needs to know target program

slide-13
SLIDE 13

CIS-5372: 9.Nov.2011

13

Targeted Executable Virus

Virus Part 1 Virus Part 2 Virus Part n

Integrated Virus (cont’d)

slide-14
SLIDE 14

CIS-5372: 9.Nov.2011

14

Targeted Executable Virus Virus

Overwriting Virus

  • Replace entire target
  • Mimick effect of target or
  • Not – user likely to perceive virus
slide-15
SLIDE 15

CIS-5372: 9.Nov.2011

15

  • After attachment virus needs to be invoked
  • Overwriting a target program
  • Changing pointers to programs
  • V denotes virus, T is the target program

How Viruses Gain Control

slide-16
SLIDE 16

CIS-5372: 9.Nov.2011

16

Overwriting the Target

File Directory T Hard Disk

T V V When T is invoked V is actually executed !

  • Overwrite T with V
slide-17
SLIDE 17

CIS-5372: 9.Nov.2011

17

Changing Pointer To Target

File Directory T Hard Disk

T V When T is invoked V is again executed !

  • Change pointer to T to point to V
slide-18
SLIDE 18

CIS-5372: 9.Nov.2011

18

  • One-Time execution
  • Boot sector
  • Memory resident

Where Are Viruses Stored

slide-19
SLIDE 19

CIS-5372: 9.Nov.2011

19

Virus writer generates e-mail

1. Sends it to all addresses in victim’s address book 2. Or leave it to the victim to forward it

One-Time Execution: E-mail

slide-20
SLIDE 20

CIS-5372: 9.Nov.2011

20

  • Waledac malicious domain from pandalab blog

One-Time Execution: Valentine Day

slide-21
SLIDE 21

CIS-5372: 9.Nov.2011

21

  • from pandalab blog

One-Time Execution: Fake Antivirus

slide-22
SLIDE 22

CIS-5372: 9.Nov.2011

22

  • from pandalab blog

One-Time Execution: Fake Page

slide-23
SLIDE 23

CIS-5372: 9.Nov.2011

23

  • Popular

query

  • 35.5% are

malwares

(Kalafut 2006)

One-Time Execution: P2P Files

slide-24
SLIDE 24

CIS-5372: 9.Nov.2011

24

  • When computer starts
  • Firmware determines hardware components
  • Transfer control to OS
  • OS stored on disk
  • Bootstrap process:
  • Firmware reads boot sector to a fixed address in mem
  • Jump to that address
  • Boot sector contains the bootloader
  • Bootloader pulls the rest of the OS from disk

Boot Sector Viruses

slide-25
SLIDE 25

CIS-5372: 9.Nov.2011

25

  • Boot sector has 512 bytes
  • Bootstrap loader size > 512 bytes
  • Use chaining

Boot Sector

Bootstrap Loader

Hard Disk

Bstrap Ldr (bloc 2) Bstrap Ldr (bloc 3) Boot sector

slide-26
SLIDE 26

CIS-5372: 9.Nov.2011

26

  • The virus could be placed in any bootstrap sector
  • But … boot sector particularly appealing
  • Virus gains control right at the beginning
  • Protection tools are not yet active

Placing Virus in Boot Sector

Virus Code

Hard Disk

Bstrap Ldr (bloc 2) Bstrap Ldr (bloc 3) Boot sector Bootstrap Loader

slide-27
SLIDE 27

CIS-5372: 9.Nov.2011

27

  • Changes label of infected disks to BRAIN 
  • From Pakistan (Believed)
  • Sole purpose: to pass the infection
  • Traps disk read interrupts
  • Only interested in reads in the boot sector
  • Believed to be proof-of-concept
  • Many other variants, more efficient …

Example: The BRAIN Virus

slide-28
SLIDE 28

CIS-5372: 9.Nov.2011

28

The BRAIN Virus Location

Boot sector BRAIN 1 Boot sector BRAIN 2 BRAIN 3 BRAIN 1-dup BRAIN 3-dup BRAIN 2-dup Before After … Marked as faulty Hard Drive

slide-29
SLIDE 29

CIS-5372: 9.Nov.2011

29

The BRAIN Virus Infection

1. Locates in upper memory 2. System call to reset upper memory below it 3. Traps interrupt #19 (disk read) 4. Any disk read for boot sector returns content of hijacked sector Interrupt Address Table # 19 # 6 Memory To upper To lower

BRAIN

Reset Upper Memory Bound Code for interrupt 19

slide-30
SLIDE 30

CIS-5372: 9.Nov.2011

30

  • Viruses
  • How they attach
  • How they gain control
  • Where they are stored
  • Detection …
  • Worms
  • Web Bugs
  • Trapdoors

In this lecture

slide-31
SLIDE 31

CIS-5372: 9.Nov.2011

31

  • Based on
  • Virus Signatures
  • Storage Patterns
  • Execution Patterns
  • Transmission Patterns
  • Virus scanner uses such patterns to
  • Detect
  • And even remove viruses

Virus Detection

slide-32
SLIDE 32

CIS-5372: 9.Nov.2011

32

  • Virus cannot be completely invisible
  • Code must be stored somewhere
  • Code must be in memory to execute
  • Executes according to a pattern
  • Spreads using certain mechanisms
  • Example: Code Red

Virus signatures

Signature

GET /default.ida?XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX %u9090%u6858%ucbd3%u7801%u9090%u6858%ucbd3%u7801 %u9090%u6858%ucbd3%u7801%u9090%u9090%u8190%u00c3 %u0003%u8b00%u531b%u53ff%u0078%u0000%u00=a HTTP/1.0

slide-33
SLIDE 33

CIS-5372: 9.Nov.2011

33

  • Viruses
  • Worms
  • Web Bugs
  • Trapdoors

In this lecture

slide-34
SLIDE 34

CIS-5372: 9.Nov.2011

34

  • Reproducing programs that run independently

and travel across network connections.

  • Reproduction Differences:
  • A virus is dependent upon a host file or boot

sector, and the transfer of files between machines to spread.

  • A worm can run completely independently and

spread of its own will through network connections.

Reminder: What is a Worm

slide-35
SLIDE 35

CIS-5372: 9.Nov.2011

35

  • November 2nd 1988
  • Internet Worm released
  • Infected many computers
  • Many more severed network connection
  • Robert T. Morris Jr.
  • $10,000 fine
  • 3 year suspended jail sentence
  • 400 hours community service
  • Now with MIT

Example: The Internet Worm

slide-36
SLIDE 36

CIS-5372: 9.Nov.2011

36

1. Determine where it could spread 2. Spread to new target 3. Remain undiscovered and undiscoverable

Intent of Internet Worm

slide-37
SLIDE 37

CIS-5372: 9.Nov.2011

37

  • Exploited three known vulnerabilities

1. Find user accounts to invade on target system

  • Remember password vulnerabilities
  • 432 common passwords + dictionary file

2. Fingerd: daemon which responds to queries about users

  • Known buffer overflow vulnerability
  • Give worm a remote shell

3. Sendmail trapdoor

  • In debug mode, sendmail can execute input string

Determine Targets

slide-38
SLIDE 38

CIS-5372: 9.Nov.2011

38

  • Send a bootstrap loader to target machine
  • 99 lines of C code
  • Compile and execute on target machine
  • Fetch rest of worm code from the sending system
  • Element of good security 
  • Bootstrap loader required to provide password to

sending system

  • If fail, sending system breaks connection

Spread Infection

slide-39
SLIDE 39

CIS-5372: 9.Nov.2011

39

1. If transmission error occurs during worm fetch

  • Bootstrap loader removes code and exits

2. Bring all worm code in memory

  • Encrypt copy in memory
  • Delete copy from disk
  • Thus, the worm cannot easily be discovered

3. Periodic change of name and process id

  • Avoid single process running a long time

Remain Undiscovered

slide-40
SLIDE 40

CIS-5372: 9.Nov.2011

40

1. Resource exhaustion

  • If target was already infected, propagate one copy
  • Bug in code (): many copies did not terminate !
  • Thus, serious performance degradation

2. Disconnection of machines from Internet

  • To prevent copies from trying to propagate
  • … or to prevent infection

3. Isolation and inability to perform work

  • Estimated cost $100,000 - $97 million
  • Thousands of systems were disconnected

Effect of Internet Worm

slide-41
SLIDE 41

CIS-5372: 9.Nov.2011

41

  • Viruses
  • Worms
  • Web Bugs
  • Trapdoors
  • Salami Attack
  • Rootkits
  • Privilege Escalation
  • Keystroke Logging
  • Covert Channels

What do we cover

slide-42
SLIDE 42

CIS-5372: 9.Nov.2011

42

  • Pixel tag, clear gif/one-by-one/invisible gif
  • Part of a web page
  • Invisible to user
  • Track activities of the user
  • Plants a cookie in your computer

Web Bugs

slide-43
SLIDE 43

CIS-5372: 9.Nov.2011

43

  • Set by web sites
  • To push storage from web sites to user platform
  • Have 6 fields
  • (name, value, expiration, path to server, server

domain, SSL-req?)

  • Used to remember values for subsequent usage
  • (“visa credit card”, 1234 1234 1234 1234, …)
  • (“user id”, carbunar, …)
  • (“password”, ****, …)
  • Used to build browsing profile
  • (“visits for www.abc.com”, 10, …)

Cookies

slide-44
SLIDE 44

CIS-5372: 9.Nov.2011

44

  • Can build a profile for the user containing
  • Surfing habits
  • Personal data: name, DOB, address, IP address, etc
  • Can be used for good or bad purposes
  • How ?

Web Bugs (cont’d)

slide-45
SLIDE 45

CIS-5372: 9.Nov.2011

45

  • Viruses
  • Worms
  • Web Bugs
  • Trapdoors
  • Salami Attack
  • Rootkits
  • Privilege Escalation
  • Keystroke Logging
  • Covert Channels

What do we cover

slide-46
SLIDE 46

CIS-5372: 9.Nov.2011

46

  • Undocumented entry point to a software module
  • For testing purposes
  • For future updates
  • For access in case of future failures

Trapdoors

slide-47
SLIDE 47

CIS-5372: 9.Nov.2011

47

  • Hidden trap door in Linux, Nov 2003
  • Allows attacker to take over a computer
  • Practically undetectable change
  • Uncovered by anomaly in CVS usage
  • Inserted line in wait4()

if ((options == (__WCLONE|__WALL)) && (current->uid = 0)) retval = -EINVAL;

See: http://lwn.net/Articles/57135/

Trapdoor: Example 1

  • Looks like a standard error check
  • Anyone see the problem?
slide-48
SLIDE 48

CIS-5372: 9.Nov.2011

48

  • Rob Harris case - slot machines
  • Insider: worked for Gaming Control Board
  • Malicious code in testing unit
  • When testers checked slot machines
  • Downloaded malicious code to slot machine
  • Was never detected
  • Special sequence of coins activated “winning

mode”

  • Caught when greed sparked investigation
  • $100,000 jackpot

Trapdoor: Example 2

slide-49
SLIDE 49

CIS-5372: 9.Nov.2011

49

  • Breeder’s cup race
  • Upgrade of software to phone betting system
  • Insider, Christopher Harn, rigged software
  • Allowed him and accomplices to call in
  • Change the bets that were placed
  • Undetectable
  • Caught when got greedy
  • Won $3 million

http://horseracing.about.com/library/weekly/aa110102a.htm

Trapdoor: Example 3

slide-50
SLIDE 50

CIS-5372: 9.Nov.2011

50

  • Reason for persistence: developers
  • Forget to remove them
  • Leave them for testing
  • Leave them for maintenance
  • Leave them as covert means of access to component

Trapdoors (cont’d)

slide-51
SLIDE 51

CIS-5372: 9.Nov.2011

51

  • Viruses
  • Worms
  • Web Bugs
  • Trapdoors
  • Salami Attack
  • Rootkits
  • Privilege Escalation
  • Keystroke Logging
  • Covert Channels

What do we cover

slide-52
SLIDE 52

CIS-5372: 9.Nov.2011

52

  • Perform many inconsequential operations with

powerful final results

  • Example 1 – bank interest
  • Account has $102.87
  • Interest rate is 6.5% per year
  • After one month interest = 31/365 * 0.065 * 102.87 =

$0.5495726

  • Round to 0.54 instead of 0.55: nobody notices !
  • $0.0095726 goes into attacker’s account
  • Example 2 – steal a few cents from each account
  • Who checks balance ?

Salami Attack

slide-53
SLIDE 53

CIS-5372: 9.Nov.2011

53

  • Viruses
  • Worms
  • Web Bugs
  • Trapdoors
  • Salami Attack
  • Rootkits
  • Privilege Escalation
  • Keystroke Logging
  • Covert Channels

What do we cover

slide-54
SLIDE 54

CIS-5372: 9.Nov.2011

54

  • Virus variation
  • Attempts to operate as root
  • While staying undiscovered
  • And attempting to reinstall itself if removed
  • How to go undiscovered ?
  • If the system call is ls or dir

1. Intercept system call result 2. Remove itself from the list 3. Adjust sizes of other files so free space seems legitimate

Rootkits

slide-55
SLIDE 55

CIS-5372: 9.Nov.2011

55

  • Prevents users from copying music CDs
  • Allows them to play music
  • Has its own music player
  • Garbles the results of any other access to CD
  • Installs with first insertion of CD
  • Due to autorun feature of Microsoft
  • To conceal existence, XCP
  • Blocks display of any program starting with $sys$
  • Including a virus called $sys$virus-1 …

Sony XCP Rootkit

slide-56
SLIDE 56

CIS-5372: 9.Nov.2011

56

  • Viruses
  • Worms
  • Web Bugs
  • Trapdoors
  • Salami Attack
  • Rootkits
  • Privilege Escalation
  • Keystroke Logging
  • Covert Channels

What do we cover

slide-57
SLIDE 57

CIS-5372: 9.Nov.2011

57

  • Assume malicious code has installed on your

account

  • Can run processes with your capabilities
  • Can access all your resources
  • … But not other resources
  • Attacker wants to run with superuser capabilities
  • To access system resources
  • Or other user’s resources

Privilege Escalation

slide-58
SLIDE 58

CIS-5372: 9.Nov.2011

58

  • Symantec: software security company
  • Virus scanners, spam filters, system integrity tools …
  • Has a Live Update feature
  • Ensure you are running the latest version
  • Periodic or manual invocation
  • Runs with elevated privileges
  • Installs programs in system directory

Privilege Escalation Example

slide-59
SLIDE 59

CIS-5372: 9.Nov.2011

59

  • Assume Live Update consists of two components

Example (cont’d)

LU1.exe Live Update component sys2.exe OS component Runs with elevated privileges !

Invokes

slide-60
SLIDE 60

CIS-5372: 9.Nov.2011

60

  • Search Path:
  • Mechanism allowing OS to find program to execute
  • E.g., Path = C:\program files\symantec (LU1.exe)
  • OS uses first instance found in path
  • User can specify the search path (add/remove)

Search Path

slide-61
SLIDE 61

CIS-5372: 9.Nov.2011

61

1. Attacker has infected user account 2. Attacker creates its own sys2.exe version

  • D:\Documents\sys2.exe
  • Path = D:\Documents\::C:\program files\symantec

3. Launch Live Update

  • When LU1 invokes sys2.exe
  • The OS uses first sys2.exe instance in search path
  • Which runs with elevated privileges

Privilege Escalation Attack

slide-62
SLIDE 62

CIS-5372: 9.Nov.2011

62

  • Viruses
  • Web Bugs
  • Trapdoors
  • Salami Attack
  • Rootkits
  • Privilege Escalation
  • Keystroke Logging
  • Covert Channels

What do we cover

slide-63
SLIDE 63

CIS-5372: 9.Nov.2011

63

Keystroke Logging

Signal

Keyboard Device driver

Pass along

Key press

Log keys

Keylogger

Types of keyloggers

 Independent – log of all keystrokes  Tied to a certain app – log only keystrokes for banking app

Word processor

slide-64
SLIDE 64

CIS-5372: 9.Nov.2011

64

  • Viruses
  • Worms
  • Web Bugs
  • Trapdoors
  • Salami Attack
  • Rootkits
  • Privilege Escalation
  • Keystroke Logging
  • Covert Channels

What do we cover

slide-65
SLIDE 65

CIS-5372: 9.Nov.2011

65

  • Communicate information surreptitiously
  • How ?
  • Use existing communication channels to hide

information

  • Example: cheating students 
  • One student knows the material
  • Four types of answers: a, b, c, d
  • Cough for a, yawn for b, …
  • Problem !
  • If student looses track, it may get the answer for

wrong question

Covert Channels: Intro

slide-66
SLIDE 66

CIS-5372: 9.Nov.2011

66

  • Attacker needs access to data

Covert Channels: The Problem

Data Trojan Horse Organization Attacker

Read data Signal data

Attacker cannot simply send the data (even encrypted) Why ?

slide-67
SLIDE 67

CIS-5372: 9.Nov.2011

67

  • Modify existing communication in slight ways
  • Assumes attacker and trojan horse share a code
  • Example:
  • Change header of file:
  • Word TOTAL implies bit=0
  • Word TOTALS implies bit=1
  • Adding spaces
  • Modify last digit in insignificant field
  • Use of . instead of :

Covert Channels: How To

slide-68
SLIDE 68

CIS-5372: 9.Nov.2011

68

  • Pass information using presence of absence of
  • bjects in storage
  • Assumes attacker and trojan horse
  • Divide time into intervals
  • Are time synchronized

Storage Channels

slide-69
SLIDE 69

CIS-5372: 9.Nov.2011

69

  • File lock channel
  • Used to provide atomic operations on file
  • Trojan and attacker share a file
  • In each interval
  • If bit=1 then trojan locks the file
  • Attacker tries to access file. If fail, bit=1
  • Disk quota
  • If bit=1, trojan creates large file, otherwise does nothing
  • Attacker tries to create file; if not able, bit=1

Storage Channels: Example

slide-70
SLIDE 70

CIS-5372: 9.Nov.2011

70

  • Trojan
  • bit = 1  enter computation intensive loop
  • bit = 0  go to sleep
  • Attacker
  • perform a task with known computational requirements
  • if completed quickly then bit = 0 otherwise bit = 1

Timing Channel

slide-71
SLIDE 71

CIS-5372: 9.Nov.2011

71

  • Malicious code – Malware
  • What attackers can do with vulnerabilities
  • Many other attacks- the list is by far incomplete
  • Have created significant damage
  • Why a problem
  • Good code is hard to write
  • Patching vulnerabilities is error prone
  • Not everyone does it
  • Cat-and-mouse game between attackers and defense

Summary