DOC PREVIEW
Princeton COS 217 - Computer Security

This preview shows page 1-2-15-16-31-32 out of 32 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Computer SecurityInteracting With the WorldProtection MechanismsUser Processes Can’t Directly Access I/OHow Attackers Defeat ProtectionA Nice Little ProgramWhy Did This Program Crash?Stack Frame Layout: Local VariablesStack Frame: Modifying Local VariableStack Frame: Returning From FunctionBuffer OverrunInnocuous? Buffer OverrunBuffer overrunBuffer-Overrun VulnerabilitiesAttacking a Web ServerAttacking a Web BrowserAttacking everything in sightYour Programming AssignmentThree Ways to Change the GradeOK, That’s a B...How About an A?A Simpler SolutionThe File getAWhat Value to Use for New Return Address?Use gdb to Find OutDefenses Against This AttackSlide 27Slide 28Segment Register DefenceAt Your Service...How to Get StartedStart Early1Computer SecurityProfessor Jennifer RexfordCS 2172Interacting With the WorldHardwareOS KernelUserProcessUserProcessInternetKeypress goesto OS kernelOS looks up which window has “keyboard focus,” routes to appropriate user process’s stdinUser process does fprintf (asks OS to write to disk)OS writes to diskTCP packet goes to OS kernelOS looks up which process is listening on that port, sends data to stdinUser process does fprintf (asks OS to write to disk)OS writes to disk3Protection MechanismsKeypress goesto OS kernelOS looks up which window has “keyboard focus,” routes to appropriate user process’s stdinUser process does fprintf (asks OS to write to disk)OS writes to diskTCP packet goes to OS kernelOS looks up which process is listening on that port, sends data to stdinUser process does fprintf (asks OS to write to disk)OS writes to disk• Not to user process directly!• Not to unauthorized user process!• User process can’t access disk directly!• OS writes only to files that user process has privileges to open!User Processes Can’t Directly Access I/O•Input/output instructions are privileged instructionsTrying to run them in unprivileged mode triggers trap to OS•Input/output device registers may be memory-mappedVirtual-memory system doesn’t map those pages into user space•Virtual-memory system prevents user process from modifying OS memoryCan’t fool OS into performing unauthorized services•Virtual-memory prevents user processes from modifying each others’ memoryCan’t fool other processes into writing bad data to its files on disk5How Attackers Defeat Protection•Make the protection mechanism failBy exploiting bugs in protection software•Operate politely through the protection mechanism Manipulating application semantics to obtain servicesBy exploiting bad design of applications•Example: buffer overflow attacksExploit a program that doesn’t perform bounds checkingBy presenting large input that runs past the array bounds… and craft that input to be executed as machine code6A Nice Little Program% a.outWhat is your name?John SmithThank you, John Smith.%#include <stdio.h>int main(int argc, char **argv) { char a[12]; int i; printf(“What is your name?\n”); for (i=0; ; i++) { int c = getchar(); if (c ==‘\n’|| c == EOF) break; a[i] = c; } a[i]=’\0’; printf(“Thank you, %s.\n”,a); return 0;}7Why Did This Program Crash?% a.outWhat is your name?adsli57asdkhj5jklds;ahj5;klsaduj5klysdukl5aujksd5ukals;5uj;akuklaSegmentation fault%#include <stdio.h>int main(int argc, char **argv) { char a[12]; int i; printf(“What is your name?\n”); for (i=0; ; i++) { int c = getchar(); if (c ==‘\n’|| c == EOF) break; a[i] = c; } a[i]=’\0’; printf(“Thank you, %s.\n”,a); return 0;}8Stack Frame Layout: Local Variables•Allocates 12 bytes on the stack for array a[]•Uses registers for integers i and c(compiled with “gcc –O”)2Saved RegistersargcargvParametersOld EIP%EBPOld EBP#include <stdio.h>int main(int argc, char **argv) { char a[12]; int i; printf(“What is your name?\n”); for (i=0; ; i++) { int c = getchar(); if (c ==‘\n’|| c == EOF) break; a[i] = c; } a[i]=’\0’; printf(“Thank you, %s.\n”,a); return 0;}%ESPaLocal variables? ? ? ?? ? ??? ???9Stack Frame: Modifying Local Variable%EBP2%ESPSaved Registersargcargvan h o Ji m S_?\0h tLocal variablesParameters% a.outWhat is your name?John SmithThank you, John Smith.%Old EBPOld EIP#include <stdio.h>int main(int argc, char **argv) { char a[12]; int i; printf(“What is your name?\n”); for (i=0; ; i++) { int c = getchar(); if (c ==‘\n’|| c == EOF) break; a[i] = c; } a[i]=’\0’; printf(“Thank you, %s.\n”,a); return 0;}10Stack Frame: Returning From Function•Discard the stack frame by setting ESP to EBPmovl %ebp, %esp•Pop the old base pointer (EBP) to restore the valuepopl %ebp•Pop instruction pointer (EIP) to return control to calling functionret%EBP2%ESPSaved Registersargcargvan h o Ji m S_?\0h tLocal variablesParametersOld EBPOld EIP11Buffer Overrun%EBP117%ESPSaved Registersargcargvad c b ah g f el k j iLocal variablesParameters% a.outWhat is your name?abcdefghijklmnopqrstuSegmentation fault%Old EBPOld EIPp o n mt s r qu#include <stdio.h>int main(int argc, char **argv) { char a[12]; int i; printf(“What is your name?\n”); for (i=0; ; i++) { int c = getchar(); if (c ==‘\n’|| c == EOF) break; a[i] = c; } a[i]=’\0’; printf(“Thank you, %s.\n”,a); return 0;}12Innocuous? Buffer Overrun%EBP1%ESPSaved Registersargcargvad c b ah g f el k j iLocal variablesParameters% a.outWhat is your name?abcdefghijkl????!!!!^A%Old EBPOld EIP? ? ? ?! ! ! !^A#include <stdio.h>int main(int argc, char **argv) { char a[12]; int i; printf(“What is your name?\n”); for (i=0; ; i++) { int c = getchar(); if (c ==‘\n’|| c == EOF) break; a[i] = c; } a[i]=’\0’; printf(“Thank you, %s.\n”,a); return 0;}After “return”, the computer starts running the “code” stored at this address!!!13Buffer overrun%EBPexecutablemachinecode. . .argcargvad c b ah g f el k j iLocal variablesParameters% a.outWhat is your name?abcdefghijkl????&&&&executable-machine-code...How may I serve you, master?%Old EBPOld EIP? ? ? ?& & & &Cleverly malicious?Maliciously clever?#include <stdio.h>int main(int argc, char **argv) { char a[12]; int i; printf(“What is your name?\n”); for (i=0; ; i++) { int c = getchar(); if (c ==‘\n’|| c == EOF) break; a[i] = c; } a[i]=’\0’; printf(“Thank you, %s.\n”,a); return 0;}%ESP14Buffer-Overrun VulnerabilitiesHardwareOS KernelE-mailclientWeb


View Full Document

Princeton COS 217 - Computer Security

Documents in this Course
Summary

Summary

4 pages

Lecture

Lecture

4 pages

Generics

Generics

14 pages

Generics

Generics

16 pages

Lecture

Lecture

20 pages

Debugging

Debugging

35 pages

Types

Types

7 pages

Lecture

Lecture

21 pages

Assembler

Assembler

16 pages

Lecture

Lecture

20 pages

Lecture

Lecture

39 pages

Testing

Testing

44 pages

Pipeline

Pipeline

19 pages

Lecture

Lecture

6 pages

Signals

Signals

67 pages

Building

Building

17 pages

Lecture

Lecture

7 pages

Modules

Modules

12 pages

Generics

Generics

16 pages

Testing

Testing

22 pages

Signals

Signals

34 pages

Lecture

Lecture

19 pages

Load more
Download Computer Security
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Computer Security and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Computer Security 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?