Git Product home page Git Product logo

tenet's Introduction

Tenet - A Trace Explorer for Reverse Engineers

Tenet Trace Explorer

Overview

Tenet is an IDA Pro plugin for exploring execution traces. The goal of this plugin is to provide more natural, human controls for navigating execution traces against a given binary. The basis of this work stems from the desire to research new or innovative methods to examine and distill complex execution patterns in software.

For more context about this project, please read the blogpost about its initial release.

Special thanks to QIRA / geohot et al. for the inspiration.

Releases

  • v0.2 -- Imagebase detection, cell visualization, breakpoint refactor, bugfixes.
  • v0.1 -- Initial release

Installation

Tenet is a cross-platform (Windows, macOS, Linux) Python 3 plugin. It takes zero third party dependencies, making the code both portable and easy to install.

  1. From your disassembler's python console, run the following command to find its plugin directory:

    • IDA Pro: import idaapi, os; os.path.join(idaapi.get_user_idadir(), "plugins")
  2. Copy the contents of this repository's /plugins/ folder to the listed directory.

  3. Restart your disassembler.

This plugin is only supported for IDA 7.5 and newer.

Usage

Once properly installed, there will be a new menu entry available in the disassembler. This can be used to load externally-collected execution traces into Tenet.

Load Tenet trace

As this is the initial release, Tenet only accepts simple human-readable text traces. Please refer to the tracing readme in this repository for additional information on the trace format, limitations, and reference tracers.

Bidirectional Exploration

While using Tenet, the plugin will 'paint' trails to indicate the flow of execution forwards (blue) and backwards (red) from your present position in the active execution trace.

Tenet trails

To step forwards or backwards through time, you simply scroll while hovering over the timeline on the right side of the disassembler. To step over function calls, hold SHIFT while scrolling.

Trace Timeline

The trace timeline will be docked on the right side of the disassembler. This widget is used to visualize different types of events along the trace timeline and perform basic navigation as described above.

Zooming in on the trace timeline

By clicking and dragging across the timeline, it is possible to zoom in on a specific section of the execution trace. This action can be repeated any number of times to reach the desired granularity.

Execution Breakpoints

Double clicking the instruction pointer in the registers window will highlight it in red, revealing all the locations the instruction was executed across the trace timeline.

Placing a breakpoint on the current instruction

To jump between executions, scroll up or down while hovering the highlighted instruction pointer.

Additionally, you can right click in the disassembly listing and select one of the navigation-based menu entries to quickly seek to the execution of an instruction of interest.

Seeking to the first execution of an instruction

IDA's native F2 hotkey can also be used to set breakpoints on arbitrary instructions.

Memory Breakpoints

By double clicking a byte in either the stack or memory views, you will instantly see all reads/writes to that address visualized across the trace timeline. Yellow indicates a memory read, blue indicates a memory write.

Exploring memory accesses using memory breakpoints

Memory breakpoints can be navigated using the same technique described for execution breakpoints. Double click a byte, and scroll while hovering the selected byte to seek the trace to each of its accesses.

Right clicking a byte of interest will give you options to seek between memory read / write / access if there is a specific navigation action that you have in mind.

Memory seeking

To navigate the memory view to an arbitrary address, click onto the memory view and hit G to enter either an address or database symbol to seek the view to.

Region Breakpoints

It is possible to set a memory breakpoint across a region of memory by highlighting a block of memory, and double clicking it to set an access breakpoint.

Memory region access breakpoints

As with normal memory breakpoints, hovering the region and scrolling can used to traverse between the accesses made to the selected region of memory.

Register Seeking

In reverse engineering, it's pretty common to encounter situations where you ask yourself "Which instruction set this register to its current value?"

Using Tenet, you can seek backwards to that instruction in a single click.

Seeking to the previous register write

Seeking backwards is by far the most common direction to navigate across register changes... but for dexterity you can also seek forward to the next register assignment using the blue arrow on the right of the register.

Timestamp Shell

A simple 'shell' is provided to navigate to specific timestamps in the trace. Pasting (or typing...) a timestamp into the shell with or without commas will suffice.

