blint 3.2.1__tar.gz → 3.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. {blint-3.2.1 → blint-3.2.2}/PKG-INFO +13 -2
  2. {blint-3.2.1 → blint-3.2.2}/README.md +12 -1
  3. {blint-3.2.1 → blint-3.2.2}/blint/cli.py +2 -1
  4. {blint-3.2.1 → blint-3.2.2}/blint/config.py +4 -1
  5. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_methods_android.yml +35 -0
  6. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_symbols_macho.yml +224 -0
  7. {blint-3.2.1 → blint-3.2.2}/blint/lib/android.py +73 -1
  8. {blint-3.2.1 → blint-3.2.2}/blint/lib/android_services.py +45 -3
  9. {blint-3.2.1 → blint-3.2.2}/blint/lib/binary.py +50 -0
  10. {blint-3.2.1 → blint-3.2.2}/blint/lib/dalvik.py +144 -31
  11. {blint-3.2.1 → blint-3.2.2}/blint/lib/dalvik_callgraph.py +7 -2
  12. blint-3.2.2/blint/lib/dalvik_cfg.py +194 -0
  13. blint-3.2.2/blint/lib/dalvik_dataflow.py +253 -0
  14. {blint-3.2.1 → blint-3.2.2}/blint/lib/dalvik_review.py +57 -2
  15. blint-3.2.2/blint/lib/dalvik_semantics.py +271 -0
  16. {blint-3.2.1 → blint-3.2.2}/blint/lib/disassembler.py +126 -5
  17. blint-3.2.2/blint/lib/ios.py +169 -0
  18. blint-3.2.2/blint/lib/macho_objc.py +272 -0
  19. {blint-3.2.1 → blint-3.2.2}/blint/lib/review_runner.py +6 -0
  20. {blint-3.2.1 → blint-3.2.2}/blint/lib/review_utils.py +3 -0
  21. {blint-3.2.1 → blint-3.2.2}/blint/lib/runners.py +73 -11
  22. {blint-3.2.1 → blint-3.2.2}/blint/lib/sbom.py +1 -1
  23. {blint-3.2.1 → blint-3.2.2}/blint/lib/utils.py +14 -2
  24. {blint-3.2.1 → blint-3.2.2}/pyproject.toml +1 -1
  25. {blint-3.2.1 → blint-3.2.2}/LICENSE +0 -0
  26. {blint-3.2.1 → blint-3.2.2}/blint/__init__.py +0 -0
  27. {blint-3.2.1 → blint-3.2.2}/blint/cyclonedx/README.md +0 -0
  28. {blint-3.2.1 → blint-3.2.2}/blint/cyclonedx/__init__.py +0 -0
  29. {blint-3.2.1 → blint-3.2.2}/blint/cyclonedx/spdx.py +0 -0
  30. {blint-3.2.1 → blint-3.2.2}/blint/cyclonedx/spec.py +0 -0
  31. {blint-3.2.1 → blint-3.2.2}/blint/data/__init__.py +0 -0
  32. {blint-3.2.1 → blint-3.2.2}/blint/data/android-services.json +0 -0
  33. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/__init__.py +0 -0
  34. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_apple_local_privesc_mie.yml +0 -0
  35. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_entries_generic.yml +0 -0
  36. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_entries_pe.yml +0 -0
  37. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_exe_go.yml +0 -0
  38. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_functions_generic.yml +0 -0
  39. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_imports_pe.yml +0 -0
  40. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_methods_generic.yml +0 -0
  41. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_methods_mips.yml +0 -0
  42. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_methods_pe.yml +0 -0
  43. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_monero_generic.yml +0 -0
  44. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_monero_go.yml +0 -0
  45. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_monero_rust.yml +0 -0
  46. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_rootkits_win.yml +0 -0
  47. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_rpc_win.yml +0 -0
  48. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_symbols_antiforensic.yml +0 -0
  49. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_symbols_generic.yml +0 -0
  50. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_symbols_hooka.yml +0 -0
  51. {blint-3.2.1 → blint-3.2.2}/blint/data/annotations/review_symbols_rust.yml +0 -0
  52. {blint-3.2.1 → blint-3.2.2}/blint/data/rules.yml +0 -0
  53. {blint-3.2.1 → blint-3.2.2}/blint/data/trackers.json +0 -0
  54. {blint-3.2.1 → blint-3.2.2}/blint/db.py +0 -0
  55. {blint-3.2.1 → blint-3.2.2}/blint/lib/__init__.py +0 -0
  56. {blint-3.2.1 → blint-3.2.2}/blint/lib/analysis.py +0 -0
  57. {blint-3.2.1 → blint-3.2.2}/blint/lib/callgraph/__init__.py +0 -0
  58. {blint-3.2.1 → blint-3.2.2}/blint/lib/callgraph/algorithms.py +0 -0
  59. {blint-3.2.1 → blint-3.2.2}/blint/lib/callgraph/api.py +0 -0
  60. {blint-3.2.1 → blint-3.2.2}/blint/lib/callgraph/canon.py +0 -0
  61. {blint-3.2.1 → blint-3.2.2}/blint/lib/callgraph/command.py +0 -0
  62. {blint-3.2.1 → blint-3.2.2}/blint/lib/callgraph/fingerprint.py +0 -0
  63. {blint-3.2.1 → blint-3.2.2}/blint/lib/callgraph/match.py +0 -0
  64. {blint-3.2.1 → blint-3.2.2}/blint/lib/callgraph/model.py +0 -0
  65. {blint-3.2.1 → blint-3.2.2}/blint/lib/callgraph/rusi.py +0 -0
  66. {blint-3.2.1 → blint-3.2.2}/blint/lib/callgraph_kpi.py +0 -0
  67. {blint-3.2.1 → blint-3.2.2}/blint/lib/checks.py +0 -0
  68. {blint-3.2.1 → blint-3.2.2}/blint/lib/function_reviews.py +0 -0
  69. {blint-3.2.1 → blint-3.2.2}/blint/lib/indicators.py +0 -0
  70. {blint-3.2.1 → blint-3.2.2}/blint/logger.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blint
