Skip to content

Commit 83f48bb

Browse files
committed
feat: setting up for v1.0
1 parent 2bf3368 commit 83f48bb

33 files changed

Lines changed: 1320 additions & 511 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ Use function matching to identify similar functions in other binaries or collect
125125

126126
- Click `RevEng.AI > Match Functions`
127127

128-
> 🖼️ *Insert screenshot of match functions result*
128+
<img src="./images/matchedfunctions.png" >
129129

130-
Matched functions are displayed with similarity and metadata. You can navigate or rename based on the results.
130+
Matched functions are displayed based on the given confidence value. You can navigate or rename based on the results.
131131

132132
---
133133

images/matchedfunctions.png

292 KB
Loading

revengai/features/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
from .auto_unstrip import AutoUnstripFeature
44
from .choose_source import ChooseSourceFeature
55
from .match_functions import MatchFunctionsFeature
6+
from .match_current_function import MatchCurrentFunctionFeature
67

7-
__all__ = ['ConfigurationFeature', 'UploadFeature', 'AutoUnstripFeature', 'ChooseSourceFeature', 'MatchFunctionsFeature']
8+
__all__ = ['ConfigurationFeature', 'UploadFeature', 'AutoUnstripFeature', 'ChooseSourceFeature', 'MatchFunctionsFeature', 'MatchCurrentFunctionFeature']

revengai/features/auto_unstrip/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __init__(self, config=None):
1111

