Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions idaplugin/rematch/automate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import idaapi

from . import actions
from . import dialogs


def main():
# add file
description = "Automatically collected / uploaded by autoupload.py"
calls = [('submit', {'project': -1, 'name': "filename", 'md5hash': "hash",
'description': description, 'shareidb': True})]
add_file_silent = dialogs.silent.SilentDialog(calls)
actions.project.AddFileAction(add_file_silent).activate(None)

##############
# skipped: add a project for file
calls = [('submit', {'name': "proj_name", 'description': description,
'private': False, 'bind_current': True})]
add_file_silent = dialogs.silent.SilentDialog(calls)

# upload data and start matching
calls = [('submit', {'source': 'idb', 'source_single': None,
'source_range': None, 'target': 'db',
'target_project': None, 'target_file': None,
'matchers': None})]
match_silent = dialogs.silent.SilentDialog(calls)
actions.match.MatchAction(match_silent).activate(None)


if __name__ == "__main__":
# action = str(idc.ARGV[1])
# task_id = int(idc.ARGV[2])
# owner_id = int(idc.ARGV[3])

# wait until autoanalysis is done, if needed
idaapi.autoWait()

main()

# and exit the IDA instance
idaapi.qexit(0)
5 changes: 3 additions & 2 deletions idaplugin/rematch/dialogs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from . import base
from . import widgets
from . import gui
from . import auto
from . import login
from . import upload
from . import match
Expand All @@ -9,5 +10,5 @@
from . import settings
from . import serializedgraph

__all__ = ['base', 'widgets', 'gui', 'login', 'upload', 'match', 'result',
'project', 'settings', 'serializedgraph']
__all__ = ['base', 'widgets', 'gui', 'auto', 'login', 'upload', 'match',
'result', 'project', 'settings', 'serializedgraph']
36 changes: 36 additions & 0 deletions idaplugin/rematch/dialogs/auto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from .. import log
from .base import BaseDialog


class AutoDialog(BaseDialog):
def __init__(self, calls):
# initialize super without any callbacks to avoid code review warnings
super(AutoDialog, self).__init__()
self.data_value = None
self.calls = calls

def __call__(self, **kwargs):
super(AutoDialog, self).__init__(**kwargs)
return self

def show(self):
for handler, kws in self.calls:
response = None
log('silent_dialog').info("dispatching silent dialog action %s: %s",
handler, kws)
if handler == 'reject':
response = self.reject_base(**kws)
elif handler == 'submit':
self.data_value = kws
response = self.submit_base()
elif handler == 'response':
response = self.response_base(**kws)
elif handler == 'exception':
response = self.exception_base(**kws)
else:
log('silent_dialog').error("failed resolving handler")

log('silent_dialog').info("response: %s", response)

def data(self):
return self.data_value
7 changes: 7 additions & 0 deletions tests/idaplugin/test_autoupload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import idaplugin


def test_main(idapro_app):
del idapro_app

idaplugin.rematch.autoupload.main()