11 Commits

Author SHA1 Message Date
Joxean Koret afc31c33ae Bug fixes and removal of waste code
BUG: Fixed issues #200 and #324.

Also, removed all pylint directives. They are unused.
2026-05-04 19:47:57 +02:00
joxeankoret@yahoo.es 3ad068644b Fixes to the current beta
ML: The current local model causes false positives with small functions, and functions with a huge difference in basic blocks. Diaphora will ignore such matches.
CORE: Increase the added similarity score in `deep_ratio` when constants (like strings or cryptographic constants) match.
HEUR: Remove the unreliable flag from heuristics "Pseudo-code fuzzy AST hash" and "Loop Count".
VULN: Do not use difflib.unified_diff as it's terribly slow; instead use difflib.ndiff.
2024-02-23 10:59:04 +01:00
joxeankoret@yahoo.es 477dd87afa Multiple bug fixes and little improvements
CORE: Try to use `cdifflib` instead of Python's standard `difflib` when possible to get some performance gains.
BUG: High addresses in operands could cause the Python's sqlite3 module to crash when inserting into the database.
ML: Try to use the Ridge classifier as just another method to get a similarity ratio in `check_ratio`.
ML: Simplifications of the supervised learning based experimental engine.
CONFIG: Added parameter `COMMIT_AFTER_EACH_GUI_UPDATE` to force committing.
CONFIG: Added parameter `EXPORTING_COMPILATION_UNITS` to enable/disable exporting them (with some huge databases it might take even hours!).
CONFIG: Added parameters handling SQLite pragmas `SQLITE_JOURNAL_MODE` and `SQLITE_PRAGMA_SYNCHRONOUS`.
CONFIG: Added parameter `SHOW_IMPORT_WARNINGS` to enable/disable showing warnings when some important but optional Python packages aren't found.
BUG: Be sure to delete orphaned comments when importing pseudo-code comments.
BUG: The workaround for "max non-trivial tinfo_t count has been reached" was wrong. Now, the Hex-Rays functions cache is cleared every 10,000 rows.
GUI: Display the progress when exporting a large number of compilation units.
BUG: Inserting the link between functions and compilation units was terribly-utterly-horribly wrong.
VULN: Add pattern "UNC" to potentially detect vulnerabilities fixed in Windows components involving UNC paths.
EXTRAS: Added independent IDA plugin `extras/diaphora_local.py` to be able to diff functions inside the current binary.
BUG: Do a commit after all functions are exported so, in case IDA crashes for a reason/bug, Diaphora can properly recover from errors and have all the functions already exported there.
2024-02-22 18:15:09 +01:00
joxeankoret@yahoo.es 08a62e0723 First working milestone of the (local) machine learning engine
CORE: Train a Ridge classifier using known good and bad results after `find_partial_matches()` in order to try to better determine what looks like a good match and what does not.
MISC: Increase version number to 3.2.0.

The ML approach that is being tested in this version works as follows:

 * Diaphora uses the usual approaches to find matches labelled as "Best" or "Partial".
 * After `find_partial_matches()` is executed, it then generates a dataset to train the classifier.
 * The dataset is generated by iterating through all the best and partial results previously found.
 * Good results are labelled as "0", bad results are labelled as "0".
 * The dataset generated contains a comparison of almost each field extracted by Diaphora.
 * For integer columns, it calculates a ratio by doing `1 - ( abs(num1 - num2) / max(num1, num2) )`.
 * For text columns, it uses `SequenceMatcher().quick_ratio()`.
 * For lists of items, it tries to calculate a similarity ratio like this:
```
  inter = len(s1.intersection(s2))
  maxs  = len(max(s1, s2))
  val = 1. - (inter / maxs)
```
 * After the dataset is generated and the model fitted, the classifier is ready to be used.
 * Then, for any future function match `deep_ratio()` will add a value to the final similarity ratio if the classifier thinks it found a good match.
 * This added value is specified in `diaphora_config.py`, the directive is `ML_DEEP_RATIO_ADDED_SCORE`.

Also, I have done various little refactorizations here and there mostly to try to use the same variable/field names everywhere, instead of different names on different parts of the code.
2024-02-01 12:23:54 +01:00
joxeankoret@yahoo.es 63c90def0e Fixed a bug hiding differences and added a new "vuln pattern"
BUG: When checking if functions are 100% equals check more fields than just the id, address, mangled_function and nodes.
VULN: Mark as interesting differences with the functions `ProbeForRead` and `ProbeForWrite`.
2023-12-14 11:05:12 +01:00
joxeankoret@yahoo.es c69f392249 Multiple bug fixes, new and experimental heuristics
EXPORT: Added a column to save how long it took to export a single function.
EXPORT: Use `cur.executemany()` instead of `cur.execute()` whenever it's possible.
DIFF: Added a ratios cache to speed up comparison operations.
HEUR: Added heuristic "Same constants related matches" to find functions using the same constants in different places.
HEUR: Added heuristic "Related compilation unit" to find functions by matching potential compilation units.
HEUR: Added absolutely experimental (and subject to be removed) heuristic "Similar export time".
BUG: The microcode instructions list was built a lot of times instead of being done only once.
GUI: Added menu item "Show assembly patch".
BUG: Diaphora was calling ida_lines.get_srcline() for every assembly line. Fixed by doing it once per basic block.
BUG: The code for calculating the primes assigned to a compilation unit was terribly slow.
MISC: Replace multiple "SELECT *" appearances with just the required fields, where appropriate.
VULN: Added a few new patterns to try to find potentially fixed vulnerabilities.
VULN: Added heuristic to try to find fixed signedness issues for x86 and ARM.
MISC: Refactored the code for finding potentially fixed vulnerabilities.
2023-10-21 12:27:36 +02:00
joxeankoret@yahoo.es 706308bce5 Fix for issues #266, #267 and #268
GUI: BUG: The main UI dialog might not be 100% visible with some screen resolutions.
GUI: BUG: Adding manual matches was partially wrong.
GUI: BUG: After closing the "Interesting matches" tab there was no way to reshow it again (like F3 does).
2023-09-01 10:58:03 +02:00
joxeankoret@yahoo.es 62357ad710 Do not crash when there is no pseudo-code available
BUG: Do not crash in patch diffing sessions if there is no pseudo-code available.
2023-08-03 12:18:09 +02:00
joxeankoret@yahoo.es 183e2dce84 So many refactorizations and cleanups I cannot even list all of them 2023-06-11 13:32:01 +02:00
joxeankoret@yahoo.es a2e17b9b4d Moved the logic to load scripts
Moved `load_hooks` from diaphora_ida.py to diaphora.py.
2023-05-06 18:01:53 +02:00
joxeankoret@yahoo.es 07efccce79 Run a specific script by default to search vulnerabilities for patch diffing sessions with function names
CORE: By default, run a helper script that tries to find potentially fixed vulnerabilities when a patch diffing session with function names is detected.
2023-05-05 17:28:55 +02:00