1212
def register(self):
1313
PluginCommand.register(
14-
"RevEng.AI\\Auto Unstrip",
14+
"RevEng.AI\\4 - Auto Unstrip",
1515
"Attempt to recover stripped function names",
1616
self.show_auto_unstrip_dialog,
1717
self.is_valid

revengai/features/auto_unstrip/auto_unstrip.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from concurrent.futures import ThreadPoolExecutor, as_completed
44
from typing import List, Dict, Tuple
55
import math
6+
from revengai.utils import rename_function as rename_function_util
67

78
class AutoUnstrip:
89
def __init__(self, config):
@@ -12,29 +13,7 @@ def __init__(self, config):
1213
self.path = None
1314
self.max_workers = 4
1415

15-
def _rename_function(self, bv: BinaryView, addr: int, new_name: str, new_name_mangled: str) -> bool:
16-
try:
17-
func = bv.get_function_at(addr)
18-
if not func:
19-
log_error(f"RevEng.AI | No function found at address {hex(addr)}")
20-
return False
21-
22-
if func.name == new_name or func.name == new_name_mangled:
23-
log_info(f"RevEng.AI | Function at {hex(addr)} already has name {func.name}")
24-
return False
25-
26-
new_symbol = Symbol(SymbolType.FunctionSymbol, addr, new_name)
27-
bv.define_user_symbol(new_symbol)
28-
29-
log_info(f"RevEng.AI | Renamed function at {hex(addr)} to {new_name}")
30-
return True
31-
32-
except Exception as e:
33-
log_error(f"RevEng.AI | Error renaming function at {hex(addr)}: {str(e)}")
34-
return False
35-
3616
def _process_batch(self, function_ids: List[int], id_to_addr: Dict[int, int], bv: BinaryView) -> Tuple[int, List[str]]:
37-
"""Process a batch of function IDs and return the number of renamed functions"""
3817
try:
3918
functions_by_distance = RE_nearest_symbols_batch(
4019
function_ids=function_ids,
@@ -69,16 +48,17 @@ def _process_batch(self, function_ids: List[int], id_to_addr: Dict[int, int], bv
6948
for function in functions_by_score:
7049
if function['function_id'] == func_id:
7150
if function['box_plot']["average"] < 0.9:
72-
log_info(f"RevEng.AI | Function {function['function_id']} has a score of {function['box_plot']['average']:.2f} for name {function['function_name']}, skipping")
51+
log_info(f"RevEng.AI | Function {function['function_id']} has a score of {function['box_plot']['average']:.2f} for name {new_name_mangled}, skipping")
7352
break
7453
else:
75-
log_info(f"RevEng.AI | Function {function['function_id']} has a score of {function['box_plot']['average']:.2f} for name {function['function_name']}, renaming")
76-
if self._rename_function(bv, func_addr, new_name, new_name_mangled):
54+
log_info(f"RevEng.AI | Function {function['function_id']} has a score of {function['box_plot']['average']:.2f} for name {new_name_mangled}, renaming")
55+
if rename_function_util(bv, func_addr, new_name_mangled):
7756
renamed_count += 1
7857
break
7958

8059

8160
except Exception as e:
61+
log_error(f"RevEng.AI | Error processing function {result['origin_function_id']}: {str(e)}")
8262
errors.append(str(e))
8363

8464
return renamed_count, errors

revengai/features/auto_unstrip/auto_unstrip_dialog.py

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
from binaryninja import BinaryView, PluginCommand, log_info, log_error
1+
from binaryninja import log_error
22
from PySide6.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout,
3-
QPushButton, QLabel, QCheckBox,
4-
QGroupBox, QRadioButton, QSpacerItem,
5-
QSizePolicy)
3+
QPushButton, QLabel)
64
from PySide6.QtCore import Qt
7-
from PySide6.QtGui import QPixmap, QIcon
5+
from PySide6.QtGui import QPixmap
86
from PySide6.QtCore import QCoreApplication
97
from PySide6.QtWidgets import QMessageBox
108
from revengai.utils import create_progress_dialog
11-
from .auto_unstrip_thread import AutoUnstripThread
9+
from revengai.utils.data_thread import DataThread
1210
import os
1311

1412
class AutoUnstripDialog(QDialog):
@@ -38,9 +36,7 @@ def init_ui(self):
3836
info_layout = QVBoxLayout()
3937
title_label = QLabel("Auto Unstrip Binary")
4038
title_label.setStyleSheet("font-size: 18px; font-weight: bold;")
41-
description_label = QLabel(
42-
"Using official RevEng.AI sources, function names will be recovered based on a high similarity and confidence threshold and limited to available debug symbols.\nFunctions will be renamed automatically for easier analysis.\n\nThis process may take several minutes depending on the binary size."
43-
)
39+
description_label = QLabel("Using official RevEng.AI sources, function names will be recovered based on a high similarity and confidence threshold and limited to available debug symbols.\nFunctions will be renamed automatically for easier analysis.\n\nThis process may take several minutes depending on the binary size.")
4440
description_label.setWordWrap(True)
4541
info_layout.addWidget(title_label)
4642
info_layout.addWidget(description_label)
@@ -49,7 +45,6 @@ def init_ui(self):
4945
layout.addLayout(header_layout)
5046
layout.addSpacing(20)
5147

52-
# Buttons
5348
button_layout = QHBoxLayout()
5449
self.save_button = QPushButton("Auto Unstrip")
5550
self.save_button.setStyleSheet("""
@@ -76,40 +71,24 @@ def init_ui(self):
7671
button_layout.addWidget(self.save_button)
7772
button_layout.addWidget(self.cancel_button)
7873
layout.addLayout(button_layout)
79-
8074
self.setLayout(layout)
8175

8276
def _auto_unstrip(self):
83-
log_info("RevEng.AI | Auto Unstripping binary")
84-
# Create and show progress dialog using utility function
8577
self.progress = create_progress_dialog(self, "RevEng.AI Auto Unstrip", "Auto Unstripping binary...")
78+
self.progress.show()
79+
QCoreApplication.processEvents()
8680

87-
# Create and start upload thread
88-
self.auto_unstrip_thread = AutoUnstripThread(self.auto_unstrip, self.bv)
81+
self.auto_unstrip_thread = DataThread(self.auto_unstrip.auto_unstrip, self.bv)
8982
self.auto_unstrip_thread.finished.connect(self._on_auto_unstrip_finished)
9083
self.auto_unstrip_thread.start()
91-
92-
self.progress.show()
93-
QCoreApplication.processEvents()
94-
9584

9685
def _on_auto_unstrip_finished(self, success, message):
97-
"""Handle auto unstrip completion"""
9886
self.progress.close()
9987

10088
if success:
101-
QMessageBox.information(
102-
self,
103-
"RevEng.AI Auto Unstrip",
104-
f"Binary auto unstripped successfully!\n{message}",
105-
QMessageBox.Ok
106-
)
89+
QMessageBox.information(self, "RevEng.AI Auto Unstrip", f"Binary auto unstripped successfully!\n{message}", QMessageBox.Ok)
10790
self.accept()
10891
else:
10992
log_error(f"RevEng.AI | Failed to auto unstrip binary: {message}")
110-
QMessageBox.critical(
111-
self,
112-
"RevEng.AI Auto Unstrip Error",
113-
f"Failed to auto unstrip binary: {message}",
114-
QMessageBox.Ok
115-
)
93+
QMessageBox.critical(self, "RevEng.AI Auto Unstrip Error", f"Failed to auto unstrip binary: {message}", QMessageBox.Ok)
94+
self.reject()

revengai/features/auto_unstrip/auto_unstrip_thread.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

revengai/features/choose_source/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __init__(self, config=None):
1111

1212
def register(self):
1313
PluginCommand.register(
14-
"RevEng.AI\\Choose Source",
14+
"RevEng.AI\\3 - Choose Source",
1515
"Choose a source for the binary analysis",
1616
self.show_choose_source_dialog,
1717
self.is_valid

revengai/features/choose_source/analysis_load_thread.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

revengai/features/choose_source/choose_source.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
from binaryninja import BinaryView, log_info, log_error, Symbol, SymbolType
2-
from reait.api import RE_authentication, RE_search, RE_nearest_symbols_batch, RE_analyze_functions
3-
from concurrent.futures import ThreadPoolExecutor, as_completed
4-
from typing import List, Dict, Tuple
5-
import math
1+
from binaryninja import BinaryView, log_info, log_error
2+
from reait.api import RE_search
63

74
class ChooseSource:
85
def __init__(self, config):
@@ -15,15 +12,15 @@ def choose_source(self, bv: BinaryView, chose: str):
1512
binary_id = self.config.get_binary_id(bv)
1613
if binary_id == new_binary_id:
1714
log_info("RevEng.AI | Binary ID is already set to the chosen one.")
18-
return True
15+
return True, "Binary ID is already set to the chosen one."
1916

2017
log_info(f"RevEng.AI | Changing Binary ID: {binary_id} to {new_binary_id}")
2118
self.config.set_current_info(new_binary_id)
2219

23-
return True
20+
return True, "Binary ID changed successfully."
2421
except Exception as e:
2522
log_error(f"RevEng.AI | Failed to choose source: {str(e)}")
26-
return False
23+
return False, str(e)
2724

2825
def get_analysis(self, bv: BinaryView):
2926
try:
@@ -46,7 +43,7 @@ def get_analysis(self, bv: BinaryView):
4643
else:
4744
options.append(option)
4845

49-
return options
46+
return True, options
5047
except Exception as e:
5148
log_error(f"RevEng.AI | Failed to get analysis: {str(e)}")
52-
return []
49+
return False, str(e)

0 commit comments

Comments
 (0)