Seeking around the trace using the timestamp shell

Using an exclamation point, you can also seek a specified 'percentage' into the trace. Entering !100 will seek to the final instruction in the trace, where !50 will seek approximately 50% of the way through the trace. !last will seek to the last navigable instruction that can be viewed in the disassembler.

Themes

Tenet ships with two default themes -- a 'light' theme, and a 'dark' one. Depending on the colors currently used by your disassembler, Tenet will attempt to select the theme that seems most appropriate.

Tenet Themes

The theme files are stored as simple JSON on disk and are highly configurable. If you are not happy with the default themes or colors, you can create your own themes and simply drop them in the user theme directory.

Tenet will remember your theme preference for future loads and uses.

FAQ

Q: How do I record an execution trace using Tenet?

  • A: Tenet is a trace reader, not a trace recorder. You will have to use dynamic binary instrumentation frameworks (or other related technologies) to generate a compatible execution trace. Please refer to the tracing readme for more information on existing tracers, or how to implement your own.

Q: What trace architectures does Tenet support loading?

  • A: Only x86 and AMD64, but the codebase is almost entirely architecture agnostic.

Q: How big of a trace file can Tenet load / navigate?

  • A: Tenet's trace reader is pure python, it was written as an MVP. There is no guarantee that traces which exceed 10 million instructions will be reasonable to navigate until a native backend replaces it.

Q: I loaded an execution trace, now there is a '.tt' file. What is it?

  • A: When Tenet loads a given text trace, it will parse, index, and compress the trace into a more performant format. On subsequent loads, Tenet will attempt to load the '.tt' file which should load in fraction of the time that it would take to load the original text trace.

Q: The plugin crashed / threw an error / is showing bad trace information, what should I do?

  • A: If you encounter an issue or inaccuracy that can be reproduced, please file an issue against this repository and upload a sample trace + executable.

Q: Memory in my trace is changing, but there are no writes to the region. Is this a bug!?

  • A: Your log file may not have captured all memory writes. For example, usermode DBI generally do not get a memory callback for external writes to process memory. This is most common when reading from a file, or from socket -- it is the kernel that writes memory into your designated usermode buffer, making the event invisible to traditional instrumentation.
    • Microsoft TTD generally exhibits the same behavior, it's tricky to solve without modeling syscalls.

Q: Will this be ported to Binary Ninja / Ghidra / ... ?

  • A: Possibly, but not anytime soon (unless there is significant incentive). As a research oriented project, the driving motivation is on developing novel strategies to organize and explore program execution -- not porting them.

Q: My organization would like to support this project, how can we help?

  • A: Without funding, the time I can devote to this project is limited. If your organization is excited by the ideas put forth here and capable of providing capital to sponsor dedicated R&D, please contact us.

Future Work

Time and motivation funding permitting, future work may include:

  • Filtering / coagulating library calls from traces
  • Pointer analysis (e.g. annotations) for the register / stack views
  • Native TraceFile & TraceReader implementations (e.g. bigger and faster traces)
  • Navigation history + bookmarks view (maybe 2-in-1?)
  • Richer trace informatics, more aggressive indexing of relevant events (e.g. function calls)
  • Trace cartography, improved summarization and representation of trace geography
  • Make the 'cpu architecture' selection/detection slightly less hardcoded
  • More out-of-the-box tracing bridges, DynamoRIO, TTD, RR, QEMU, Bochs, ...
  • Support for Hex-Rays / decompiled views (besides basic view sync)
  • Improved workflow for automatically loading or iterating on traces
  • Differential analysis, high level 'trace diffing'
  • Better navigation and breakdown of threads, quantum's
  • Better support for navigating 'multi module' traces (e.g. full system traces)
  • Binary Ninja support
  • ... ?

I welcome external contributions, issues, and feature requests. Please make any pull requests to the develop branch of this repository if you would like them to be considered for a future release.

Authors

tenet's People

Contributors

gaasedelen avatar mrexodia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tenet's Issues

Support wow64 traces?

Hello, thanks for the awesome project!

