Docsity

Lecture 27: Viruses and Object-Oriented Programming - Undecidability and History - Prof. D, Study notes of Computer Science

Toggle sidebar
bg1
1
David Evans
http://www.cs.virginia.edu/evans
CS150: Computer Science
University of Virginia
Computer Science
Lecture 27:
Lecture 27:
Viruses and
Viruses and
Object
Object-
-Oriented
Oriented
Programming
Programming
Avian Flu Virus
2
Lecture 27: Viruses and OOP
From Paul Graham’s ā€œUndergraduationā€:
My friend Robert learned a lot by writing network software
when he was an undergrad. One of his projects was to connect
Harvard to the Arpanet; it had been one of the original nodes,
but by 1984 the connection had died. Not only was this work
not for a class, but because he spent all his time on it and
neglected his studies, he was kicked out of school for a year.
... When Robert got kicked out of grad school for writing the
Internet worm of 1988, I envied him enormously for finding a
way out without the stigma of failure.
... It all evened out in the end, and now he’s a professor at
MIT. But you’ll probably be happier if you don’t go to that
extreme; it caused him a lot of worry at the time.
3 years of probation, 400 hours of community service, $10,000+ fine
3
Lecture 27: Viruses and OOP
Morris Internet Worm (1988)
•
P
= fingerd
– Program used to query user status
– Worm also attacked other programs
•
I
= ā€œnop400 pushl $68732f pushl $6e69622f movl
sp,r10 pushl $0 pushl $0 pushl r10 pushl $3 movl
sp,ap chmk $3bā€
(is-worm? ā€˜(P I)) should evaluate to #t
• Worm infected several thousand computers
(~10% of Internet in 1988)
4
Lecture 27: Viruses and OOP
Worm Detection Problem
Input: A program
P
and input
I
Output: true if evaluating (P I) would cause
a remote computer to be ā€œinfectedā€.
Virus Detection Problem
Input: A program specification
P
Output: true if evaluating (P) would cause a
file on the host computer to be ā€œinfectedā€.
5
Lecture 27: Viruses and OOP
Uncomputability Proof
Suppose we could define is-virus? Then:
(define (halts? P)
(is-virus?
ā€˜(lambda ()
(begin ((remove-infects P))
(infect-files)))))
6
Lecture 27: Viruses and OOP
Uncomputability Proof
(define (halts? P)
(is-virus?
ā€˜(lambda ()
(begin ((remove-infects P))
(infect-files)))))
#t: Since it
is
a virus, we know (infect-files) was
evaluated, and
P
must halt.
#f: The (infect-files) would not evaluate, so
P
must not halt.
Can we make
remove-
infects
?
Yes, just remove
all file writes.
pf3
pf4
pf5

Partial preview of the text

Download Lecture 27: Viruses and Object-Oriented Programming - Undecidability and History - Prof. D and more Study notes Computer Science in PDF only on Docsity!

David Evans http://www.cs.virginia.edu/evans

CS150: Computer Science University of Virginia Computer Science

Lecture 27: Lecture 27:

Viruses and Viruses and

Object Object--OrientedOriented

Programming Programming

Avian Flu Virus

Lecture 27: Viruses and OOP 2

From Paul Graham’s ā€œUndergraduationā€: My friend Robert learned a lot by writing network software when he was an undergrad. One of his projects was to connect Harvard to the Arpanet; it had been one of the original nodes, but by 1984 the connection had died. Not only was this work not for a class, but because he spent all his time on it and neglected his studies, he was kicked out of school for a year. ... When Robert got kicked out of grad school for writing the Internet worm of 1988, I envied him enormously for finding a way out without the stigma of failure. ... It all evened out in the end, and now he’s a professor at MIT. But you’ll probably be happier if you don’t go to that extreme; it caused him a lot of worry at the time. 3 years of probation, 400 hours of community service, $10,000+ fine

Lecture 27: Viruses and OOP 3

Morris Internet Worm (1988)

  • P = fingerd
    • Program used to query user status
    • Worm also attacked other programs
  • I = ā€œnop^400 pushl $68732f pushl $6e69622f movl sp,r10 pushl $0 pushl $0 pushl r10 pushl $3 movl sp,ap chmk $3bā€ (is-worm? ā€˜(P I)) should evaluate to #t
  • Worm infected several thousand computers (~10% of Internet in 1988)

Lecture 27: Viruses and OOP 4

Worm Detection Problem

Input: A program P and input I Output: true if evaluating (P I) would cause a remote computer to be ā€œinfectedā€.

Virus Detection Problem

Input: A program specification P Output: true if evaluating (P) would cause a file on the host computer to be ā€œinfectedā€.

Lecture 27: Viruses and OOP 5

Uncomputability Proof

Suppose we could define is-virus? Then:

(define (halts? P)

(is-virus?

ā€˜(lambda ()

(begin ((remove-infects P))

(infect-files)))))

Lecture 27: Viruses and OOP 6

