Project Name: sensepost+objection
Language: Python
Statement Type: Assignment

Source Code:
def dump_all(args: list) -> None:
    """
        Dump memory from the currently injected process.
        Loosely based on:
            https://github.com/Nightbringer21/fridump

        :param args:
        :return:
    """

    if len(clean_argument_flags(args)) <= 0:
        click.secho('Usage: memory dump all <local destination>', bold=True)
        return

    # the destination file to write the dump to
    destination = args[0]

    # Check for file override
    if os.path.exists(destination):
        click.secho('Destination file {dest} already exists'.format(dest=destination), fg='yellow', bold=True)
        if not click.confirm('Continue, appending to the file?'):
            return

    # access type used when enumerating ranges
    access = 'rw-'

    api = state_connection.get_api()
    ranges = api.memory_list_ranges(access)

    total_size = sum([x['size'] for x in ranges])
    click.secho('Will dump {0} {1} images, totalling {2}'.format(
        len(ranges), access, sizeof_fmt(total_size)), fg='green', dim=True)

    with click.progressbar(ranges) as bar:
        for image in bar:
            dump = bytearray()
            bar.label = 'Dumping {0} from base: {1}'.format(sizeof_fmt(image['size']), hex(int(image['base'], 16)))

            # catch and exception thrown while dumping.
            # this could for a few reasons like if the protection
            # changes or the range is reallocated
            try:
                # grab the (size) bytes starting at the (base_address) in chunks of BLOCK_SIZE
                chunks = _get_chunks(int(image['base'], 16), int(image['size']), BLOCK_SIZE)
                for chunk in chunks:
                    dump.extend(bytearray(api.memory_dump(chunk[0], chunk[1])))

            except Exception as e:
                continue

            # append the results to the destination file
            with open(destination, 'ab') as f:
                f.write(dump)

    click.secho('Memory dumped to file: {0}'.format(destination), fg='green')

dump_all(args=['/foo'])

Selected Statement: destination = args[0]

Function Input:
args: /foo

Variable Values Before Statement:
args: /foo

Value After Statement Execution: '/foo'

Variable States During Runtime (line, value):
args: 1
/foo
destination: 16
'/foo'
access: 25
'rw-'
api: 27
<MagicMock name='get_api()' id='140041837128480'>
ranges: 28
size: 100
base: 0x7fff90800000
total_size: 30
100
bar: 34
{fill_char='#', empty_char='-', bar_template='%(label)s  [%(bar)s]  %(info)s', info_sep='  ', show_eta=True, show_percent=None, show_pos=False, item_show_func=None, label='', file=<_io.StringIO object at 0x7f5e07a3a3a0>, color=None, update_min_steps=1, _completed_intervals=0, width=36, autowidth=False, iter=<list_iterator object at 0x7f5e079fda90>, length=1, pos=0, avg=[], start=1712231192.5557132, last_eta=1712231192.5557132, eta_known=False, finished=False, max_width=None, entered=True, current_item=None, is_hidden=True, _last_line=''}
37
{fill_char='#', empty_char='-', bar_template='%(label)s  [%(bar)s]  %(info)s', info_sep='  ', show_eta=True, show_percent=None, show_pos=False, item_show_func=None, label='Dumping 100.0 B from base: 0x7fff90800000', file=<_io.StringIO object at 0x7f5e07a3a3a0>, color=None, update_min_steps=1, _completed_intervals=0, width=36, autowidth=False, iter=<list_iterator object at 0x7f5e079fda90>, length=1, pos=0, avg=[], start=1712231192.5557132, last_eta=1712231192.5557132, eta_known=False, finished=False, max_width=None, entered=True, current_item=None, is_hidden=True, _last_line=''}
image: 35
size: 100
base: 0x7fff90800000
dump: 36
bytearray(b'')
46
bytearray(b'\x00')
chunks: 44
[(140735617695744, 100)]
chunk: 45
(140735617695744, 100)
f: 52
<MagicMock name='open().__enter__()' id='140041837437520'>