Skip to content

Commit

Permalink
improve ida gui integration
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Jun 26, 2020
1 parent 0194c66 commit b9c5aeb
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 30 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ FA> project set: test-project-ida
```

Also, an additional `FA Toolbar` will be added with quick functions that
are also available under the `Edit` menu.
are also available under the newly created `FA` menu.

![FA Menu](https://github.com/doronz88/fa/raw/master/res/screenshots/menu.png "FA Menu")

A QuickStart Tip:

Expand Down Expand Up @@ -889,10 +891,3 @@ optional arguments:
--name NAME parameter as label name
--bytes BYTES parameter as bytes
```

### Credits

Icons were downloaded from: [www.flaticon.com](http://www.flaticon.com).

Creators: inipagistudio, becris, freepik

80 changes: 58 additions & 22 deletions ida_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import hjson
import click

from ida_kernwin import Form
import ida_kernwin
import ida_bytes
import idautils
Expand Down Expand Up @@ -200,30 +201,39 @@ def reload_segments(self):
return

def interactive_set_project(self):
from idaapi import Form

class SetProjectForm(Form):
def __init__(self, signatures_root, projects, current):
self.__n = 0
description = '''
<h2>Project Selector</h2>
<div>
Select project you wish to work on from your
signatures root:
</div>
<div><pre>{}</pre></div>
<div><i>(Note: You may change this in config.ini)</i></div>
'''.format(signatures_root)

Form.__init__(self,
r"""BUTTON YES* OK
FA Project Select
Select project you wish to work on from your
signatures root:
{}
(Note: You may change this in config.ini)
{{FormChangeCb}}
{{StringLabel}}
<Set Project :{{cbReadonly}}>
""".format(signatures_root), {
'FormChangeCb': Form.FormChangeCb(self.OnFormChange),
'cbReadonly': Form.DropdownListControl(
items=projects,
readonly=True,
selval=projects.index(current)),
'StringLabel': Form.StringLabel(description,
tp=Form.FT_HTML_LABEL),
})
self.__n = 0

def OnFormChange(self, fid):
return 1
Expand Down Expand Up @@ -276,7 +286,7 @@ def update(self, ctx):
print("Action registered. Attaching to menu.")

# Insert the action in the menu
if ida_kernwin.attach_action_to_menu("Edit/Export data", act_name, ida_kernwin.SETMENU_APP):
if ida_kernwin.attach_action_to_menu("FA/", act_name, ida_kernwin.SETMENU_APP):
print("Attached to menu.")
else:
print("Failed attaching to menu.")
Expand All @@ -298,35 +308,58 @@ def finish_populating_widget_popup(self, widget, popup):

def load_ui():
actions = [
Action(name='fa:set-project', icon_filename='project_becris.png',
handler=fa_instance.interactive_set_project, label='FA Set project...',
Action(name='fa:set-project', icon_filename='suitcase.png',
handler=fa_instance.interactive_set_project, label='Set project...',
hotkey='Ctrl+6'),

Action(name='fa:symbols', icon_filename='search_inipagistudio.png',
handler=fa_instance.symbols, label='FA Find all project\'s symbols',
Action(name='fa:symbols', icon_filename='find_all.png',
handler=fa_instance.symbols, label='Find all project\'s symbols',
hotkey='Ctrl+7'),

Action(name='fa:extended-create-signature', icon_filename='signature_freepik.png',
handler=fa_instance.extended_create_symbol, label='FA Create temp signature...',
Action(name='fa:extended-create-signature', icon_filename='create_sig.png',
handler=fa_instance.extended_create_symbol, label='Create temp signature...',
hotkey='Ctrl+8'),

Action(name='fa:find-symbol', icon_filename='find_inipagistudio.png',
handler=fa_instance.find_symbol, label='FA Find last created temp signature',
Action(name='fa:find-symbol', icon_filename='find.png',
handler=fa_instance.find_symbol, label='Find last created temp signature',
hotkey='Ctrl+9'),

Action(name='fa:prompt-save', icon_filename='save_freepik.png',
handler=fa_instance.prompt_save_signature, label='FA Save last created temp signature',
Action(name='fa:prompt-save', icon_filename='save.png',
handler=fa_instance.prompt_save_signature, label='Save last created temp signature',
hotkey='Ctrl+0'),
]

# init toolbar
ida_kernwin.delete_toolbar("fa")
ida_kernwin.create_toolbar("fa", "FA Toolbar")
ida_kernwin.delete_toolbar('fa')
ida_kernwin.create_toolbar('fa', 'FA Toolbar')

# init menu
ida_kernwin.delete_menu('fa')
ida_kernwin.create_menu('fa', 'FA')

for action in actions:
add_action(action)


def install():
ida_python_rc_path = os.path.join(idaapi.get_user_idadir(), "idapythonrc.py")
if not os.path.exists(ida_python_rc_path):
IdaLoader.log('failed location ida rc file')
return

with open(ida_python_rc_path, 'rt') as rc:
if 'FA loading start' in rc.read():
# already installed
return

with open(ida_python_rc_path, 'at') as rc:
rc.write('\n\n# FA loading start\n')
rc.write('exec(open(r"{}", "rb").read())\n'.format(os.path.abspath(__file__)))
rc.write('# FA loading end\n')

IdaLoader.log('Successfullt installed :)')


@click.command()
@click.argument('signatures_root', default='.')
@click.argument('project_name', default='test-project-ida')
Expand Down Expand Up @@ -365,6 +398,9 @@ def main(signatures_root, project_name, symbols_file=None):
fa_instance.symbols(symbols_file)
ida_pro.qexit(0)

# TODO: consider adding as autostart script
# install()


if __name__ == '__main__':
main(standalone_mode=False, args=idc.ARGV[1:])
Binary file added res/icons/create_sig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/icons/find.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/icons/find_all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed res/icons/find_inipagistudio.png
Binary file not shown.
Binary file removed res/icons/project_becris.png
Binary file not shown.
Binary file added res/icons/save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed res/icons/save_freepik.png
Binary file not shown.
Binary file removed res/icons/search_inipagistudio.png
Binary file not shown.
Binary file removed res/icons/signature_freepik.png
Binary file not shown.
Binary file added res/icons/suitcase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/screenshots/menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/screenshots/set-project.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b9c5aeb

Please sign in to comment.