Beispiel #1
0
def mrchist():
    parser = mrchist_parser()
    raw_args = parser.parse_args()

    source_paths = raw_args.source
    multi = len(raw_args.source) != 1 or raw_args.recursive
    if raw_args.recursive:
        source_paths = common.file_path_recurse(*source_paths)

    for i, path in enumerate(source_paths):
        try:
            with open(path, 'rb') as src:
                if multi:
                    print(src.name)
                with common.read(src) as source:
                    if raw_args.summary:
                        utils.stats(source,
                                    start=raw_args.start,
                                    end=raw_args.end,
                                    length=raw_args.length,
                                    width=raw_args.width,
                                    height=raw_args.height)
                    else:
                        utils.histdump(
                            source,
                            start=raw_args.start,
                            end=raw_args.end,
                            length=raw_args.length,
                            samples=raw_args.samples,
                            width=raw_args.width,
                            address_base=raw_args.address_base,
                        )
                print()
        except OSError as e:
            logger.warning(f'{e}')
Beispiel #2
0
def mrcpix():
    parser = mrcpix_parser()
    raw_args = parser.parse_args()

    source_paths = raw_args.source
    multi = len(raw_args.source) != 1 or raw_args.recursive
    if raw_args.recursive:
        source_paths = common.file_path_recurse(*source_paths)

    for i, path in enumerate(source_paths):
        try:
            with open(path, 'rb') as src:
                if multi:
                    print(src.name)
                with common.read(src) as source:
                    utils.pixdump(
                        source,
                        start=raw_args.start,
                        end=raw_args.end,
                        length=raw_args.length,
                        width=raw_args.width,
                    )
                print()
        except OSError as e:
            logger.warning(f'{e}')
Beispiel #3
0
def mrcdump():
    parser = mrcdump_parser()
    raw_args = parser.parse_args()

    source_paths = raw_args.source
    multi = len(raw_args.source) != 1 or raw_args.recursive
    if raw_args.recursive:
        source_paths = common.file_path_recurse(*source_paths)

    for i, path in enumerate(source_paths):
        try:
            with open(path, 'rb') as src:
                if multi:
                    print(src.name)
                with common.read(src) as source:
                    utils.hexdump(
                        source,
                        start=raw_args.start,
                        end=raw_args.end,
                        length=raw_args.length,
                        major_len=raw_args.major_len,
                        minor_len=raw_args.minor_len,
                        colour=raw_args.colour,
                        address_base=raw_args.address_base,
                        show_offsets=raw_args.show_offsets,
                        show_glyphs=raw_args.show_glyphs,
                    )
                print()
        except OSError as e:
            logger.warning(f'{e}')
Beispiel #4
0
def mrcgrep():
    parser = mrcgrep_parser()
    raw_args = parser.parse_args()

    source_paths = raw_args.source
    multi = len(raw_args.source) != 1 or raw_args.recursive
    if raw_args.recursive:
        source_paths = common.file_path_recurse(*source_paths)

    for i, path in enumerate(source_paths):
        try:
            with open(path, 'rb') as src:
                title = None
                if multi:
                    title = src.name
                with common.read(src) as source:
                    if raw_args.no_hexdump:
                        utils.listdump_grep(raw_args.pattern,
                                            source,
                                            encoding=raw_args.encoding,
                                            fixed_string=raw_args.fixed_string,
                                            hex_format=raw_args.hex_format,
                                            start=raw_args.start,
                                            end=raw_args.end,
                                            length=raw_args.length,
                                            title=title,
                                            ignore_case=raw_args.ignore_case)
                    else:
                        utils.hexdump_grep(raw_args.pattern,
                                           source,
                                           encoding=raw_args.encoding,
                                           fixed_string=raw_args.fixed_string,
                                           hex_format=raw_args.hex_format,
                                           start=raw_args.start,
                                           end=raw_args.end,
                                           length=raw_args.length,
                                           before=raw_args.before,
                                           after=raw_args.after,
                                           title=title,
                                           ignore_case=raw_args.ignore_case)
        except OSError as e:
            logger.warning('{}'.format(e))
Beispiel #5
0
def mrcfind():
    parser = mrcfind_parser()
    raw_args = parser.parse_args()

    source_paths = raw_args.source
    multi = len(raw_args.source) != 1 or raw_args.recursive
    if raw_args.recursive:
        source_paths = common.file_path_recurse(*source_paths)

    for i, path in enumerate(source_paths):
        try:
            with open(path, 'rb') as src:
                title = None
                if multi:
                    title = src.name
                with common.read(src) as source:
                    utils.finddump(
                        raw_args.string.split(raw_args.delimiter),
                        source,
                        start=raw_args.start,
                        end=raw_args.end,
                        length=raw_args.length,
                        overlap=raw_args.overlap,
                        ignore_case=raw_args.ignore_case,
                        encodings=raw_args.encoding.split(','),
                        brute=raw_args.brute,
                        char_size=raw_args.char_size,
                        major_len=raw_args.major_len,
                        minor_len=raw_args.minor_len,
                        colour=raw_args.colour,
                        before=raw_args.before,
                        after=raw_args.after,
                        title=title,
                        format=raw_args.format,
                    )
        except OSError as e:
            logger.warning(f'{e}')