Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
In The Middle Of Chatter #2
Search
Takahiro Yoshimura
October 29, 2024
Technology
0
10
In The Middle Of Chatter #2
Somewhat detailed dive to iOS application analysis methodology. (OWASP Saitama MTG #22, talk #1)
Takahiro Yoshimura
October 29, 2024
Tweet
Share
More Decks by Takahiro Yoshimura
See All by Takahiro Yoshimura
Chaotic Channel
alterakey
0
27
In The Middle Of Chatter #1
alterakey
0
32
Shadow Runners 2
alterakey
0
6
Shadow Runners
alterakey
0
6
Looking Back: 2023
alterakey
0
8
Fill In The Blank
alterakey
0
8
Ticket To The Dark World
alterakey
0
11
Looking Back: 2022
alterakey
0
8
Hazy Datagrams
alterakey
0
5
Other Decks in Technology
See All in Technology
CysharpのOSS群から見るModern C#の現在地
neuecc
2
4k
Is Go A Good Language to Build Compilers?
kennethanceyer
0
100
SkiaとImpellerについて
moriya0130
0
170
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
140
rootlessコンテナのすゝめ - 研究室サーバーでもできる安全なコンテナ管理
kitsuya0828
3
400
Platform Engineering for Software Developers and Architects
syntasso
1
620
組織成長を加速させるオンボーディングの取り組み
sudoakiy
3
340
SDNという名のデータプレーンプログラミングの歴史
ebiken
PRO
2
220
SSMRunbook作成の勘所_20241120
koichiotomo
3
190
OCI Vault 概要
oracle4engineer
PRO
0
9.8k
アプリエンジニアのためのGraphQL入門.pdf
spycwolf
0
140
Next.jsとNuxtが混在? iframeでなんとかする!
ypresto
2
1.7k
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Typedesign – Prime Four
hannesfritz
40
2.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Being A Developer After 40
akosma
87
590k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
The Language of Interfaces
destraynor
154
24k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Transcript
IN THE MIDDLE OF CHATTER 2 OWASP SAITAMA MTG #22,
TALK #1 Image by quinn.anya on flickr, CC-BY-SA 2.0
TEXT SESSION FLAGS ▸ ըɾԻɾެ։: OK Image by Nico Kaiser
on flickr, CC-BY 2.0
TEXT WHO I AM ▸ Takahiro Yoshimura (@alterakey) https://keybase.io/alterakey ▸
Monolith Works Inc. Co-founder, CTO Security researcher ▸ ໌࣏େֶαΠόʔηΩϡϦςΟݚڀॴ ٬һݚڀһ
TEXT WHAT I DO ▸ Security research and development ▸
iOS/Android Apps →Financial, Games, IoT related, etc. (>200) →trueseeing: Non-decompiling Android Application Vulnerability Scanner [2017] ▸ Windows/Mac/Web/HTML5 Apps →POS, RAD tools etc. ▸ Network/Web penetration testing →PCI-DSS etc. ▸ Search engine reconnaissance (aka. Google Hacking) ▸ Whitebox testing ▸ Forensic analysis
TEXT WHAT I DO ▸ CTF ▸ Enemy10, Sutegoma2 ▸
METI CTFCJ 2012 Qual.: Won ▸ METI CTFCJ 2012: 3rd ▸ DEF CON 21 CTF: 6th ▸ DEF CON 22 OpenCTF: 4th ▸ ൃදɾߨԋͳͲ DEF CON 25 Demo Labs (2017) DEF CON 27 AI Village (2019) CODE BLUE (2017, 2019) CYDEF (2020) etc. Image by Wiyre Media on flickr, CC-BY 2.0
TEXT BACKGROUND ▸ LLMͷνϟοτΞϓϦ ʢChatGPT, GPT-4o, Claude .. ʣ ▸
͜ΕΒͷڍಈ…Ͳ͏ͳ͍ͬͯΔͷͩΖ͏͔ ▸ iOS൛ΞϓϦΛର Image by focal5 on flickr, CC-BY-NC 2.0
TEXT DEFEATING DRM ▸ App Store͕ʹ͋ͨΓ҉߸Խ+ॺ໊ ▸ ҉߸Խ͞Ε͍ͯΔͱવಡΊͳ͍ ▸ ҉߸ͷ͍ํʹ͞΄Ͳେ͖ͳͳ͍
→ਖ਼߈๏Ͱ͍͠ ▸ ࣮ʹղಡͤ͞Δͷ͕ྑ͍ɺ͕ ▸ ղಡπʔϧ͕App Storeʹ͋Δ…Θ͚ͳ͍ ▸ ղಡʹjailbreak͕ඞਢ Image by lantzilla on flickr, CC-BY-NC-ND 2.0
TEXT BREAKING OUT OF PRISON ▸ jailbreak ▸ ίʔυॺ໊ݕূػߏΛແޮԽ →Χʔωϧͷ੬ऑੑΛಥ͍ͯϑϥάΛԚછ
▸ checkm8: BootROMʹ͓͚Δuse-after-free →BootROMͳͷͰύονͰ͖ͳ͍ (<A12) ▸ checkra1n (12.x ..14.x) ▸ palera1n (15 .. 16.4, 15 .. 17.x) →2.0ܥ͔Βcheckra1nΛ෦తʹར༻ Image by Prab Bhatia Photography on flickr, CC-BY-NC-ND 2.0
TEXT NOW UNLEASHED, WHERE TO GO? ▸ ରͷΞϓϦΛղಡ͍ͨ͠ ▸ frida-ios-dump
→ϝϞϦμϯϓ͠ΞϓϦΛ࠶ߏ →frida͕ඞཁ ▸ frida: dynamic instrumentation framework! ▸ frida-serverΛattach ▸ APIݺͼग़͠ͷI/OͳͲࡉ෦͔Β੍ޚՄೳʹ Image by Mr. Littlehand on flickr, CC-BY-ND 2.0
TEXT REVERSING ▸ Ghidra: Multi-arch disassembler (NSA) radare2: Binary analysis
framework (pancake et al.) ▸ ؆୯ͷͨΊʹghidraΛ༻ Image by Simon Rankin on flickr, CC-BY-NC-ND 2.0
TEXT REVERSING TAKEAWAYS ▸ ղੳ analyzeHeadless ~/works/claude/t claude -preScript analysisopts_ios.py
-import Payload/ Claude.app/Claude ▸ औΓग़͠ analyzeHeadless ~/works/claude/t claude -postScript out.py -process Claude -noanalysis → out.asm(※) ͕ੜ͞ΕΔͷͰrename ▸ ※out.asmout.py͕উखʹܾΊ͍ͯΔϑΝΠϧ໊ Image by Thomas_H_foto on flickr, CC-BY-ND 2.0
TEXT NOW YOU ARE PIECES ▸ όΠφϦΛೖͯ͠ΞηϯϒϦΛճऩ ▸ ͋ͱ… ࣮ࡍͷղੳΛߦͳ͏
Image by Thomas_H_foto on flickr, CC-BY-ND 2.0
TEXT ANATOMY OF IOS APP ▸ iOSΞϓϦͷߏ ▸ Info.plist: ϝλใ
(_CodeSignature: ॺ໊) ▸ assets.car: Ϧιʔεྨ ▸ Frameworks: ϥΠϒϥϦྨ˞ ▸ (ΞϓϦ໊): Mach-O࣮ߦϑΝΠϧ˞
TEXT INFO.PLIST: METADATA ▸ ϝλใ ▸ ΞϓϦ໊ ▸ ATS ▸
bundle id ▸ ཁٻݖݶ ▸ URLεΩʔϜ etc.
TEXT FRAMEWORKS ▸ ΞϓϦ͕༻͢ΔϑϨʔϜϫʔΫ ▸ Mach-O dylib
TEXT EXECUTABLES ▸ ΞϓϦຊମ ▸ Mach-O executable - ԟʑʹͯ͠େ͖͍ ▸
͞·͟·ͳϥΠϒϥϦ͕੩తϦϯΫ͞ΕΔͨΊ
TEXT DISASSEMBLED CODE ▸ arm64-v8a (كʹarmv7s) ▸ OSʹObjC৭͕͍ͬͯΔͷͰจࣈྻΛղܾͰ͖ ͯ͠·͑APIϨϕϧͷղੳ͍͢͠ ▸
Swiftײ֮తʹC++ίʔυʹ͍ۙ name mangling: ॲཧܥͰdemangleͰ͖Δ͕… ىಈίετ͕ߴ͍ͷͰ͕ඞཁ ▸ AppleʹΑΔ৹͕ࠪ͋ΔͨΊ͔ɺཱͪೖͬͨ͜ͱ Λ͍ͯ͠Δίʔυ͋·ΓΈͳ͍…ͣʢʂʣ
TEXT ARTIFACTS ▸ ݟΔ͖Օॴ ▸ API call ▸ File operation
▸ Network operation ▸ Re fl ection ▸ Dynamic code loading ▸ etc...
TEXT ARTIFACTS: API CALL ▸ API call ▸ ObjC: objc_msgSend
▸ Swift: (mangled name)
TEXT ARTIFACTS: FILE ACCESS ▸ API call ▸ NSFile, NSFileManager,
etc. ▸ ϑΝΠϧΞΫηε
TEXT ARTIFACTS: NETWORK ACCESS ▸ API call ▸ NSURLRequest, etc.
▸ ωοτϫʔΫΞΫηε; ஶ໊ͳϥΠϒϥϦͷݺ ग़͕͜͠ΕʹΘΔ߹͕ԟʑʹͯ͋͠Δ (Alamo fi re, Moya, etc..)
TEXT ARTIFACTS: REFLECTIONS ▸ API call ▸ classFromString, selectorFromString, etc.
▸ ΫϥεηϨΫλΛจࣈྻ͔Βੜ
TEXT ARTIFACTS: DYNAMIC CODE LOADINGS ▸ API call ▸ dlsym
etc. ▸ ϥΠϒϥϦͷϓϩγʔδϟΞυϨεΛऔಘ
TEXT TS2-IOS: AUTOMATE THE ANALYSIS ▸ iOSΞϓϦղੳΛߦͳ͏trueseeing extension ▸ 2.2.5ͰmainϚʔδͨ͠:
ipa͕ղੳՄೳʹʂ ▸ API call, URL, dynamic code loading, syscall, re fl ection, jailbreak detection, debug probe, privacy concerns, obfuscations, assertions, logging, library imports, motion sensor, url scheme, ATS, permission, device requirements, device info probes, entitilements, copyright info, XOR ciphers, statically linked libraries ..
TEXT TS2-IOS: AUTOMATE THE ANALYSIS ▸ dockerͷ߹ͳΒ wc Λ /ext/ios
ͱͯ͠Ϛϯτ ͢Δ͚ͩ ▸ venvʹΠϯετʔϧ͍ͯ͠ΔͳΒpip ▸ ͜Ε͕ೖΔͱtrueseeingͰipaΛ։͚ΔΑ͏ʹ →͋ͱas!;gt report.txtͱ͢ΕऴΘΓ →HTMLͰग़͢ͳΒgh report.html ▸ disasm.tar.gzͱͯ͠ghidraͰdisasm͓ͯ͘͠ →ࠓͷͱ͜Ζ10.3ܥͷΈ
TEXT INSIDE TS2-IOS ▸ ipaͷplistྨΛղಡɾੳ ▸ disasm.tar.gzͱͯ͠·ͱΊΒΕ͍ͯΔ disassembled codeΛಡΜͰಛΛݕग़ ▸
API callΛྨ ▸ Swift symbol demangling ▸ Ϋϥε໊ͷ಄ࣙΛநग़
TEXT INSIDE TS2-IOS ▸ จࣈྻఆͷਪghidra·͔ͤ ▸ จࣈྻఆͷੳΛ༗ޮʹ ▸ fi eldΛେ͖͘औΔ
→લճݟͨΑ͏ͳܗͰpostscriptΛט·ͤΔ
TEXT TS2-SWIFT-DEMANGLE ▸ ໊લ͕ͻͲ͍… ▸ swiftॲཧܥdemanglerΛAPIԽ →swiftॲཧܥͷىಈ͕͗͢ΔͨΊ… ▸ ts2ͱϦϯΫ͢Δ͚ͩ (--link
ts2-swift-demangle)
TEXT TS2-DISASM-GHIDRA ▸ ipa/apkΛ͢ͱghidraͰdisasm͢Δcontainer ▸ docker run --rm -v $(pwd):/out
ts2-disasm- ghidra target.ipa → ͜Ε͚ͩͰdisasm.tar.gzΛੜ ▸ streamingੜ: σΟεΫʹ༏͍͠ ▸ ͨͩແ͔͔ۤ࣌ؒΔ
TEXT CLAUDE: FINDINGS ▸ ͋·Γͳ͍…͕ ▸ ಈతίʔυϩʔυ ▸ PasteboardͷΞΫηε ▸
cydiaͷݕग़ ▸ σόΠεϞσϧφϯόʔͷݕग़
TEXT TAKEAWAYS ▸ iOSΞϓϦੳʹ͓͍ͯݟΔ͖Օॴ ▸ Info.plist: ϝλใ Frameworks: ϥΠϒϥϦྨ˞ (ΞϓϦ໊):
Mach-O࣮ߦϑΝΠϧ˞ ▸ ObjC৭͕·ͩ·ͩڧ͍: call͕จࣈྻఆͰग़ݱ ▸ SwiftC++ʹ͍ۙҹ: demangling͕༗༻ ▸ ࠷৽։ൃಈͱϥΠϒϥϦͷ͕ࣝେࣄ
TEXT TAKEAWAYS ▸ ͳͷjailbreak͔Βͷఠग़ ▸ trueseeingͱghidraͷҖ ▸ disasmͯ͠͠·͑ੳ·ͰҰؾ௨؏ ▸ disasm͕͔͔࣌ؒΔ͕ࣗಈԽՄೳ
(radare2ͰͰ͖Δͱ͍͍ͷ͕ͩ…) ▸ ͱ͍͏͜ͱͰͦΖͦΖiOSਖ਼ࣜରԠ༧ఆ
FIN. 29.10.2024 TAKAHIRO YOSHIMURA (@ALTERAKEY)