3
- Version: 3.2.1
3
+ Version: 3.2.2
4
4
  Summary: Linter and SBOM generator for binary files.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -60,7 +60,8 @@ blint is a tool for reverse engineers, security analysts, and developers to quic
60
60
 
61
61
  - ELF (for GNU and musl libc)
62
62
  - PE (Windows executables and DLLs)
63
- - Mach-O (macOS and iOS, x64 and arm64)
63
+ - Mach-O (macOS and iOS, x64 and arm64), including Objective-C and Swift metadata
64
+ - iOS/macOS apps (`.ipa`): the main executable, embedded frameworks, dylibs, and app extensions are all analyzed
64
65
  - WASM (WebAssembly modules)
65
66
  - Android (APK, APKM, AAB, including DEX files in deep mode)
66
67
  - Disassembler: AArch64, x86/x86-64, ARM, Mips, MicroMips (native), and Dalvik (DEX).
@@ -75,6 +76,7 @@ blint is a tool for reverse engineers, security analysts, and developers to quic
75
76
  - Navigate to the [disassembly guide](./docs/DISASSEMBLE.md).
76
77
  - For callgraph internals and analyst-facing interpretation, see the [callgraph guide](./docs/CALLGRAPH.md).
77
78
  - **Android Deep Analysis:** In deep mode blint parses the dex classes, detects bundled service and tracker SDKs, and runs a Dalvik behavioural review that decodes the bytecode and flags risky behaviours such as dynamic code loading, reflection, native command execution, weak cryptography, and cleartext networking. The findings are attached to the BOM as custom properties. When disassembly is enabled, blint also writes a Dalvik callgraph sidecar next to the BOM.
79
+ - **iOS/macOS App Analysis:** Point blint at an `.ipa` and it unpacks the app bundle, reads the `Info.plist` context (bundle id, version, minimum OS, FairPlay encryption status), and analyzes the main executable along with every embedded framework, dylib, and app extension. For Mach-O binaries, blint recovers Objective-C metadata (classes, superclasses, methods, protocols, and referenced selectors) and demangles Swift symbols, then surfaces iOS privacy capabilities such as location, camera, microphone, contacts, photos, telephony, motion, biometrics, and device fingerprinting.
78
80
  - **Capability Analysis:** Identifies potentially sensitive capabilities by reviewing imported functions and symbols, such as network access, filesystem operations, or cryptographic API usage.
79
81
  - Includes cluster-style behavioral reviews for low-level networking patterns (for example eBPF sock_ops usage, TUN interception stacks, raw packet injection primitives, and local DoH redirection indicators).
80
82
  - **CI/CD Integration:** Can be added to build pipelines to enforce security policies, such as requiring code signing on all release artifacts.
@@ -121,6 +123,15 @@ Analyze a Go or Rust binary and get suggestions for fuzzing targets:
121
123
  blint -i /path/to/my-binary --suggest-fuzzable
122
124
  ```
123
125
 
126
+ Analyze an iOS/macOS app (`.ipa`). blint unpacks the bundle and writes a separate
127
+ `*-metadata.json` for the main executable and each embedded framework, dylib, and
128
+ app extension. Add `--disassemble` for instruction-level analysis (Objective-C and
129
+ Swift call sites are resolved to imported APIs):
130
+
131
+ ```shell
132
+ blint -i /path/to/app.ipa -o /tmp/blint --disassemble
133
+ ```
134
+
124
135
  Generate a CycloneDX SBOM for an Android application:
125
136
 
126
137
  ```shell
@@ -14,7 +14,8 @@ blint is a tool for reverse engineers, security analysts, and developers to quic
14
14
 
15
15
  - ELF (for GNU and musl libc)
16
16
  - PE (Windows executables and DLLs)
17
- - Mach-O (macOS and iOS, x64 and arm64)
17
+ - Mach-O (macOS and iOS, x64 and arm64), including Objective-C and Swift metadata
18
+ - iOS/macOS apps (`.ipa`): the main executable, embedded frameworks, dylibs, and app extensions are all analyzed
18
19
  - WASM (WebAssembly modules)