Uncomputability Proof

(define (halts? P) (is-virus? ā€˜(lambda () (begin ((remove-infects P)) (infect-files))))) #t: Since it is a virus, we know (infect-files) was evaluated, and P must halt.

#f: The (infect-files) would not evaluate, so P must not halt.

Can we make remove- infects? Yes, just remove all file writes.

Lecture 27: Viruses and OOP 7

ā€œSolvingā€ Undecidable Problems

  • No perfect solution exists:
    • Undecidable means there is no procedure that:
      • Always gives the correct answer
      • Always terminates
  • Must give up one of these to ā€œsolveā€ undecidable problems - Giving up #2 is not acceptable in most cases - Must give up #
  • Or change the problem: e.g., detect file infections during an execution Lecture 27: Viruses and OOP 8

Conclusion?

  • Anti-Virus programs cannot exist! ā€œThe Art of Computer Virus Research and Defenseā€ Peter Szor, Symantec

Lecture 27: Viruses and OOP 9

Actual is-virus? Programs

  • Give the wrong answer sometimes
    • ā€œFalse positiveā€: say P is a virus when it isn’t
    • ā€œFalse negativeā€: say P is safe when it is
  • Database of known viruses: if P matches one of these, it is a virus
  • Clever virus authors can make viruses that change each time they propagate - Emulate program for a limited number of steps; if it doesn’t do anything bad, assume it is safe

Lecture 27: Viruses and OOP 10

Proof Recap

  • If we had is-virus? we could define halts?
  • We know halts? is undecidable
  • Hence, we can’t have is-virus?
  • Thus, we know is-virus? is undecidable

Lecture 27: Viruses and OOP 11

History of Object-Oriented Programming

Lecture 27: Viruses and OOP 12

Pre-History:

MIT’s Project Whirlwind (1947-1960s)

Jay Forrester

Lecture 27: Viruses and OOP 19

Counter in Simula

class counter; integer count; begin procedure reset(); count := 0; end; procedure next(); count := count + 1; end; integer procedure current(); current := count; end; end Lecture 27: Viruses and OOP 20

XEROX Palo Alto Research Center (PARC) 1970s:

  • Bitmapped display
  • Graphical User Interface
    • Steve Jobs paid $1M to visit and PARC, and returned to make Apple Lisa/Mac
  • Ethernet
  • First personal computer (Alto)
  • PostScript Printers
  • Object-Oriented Programming

Lecture 27: Viruses and OOP 21

Dynabook, 1972

(Just a model)

ā€œ Don’t worry about what anybody else is going to do… The best way to predict the future is to invent it. Really smart people with reasonable funding can do just about anything that doesn't violate too many of Newton's Laws!ā€ — Alan Kay, 1971

Lecture 27: Viruses and OOP 22

Dynabook 1972

  • Tablet computer
  • Intended as tool for learning
  • Kay wanted children to program it also
  • Hallway argument, Kay claims you could define ā€œthe most powerful language in the world in a page of codeā€
  • Proof: Smalltalk
    • Scheme is as powerful, but takes two pages
    • Before the end of the class, we will see an equally powerful language that fits in ¼ page

Lecture 27: Viruses and OOP 23

BYTE

Magazine,

August

Lecture 27: Viruses and OOP 24

Smalltalk

  • Everything is an object
  • Objects communicate by sending and receiving messages
  • Objects have their own state (which may contain other objects)
  • How do you do 3 + 4? send the object 3 the message ā€œ+ 4ā€

Lecture 27: Viruses and OOP 25

Counter in Smalltalk

class name counter

instance variable names count

new count <- 0

next count <- count + 1

current ^ count

Lecture 27: Viruses and OOP 26

Counter in Python

class counter: def init(self): self._count = 0 def rest(self): self._count = 0 def next(self): self._count = self._count + 1 def current(self): return self._count

counter() creates a new counter using the init method count is the instance variable ( is just a naming convention)

Lecture 27: Viruses and OOP 27

Who was the first

object-oriented

programmer?

Lecture 27: Viruses and OOP 28

By the word operation, we mean any process which alters the mutual relation of two or more things, be this relation of what kind it may. This is the most general definition, and would include all subjects in the universe. Again, it might act upon other things besides number, were objects found whose mutual fundamental relations could be expressed by those of the abstract science of operations, and which should be also susceptible of adaptations to the action of the operating notation and mechanism of the engine... Supposing, for instance, that the fundamental relations of pitched sounds in the science of harmony and of musical composition were susceptible of such expression and adaptations, the engine might compose elaborate and scientific pieces of music of any degree of complexity or extent. (^) Ada, Countess of Lovelace, around 1843

Lecture 27: Viruses and OOP 29

Charge

  • Chapter 12 and PS7 out now: start reading Chapter 12 before next class
  • The statement ā€œThere will be a surprise quiz some day this weekā€ may still be true
  • Wednesday: one more computability problem (ā€œthe AliG problemā€); interpreters and Python