I'm attempting to fuzz a wow64 application with wtf - my traces end up 64bit but tenet on ida with a 32bit binary is able to load only 32bit traces. It would be nice if tenet was able to load these as well.

I guess another option would be for wtf to support 32bit trace output? That would leave out some steps that happen in 64bit land tho.

I'm currently using a hacky script to convert the 64bit trace to 32. It simply drops anything 64bit related and converts r[xx] to e[xx]. Seems to somewhat work in most cases. Adding it below if anyone needs it.

<?php

$infile = $argv[1];
$out = [];

foreach (file($infile, 6) as $line)
{
    $items = [];
    foreach (explode(',', $line) as $item)
    {
        if (preg_match('#0x[\da-f]{9}#', $item)) // drop anything that looks 64bit
            continue;
        
        list($key, $value) = explode('=', $item);
        
        if (preg_match('#r\d+#', $key)) // drop r8-r15
            continue;
        
        if (preg_match('#r\w\w#', $key)) // rxx -> exx
            $item = 'e'.substr($key,1).'='.$value;
        
        $items[] = $item;
    }
    
    $out[] = implode(',', $items);
}

file_put_contents($infile.'.wow64', implode("\n", array_filter($out)));

Support address-only tracing formats

First of all, awesome project!

It would be very helpful if you can add support for additional, more basic, tracing formats.
In many cases a collection of execution addresses is available but not the registers / memory.

If would be awesome if you could add support for a module + offset format like lighthouse (or additional formats as described here).

can not load tenet

:\Users\test\AppData\Roaming\Hex-Rays\IDA Pro\plugins\tenet_plugin.py: name 'QtCore' is not defined
Traceback (most recent call last):
File "C:\Program Files\IDA Pro 7.5 SP3\python\3\ida_idaapi.py", line 616, in IDAPython_ExecScript
exec(code, g)
File "C:/Users/test/AppData/Roaming/Hex-Rays/IDA Pro/plugins/tenet_plugin.py", line 1, in
from tenet.util.log import logging_started, start_logging
File "C:/Program Files/IDA Pro 7.5 SP3/plugins\tenet\util\log.py", line 6, in
from ..integration.api import disassembler
File "C:/Program Files/IDA Pro 7.5 SP3/plugins\tenet\integration\api_init_.py", line 18, in
from .ida_api import IDACoreAPI, IDAContextAPI, DockableWindow
File "C:/Program Files/IDA Pro 7.5 SP3/plugins\tenet\integration\api\ida_api.py", line 538, in
class IDADockSizeHack(QtCore.QObject):
NameError: name 'QtCore' is not defined

bug in loading in ida version 7.7

i dont think its about the version of ida but in the code from this function you return a double then pass it to qt
file : util/qt/util.py line 47

def get_dpi_scale():
    """
    Get a DPI-afflicted value useful for consistent UI scaling.
    """
    font = MonospaceFont()
    font.setPointSize(normalize_font(120))
    fm = QtGui.QFontMetricsF(font)

    # xHeight is expected to be 40.0 at normal DPI
    return fm.height() / 173.0

then you pass it to qt functions which all params are int here
file : util/qt/waitbox.py line 89

v_layout.setSpacing(int(self._dpi_scale*3))
v_layout.setContentsMargins(
    self._dpi_scale*5,
    self._dpi_scale,
    self._dpi_scale*5,
    self._dpi_scale
)

# scale widget dimensions based on DPI
height = self._dpi_scale * 15
self.setMinimumHeight(height)

so if you change that line 65 of code in waitbox.py to that you will fix the issue

self._dpi_scale = int(get_dpi_scale()*5.0)

Does not detect changes in trace file

Say you create a trace file trace.txt and save it on your desktop. When you load the trace into Tenet for the first time, it will generate a trace.tt file in the same directory. If you now change trace.txt and reload it, nothing will change inside Tenet, because it will just load the old trace.tt file instead. To solve this, you need to either delete trace.tt or save the new version of the trace under a different file name.

Tenet does not load when using Python 3.9, 'NameError: name 'QtCore' is not defined'

