# Path: mobsf/StaticAnalyzer/views/ios/macho_analysis.py
# def macho_analysis(binary):
#     try:
#         logger.info('Running MachO Analysis on %s', binary.name)
#         cs = Checksec(binary)
#         chksec = cs.checksec()
#         symbols = cs.get_symbols()
#         libs = cs.get_libraries()
#         return {
#             'checksec': chksec,
#             'symbols': symbols,
#             'libraries': libs,
#         }
#     except Exception:
#         logger.exception('Running MachO Analysis')
#         return {}


import logging
from pathlib import Path
from macholib.mach_o import (CPU_TYPE_NAMES, MH_CIGAM_64, MH_MAGIC_64,
                             get_cpu_subtype)
from macholib.MachO import MachO
from mobsf.StaticAnalyzer.views.ios.classdump import (
    get_class_dump,
)
from mobsf.StaticAnalyzer.views.ios.macho_analysis import (
    macho_analysis,
)
from mobsf.StaticAnalyzer.views.ios.binary_rule_matcher import (
    binary_rule_matcher,
)
from mobsf.StaticAnalyzer.tools.strings import (
    strings_util,
)
        'bin_code_analysis': {},
        'strings': [],
        'bin_info': {},
        'bin_type': '',
    }
    try:
        binary_findings = {}
        logger.info('Starting Binary Analysis')
        dirs = Path(src).glob('*')
        dot_app_dir = ''
        bin_name = ''
        for dir_ in dirs:
            if dir_.suffix == '.app':
                dot_app_dir = dir_.as_posix()
                break
        # Bin Dir - Dir/Payload/x.app/
        bin_dir = Path(src) / dot_app_dir
        if not executable_name:
            bin_name = dot_app_dir.replace('.app', '')
        else:
            _bin = bin_dir / executable_name
            if _bin.exists():
                bin_name = executable_name
        # Bin Path - Dir/Payload/x.app/x
        bin_path = bin_dir / bin_name
        if not (bin_path.exists() or bin_path.is_file()):
            logger.warning(
                'MobSF Cannot find binary in %s', bin_path.as_posix())
            logger.warning('Skipping Binary analysis')
        else:

# Path: mobsf/StaticAnalyzer/views/ios/macho_analysis.py
# def macho_analysis(binary):
#     try:
#         logger.info('Running MachO Analysis on %s', binary.name)
#         cs = Checksec(binary)
#         chksec = cs.checksec()
#         symbols = cs.get_symbols()
#         libs = cs.get_libraries()
#         return {
#             'checksec': chksec,
#             'symbols': symbols,
#             'libraries': libs,
#         }
#     except Exception:
#         logger.exception('Running MachO Analysis')
#         return {}


# Path: mobsf/StaticAnalyzer/views/ios/binary_analysis.py
import logging
from pathlib import Path
from macholib.mach_o import (CPU_TYPE_NAMES, MH_CIGAM_64, MH_MAGIC_64,
                             get_cpu_subtype)
from macholib.MachO import MachO
from mobsf.StaticAnalyzer.views.ios.classdump import (
    get_class_dump,
)
from mobsf.StaticAnalyzer.views.ios.macho_analysis import (
    macho_analysis,
)
from mobsf.StaticAnalyzer.views.ios.binary_rule_matcher import (
    binary_rule_matcher,
)
from mobsf.StaticAnalyzer.tools.strings import (
    strings_util,
)

        'bin_code_analysis': {},
        'strings': [],
        'bin_info': {},
        'bin_type': '',
    }
    try:
        binary_findings = {}
        logger.info('Starting Binary Analysis')
        dirs = Path(src).glob('*')
        dot_app_dir = ''
        bin_name = ''
        for dir_ in dirs:
            if dir_.suffix == '.app':
                dot_app_dir = dir_.as_posix()
                break
        # Bin Dir - Dir/Payload/x.app/
        bin_dir = Path(src) / dot_app_dir
        if not executable_name:
            bin_name = dot_app_dir.replace('.app', '')
        else:
            _bin = bin_dir / executable_name
            if _bin.exists():
                bin_name = executable_name
        # Bin Path - Dir/Payload/x.app/x
        bin_path = bin_dir / bin_name
        if not (bin_path.exists() or bin_path.is_file()):
            logger.warning(
                'MobSF Cannot find binary in %s', bin_path.as_posix())
            logger.warning('Skipping Binary analysis')
        else:

            macho = macho_analysis(bin_path)