Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2020 交大程式安全:逆向工程上課講義-第一週(第三段)

terrynini
November 20, 2020

2020 交大程式安全:逆向工程上課講義-第一週(第三段)

(檔案大小有限制所以分三段上傳...)
這是三校合開的資訊安全課程,今年有幸可以負責逆向工程的部分,逆向工程總共有三週,由於第三週為作業講解所以並沒有簡報。

這門課在三校的選課系統上的名字如下:
台大-計算機安全
台科大-資訊安全實務
交大-程式安全

terrynini

November 20, 2020
Tweet

More Decks by terrynini

Other Decks in Technology

Transcript

  1. 附上⼈權指數 ID : Terrynini38514 ▸ ᪑զ༗ᴍख़ɿ 
 ٯٯ ▸ ᪑զຑ٢ຑɿ

    
 ᅳཱަ௨େላ  -"# 
 ࢿిҫ٬ᢛ҆શ੽࢜ላҐላఔ௠ఊӉ ▸ ᜗ඍೳ፤ိਧత౦੢ɿ 
 ೥ۚ६ᘋף܉ 
  'JSF&ZF'MBSF0O$IBMMFOHFഁ୆ ▸ $5'5FBNɿ 
 %PVCMF4JHNBʢቮ጗ૺ#BMTOซ吞Խ࡞ଖ݂೑ʣ 
 #BMTO  3 ᔒরยՄ༻ٹ໋
  2. BABY STEP 4UBDL'SBNF  4 low memory address high memory

    address highlight means RIP points to here 0x40 0x8048536 return address main's ebp old ebp esp -> ebp -> 0xff8 0xffc 0x1000 eax: 0x20 0x20 bossA_want 0xfec 0xfe0
  3. BABY STEP 4UBDL'SBNF  5 low memory address high memory

    address highlight means RIP points to here 0x40 0x8048536 return address main's ebp old ebp esp -> ebp -> 0xff8 0xffc 0x1000 eax: 0x20 0x20 bossA_want 0xfec SKIP SOME OPERATIONS ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 0xfe0
  4. BABY STEP 4UBDL'SBNF  6 low memory address high memory

    address highlight means RIP points to here 0x40 0x8048536 return address main's ebp old ebp esp -> ebp -> 0xff8 0xffc 0x1000 0x20 bossA_want 0xfec 0xfe0
  5. BABY STEP 4UBDL'SBNF  7 low memory address high memory

    address highlight means RIP points to here esp -> ebp -> 0xfe0 0xff8 0x20 bossA_want 0xfec
  6. BABY STEP 4UBDL'SBNF  8 low memory address high memory

    address highlight means RIP points to here esp -> ebp -> 0xfe0 0xff8 0x20 bossA_want 0xfec just for alignment 0xfd4
  7. BABY STEP 4UBDL'SBNF  9 low memory address high memory

    address highlight means RIP points to here esp -> ebp -> 0xfe0 0xff8 0x20 bossA_want 0xfec just for alignment 0xfd4 0x20 0xfd0
  8. BABY STEP 4UBDL'SBNF  10 low memory address high memory

    address highlight means RIP points to here esp -> just for alignment 0xfd4 0x20 0xfd0 0x80484ff return address 0xfcc 0xfe0
  9. BABY STEP 4UBDL'SBNF  11 low memory address high memory

    address just for alignment 0xfd4 0x20 0xfd0 0x80484ff return address 0xfcc 0xfe0 esp ->
  10. BABY STEP 4UBDL'SBNF  12 low memory address high memory

    address esp -> just for alignment 0xfd4 0x20 0xfd0 0x80484ff return address 0xfcc 0xfe0 0xff8 old ebp 0xfc8
  11. BABY STEP 4UBDL'SBNF  13 low memory address high memory

    address just for alignment 0xfd4 0x20 0xfd0 0x80484ff return address 0xfcc 0xfe0 0xff8 old ebp 0xfc8 esp -> ebp -> leave = mov esp, ebp 
 pop ebp
  12. BABY STEP 4UBDL'SBNF  14 low memory address high memory

    address just for alignment 0xfd4 0x20 0xfd0 0x80484ff return address 0xfcc 0xfe0 leave = mov esp, ebp 
 pop ebp 0xff8 old ebp 0xfc8 esp -> ebp ->
  13. BABY STEP 4UBDL'SBNF  15 low memory address high memory

    address just for alignment 0xfd4 0x20 0xfd0 0x80484ff return address 0xfcc 0xfe0 esp -> ret = pop eip
  14. BABY STEP 4UBDL'SBNF  16 low memory address high memory

    address highlight means RIP points to here esp -> just for alignment 0xfd4 0x20 0xfd0 0xfe0
  15. BABY STEP 4UBDL'SBNF  17 highlight means RIP points to

    here low memory address high memory address 0x40 0x8048536 return address main's ebp old ebp esp -> ebp -> 0xff8 0xffc 0x1000 0x20 bossA_want 0xfec 0xfe0
  16. BABY STEP 4UBDL'SBNF  18 highlight means RIP points to

    here low memory address high memory address 0x40 0x8048536 return address main's ebp old ebp esp -> ebp -> 0xff8 0xffc 0x1000 0x20 bossA_want 0xfec 0xfe0 leave = mov esp, ebp 
 pop ebp
  17. BABY STEP 4UBDL'SBNF  19 highlight means RIP points to

    here low memory address high memory address 0x40 0x8048536 return address main's ebp old ebp esp -> 0xff8 0xffc 0x1000 leave = mov esp, ebp 
 pop ebp ebp ->
  18. BABY STEP 4UBDL'SBNF  20 highlight means RIP points to

    here low memory address high memory address 0x40 0x8048536 return address esp -> 0xff8 0xffc 0x1000
  19. BABY STEP $BMMJOH$POWFOUJPODEFDM  22 caller pop stack from right

    to left low memory address high memory address 1 0x8048536 return address main's ebp old ebp ebp -> 0xff8 0x1000 2 3 ༝DBMMFSਗ਼ۭTUBDLൺֱ༰қመ࡞QSJOUG೭ྨతෆఆ௕ҾᏐവࣜ
  20. BABY STEP $BMMJOH$POWFOUJPOGBTUDBMM  24 put first two args in

    regs put rest args on stack callee pop stack
  21. BABY STEP Y@$BMMJOH$POWFOUJPO windows function(rcx, rdx, r8, r9)  26

    Linux function(rdi, rsi, rdx, rcx, r8, r9) ೗ՌჩᏐ௒աݸ࣌ɼ௒աతಉYDBMMJOHDPOWFOUJPOɼ௚઀์TUBDL XJOEPXT์తҐஔཁ஫ҙҰԼ
  22. OPTIMIZATION $POTUBOU'PMEJOH  28 i = 320 * 200 *

    32; >> i = 2048000; (example from wiki)
  23. CLASS & STRUCT .FNPGPSEFNP OBNFNBOHMJOH ੒һؒሣᴡऔNJO TJ[FPG NFNCFS QBDL 

    ݁ߏ࠷ޙሣᴡऔNJO NBY.FNCFS4J[F QBDL  ቕ౟݁ߏෆҎ੔ᱪ௕౓ိܭࢉɼࣕੋҎ֘݁ߏॴ࢖༻తሣᴡ值ိሣᴡ ҝྃመݱଟଶɼDMBTTతୈҰݸNFNCFS။ࢦ޲WUBCMF  36