Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Self-modifying Code program intentionally modifies code in the program by overwriting machine code may be used by code designers to obscure branch addresses."— Presentation transcript:

1 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)

2 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 wait 6. Acc <- MDR Single bus architecture, instruction execution (simplified!) M D R Accumulator IR SP MAR PC Rn R0 ALU CCR buffer

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

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

5 data dc.l $13fc01ff, $00e0110,$533901e0,$001067f8,$4e722600
self modifying code START ORG $1000 F lea data,a0 E3C 00000FFF move.l #4095,d7 100C 203C move.l #$100,d0 1012 B loop: eor.l d0,(a0)+ CF FFFC dbra d7,loop bra data 101C 4E stop #$2700 1020= 13FC01FF 000E data dc.l $13fc01ff, $00e0110,$533901e0,$001067f8,$4e722600 END START

6 1008 41FA 000A time1 lea label+2(pc),a0 100C 3210 move.w (a0),d1
self modifying code START ORG $1000 C move.w #$0004,d2 C move.w #5,d0 FA 000A time1 lea label+2(pc),a0 100C move.w (a0),d1 100E B eor.w d2,d1 C move.w d1,(a0)+ C8 FFF4 label dbra d0,time1 1016 4E stop #$2700 END START


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

Similar presentations


Ads by Google