Skip to content

Commit 8f38d85

Browse files
author
trib0re
committed
binja: full support of plugin
1 parent af3ebf8 commit 8f38d85

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

syms2elf.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#
77
# Daniel García <danigargu [at] gmail.com>
88
# Jesús Olmos <sha0 [at] badchecksum.net>
9+
# sheadovas
910
#
1011
# ELF parser - based on the lib of ROPgadget tool by Jonathan Salwan
1112
# http://shell-storm.org/project/ROPgadget/
@@ -17,7 +18,7 @@
1718
#
1819

1920
PLUG_NAME = "syms2elf"
20-
VERSION = "v0.2"
21+
VERSION = "v0.3"
2122

2223
import os
2324
import sys
@@ -578,7 +579,7 @@ def log_r2(msg=''):
578579
print("%s" % msg)
579580

580581
def log_binja(msg=''):
581-
log_info("[%s] %s" % (PLUG_NAME, msg))
582+
binaryninja.log_info("[%s] %s" % (PLUG_NAME, msg))
582583

583584
def write_symbols(input_file, output_file, symbols):
584585
try:
@@ -718,7 +719,10 @@ def get_binja_symbols(bv):
718719
addr = fnc.start
719720
name = fnc.name
720721
size = sum(bb.length for bb in fnc)
721-
symbols.append(Symbol(name, STB_GLOBAL_FUNC, addr, size, name))
722+
sh_name = bv.get_sections_at(addr)[0].name
723+
724+
s = Symbol(name, STB_GLOBAL_FUNC, addr, size, sh_name)
725+
symbols.append(s)
722726
# FIXME figure out what is the reason of the error
723727
return symbols
724728

@@ -734,7 +738,9 @@ def get_binja_arch(bv):
734738
def save_binja_binary(bv):
735739
arch = get_binja_arch(bv)
736740
if arch is None:
737-
interaction.show_message_box("ERROR", "ELF binaries are supported only")
741+
binaryninja.interaction.show_message_box(
742+
"ERROR, {} found!".format(bv.view_type), "The input file is not a ELF"
743+
)
738744
return
739745

740746
symbols = get_binja_symbols(bv)
@@ -744,7 +750,7 @@ def save_binja_binary(bv):
744750
)
745751
write_symbols(
746752
bv.file.original_filename,
747-
interaction.get_save_filename_input('Save binary to file', default_name=path),
753+
binaryninja.interaction.get_save_filename_input('Save binary to file', default_name=path),
748754
symbols
749755
)
750756

@@ -838,6 +844,6 @@ def PLUGIN_ENTRY():
838844

839845

840846
elif USE_BINJA:
841-
from binaryninja import *
847+
import binaryninja
842848
log = log_binja
843-
PluginCommand.register('[sym2elf] Export binary', 'Craft binary with symbols got from function names used in this project', save_binja_binary)
849+
binaryninja.PluginCommand.register('[sym2elf] Export binary', 'Craft binary with symbols got from function names used in this project', save_binja_binary)

syms2elf.pyc

29.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)