My System Version:Win10 20H2

My IDA Version: IDA Pro 7.5 sp3
My Python version:Python 3.9.0
The errors I encountered:

***********\IDA Pro 7.5 SP3\plugins\tenet_plugin.py: name 'QtCore' is not defined
Traceback (most recent call last):
  File "***********\IDA Pro 7.5 SP3\python\3\ida_idaapi.py", line 616, in IDAPython_ExecScript
    exec(code, g)
  File "***********/Tools/IDA Pro 7.5 SP3/plugins/tenet_plugin.py", line 1, in <module>
    from tenet.util.log import logging_started, start_logging
  File "***********/IDA Pro 7.5 SP3/plugins\tenet\util\log.py", line 6, in <module>
    from ..integration.api import disassembler
  File "***********/IDA Pro 7.5 SP3/plugins\tenet\integration\api\__init__.py", line 18, in <module>
    from .ida_api import IDACoreAPI, IDAContextAPI, DockableWindow
  File "***********/IDA Pro 7.5 SP3/plugins\tenet\integration\api\ida_api.py", line 538, in <module>
    class IDADockSizeHack(QtCore.QObject):
NameError: name 'QtCore' is not defined

No new options appear in the menu, how do I fix it

error loading trace file

when loading trace file it shows this error:

[TENET] Traceback (most recent call last):
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\context.py", line 270, in interactive_load_trace
    self.load_trace(filepath)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\context.py", line 177, in load_trace
    self.trace.attach_reader(self.reader)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\ui\trace_view.py", line 715, in attach_reader
    self.view.attach_reader(reader)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\ui\trace_view.py", line 621, in attach_reader
    self.trace_global.attach_reader(reader)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\ui\trace_view.py", line 126, in attach_reader
    self.set_zoom(0, reader.trace.length)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\ui\trace_view.py", line 264, in set_zoom
    self.refresh()
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\ui\trace_view.py", line 155, in refresh
    self._draw_trace()
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\ui\trace_view.py", line 334, in _draw_trace
    self._draw_cursor(painter)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\ui\trace_view.py", line 379, in _draw_cursor
    cursor_y = int(relative_idx / self.density) + BORDER_SIZE
ZeroDivisionError: float division by zero

Exception in ida_kernwin.UI_Hooks dispatcher function: SWIG director method error. Error detected when calling 'UI_Hooks.get_lines_rendering_info'
Traceback (most recent call last):
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 397, in _render_lines
    self._highlight_disassesmbly(lines_out, widget, lines_in)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 449, in _highlight_disassesmbly
    if address == ctx.reader.ip:
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 79, in ip
    return self.get_register(self.arch.IP)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1462, in get_register
    return self.get_registers([reg_name], idx)[reg_name]
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1519, in get_registers
    output_registers[self.arch.IP] = self.trace.get_ip(idx)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 590, in get_ip
    raise ValueError("Invalid IDX")
ValueError: Invalid IDX
Exception in ida_kernwin.UI_Hooks dispatcher function: SWIG director method error. Error detected when calling 'UI_Hooks.get_lines_rendering_info'
Traceback (most recent call last):
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 397, in _render_lines
    self._highlight_disassesmbly(lines_out, widget, lines_in)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 449, in _highlight_disassesmbly
    if address == ctx.reader.ip:
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 79, in ip
    return self.get_register(self.arch.IP)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1462, in get_register
    return self.get_registers([reg_name], idx)[reg_name]
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1519, in get_registers
    output_registers[self.arch.IP] = self.trace.get_ip(idx)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 590, in get_ip
    raise ValueError("Invalid IDX")
ValueError: Invalid IDX
Rebasing program to 0x56646000...
Exception in ida_kernwin.UI_Hooks dispatcher function: SWIG director method error. Error detected when calling 'UI_Hooks.get_lines_rendering_info'
Traceback (most recent call last):
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 397, in _render_lines
    self._highlight_disassesmbly(lines_out, widget, lines_in)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 449, in _highlight_disassesmbly
    if address == ctx.reader.ip:
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 79, in ip
    return self.get_register(self.arch.IP)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1462, in get_register
    return self.get_registers([reg_name], idx)[reg_name]
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1519, in get_registers
    output_registers[self.arch.IP] = self.trace.get_ip(idx)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 590, in get_ip
    raise ValueError("Invalid IDX")
