Exemple #1
0
def config():
    values = [
        v for k, v in pwndbg.config.__dict__.items()
        if isinstance(v, pwndbg.config.Parameter) and v.scope == 'config'
    ]
    longest_optname = max(map(len, [v.optname for v in values]))
    longest_value = max(
        map(len, [
            extend_value_with_default(repr(v.value), repr(v.default))
            for v in values
        ]))

    header = print_row('Name', 'Value', 'Def', 'Documentation',
                       longest_optname, longest_value)
    print('-' * (len(header)))

    for v in sorted(values):
        print_row(v.optname, repr(v.value), repr(v.default), v.docstring,
                  longest_optname, longest_value)

    print(
        light_yellow(
            'You can set config variable with `set <config-var> <value>`'))
    print(
        light_yellow(
            'You can generate configuration file using `configfile` '
            '- then put it in your .gdbinit after initializing pwndbg'))
Exemple #2
0
def theme():
    values = [
        v for k, v in pwndbg.config.__dict__.items()
        if isinstance(v, pwndbg.config.Parameter) and v.scope == 'theme'
    ]
    longest_optname = max(map(len, [v.optname for v in values]))
    longest_value = max(
        map(len, [
            extend_value_with_default(str(v.value), str(v.default))
            for v in values
        ]))

    header = print_row('Name', 'Value', 'Def', 'Documentation',
                       longest_optname, longest_value)
    print('-' * (len(header)))
    for v in sorted(values):
        if isinstance(v, pwndbg.color.theme.ColoredParameter):
            value = generateColorFunction(v.value)(v.value)
            default = generateColorFunction(v.default)(v.default)
        elif isinstance(v.value, str):
            value = "'%s'" % str(v.value)
            default = str(v.default)
        else:
            value = repr(v.value)
            default = repr(v.default)
        print_row(v.optname, value, default, v.docstring, longest_optname,
                  longest_value)

    print(
        light_yellow(
            'You can set theme variable with `set <theme-var> <value>`'))
    print(
        light_yellow(
            'You can generate theme config file using `themefile` '
            '- then put it in your .gdbinit after initializing pwndbg'))
Exemple #3
0
def configfile_print_scope(scope, show_all=False):
    params = pwndbg.config.get_params(scope)

    if not show_all:
        params = list(filter(lambda p: p.is_changed, params))

    if params:
        if not show_all:
            print(light_yellow('Showing only changed values:'))
        for p in params:
            print('# %s: %s' % (p.optname, p.docstring))
            print('# default: %s' % p.native_default)
            print('set %s %s' % (p.optname, p.native_value))
            print()
    else:
        print(light_yellow('No changed values. To see current values use `%s`.' % scope))
Exemple #4
0
def got(name_filter=''):

    relro_status = pwndbg.wrappers.checksec.relro_status()
    pie_status = pwndbg.wrappers.checksec.pie_status()
    jmpslots = list(pwndbg.wrappers.readelf.get_jmpslots())

    if not len(jmpslots):
        print(red("NO JUMP_SLOT entries available in the GOT"))
        return
    if "PIE enabled" in pie_status:
        bin_text_base = pwndbg.memory.page_align(pwndbg.elf.entry())

    print("\nGOT protection: %s | GOT functions: %d\n " %
          (green(relro_status), len(jmpslots)))

    for line in jmpslots:
        address, info, rtype, value, name = line.split()[:5]

        if name_filter not in name:
            continue

        address_val = int(address, 16)

        if "PIE enabled" in pie_status:  # if PIE, address is only the offset from the binary base address
            address_val = bin_text_base + address_val

        got_address = pwndbg.memory.pvoid(address_val)
        print("[0x%x] %s -> %s" % (address_val, light_yellow(name),
                                   pwndbg.chain.format(got_address)))
Exemple #5
0
def got(name_filter=''):
    local_path = pwndbg.file.get_file(pwndbg.proc.exe)
    cs_out = pwndbg.wrappers.checksec("--file", local_path)

    file_out = pwndbg.wrappers.file(local_path)
    if "statically" in file_out:
        return "Binary is statically linked."

    readelf_out = pwndbg.wrappers.readelf("-r", local_path)

    jmpslots = '\n'.join(
        filter(lambda l: _extract_jumps(l), readelf_out.splitlines()))

    if not len(jmpslots):
        return "NO JUMP_SLOT entries available in the GOT"

    if "PIE enabled" in cs_out:
        bin_text_base = pwndbg.memory.page_align(pwndbg.elf.entry())

    relro_status = "No RELRO"
    if "Full RELRO" in cs_out:
        relro_status = "Full RELRO"
    elif "Partial RELRO" in cs_out:
        relro_status = "Partial RELRO"

    print("\nGOT protection: %s | GOT functions: %d\n " %
          (green(relro_status), len(jmpslots.splitlines())))

    for line in jmpslots.splitlines():
        address, info, rtype, value, name = line.split()[:5]

        if name_filter not in name:
            continue

        address_val = int(address, 16)

        if "PIE enabled" in cs_out:  # if PIE, address is only the offset from the binary base address
            address_val = bin_text_base + address_val

        got_address = pwndbg.memory.pvoid(address_val)
        print("[%s] %s -> %s" %
              (address, light_yellow(name), pwndbg.chain.format(got_address)))