19
20
  - Android (APK, APKM, AAB, including DEX files in deep mode)
20
21
  - Disassembler: AArch64, x86/x86-64, ARM, Mips, MicroMips (native), and Dalvik (DEX).
@@ -29,6 +30,7 @@ blint is a tool for reverse engineers, security analysts, and developers to quic
29
30
  - Navigate to the [disassembly guide](./docs/DISASSEMBLE.md).
30
31
  - For callgraph internals and analyst-facing interpretation, see the [callgraph guide](./docs/CALLGRAPH.md).
31
32
  - **Android Deep Analysis:** In deep mode blint parses the dex classes, detects bundled service and tracker SDKs, and runs a Dalvik behavioural review that decodes the bytecode and flags risky behaviours such as dynamic code loading, reflection, native command execution, weak cryptography, and cleartext networking. The findings are attached to the BOM as custom properties. When disassembly is enabled, blint also writes a Dalvik callgraph sidecar next to the BOM.
33
+ - **iOS/macOS App Analysis:** Point blint at an `.ipa` and it unpacks the app bundle, reads the `Info.plist` context (bundle id, version, minimum OS, FairPlay encryption status), and analyzes the main executable along with every embedded framework, dylib, and app extension. For Mach-O binaries, blint recovers Objective-C metadata (classes, superclasses, methods, protocols, and referenced selectors) and demangles Swift symbols, then surfaces iOS privacy capabilities such as location, camera, microphone, contacts, photos, telephony, motion, biometrics, and device fingerprinting.
32
34
  - **Capability Analysis:** Identifies potentially sensitive capabilities by reviewing imported functions and symbols, such as network access, filesystem operations, or cryptographic API usage.
33
35
  - Includes cluster-style behavioral reviews for low-level networking patterns (for example eBPF sock_ops usage, TUN interception stacks, raw packet injection primitives, and local DoH redirection indicators).
34
36
  - **CI/CD Integration:** Can be added to build pipelines to enforce security policies, such as requiring code signing on all release artifacts.
@@ -75,6 +77,15 @@ Analyze a Go or Rust binary and get suggestions for fuzzing targets:
75
77
  blint -i /path/to/my-binary --suggest-fuzzable
76
78
  ```
77
79
 
80
+ Analyze an iOS/macOS app (`.ipa`). blint unpacks the bundle and writes a separate
81
+ `*-metadata.json` for the main executable and each embedded framework, dylib, and
82
+ app extension. Add `--disassemble` for instruction-level analysis (Objective-C and
83
+ Swift call sites are resolved to imported APIs):
84
+
85
+ ```shell
86
+ blint -i /path/to/app.ipa -o /tmp/blint --disassemble
87
+ ```
88
+
78
89
  Generate a CycloneDX SBOM for an Android application:
79
90
 
80
91
  ```shell
@@ -189,7 +189,8 @@ def build_parser():
189
189
  default=False,
190
190
  dest="deep_mode",
191
191
  help="Enable deep mode to collect more used symbols and modules "
192
- "aggressively. Slow operation. When combined with --use-blintdb, disassembly is enabled automatically to use function-hash lookup.",
192
+ "aggressively. Slow operation. Enables disassembly automatically "
193
+ "(function-hash lookup with --use-blintdb, dex callgraph export for android apps).",
193
194
  )