ValueError: Invalid IDX
Exception in ida_kernwin.UI_Hooks dispatcher function: SWIG director method error. Error detected when calling 'UI_Hooks.get_lines_rendering_info'
Traceback (most recent call last):
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 397, in _render_lines
    self._highlight_disassesmbly(lines_out, widget, lines_in)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 449, in _highlight_disassesmbly
    if address == ctx.reader.ip:
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 79, in ip
    return self.get_register(self.arch.IP)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1462, in get_register
    return self.get_registers([reg_name], idx)[reg_name]
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1519, in get_registers
    output_registers[self.arch.IP] = self.trace.get_ip(idx)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 590, in get_ip
    raise ValueError("Invalid IDX")
ValueError: Invalid IDX
Exception in ida_kernwin.UI_Hooks dispatcher function: SWIG director method error. Error detected when calling 'UI_Hooks.get_lines_rendering_info'
Traceback (most recent call last):
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 397, in _render_lines
    self._highlight_disassesmbly(lines_out, widget, lines_in)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 449, in _highlight_disassesmbly
    if address == ctx.reader.ip:
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 79, in ip
    return self.get_register(self.arch.IP)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1462, in get_register
    return self.get_registers([reg_name], idx)[reg_name]
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1519, in get_registers
    output_registers[self.arch.IP] = self.trace.get_ip(idx)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 590, in get_ip
    raise ValueError("Invalid IDX")
ValueError: Invalid IDX
Exception in ida_kernwin.UI_Hooks dispatcher function: SWIG director method error. Error detected when calling 'UI_Hooks.get_lines_rendering_info'
Traceback (most recent call last):
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 397, in _render_lines
    self._highlight_disassesmbly(lines_out, widget, lines_in)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 449, in _highlight_disassesmbly
    if address == ctx.reader.ip:
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 79, in ip
    return self.get_register(self.arch.IP)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1462, in get_register
    return self.get_registers([reg_name], idx)[reg_name]
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1519, in get_registers
    output_registers[self.arch.IP] = self.trace.get_ip(idx)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 590, in get_ip
    raise ValueError("Invalid IDX")
ValueError: Invalid IDX
[TENET] Failed to load trace...
[TENET] Traceback (most recent call last):
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\context.py", line 270, in interactive_load_trace
    self.load_trace(filepath)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\context.py", line 159, in load_trace
    self.reader = TraceReader(filepath, self.arch, disassembler[self])
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 59, in __init__
    self.trace = TraceFile(filepath, architecture)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 294, in __init__
    self._load_trace()
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 459, in _load_trace
    self._load_packed_trace(self.packed_filepath)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 470, in _load_packed_trace
    self._load_segments(zip_archive)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 533, in _load_segments
    segment.from_file(f)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 946, in from_file
    self.load(f)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 1196, in load
    ip_itemsize = info.ip_length // info.ip_num
ZeroDivisionError: integer division or modulo by zero

Exception in ida_kernwin.UI_Hooks dispatcher function: SWIG director method error. Error detected when calling 'UI_Hooks.get_lines_rendering_info'
Traceback (most recent call last):
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 397, in _render_lines
    self._highlight_disassesmbly(lines_out, widget, lines_in)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\integration\ida_integration.py", line 449, in _highlight_disassesmbly
    if address == ctx.reader.ip:
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 79, in ip
    return self.get_register(self.arch.IP)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1462, in get_register
    return self.get_registers([reg_name], idx)[reg_name]
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\reader.py", line 1519, in get_registers
    output_registers[self.arch.IP] = self.trace.get_ip(idx)
  File "C:/Users/alex/AppData/Roaming/Hex-Rays/IDA Pro/plugins\tenet\trace\file.py", line 590, in get_ip
    raise ValueError("Invalid IDX")
ValueError: Invalid IDX

