Self-modifying Code program intentionally modifies code in the program by overwriting machine code may be used by code designers to obscure branch addresses.

Slides:



Advertisements
Similar presentations
The Fetch – Execute Cycle
Advertisements

Computer Architecture and the Fetch-Execute Cycle
Central Processing Unit
The Microprocessor and its Architecture
Multicycle Datapath & Control Andreas Klappenecker CPSC321 Computer Architecture.
1  1998 Morgan Kaufmann Publishers We will be reusing functional units –ALU used to compute address and to increment PC –Memory used for instruction and.
Chapters 5 - The LC-3 LC-3 Computer Architecture Memory Map
Dale & Lewis Chapter 5 Computing components. Let’s design a computer Generic CPU with registers −Program counter (PC) – 5 bits (size of addresses) −Instruction.
Lecture 13 - Introduction to the Central Processing Unit (CPU)
CPU Fetch/Execute Cycle
Fetch Execute Cycle Travis Griffiths. Naming Conventions and Disclaimer Individual registers in a particular CPU will have different names depending on.
Computer Science 210 Computer Organization The Instruction Execution Cycle.
TDC 311 The Microarchitecture. Introduction As mentioned earlier in the class, one Java statement generates multiple machine code statements Then one.
Processor Design ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.
Computer Architecture and the Fetch-Execute Cycle
Computer Architecture and the Fetch-Execute Cycle
Model Computer CPU Arithmetic Logic Unit Control Unit Memory Unit
The structure COMPUTER ARCHITECTURE – The elementary educational computer.
Fetch-execute cycle.
COMPILERS CLASS 22/7,23/7. Introduction Compiler: A Compiler is a program that can read a program in one language (Source) and translate it into an equivalent.
Fetch-Execute Cycle Fetch the next instruction Decode Execute It.
Computer Systems Organization
Dale & Lewis Chapter 5 Computing components
Bus Architecture Memory unit AR PC DR E ALU AC INPR 16-bit Bus IR TR
Chapter 20 Computer Operations Computer Studies Today Chapter 20.
Lec 4-2 Five operations of the machine cycle Fetch- fetch the next program instruction from memory. (PC+1); instruction to IR Decode- decode the instruction.
Stored Program Concept Learning Objectives Learn the meaning of the stored program concept The processor and its components The fetch-decode-execute and.
OCR GCSE Computer Science Teaching and Learning Resources
ELEC 418 Advanced Digital Systems Dr. Ron Hayne
ELEC 418 Advanced Digital Systems Dr. Ron Hayne
Chapter 10: Computer systems (1)
Figure 8.1 of course package
Lecture 13 - Introduction to the Central Processing Unit (CPU)
Gunjeet Kaur Dronacharya Group of institutions
Subroutines … passing data
Lecture on Microcomputer
Chapter 4 The Von Neumann Model
Five Execution Steps Instruction Fetch
MIPS Instructions.
Ghifar Parahyangan Catholic University Sept 12, 2011
Computer Science 210 Computer Organization
System Architecture 1 Chapter 2.
The fetch-execute cycle
The Processor and Machine Language
ECE 445 CS1251 Computer Organization Carl Hamacher
Subroutines … a 1st look procedures and functions in high level languages are modeled on subroutines typically, assembly code is very modular with.
Computer Science 210 Computer Organization
Functional Units.
Computer Structure S.Abinash 11/29/ _02.
Topic 6 LC-3.
Passing Parameters Data passed to a subroutine is called a parameter.
Systems Architecture I (CS ) Lecture 2: A Simplified Computer
The Little Man Computer
Figure 8.1 of course package
PZ01C - Machine architecture
Multicycle Approach We will be reusing functional units
THE FETCH-EXECUTE CYCLE.
The Von Neumann Architecture Odds and Ends
Multicycle Design.
Subroutines … passing data
ARM7TDMI Block Diagram Barrel Shifter Booth Multiplie r Data Out Register. D[31:0] Control Lines Data In Register. B busA bus ALU bus PC A[31:0] A.L.U.
ARM7TDMI Block Diagram Barrel Shifter Booth Multiplie r Data Out Register. D[31:0] Control Lines Data In Register. B busA bus ALU bus PC A[31:0] A.L.U.
Basic Instruction Cycle
The Stored Program Computer
THE FETCH-EXECUTE CYCLE.
Information Representation: Machine Instructions
Objectives Describe common CPU components and their function: ALU Arithmetic Logic Unit), CU (Control Unit), Cache Explain the function of the CPU as.
Computer Architecture
ECE511: Digital System & Microprocessor
COMPUTER ARCHITECTURE
Presentation transcript:

Self-modifying Code program intentionally modifies code in the program by overwriting machine code may be used by code designers to obscure branch addresses -> obfuscation - security through obscurity sometimes used to write really tight code (really discouraged, code not maintainable)

Microprocessor Architecture ADD R0,NUM Microprocessor Architecture Instruction Fetch Execute 1. MAR<-PC, read 7. alu<-R0, add 2. wait, PC<-PC+1 Write Back 3. IR <- MDR 8. MDR<-buffer Instruction Decode 9. MAR<- ‘NUM’, 4. MAR <- ’NUM’, read write 5. Wait 10. wait 6. Acc <- MDR Single bus architecture, instruction execution (simplified!) M D R Accumulator IR SP MAR PC Rn … R0 ALU CCR buffer

1006 223A FFFA move.l start+2(pc),d1 code/data reuse Objective: obscure value in D1 1000 ORG $1000 1000 start: 1000 203C 20012002 move.l #$20012002,d0 1006 223A FFFA move.l start+2(pc),d1 100A 4EB9 00001xxx jsr dobasedond1 ... 1xxx 4E72 2700 stop #$2700 1xxx dobasedond1: 1xxx 4E75 rts END start

1000 4EBA 000E entry: jsr label2(pc) 1004 4EBA 0006 jsr label(pc) self modifying code 1000 ORG $1000 1000 4EBA 000E entry: jsr label2(pc) 1004 4EBA 0006 jsr label(pc) 1008 4E72 2700 stop #$2700 100C label: 100C 4E75 rts 100E 4E71 nop ← code of interest here 1010 41FA FFFA label2: lea label(pc),a0 1014 30BC 4E71 move.w #$4e71,(a0) 1018 4E75 rts 101A END entry

data dc.l $13fc01ff, $00e0110,$533901e0,$001067f8,$4e722600 self modifying code 1000 START ORG $1000 1000 41F9 00001020 lea data,a0 1006 2E3C 00000FFF move.l #4095,d7 100C 203C 00000100 move.l #$100,d0 1012 B198 loop: eor.l d0,(a0)+ 1014 51CF FFFC dbra d7,loop 1018 6000 0006 bra data 101C 4E72 2700 stop #$2700 1020= 13FC01FF 000E0110 ... data dc.l $13fc01ff, $00e0110,$533901e0,$001067f8,$4e722600 1034 END START

1008 41FA 000A time1 lea label+2(pc),a0 100C 3210 move.w (a0),d1 self modifying code 1000 START ORG $1000 1000 343C 0004 move.w #$0004,d2 1004 303C 0005 move.w #5,d0 1008 41FA 000A time1 lea label+2(pc),a0 100C 3210 move.w (a0),d1 100E B541 eor.w d2,d1 1010 30C1 move.w d1,(a0)+ 1012 51C8 FFF4 label dbra d0,time1 1016 4E72 2700 stop #$2700 END START