Giter Club home page Giter Club logo

idaref's Introduction

IdaRef

IDA Pro Full Instruction Reference Plugin - It's like auto-comments but useful.

I'm generally pretty good at figuring out what various Intel instructions do. But, once in a while I need to either know some precise detail (i.e. exact side effects of SUB) or come across a rare instruction. Then I break my train of thought and have to dig out the reference manual. Which got me thinking: Why can't IDA just give me the full documentation?

Enter IdaRef: The plugin will monitor the location for your cursor (ScreenEA) and display the full documentation of the instruction. At the moment it only supports x86-64, ARM and MIPS 32bit, however adding support for other architectures is relatively easy.

Usage

Simply checkout or download the repository and install it to your IDA plugins directory:

idaref.py -> <ida_path>/plugins/idaref.py
arm.sql -> <ida_path>/plugins/archs/arm.sql
x86-64.sql -> <ida_path>/plugins/archs/x86-64.sql
mips32.sql -> <ida_path>/plugins/archs/mips32.sql
xtensa.sql -> <ida_path>/plugins/archs/xtensa.sql

You can also use the installer.sh file but you'll need to open it and edit the IDA path if you're not using Mac OS and IDA 6.8.

Once loaded, the plugin can be turned ON by going to Edit/Start IdaRef menu option. To control the output right-click on the tab window to get a menu:

  • Update View - Load documentation for currectly selected instruction.
  • Lookup Instruction - Manual load documentation, you'll be prompted for the instruction.
  • Toggle Auto-refresh - Turn on/off auto loading of documentation and rely on the first two options.

Internals

Upon loading the script will look for SQlite databases in the same directory as the itself. The naming convention for the database files is [arch name].sql. The [arch name] will be presented to the user as choice.

The database has a table called 'instructions' and two columns called 'mnem' and 'description'. The instructions are looked up case insensitive (upper case) by the mnem value. The text from description is displayed verbatim in the view.

To add support for more architectures simply create a new database with those columns and place it in the the script directory.

import sqlite3 as sq
con = sq.connect("asm.sqlite")
con.text_factory = str
cur = con.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS instructions (platform TEXT, mnem TEXT, description TEXT)")
con.commit()

When working with x86, I noticed that many instructions point to the same documentation. So, the plugin supports single level referencing. Just place '-R:[new instruction]' into description to redirect the loading. 'new instruction' is the target. So, when loading the script will detect the link and load the new target automatically.

cur.execute("INSERT INTO instructions VALUES (?, ?, ?)", ("x86", inst, "-R:%s" % first_inst))

Skeletons in the closet

The documentation database was created using a rather hackish screen scraping technique by the x86doc project which I forked. So, there are probably some strange characters or tags in the text. At least, it is a mechanical process so I expect that the information is correct relative to the original Intel PDF.

Ports

If you're a hopper user, there is a port called hopperref: https://github.com/zbuc/hopperref

If you're an x64dbg user, IdaRef is integrated with the mnemonichelp xxx command or through the context menu. Fork: https://github.com/x64dbg/idaref

Enjoy!

idaref's People

Contributors

0xricksanchez avatar cnsheds avatar mrexodia avatar nologic avatar simob avatar sven337 avatar williballenthin avatar xanarin 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  avatar  avatar  avatar  avatar  avatar

idaref's Issues

Plugin fails to load under IDA 7.1 because idaapi and idc are not explictly imported

This issue occurs on IDA 7.1.180227 Linux x86_64 with the following python installation:

Python 2.7.15 (default, May  1 2018, 20:16:04) 
[GCC 7.3.1 20180406] 
IDAPython v1.7.0 final (serial 0) (c) The IDAPython Team <[email protected]>

When IDA is started, the idaref plugin fails to initalize with the following traceback:

/opt/ida-7.1/plugins/idaref.py: name 'idaapi' is not defined
Traceback (most recent call last):
  File "/opt/ida-7.1/python/ida_idaapi.py", line 566, in IDAPython_ExecScript
    execfile(script, g)
  File "/opt/ida-7.1/plugins/idaref.py", line 12, in <module>
    class StopHandler(idaapi.action_handler_t):
NameError: name 'idaapi' is not defined

If the statement import idaapi is added after line 5 of idaref.py, the first issue is resolved, but a new error occurs when starting idaref:

Starting IdaRef
available architectures ['x86-64', 'arm']
Manual loaded for architecture: arm
Traceback (most recent call last):
  File "/opt/ida-7.1/plugins/idaref.py", line 121, in update
    self.update()
  File "/opt/ida-7.1/plugins/idaref.py", line 257, in update
    inst = self.cleanInstruction(GetMnem(ScreenEA()))
NameError: global name 'GetMnem' is not defined

This can be resolved by explicitly importing GetMnem and ScreenEA from the idc package.

Python error on line 119 in idaref.py at launch, on IDA 6.8

Windows 10, IDA 6.8 x64

When IDA Pro is launched, it displays a dialog box, with the message:

idaref.py: invalid syntax ...
File "C:/Program Files (x86)/IDA 6.8/plugins/idaref.py", line 119
if(not os.path.isfile(dbpath)):
.............................^
SyntaxError: invalid syntax

Looks like a closed paren typo on line 118, as referenced in this pull request #10

duplicate mnemonics

Just in case someone is wondering, if you run the SQL

SELECT
    mnem, description, COUNT(*)
FROM
    instructions
GROUP BY
    mnem
HAVING
    COUNT(*) > 1

You get the duplicate mnemonics, which are:

s

Not really an issue, but might come up.

Fix "Lookup Instruction"

As this porting guide suggests idc.AskStr is replaced with ida_kernwin.ask_str.
This patch that fixes the "Lookup Instruction" functionality, tested with IDA 7.5:

diff --git a/idaref.py b/idaref.py
index e9445f1..18008d1 100755
--- a/idaref.py
+++ b/idaref.py
@@ -5,7 +5,7 @@ import inspect
 import glob
 import idaapi
 from idc import print_insn_mnem, get_screen_ea
-from ida_kernwin import ask_long, find_widget, close_widget
+from ida_kernwin import ask_long, find_widget, close_widget, ask_str
 
 
 initialized = False
@@ -340,7 +340,7 @@ class InstructionReference(idaapi.simplecustviewer_t):
         if menu_id == self.menu_update:
             self.update(True)
         elif menu_id == self.menu_lookup:
-            inst = AskStr(self.last_inst, "Instruction: ")
+            inst = ask_str(self.last_inst, 0, "Instruction: ")
             if inst != None:
                 self.load_inst(inst, True)
         elif menu_id == self.menu_autorefresh:

support MIPS

Hi, very interesting plugin. Thanks.
Did you plan to add MIPS ? If not, can you share your script to create the database from intel arch ?

missing x86 aliases

Hi!

There are a lot of redirects missing in your .sql. While I was writing https://github.com/bnagy/cgasm I wrote a code generator to convert your .sql to a go map. Once that was done it was no trouble to add your original .sql format as an alternate output format. You can generate a cleaner .sql file for this project by running this: https://github.com/bnagy/cgasm/tree/master/codegen

sqlgen sql > name_of_file.sql

The new .sql also has explicit redirects for all Jcc variants etc, so you shouldn't need to special case those anymore.

Let me know if the tool doesn't work for you for any reason (I didn't test, I just visually compared the SQL)

Cheers!

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.