pintenet now working

Pintenet does not seem to work on Windows 11. It starts the progam and tthen nothing happens. A look at the task manager shows that nothing is happening even though the programs are all there in the task manager. Something seems to be preventing the trace.

pintenet segfaults without the -w option

test program

~/tenet/tracers/pin$ cat test.c
#include <stdio.h>

int main() { printf("hello\n"); }

~/tenet/tracers/pin$ gcc -g -o test test.c -Wall -Werror -Wextra

~/tenet/tracers/pin$ ./test
hello

crash

~/tenet/tracers/pin$ /home/test/pin/pin-3.19-98425-gd666b2bee-gcc-linux/pin -t obj-intel64/pintenet.so
   -o moo -- "./test"
Loaded image: 0x563463397000:0x563463399157 -> test
Loaded image: 0x7f01cbc50000:0x7f01cbc7bccb -> ld-linux-x86-64.so.2
Loaded image: 0x7ffce369a000:0x7ffce369aec7 -> [vdso]
Loaded image: 0x7f01b7200000:0x7f01b73f14d7 -> libc.so.6
C: [tid:38587] Tool (or Pin) caused signal 11 at PC 0x7f01c998d65d
Segmentation fault (core dumped)

no crash

~/tenet/tracers/pin$ /home/test/pin/pin-3.19-98425-gd666b2bee-gcc-linux/pin -t obj-intel64/pintenet.so   -w "test" -o moo -- "./test"
White-listing image: test
Loaded image: 0x55d75fe6f000:0x55d75fe71157 -> test
Loaded image: 0x7f78b5d1e000:0x7f78b5d49ccb -> ld-linux-x86-64.so.2
Loaded image: 0x7ffca6a61000:0x7ffca6a61ec7 -> [vdso]
Loaded image: 0x7f78a13c1000:0x7f78a15b24d7 -> libc.so.6
hello

generated trace

~/tenet/tracers/pin$ head moo.0.log  -n3
rdi=0x7f78b5d4d190,rsi=0x7f78b5d4d730,rsp=0x7ffca6a1d700,rdx=0x7f78b5d2fd50,rcx=0x7ffca6a1d718,rax=0x1c,r8=0x7f78a1573700,r9=0x9,r11=0x7f78a15738f0,r12=0x55d75fe70060,r13=0x7ffca6a1d700,rip=0x55d75fe70060,mr=0x7ffca6a1d6f8:3af1d1b5787f0000,mw=0x7f78b5d4d4ac:1c
rip=0x55d75fe70064
rip=0x55d75fe70066

Ability to apply diffs (memory, registers) from tenet context to the main state

I have a full memory dump (generated by WinDbg), and a tenet trace file (generated by wtf fuzzer), that contains trace from start point to BSOD (nt!KeBugCheck2).

image

I see that tenet context is a fully separate - it has its own windows for registers, memory, stack, etc...

It would be useful to apply the diff (to the main state) from the start of the trace to the selected tracepoint. This way I could generate a new memory dump (via '!dump' command in the Windbg shell in IDA console) directly from the nt!KeBugCheck2 state or whatever.

Bug Report: get_instruction_addresses returning 0 instructions

Hello,

Thank you for creating such great plugins. I have identified a small issue with the Tenet plugin that I would like to address. Specifically, I noticed that the get_instruction_addresses function returns zero instructions when running certain programs, such as /bin/ls. After debugging, I determined that this issue comes from the code snippet that drops data segments, as shown below:

if seg.sclass != ida_segment.SEG_CODE:
    continue

Although I was able to resolve the issue by removing this code, doing so may slow down the loading of traces. I would like to explore alternative solutions to this problem to ensure optimal performance of the plugin while still preserving its functionality.

PyQt5 float fixes (TypeError: setSpacing(self, int): argument 1 has unexpected type 'float')

Some minor fixes for Qt where it now requires floats to be truncated for some of its parameters.

