Пример #1
0
def rebase_program(index: dict):
    """Rebase the program to the offset specified in the context _index.json

    :param index: _index.json JSON data
    """

    input_name = get_input_name()
    new_base = None
    for segment in index["segments"]:
        if not segment["name"]:
            continue

        segment_name = Path(segment["name"]).name
        if input_name == segment_name:
            new_base = segment["start"]
            break

    if not new_base:
        raise ContextLoaderError("Input file is not in _index.json")

    current_base = idaapi.get_imagebase()
    ida_segment.rebase_program(new_base - current_base, 8)
Пример #2
0
    def __init__(self,
                 arch: Arch,
                 os: OS,
                 maybe_base_address: Optional[int] = None):
        if maybe_base_address is not None:
            delta = abs(ida_nalt.get_imagebase() - maybe_base_address)
            if maybe_base_address < ida_nalt.get_imagebase():
                delta = delta * -1

            if ida_segment.rebase_program(delta, ida_segment.MSF_FIXONCE) != 0:
                raise RuntimeError("Failed to rebase the program")

        # Wait until IDA has finished analysis before we proceed, otherwise
        # we will end up missing code, data and cross references
        ida_auto.auto_wait()

        super(IDASpecification, self).__init__(arch, os)

        try:
            self._init_func_thunk_ctrl_flow()
        except:
            DEBUG(
                "Failed to initialize the control flow information for functin thunks"
            )
Пример #3
0
 def rebase_to(delta):
     ida_segment.rebase_program(delta, ida_segment.MSF_FIXONCE)
Пример #4
0
 def image_rebase():
     if get_imagebase() == 0:
         rebase_program(DEFAULT_IMAGE_BASE, MSF_FIXONCE)