$30 off During Our Annual Pro Sale. View Details »

Android開発でmitmproxyを使った話

bigbackboom
December 18, 2018
950

 Android開発でmitmproxyを使った話

bigbackboom

December 18, 2018
Tweet

Transcript

  1. Android։ൃͰ mitmproxyΛ࢖ͬͨ࿩

  2. Who am I? — ٠஑/bigbackboom — גࣜձࣾΞΠελΠϧɹ ϝσΟΞ։ൃ౷ׅ෦ ΞϓϦάϧʔϓ —

    ͳΜͪΌͬͯAndroid։ൃऀ — ࠷ۙαʔόʔαΠυ Golangʹුؾத — ҟ໊ɿ͓٠ɺ٠๥ɺ٠͞Μ
  3. ܦҢ — responseͷ஋Λॻ͖׵͑ͯɺຊ൪؀ڥͰΞϓϦͷڧ੍Ξο ϓσʔτͷςετ͕͍ͨ͠ɻ — iOS͸CharlesΛ࢖͑͹Ͱ͖Δ͕ɺAndroid͸ʁ — CharlesͰ͍͚Δ͸͚ͣͩͲɺͳΜ͔httpsΩϟονͰ͖ͳ ͍Αɾɾɾ(´ŋωŋ`) —

    Charles͕ͩΊͳΒଞͷΞϓϦέʔγϣϯ୳ͯ͠ΈΑ͏ʂ
  4. mitmproxy — Charlesͱ΄΅ಉ౳ͷػೳΛఏڙ͢ΔOSS — UI͸ίϚϯυϕʔε — WebUIʢβʣ·Ͱ͋Δʂ

  5. ݒ೦఺ — ਖ਼௚ίϚϯυϥΠϯϕʔε͕ɾɾɾͬͨΔ͍

  6. ͱ͸͍͑ɾɾɾଞʹํ๏΋ͳ͍

  7. ͱΓ͋͑ͣ΍ͬͯݟΔ΂͖

  8. Πϯετʔϧ $ brew install mitmproxy

  9. ىಈ $ mitmproxy -p ϙʔτ൪߸

  10. ΞϓϦͷ४උ 1. pcͷipΞυϨεΛϝϞ 2. Android୺຤Λ༻ҙͯ͠ɺઃఆʼWi-Fiͱը໘ΛભҠ 3. ઀ଓࡁΈͷwifiΛ௕ԡ͢͠Δͱɺ"ωοτϫʔΫΛมߋ"ͷ߲໨͕ग़ΔͷͰλοϓ͢Δ 4. දࣔ͞Εͨ΢Οϯυ΢ͷ”ৄࡉઃఆ߲໨"ͷϓϩΩγ߲໨Λखಈʹมߋ͢Δ 5.

    ௥Ճදࣔ͞Ε߲ͨ໨ͷ”ϓϩΩγͷϗετ໊”ʹᶃͷipΞυϨεΛೖྗ͢Δ 6. ”ϓϩΩγϙʔτʹ͸”mitmproxyىಈ࣌ʹ࢖༻ͨ͠ϙʔτ൪߸Λೖྗ 7. อଘϘλϯΛλοϓ͢Δ(*1) 8. ϒϥ΢βΛ։͖ɺ"mitm.it"ΛΞυϨεʹೖྗ͢Δ(࣍ϖʔδը૾ࢀর) 9. ։͍ͨϖʔδͷAndroidϩΰͷϘλϯΛԡͯ͠ɺূ໌ॻΛμ΢ϯϩʔυɾΠϯετʔϧ͢Δ
  11. None
  12. ͦͯ͠ɾɾɾಈ͔ͯ͠ΈΔ

  13. Https͕औΕ͍ͯͳ͍ͩͱʁ

  14. ͦͯ͜͠ͷ ৘ใ Λݟ͚ͭΔ "ࣗ෼ͷΞϓϦͰड͚෇͚ΔΑ͏ʹ͢Δʹ͸ωοτϫʔΫɾη ΩϡϦςΟͷઃఆΛΞϓϦʹ௥Ճ͢Δඞཁ͕͋ΔΑ͏Ͱ͢ɻ"

  15. None
  16. ΍ͬͯΈΑ͏ — app/src/main/res/xmlʹnetwork_security_config.xml Λ࡞੒ɻҎԼͷ಺༰Λهड़ɻ <network-security-config> <!-- ͜͜ΛೖΕͯͳ͍ͱɺຊ൪ͷ؀ڥͰ΋ڐՄΛग़ͤͪΌ͏ͷͰ஫ҙ͕ඞཁΒ͍͠ --> <debug-overrides> <trust-anchors>

    <!-- Additionally trust user added CAs --> <certificates src="user" /> </trust-anchors> </debug-overrides> </network-security-config>
  17. — AndroidManifest.xmlʹҎԼΛ௥ه <application android:networkSecurityConfig="@xml/network_security_config" > ... </application>

  18. τϥΠΞήΠϯ

  19. None
  20. ࣮͸ɾɾɾcharlesͰ΋͍͚ͨ Android7͔ΒcharlesͰssl௨৴͕ݟΕͳ͘ͳͬͨ݅

  21. ·ͱΊ — charlesͷଞʹແྉͷmitmproxy͕͋Δ — ࢖͍উख͸ݴ͏΄Ͳѱ͘ͳ͍ — Android 7Ҏ্͔Β໌ࣔతʹূ໌ॻͷڐՄΛϓϩδΣΫτ ʹઃఆ͢Δඞཁ͕͋Δ