iff --git a/plugins/tenet/util/qt/waitbox.py b/plugins/tenet/util/qt/waitbox.py
index c0b05f9..434a35b 100644
--- a/plugins/tenet/util/qt/waitbox.py
+++ b/plugins/tenet/util/qt/waitbox.py
@@ -86,17 +86,17 @@ class WaitBox(QtWidgets.QDialog):
             self._abort_button.clicked.connect(self._abort)
             v_layout.addWidget(self._abort_button)
 
-        v_layout.setSpacing(self._dpi_scale*3)
+        v_layout.setSpacing(int(self._dpi_scale*3))
         v_layout.setContentsMargins(
-            self._dpi_scale*5,
-            self._dpi_scale,
-            self._dpi_scale*5,
-            self._dpi_scale
+            int(self._dpi_scale*5),
+            int(self._dpi_scale),
+            int(self._dpi_scale*5),
+            int(self._dpi_scale)
         )
 
         # scale widget dimensions based on DPI
         height = self._dpi_scale * 15
-        self.setMinimumHeight(height)
+        self.setMinimumHeight(int(height))
 
         # compute the dialog layout
         self.setLayout(v_layout)

That's for this exception:

Traceback (most recent call last):
  File "/home/$USER/idapro-8.0/python/3/ida_idaapi.py", line 580, in IDAPython_ExecScript
    exec(code, g)
  File "/home/$USER/.idapro/plugins/tenet_plugin.py", line 1, in <module>
    from tenet.util.log import logging_started, start_logging
  File "/home/$USER/.idapro/plugins/tenet/util/log.py", line 6, in <module>
    from ..integration.api import disassembler
  File "/home/$USER/.idapro/plugins/tenet/integration/api/__init__.py", line 19, in <module>
    disassembler = IDACoreAPI()
  File "/home/$USER/.idapro/plugins/tenet/integration/api/ida_api.py", line 74, in __init__
    super(IDACoreAPI, self).__init__()
  File "/home/$USER/.idapro/plugins/tenet/integration/api/api.py", line 47, in __init__
    self._waitbox = WaitBox("Please wait...")
  File "/home/$USER/.idapro/plugins/tenet/util/qt/waitbox.py", line 27, in __init__
    self._ui_init()
  File "/home/$USER/.idapro/plugins/tenet/util/qt/waitbox.py", line 71, in _ui_init
    self._ui_layout()
  File "/home/$USER/.idapro/plugins/tenet/util/qt/waitbox.py", line 89, in _ui_layout
    v_layout.setSpacing(self._dpi_scale*3)
TypeError: setSpacing(self, int): argument 1 has unexpected type 'float'

Pin tool consistently crashes on the first instruction (32bit, Linux)

I got the intel pin tool you provided but after I compile it in Linux, and I try to run it,
pin -t pintenet.so -w a.out -- ./a.out

it gives me

White-listing image: a.out

Loaded image: 0x56605000:0x5660572f -> a.out

Loaded image: 0xf7f0a000:0xf7f2f4e3 -> ld-linux.so.2

Loaded image: 0xf7f09000:0xf7f09c0f -> [vdso]

Loaded image: 0xed317000:0xed4f2a1f -> libc.so.6

C: Tool (or Pin) caused signal 11 at PC 0xf6dd0a8d

Segmentation fault (core dumped)

Tenet cannot follow the trace if the traced imagebase does not match the database

Hello, thanks for the amazing work😊

I use pintenet to generate trace.log for calc.exe, but the trace.log looks like can't work.
I did the following:

ps: windows 10 + IDA 7.5 + pin 3.18
1、download pin and pintenet.dll/pintenet64.dll;
2、in a CMD execute:
pin\pin.exe -t pintenet.dll -w calc.exe -o "calc" -- "C:\Users\ml\Desktop\software\pin\calc.exe"
After successful execution, nothing is displayed on the CMD
3、a file named calc.0.log generated,the size of it is 988k
4、load the calc.0.log in IDA, The interface looks like this:
image

when I scroll while hovering over the timeline on the right side of the disassembler,
The code doesn't move forward or backward with it.

I did the same thing for BoomBox.exe, and it's trace file is available.
so I thought maybe there was something wrong with the trace files for calc.exe.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.