xor reg1, reg1 is not always simplified to reg1 = 0

Aperta
#6,010 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
cpp

Direzione di ricerca

Start by opening the supplied xor_simple.bndb.zip and keygenme4.exe.bndb.zip databases, then inspect the LLIL, MLIL, and HLIL around address 0x416ed5. Compare the inconsistent xor self-assignment simplification with the simple case. Done means equivalent opaque-predicate branches are simplified consistently without changing program semantics.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Component: Core Core: LLIL Effort: Low Impact: Low

When we have some code like

xor edx, edx
jne 0x18
Screenshot 2024-10-19 at 12 56 30 PM

The LLIL simplifies the xor instruction to edx = 0, and the jne instruction is treated as opaque predicate and removed in higher level of ILs.

LLIL:

Screenshot 2024-10-19 at 12 57 55 PM

MLIL:

Screenshot 2024-10-19 at 12 58 06 PM

HLIL:

Screenshot 2024-10-19 at 12 58 33 PM

This works perfectly for the above example, however, I noticed that it does not work all of the time. See below for an example:

Screenshot 2024-10-19 at 12 59 41 PM

This is an opaque predicate as well and the left branch is fake. The code always executes the right branch.

LLIL:

Screenshot 2024-10-19 at 1 00 37 PM

MLIL:

Screenshot 2024-10-19 at 1 01 03 PM

HLIL:

Screenshot 2024-10-19 at 1 01 35 PM

While the semantics of the code is still correct and we can see it is still an opaque predicate, we should be able to simplify it automatically.

Database:

Offending binary:

keygenme4.exe.bndb.zip

Address: 0x416ed5

Simple case:
xor_simple.bndb.zip

Lingua principale
C++
Stelle
1.3k
Fork
298
Merge medio
5g 5h
PR unite (30g)
19

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Vector35/binaryninja-api

Tutte le issue di Vector35/binaryninja-api

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.