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

NTUSTxTDOH - Pwn基礎

adr
December 27, 2015

NTUSTxTDOH - Pwn基礎

BOF基礎教學 & windows上SEH BOF利用 By.aaaddress1

Live Demo的檔案與相關資料:
https://github.com/aaaddress1/NTUSTXTDOH_EasyBofBasic

adr

December 27, 2015
Tweet

More Decks by adr

Other Decks in Technology

Transcript

  1. #$176/' ➤ ⾺聖豪 (aaaddress1) ➤ 義守⼤學資訊⼯程⼆年級 ➤ Reverse Engineering Skills

    ➤ Windows / Mac OS /Android ➤ TDoHacker Core Member ➤ HITCON 2015 CMT: ➤ AIDS ➤ x86靜態⼿花詐欺術 ➤ Wooyun WhiteHat: x86⼿花詐欺 ➤ 逢甲2015⾏動計算研討會: AIDS ➤ 成功⼤學2015⾏動APP競賽
  2. #$176/' ➤ Hack BOT ➤ CrackShield / MapleHack ➤ Tower

    Of Savior ➤ FaceBook: Adr’s FB ➤ Isu Hack ➤ 競時通防爆PING
 ➤ CSharp,VB,C/CPlus,
 x86,Python,Smali,Swift
  3. [EBP+0 ] = Pointer to old EBP [EBP+4 ] =

    Return Address [EBP+8 ] = First Parameter [EBP+C ] = Second Parameter [EBP+10 ] = Third Parameter …etc [EBP+8 + 4*index] = Parameter[index]
  4. VOID FUNC() { INT A = 0; INT B =

    1; INT C = 2; } [EBP - 4] =0 [EBP - 8] =1 [EBP - C] =2 push EBP mov EBP,ESP SUB ESP, LEN
  5. VOID FUNC() { NFUNC(ARG1,ARG2,ARG3…) } push ebp mov ebp,esp .

    . push arg3 push arg2 push arg1 call nFunc
  6. Stack ESP + 0 ESP + 4 ESP + 8

    ESP + C ESP + 10 ESP + 14
  7. Stack ESP + 0 Old EBP ESP + 4 ESP

    + 8 ESP + C ESP + 10 ESP + 14 _______EIP
  8. Stack EBP + 0 =ESP Old EBP EBP + 4

    EBP + 8 EBP + C EBP + 10 EBP + 14 _______EIP
  9. Stack EBP - 8 =ESP Buffer EBP - 4 Buffer

    EBP + 0 Old EBP EBP + 4 EBP + 8 EBP + C _______EIP
  10. Stack EBP - 8 =ESP 1 EBP - 4 Buffer

    EBP + 0 Buffer EBP + 4 Old EBP EBP + 8 EBP + C _______EIP
  11. Stack EBP - 8 =ESP return Address EBP - 4

    1 EBP + 0 Buffer EBP + 4 Buffer EBP + 8 Old EBP EBP + C _______EIP
  12. Stack EBP - 8 =ESP return Address EBP - 4

    1 EBP + 0 Buffer EBP + 4 Buffer EBP + 8 Old EBP EBP + C
  13. Stack EBP - 8 =ESP EBP EBP - 4 return

    Address EBP + 0 1 EBP + 4 Buffer EBP + 8 Buffer EBP + C Old EBP _______EIP
  14. Stack EBP + 0 =ESP EBP EBP + 4 return

    Address EBP + 8 1 EBP + C Buffer EBP + 10 Buffer EBP + 14 Old EBP _______EIP
  15. Stack EBP + 0 =ESP EBP EBP + 4 return

    Address EBP + 8 1 EBP + C Buffer EBP + 10 Buffer EBP + 14 Old EBP _______EIP
  16. _______EIP Stack EBP - 8 =ESP return Address EBP -

    4 1 EBP + 0 Buffer EBP + 4 Buffer EBP + 8 Old EBP EBP + C
  17. _______EIP Stack EBP - 8 =ESP return Address EBP -

    4 1 EBP + 0 Buffer EBP + 4 Buffer EBP + 8 Old EBP EBP + C
  18. Stack EBP - 4 =ESP 1 EBP + 0 Buffer

    EBP + 4 Buffer EBP + 8 Old EBP EBP + C EBP + 10 _______EIP
  19. Stack EBP + 0 = ESP Buffer EBP + 4

    Buffer EBP + 8 Old EBP EBP + C EBP + 10 _______EIP
  20. EBP+4+4*k EBP+8 EBP+4 EBP+0 EBP-X EBP-Y Ń⊾⸹綹䥥'$2 ⇆ 䎛ⓧ甌 Ń耋⦿⨑⨡

    䡗⽅ⓞ磕TGV惔耋⦿⟋ Ń不⃡⋬⚤磕⊾⸹熿 Ń不M⋬⚤磕⊾⸹熿 Ń☡⫀$WHHGT Ń☡⫀$WHHGT
  21. Buffer overflow Stack EBP - 10 Buffer EBP - C

    Buffer EBP - 8 0x6C6C6548 = lleH EBP - 4 0x0000216F =\x00\x00!o EBP =ESP Old EBP _______EIP
  22. Buffer overflow Stack EBP - 10 Buffer EBP - C

    Buffer EBP - 8 0x6C6C6548 = lleH EBP - 4 0x0000216F =\x00\x00!o EBP =ESP Old EBP _______EIP Variable “name”
  23. Buffer overflow Stack EBP - 10 Buffer EBP - C

    Buffer EBP - 8 0x6C6C6548 = lleH EBP - 4 0x0000216F =\x00\x00!o EBP =ESP Old EBP _______EIP Variable “data”
  24. Buffer overflow Stack EBP - 10 Buffer EBP - C

    Buffer EBP - 8 0x6C6C6548 = lleH EBP - 4 0x0000216F =\x00\x00!o EBP =ESP Old EBP _______EIP
  25. Buffer overflow Stack EBP - 10 Buffer EBP - C

    Buffer EBP - 8 0x6C6C6548 = lleH EBP - 4 0x0000216F =\x00\x00!o EBP =ESP Old EBP _______EIP If you input “aaaa”
  26. Buffer overflow Stack EBP - 10 aaaa EBP - C

    Buffer EBP - 8 0x6C6C6548 = lleH EBP - 4 0x0000216F =\x00\x00!o EBP =ESP Old EBP _______EIP If you input “aaaa”
  27. Buffer overflow Stack EBP - 10 aaaa EBP - C

    BBBB EBP - 8 0x6C6C6548 = lleH EBP - 4 0x0000216F =\x00\x00!o EBP =ESP Old EBP _______EIP If you input “aaaaBBBB”
  28. Buffer overflow Stack EBP - 10 REVO EBP - C

    WOLF EBP - 8 0x6C6C6548 = lleH EBP - 4 0x0000216F =\x00\x00!o EBP =ESP Old EBP _______EIP If you input “OVERFLOW” Little Endian
  29. Buffer overflow Stack EBP - 10 REVO EBP - C

    WOLF EBP - 8 revo EBP - 4 wolf EBP =ESP Old EBP _______EIP If you input “OVERFLOWoverflow”
  30. Buffer overflow Stack EBP - 10 AAAA EBP - C

    AAAA EBP - 8 imda EBP - 4 \x00\x00\x00n EBP =ESP Old EBP _______EIP SO, We can input “AAAAAAAAadmin”
  31. ))

  32. 0GZV $WHHGT *CPFNGT +PRWV5VCTV 2CFFKPI O[0GZV 4+2 RQRRQRTGV UJQTVLWOR UGE,WOR

    NQPILWOR 5JGNNEQFG ⃮職聅䴏⌻㾶⻮㢝Ⅽ禈惔慮 NQPILWOR  缙㼣㉸峩乸㉩侟䅷Ŏ 㓲聅⋬↛磕⹙㺵懤矦⃡熿 揞䠉⛇䴏㢚㾶
  33. 0GZV $WHHGT *CPFNGT +PRWV5VCTV 2CFFKPI O[0GZV 4+2 RQRRQRTGV UJQTVLWOR UGE,WOR

    NQPILWOR 5JGNNEQFG ⛋缙⨉2CFFKPI⑈宽⃫⃡⫧PQR Z  掄熝㚈┗禆截䳜┑2CFFKPI⃫⇜∶⃡⋬PQR苌 ⼒⛐⇆⃡惐秠┑5JGNNEQFG⃫ 勭⃮䠉侟䅷䥥峩乸5JGNNEQFG惀NQPILWOR䥥瓄䳜