Skip to content

Commit

Permalink
Add angr plugin finder to generic template and work with change_watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
mahaloz committed Dec 27, 2023
1 parent 6d44b8d commit f5fcfc6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
5 changes: 5 additions & 0 deletions examples/change_watcher_plugin/bs_change_watcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,10 @@ def install_angr(self, path=None, interactive=True):
if not path:
return

path = path / "plugins" / "bs_change_watcher"
path.mkdir(parents=True, exist_ok=True)
src = self.pkg_path / "plugin.toml"
dst = Path(path) / "plugin.toml"
self.link_or_copy(src, dst, symlink=True)
self._copy_plugin_to_path(path)
return path
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,28 @@ def create_plugin(*args, **kwargs):
has_ida = True
except ImportError:
has_ida = False
try:
import angrmanagement
has_angr = True
except ImportError:
has_angr = False

if not has_ida:
if not has_ida and not has_angr:
create_plugin()
elif has_angr:
from angrmanagement.plugins import BasePlugin
class PluginThunkClass(BasePlugin):
def __init__(self, workspace):
super().__init__(workspace)
globals()["workspace"] = workspace
self.plugin = create_plugin()

def teardown(self):
pass


def PLUGIN_ENTRY(*args, **kwargs):
"""
This is the entry point for IDA to load the plugin.
"""
print("[+] Loading callback_watcher plugin (1/2)")
return create_plugin(*args, **kwargs)
13 changes: 13 additions & 0 deletions examples/change_watcher_plugin/bs_change_watcher/plugin.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[meta]
plugin_metadata_version = 0

[plugin]
name = "bs_change_watcher"
shortname = "bs_change_watcher"
version = "0.0.0"
description = ""
long_description = ""
platforms = ["windows", "linux", "macos"]
min_angr_version = "9.0.0.0"
author = "The BinSync Team"
entrypoints = ["bs_change_watcher_plugin.py"]
17 changes: 16 additions & 1 deletion examples/template_plugin_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,24 @@ def create_plugin(*args, **kwargs):
has_ida = True
except ImportError:
has_ida = False
try:
import angrmanagement
has_angr = True
except ImportError:
has_angr = False

if not has_ida:
if not has_ida and not has_angr:
create_plugin()
elif has_angr:
from angrmanagement.plugins import BasePlugin
class PluginThunkClass(BasePlugin):
def __init__(self, workspace):
super().__init__(workspace)
globals()["workspace"] = workspace
self.plugin = create_plugin()

def teardown(self):
pass


def PLUGIN_ENTRY(*args, **kwargs):
Expand Down

0 comments on commit f5fcfc6

Please sign in to comment.