194
195
  sbom_parser.add_argument(
195
196
  "--stdout",
@@ -1271,7 +1271,10 @@ class BlintOptions:
1271
1271
  self.sources = [os.getcwd()]
1272
1272
  if not self.reports_dir:
1273
1273
  self.reports_dir = os.getcwd()
1274
- if self.sbom_mode and self.use_blintdb and self.deep_mode:
1274
+ # In SBOM mode, deep analysis implies disassembly (function-hash lookup,
1275
+ # dex callgraph export, etc.). There is no separate --disassemble flag
1276
+ # for the sbom command - --deep is the single switch.
1277
+ if self.sbom_mode and self.deep_mode:
1275
1278
  self.disassemble = True
1276
1279
  if self.sbom_mode:
1277
1280
  if self.stdout_mode:
@@ -28,6 +28,28 @@ rules:
28
28
  - "Ljava/lang/Class;->getMethod"
29
29
  - "Ljava/lang/reflect/Method;->invoke"
30
30
  - "Ljava/lang/reflect/Field;->set"
31
+ - id: ANDROID_DYNAMIC_INVOCATION
32
+ title: Uses MethodHandle / invoke-dynamic dynamic invocation
33
+ severity: medium
34
+ summary: Invokes methods through MethodHandles or invoke-dynamic
35
+ description: |
36
+ The application invokes methods through the java.lang.invoke MethodHandle /
37
+ VarHandle API or invoke-custom (invoke-dynamic) call sites. Like classic
38
+ reflection, this resolves call targets at runtime and is increasingly used
39
+ by obfuscators and packers to hide sensitive API usage from static
40
+ analysis. blint resolves these polymorphic and custom call sites directly
41
+ from the bytecode.
42
+ patterns:
43
+ - "Ljava/lang/invoke/MethodHandle;->invoke"
44
+ - "Ljava/lang/invoke/MethodHandles"
45
+ - "Ljava/lang/invoke/MethodHandles$Lookup;"
46
+ - "Ljava/lang/invoke/VarHandle;"
47
+ - "Ljava/lang/invoke/CallSite;"
48
+ # invoke-custom call sites and const-method-handle operands, resolved to
49
+ # call_site@N / method_handle@N (the call-site and method-handle tables are
50
+ # not exposed by LIEF, so the index is surfaced as a stable token).
51
+ - "call_site@"
52
+ - "method_handle@"
31
53
  - id: ANDROID_NATIVE_EXEC
32
54
  title: Executes native commands or loads native libraries
33
55
  severity: high
@@ -68,6 +90,19 @@ rules:
68
90
  include_informative_strings: true
69
91
  patterns:
70
92
  - "http://"
93
+ # XML/SVG/schema namespace URIs are identifiers, not network endpoints.
94
+ exclude_patterns:
95
+ - "http://www.w3.org/"
96
+ - "http://schemas.android.com/"
97
+ - "http://schemas.microsoft.com/"
98
+ - "http://www.apache.org/"
99
+ - "http://java.sun.com/"
100
+ - "http://xml.org/"
101
+ - "http://ns.adobe.com/"
102
+ - "http://purl.org/"
103
+ - "http://www.inkscape.org/"
104
+ - "http://localhost"
105
+ - "http://127.0.0.1"
71
106
  - id: ANDROID_WEBVIEW_UNSAFE
72
107
  title: Configures a WebView with unsafe settings
73
108
  severity: medium
@@ -639,3 +639,227 @@ rules:
639
639
  - AVMediaTypeVideo
640
640
  - AVVideoCodecJPEG
641
641
  - AVVideoCodecKey
642
+ - id: DYNAMIC_CODE_LOADING
643
+ title: Dynamic library loading functions used
644
+ summary: Can Load Code at Runtime
645
+ description: |
646
+ The binary resolves and loads code at runtime via the dynamic linker (dlopen/dlsym) or Foundation bundle loading. This allows functionality to be added after the binary ships and is commonly used by plugin systems, but is also abused to load code that evades static analysis.
647
+ patterns:
648
+ - dlopen
649
+ - dlsym
650
+ - dlclose
651
+ - _dyld_register_func_for_add_image
652
+ - NSBundle
653
+ - bundleWithPath
654
+ - NSLinkModule
655
+ - DynamicLinkLibrary
656
+ - id: PROCESS_EXECUTION
657
+ title: Process execution functions used
658
+ summary: Can Execute Other Programs
659
+ description: |
660
+ The binary can spawn and execute other programs or shell commands through NSTask, the POSIX spawn/exec family, or popen/system. This is expected for developer tooling but is also a hallmark of droppers and command execution payloads.
661
+ patterns:
662
+ - NSTask
663
+ - posix_spawn
664
+ - execve
665
+ - execvp
666
+ - execlp
667
+ - _popen
668
+ - _system
669
+ - vfork
670
+ - _fork
671
+ - id: ENVIRONMENT_ACCESS
672
+ title: Environment variable access functions used
673
+ summary: Can Read & Modify Environment
674
+ description: |
675
+ The binary reads or modifies process environment variables (getenv/setenv) or inspects ProcessInfo. Environment access is routine but is also used for sandbox detection, configuration overrides, and locating injected libraries.
676
+ patterns:
677
+ - getenv
678
+ - setenv
679
+ - unsetenv
680
+ - _environ
681
+ - NSProcessInfo
682
+ - ProcessInfo
683
+ - id: KEYCHAIN_API
684
+ title: Keychain Services functions used
685
+ summary: Can Access Credentials in Keychain
686
+ description: |
687
+ The binary reads or writes secrets in the macOS/iOS Keychain via Security framework APIs. Legitimate for credential storage, but also a target for credential theft.
688
+ patterns:
689
+ - SecItemAdd
690
+ - SecItemCopyMatching
691
+ - SecItemUpdate
692
+ - SecItemDelete
693
+ - SecKeychainAddGenericPassword
694
+ - SecKeychainFindGenericPassword
695
+ - SecKeychainItemCopyContent
696
+ - id: CRYPTO_API
697
+ title: Cryptographic functions used
698
+ summary: Can Perform Cryptography
699
+ description: |
700
+ The binary performs cryptographic operations via CommonCrypto, the Security framework key APIs, or CryptoKit. Used for legitimate encryption, hashing, and signing, and also by ransomware and obfuscation routines.
701
+ patterns:
702
+ - CCCrypt
703
+ - CCCryptorCreate
704
+ - CC_SHA256
705
+ - CC_SHA1
706
+ - CC_MD5
707
+ - SecKeyCreateSignature
708
+ - SecKeyCreateEncryptedData
709
+ - SecKeyCreateDecryptedData
710
+ - CryptoKit
711
+ - id: PASTEBOARD_API
712
+ title: Pasteboard (clipboard) functions used
713
+ summary: Can Read & Write the Clipboard
714
+ description: |
715
+ The binary reads from or writes to the system pasteboard. Clipboard access is used by productivity tools and also by spyware harvesting copied secrets such as passwords and crypto wallet addresses.
716
+ patterns:
717
+ - NSPasteboard
718
+ - UIPasteboard
719
+ - PNpasteboard
720
+ - id: SCREEN_CAPTURE_API
721
+ title: Screen capture functions used
722
+ summary: Can Capture the Screen
723
+ description: |
724
+ The binary can capture screen contents via Core Graphics or ScreenCaptureKit. Legitimate for screenshot and screen-sharing tools, and a common surveillance capability in spyware.
725
+ patterns:
726
+ - CGDisplayCreateImage
727
+ - CGWindowListCreateImage
728
+ - CGDisplayStream
729
+ - SCStream
730
+ - SCShareableContent
731
+ - id: INPUT_MONITORING_API
732
+ title: Input monitoring functions used
733
+ summary: Can Monitor Keyboard & Mouse Input
734
+ description: |
735
+ The binary installs event taps or HID input monitors to observe keyboard and mouse events system-wide. This underpins accessibility tools and automation, and is the core mechanism of keyloggers.
736
+ patterns:
737
+ - CGEventTapCreate
738
+ - CGEventTapEnable
739
+ - IOHIDManagerCreate
740
+ - IOHIDManagerRegisterInputValueCallback
741
+ - id: PERSISTENCE_LOGIN_ITEM
742
+ title: Login item / service persistence functions used
743
+ summary: Can Persist via Login Items or Services
744
+ description: |
745
+ The binary registers itself to run automatically via login items or the ServiceManagement framework. Expected for background agents, and a common persistence technique for malware.
746
+ patterns:
747
+ - SMLoginItemSetEnabled
748
+ - SMAppService
749
+ - LSSharedFileListInsertItemURL
750
+ - SMJobBless
751
+ - id: LOCATION_ACCESS
752
+ title: Location services used
753
+ summary: Can Access Device Location
754
+ description: |
755
+ The app uses Core Location to read the device's geographic position. A common, privacy-sensitive capability that requires user consent and is frequently abused by stalkerware.
756
+ patterns:
757
+ - CLLocationManager
758
+ - startUpdatingLocation
759
+ - requestWhenInUseAuthorization
760
+ - requestAlwaysAuthorization
761
+ - CLGeocoder
762
+ - id: CAMERA_ACCESS
763
+ title: Camera capture used
764
+ summary: Can Access the Camera
765
+ description: |
766
+ The app captures still images or video from the device camera via AVFoundation or the image picker. Privacy-sensitive; a surveillance capability when combined with background execution.
767
+ patterns:
768
+ - AVCaptureDevice
769
+ - AVCapturePhotoOutput
770
+ - UIImagePickerController
771
+ - requestAccessForMediaType
772
+ - id: MICROPHONE_ACCESS
773
+ title: Microphone / audio recording used
774
+ summary: Can Record Audio
775
+ description: |
776
+ The app records audio or requests microphone permission. Privacy-sensitive; core to audio surveillance.
777
+ patterns:
778
+ - AVAudioRecorder
779
+ - requestRecordPermission
780
+ - setActive
781
+ - AVAudioSession
782
+ - id: CONTACTS_ACCESS
783
+ title: Contacts access used
784
+ summary: Can Access Contacts
785
+ description: |
786
+ The app reads the user's address book via the Contacts framework. Sensitive personal data commonly exfiltrated by spyware.
787
+ patterns:
788
+ - CNContactStore
789
+ - CNContactFetchRequest
790
+ - ABAddressBookCreate
791
+ - id: PHOTOS_ACCESS
792
+ title: Photo library access used
793
+ summary: Can Access Photos
794
+ description: |
795
+ The app reads or modifies the user's photo library through the Photos framework.
796
+ patterns:
797
+ - PHPhotoLibrary
798
+ - PHAsset
799
+ - PHImageManager
800
+ - id: TELEPHONY_INFO
801
+ title: Telephony information accessed
802
+ summary: Can Read Carrier & Telephony Info
803
+ description: |
804
+ The app inspects carrier and cellular network information via CoreTelephony. Used for analytics and also for device/SIM fingerprinting.
805
+ patterns:
806
+ - CTTelephonyNetworkInfo
807
+ - CTCarrier
808
+ - serviceSubscriberCellularProviders
809
+ - id: MOTION_SENSORS
810
+ title: Motion and fitness sensors used
811
+ summary: Can Read Motion Sensors
812
+ description: |
813
+ The app reads accelerometer, gyroscope or pedometer data via Core Motion. Used for fitness and games, and for inferring user activity.
814
+ patterns:
815
+ - CMMotionManager
816
+ - CMPedometer
817
+ - CMAltimeter
818
+ - startAccelerometerUpdates
819
+ - id: BIOMETRIC_AUTH
820
+ title: Biometric / local authentication used
821
+ summary: Can Use Face ID / Touch ID
822
+ description: |
823
+ The app authenticates the user locally with Touch ID/Face ID via LocalAuthentication.
824
+ patterns:
825
+ - LAContext
826
+ - evaluatePolicy
827
+ - LAPolicyDeviceOwnerAuthentication
828
+ - id: HEALTH_DATA
829
+ title: Health data access used
830
+ summary: Can Access Health Data
831
+ description: |
832
+ The app reads or writes HealthKit data, among the most sensitive personal data categories.
833
+ patterns:
834
+ - HKHealthStore
835
+ - HKQuery
836
+ - requestAuthorizationToShareTypes
837
+ - id: BLUETOOTH_ACCESS
838
+ title: Bluetooth used
839
+ summary: Can Use Bluetooth
840
+ description: |
841
+ The app communicates over Bluetooth LE via Core Bluetooth, acting as central and/or peripheral. Used for accessories and for proximity-based tracking.
842
+ patterns:
843
+ - CBCentralManager
844
+ - CBPeripheralManager
845
+ - scanForPeripheralsWithServices
846
+ - id: DEVICE_FINGERPRINTING
847
+ title: Device identifier access used
848
+ summary: Can Read Device Identifiers
849
+ description: |
850
+ The app reads stable device identifiers (vendor ID, advertising ID, device name). Used for analytics/attribution and for cross-app tracking and fingerprinting.
851
+ patterns:
852
+ - identifierForVendor
853
+ - advertisingIdentifier
854
+ - ASIdentifierManager
855
+ - deviceToken
856
+ - id: WEBVIEW_JS_EXECUTION
857
+ title: Web view JavaScript execution used
858
+ summary: Can Execute JavaScript in Web Views
859
+ description: |
860
+ The app hosts web content and injects or evaluates JavaScript via WKWebView. A code-execution surface; injected scripts can exfiltrate page data or bridge to native code.
861
+ patterns:
862
+ - WKWebView
863
+ - evaluateJavaScript
864
+ - WKUserScript
865
+ - addScriptMessageHandler
@@ -11,7 +11,7 @@ from custom_json_diff.lib.utils import file_read
11
11
  from blint.config import SYMBOL_DELIMITER
12
12
  from blint.cyclonedx.spec import Component, Property, RefType, Scope, Type
13
13
  from blint.lib.binary import parse, parse_dex
14
- from blint.lib.dalvik_review import analyze_dex
14
+ from blint.lib.dalvik_review import DEX_EXE_TYPE, analyze_dex, build_review_metadata
15
15
  from blint.lib.utils import (
16
16
  check_command,
17
17
  create_component_evidence,
@@ -610,6 +610,78 @@ def collect_dex_files_metadata(app_file, parent_component, app_temp_dir):
610
610
  return file_components
611
611
 
612
612
 
613
+ def _iter_app_dex_files(app_file):
614
+ """
615
+ Yield ``(dex_path, app_temp_dir)`` for every dex inside an app or bundle.
616
+
617
+ Bundles (.apkm/.apks/.xapk) are unzipped to locate their inner apks; each
618
+ apk (or the app itself) is then unzipped to a temp dir whose dex files are
619
+ yielded. The caller is responsible for nothing - all temp dirs are cleaned
620
+ up once iteration completes.
621
+ """
622
+ bundle_temp_dir = None
623
+ app_temp_dirs = []
624
+ try:
625
+ if app_file.endswith(BUNDLE_EXTENSIONS):
626
+ bundle_temp_dir = tempfile.mkdtemp(prefix="blint_android_bundle")
627
+ unzip_unsafe(app_file, bundle_temp_dir)
628
+ targets = sorted(find_files(bundle_temp_dir, [".apk"]))
629
+ else:
630
+ targets = [app_file]
631
+ for apk in targets:
632
+ app_temp_dir = tempfile.mkdtemp(prefix="blint_android_dex")
633
+ app_temp_dirs.append(app_temp_dir)
634
+ unzip_unsafe(apk, app_temp_dir)
635
+ for adex in sorted(find_files(app_temp_dir, [".dex"])):
636
+ yield adex, app_temp_dir
637
+ finally:
638
+ for d in app_temp_dirs:
639
+ shutil.rmtree(d, ignore_errors=True)
640
+ if bundle_temp_dir:
641
+ shutil.rmtree(bundle_temp_dir, ignore_errors=True)
642
+
643
+
644
+ def analyze_android_app(app_file, build_cg=False):
645
+ """
646
+ Build review-ready metadata for an android app in the default analysis mode.
647
+
648
+ Extracts every dex from the app (or bundle), disassembles their methods and
649
+ aggregates the resolved invoke/field descriptors and string constants into a
650
+ single ``dexbinary`` metadata dict that the shared :class:`ReviewRunner`
651
+ consumes. When ``build_cg`` is set, a merged Dalvik callgraph is attached.
652
+
653
+ Returns:
654
+ A metadata dict with ``exe_type``/``functions``/``informative_strings``
655
+ (and optionally ``callgraph``), or ``None`` when no dex could be read.
656
+ """
657
+ functions: set = set()
658
+ strings: set = set()
659
+ dex_count = 0
660
+ for adex, _ in _iter_app_dex_files(app_file):
661
+ try:
662
+ review_metadata = build_review_metadata(parse_dex(adex))
663
+ except Exception as e: # a malformed dex must not abort the whole app
664
+ LOG.debug(f"Failed to build review metadata for {adex}: {e}")
665
+ continue
666
+ dex_count += 1
667
+ functions.update(fn.get("name", "") for fn in review_metadata.get("functions", []))
668
+ strings.update(review_metadata.get("informative_strings", []))
669
+ if not dex_count:
670
+ return None
671
+ metadata = {
672
+ "name": os.path.basename(app_file),
673
+ "exe_type": DEX_EXE_TYPE,
674
+ "functions": [{"name": fn} for fn in sorted(f for f in functions if f)],
675
+ "informative_strings": sorted(s for s in strings if s),
676
+ }
677
+ if build_cg:
678
+ try:
679
+ metadata["callgraph"] = build_app_dex_callgraph(app_file)
680
+ except Exception as e: # callgraph is best-effort
681
+ LOG.debug(f"Failed to build dex callgraph for {app_file}: {e}")
682
+ return metadata
683
+
684
+
613
685
  def build_app_dex_callgraph(app_file):
614
686
  """
615
687
  Build a merged Dalvik callgraph for every dex in an app (or bundle).
@@ -7,8 +7,10 @@ matches those class names against bundled dictionaries of known service SDKs
7
7
  ``service`` entries for the ones present in the app.
8
8
 
9
9
  Detection here is presence-based: it records that the SDK is bundled in the app,
10
- not whether it is reachable at runtime. The data-flow direction is therefore
11
- reported as ``unknown``; reachability-aware tooling (atom) can refine this.
10
+ not whether it is reachable at runtime. The data-flow direction is inferred from
11
+ the SDK's category (see :data:`_CATEGORY_FLOW`) and reflects the SDK's intended
12
+ direction rather than an observed flow; reachability-aware tooling (atom) can
13
+ refine this.
12
14
  """
13
15
 
14
16
  import importlib.resources
@@ -28,6 +30,46 @@ from blint.cyclonedx.spec import (
28
30
  from blint.logger import LOG
29
31
 
30
32
 
33
+ # Data-flow direction inferred from a service/tracker category. Detection is
34
+ # presence-based, so these encode the *intended* direction of the SDK rather
35
+ # than an observed flow:
36
+ # - bi-directional: interactive services that send inputs and receive results
37
+ # (AI/ML inference, messaging, social, cloud, payment, storage, ad networks
38
+ # that both report data and fetch creatives).
39
+ # - outbound: data-collection categories whose purpose is to exfiltrate device
40
+ # data (analytics, profiling, location, identification, crash reporting).
41
+ _CATEGORY_FLOW = {
42
+ "ai-llm": DataFlowDirection.bi_directional,
43
+ "ai-local": DataFlowDirection.bi_directional,
44
+ "social": DataFlowDirection.bi_directional,
45
+ "cloud": DataFlowDirection.bi_directional,
46
+ "messaging": DataFlowDirection.bi_directional,
47
+ "payment": DataFlowDirection.bi_directional,
48
+ "storage": DataFlowDirection.bi_directional,
49
+ "http": DataFlowDirection.bi_directional,
50
+ "advertisement": DataFlowDirection.bi_directional,
51
+ "analytics": DataFlowDirection.outbound,
52
+ "monitoring": DataFlowDirection.outbound,
53
+ "location": DataFlowDirection.outbound,
54
+ "profiling": DataFlowDirection.outbound,
55
+ "identification": DataFlowDirection.outbound,
56
+ "crash-reporting": DataFlowDirection.outbound,
57
+ }
58
+
59
+
60
+ def _flow_for_category(category: str, is_tracker: bool) -> DataFlowDirection:
61
+ """Resolve the data-flow direction for a detected service/tracker category.
62
+
63
+ Known categories map per :data:`_CATEGORY_FLOW`. Unmapped trackers default to
64
+ ``outbound`` (their purpose is data collection); unmapped services fall back
65
+ to ``unknown`` since their direction cannot be inferred from presence alone.
66
+ """
67
+ flow = _CATEGORY_FLOW.get((category or "").lower())
68
+ if flow is not None:
69
+ return flow
70
+ return DataFlowDirection.outbound if is_tracker else DataFlowDirection.unknown
71
+
72
+
31
73
  def _load_dictionary(resource: str, key: str) -> list:
32
74
  """Load a bundled JSON dictionary from the blint.data package."""
33
75
  try:
@@ -81,7 +123,7 @@ def _build_service(
81
123
  group=category,
82
124
  data=[
83
125
  ServiceData(
84
- flow=DataFlowDirection.unknown,
126
+ flow=_flow_for_category(category, is_tracker),
85
127
  classification=DataClassification(category),
86
128
  )
87
129
  ],
@@ -22,6 +22,7 @@ from blint.config import (
22
22
  )
23
23
  from blint.lib.disassembler import disassemble_functions
24
24
  from blint.lib.indicators import INFORMATIVE_STRING_CATALOGS
25
+ from blint.lib.macho_objc import parse_objc_metadata
25
26
  from blint.lib.utils import (
26
27
  calculate_entropy,
27
28
  calculate_hashes,
@@ -1566,6 +1567,23 @@ def build_disassembly_callgraph_metadata(metadata: dict) -> dict:
1566
1567
  with contextlib.suppress(ValueError):
1567
1568
  image_base_int = int(image_base, 16)
1568
1569
 
1570
+ # MachO import slot/stub addresses resolved during disassembly. Calls whose
1571
+ # target lands on one of these are external imports (Foundation, libswiftCore,
1572
+ # libc, ...), not internal edges; classifying them here avoids the
1573
+ # range-containment fallback misattributing them to whichever function happens
1574
+ # to span the GOT/stub address.
1575
+ import_call_addresses = {}
1576
+ for addr_str, name in (metadata.get("import_call_addresses") or {}).items():
1577
+ with contextlib.suppress(ValueError, TypeError):
1578
+ import_call_addresses[int(addr_str, 16)] = name
1579
+
1580
+ def _resolve_import_name(addr_int):
1581
+ for variant in (addr_int, addr_int & ~1):
1582
+ name = import_call_addresses.get(variant)
1583
+ if name:
1584
+ return name
1585
+ return None
1586
+
1569
1587
  # We aggregate counts by (src, dst, kind) and track confidence separately
1570
1588
  # because the same edge can be observed through multiple heuristics.
1571
1589
  edge_counts = Counter()
@@ -1605,6 +1623,23 @@ def build_disassembly_callgraph_metadata(metadata: dict) -> dict:
1605
1623
  if isinstance(target_addr_candidates, list):
1606
1624
  numeric_candidates.extend(target_addr_candidates)
1607
1625
 
1626
+ # External import calls take priority over internal heuristics: a
1627
+ # target on a known GOT/stub slot is a call out to a dynamic library,
1628
+ # never an internal edge.
1629
+ if import_call_addresses:
1630
+ import_name = None
1631
+ for candidate in numeric_candidates:
1632
+ if not isinstance(candidate, str) or not candidate:
1633
+ continue
1634
+ with contextlib.suppress(ValueError):
1635
+ import_name = _resolve_import_name(int(candidate, 16))
1636
+ if import_name:
1637
+ break
1638
+ if import_name:
1639
+ reason = "import" if edge_kind == "direct" else f"import:{edge_kind}"
1640
+ external_counts[(src_id, import_name, reason)] += 1
1641
+ continue
1642
+
1608
1643
  for candidate in numeric_candidates:
1609
1644
  if not isinstance(candidate, str) or not candidate:
1610
1645
  continue
@@ -1841,6 +1876,8 @@ def parse(exe_file, disassemble=False): # pylint: disable=too-many-locals,too-m
1841
1876
  metadata = add_pe_metadata(exe_file, metadata, parsed_obj)
1842
1877
  elif isinstance(parsed_obj, lief.MachO.Binary):
1843
1878
  metadata = add_mach0_metadata(exe_file, metadata, parsed_obj)
1879
+ if objc_metadata := parse_objc_metadata(parsed_obj):
1880
+ metadata["objc_metadata"] = objc_metadata
1844
1881
  metadata = standardize_keys(metadata)
1845
1882
  if informative_strings := parse_informative_strings(parsed_obj):
1846
1883
  metadata["informative_strings"] = informative_strings
@@ -2891,6 +2928,19 @@ def add_mach0_commands(metadata, parsed_obj: lief.MachO.Binary):
2891
2928
  metadata["has_thread_command"] = not isinstance(
2892
2929
  parsed_obj.thread_command, lief.lief_errors
2893
2930
  )
2931
+ # FairPlay DRM: App Store binaries encrypt __TEXT (cryptid=1). Developer,
2932
+ # ad-hoc and enterprise builds are unencrypted (cryptid=0). An encrypted
2933
+ # binary cannot be meaningfully disassembled without on-device decryption.
2934
+ with contextlib.suppress(AttributeError, TypeError):
2935
+ enc = parsed_obj.encryption_info
2936
+ if enc is not None and not isinstance(enc, lief.lief_errors):
2937
+ crypt_id = getattr(enc, "crypt_id", 0)
2938
+ metadata["is_encrypted"] = bool(crypt_id)
2939
+ metadata["encryption_info"] = {
2940
+ "crypt_id": crypt_id,
2941
+ "crypt_offset": getattr(enc, "crypt_offset", 0),
2942
+ "crypt_size": getattr(enc, "crypt_size", 0),
2943
+ }
2894
2944
  return metadata
2895
2945
 
2896
2946