Exemplo n.º 1
0
def main():
    logger.info("appxtractor starting")

    parser = argparse.ArgumentParser(description='Extract information from Mac Apps.')
    parser.add_argument('-i', '--input', required=True,
                        help='The directory that contains the applications to analyse.')
    parser.add_argument('-t', '--type', 
                        default='app_folder', const='app_folder', 
                        nargs='?', choices=['app_folder', 'archive_folder'],
                        help='''Process input folder as folder containing .app bundles
                                or as folder full of archives containing .app bundles.
                                Supported archives formats are zip, tar, gz and dmg. 
                                Default type: app_folder''')
    parser.add_argument('-o', '--output', required=True,
                        help='Output directory: This directory shall also be passed to this program to update an existing output folder.')
    parser.add_argument('--all-apps', dest='all_apps', default=False, action='store_true',
                        help='Analyse all apps. By default, only Mac AppStore apps are analysed.')
    parser.add_argument('--install-only', default=False, action='store_true',
                        help='''Install archived applications into the output directory.
                                This option only works with archive folders.''')

    args = parser.parse_args()

    if args.type != 'archive_folder' and args.install_only:
        print("Option '--install-only' is only supported for archive folders.", file=sys.stderr)
        exit(1)

    exit_watcher = SignalIntelligence()

    if args.install_only:
        print("[+] Installing apps from \"{}\" to \"{}\"".format(args.input, args.output))
        print("[+] Press Ctrl+C to cancel installation\n")
    else:
        print("[+] Analysing apps at \"{}\"".format(args.input))
        print("[+] Press Ctrl+C to cancel analysis (can later be resumed)\n")

    if args.type == 'app_folder':
        app_candidates = iterate_apps_folder(args.input)
    elif args.type == 'archive_folder':
        app_candidates = iterate_archived_apps_folder(args.input)
    else:
        assert False and 'Iteration type not supported.'

    for path, hint in app_candidates:
        if exit_watcher.should_exit:
            break

        if not Bundle.is_bundle(path):
            continue

        bundle = Bundle.make(path)
        if not bundle.is_mas_app() and not args.all_apps and not args.install_only:
            continue

        if args.install_only:
            print('[    ] Installing {}'.format(path), end='')
            install_app(app_path=path,
                        logger=logger,
                        output=args.output)
        else:
            print('[+] Processing {}'.format(path))
            process_app(app_path=path,
                        info_extractors=info_extractors,
                        logger=logger,
                        output=args.output,
                        source_hint=hint)

    logger.info("appxtractor stopping")
Exemplo n.º 2
0
 def test_is_bundle(self):
     self.assertTrue(Bundle.is_bundle("/Applications/Calculator.app"))
     self.assertTrue(Bundle.is_bundle("/System/Library/Frameworks/WebKit.framework"))