In this study, we present a tool for the recognition of C++ objects in optimized binaries, where essential information like symbols and function calls is often missing. Existing approaches for recognizing C++ objects have limitations, as they rely on brittle information, do not effectively handle optimized binaries, or focus on specific classes and platforms. To address this, we propose a hybrid approach composed of a stack access model and two heuristics to recognize objects allocated on the stack. The first heuristic employs the stack access model and leverages robust objects' features to infer the type and location of objects on the stack. In this way, it generates a set of candidate objects for which we build a track that identifies their usage and lifecycle within the binary. The second heuristic improves the accuracy of the object recognition process by detecting inline methods, associated with the candidate objects, through the analysis of the memory access offsets found in the tracks. Our tool builds upon a two-phase system consisting of fingerprint generation and fingerprint matching. First, it automatically generates and analyzes appropriate binaries to extract relevant features of objects and methods and stores them in fingerprints. Then it utilizes the heuristics, along with the stored fingerprints, to recognize objects in a target binary. We evaluate our tool on a dataset of 497 GitHub C++ projects compiled with different optimization levels. We achieve promising results, although further work is required to improve the precision, especially for simple classes. We successfully recognize objects of the std::string class, with an F1-score of 62% with -O2 optimization level, which remains similar in -O3 and slightly lower in -Os. For the std::thread class, the F1-score reaches 76% in -O2, with small fluctuations in -O3 and -Os. However, for the std::vector class, the F1-score drops to 30% in -O2, showing similar results in -O3 and slightly higher results in -Os.
In questo studio presentiamo uno strumento per il riconoscimento degli oggetti C++ nei binari ottimizzati, dove spesso mancano informazioni essenziali come simboli e chiamate di funzione. Gli approcci esistenti per il riconoscimento degli oggetti C++ hanno delle limitazioni, in quanto si basano su informazioni fragili, non gestiscono efficacemente i binari ottimizzati o si concentrano su classi e piattaforme specifiche. Per risolvere questo problema, proponiamo un approccio ibrido composto da un modello di accesso allo stack e da due euristiche per riconoscere gli oggetti allocati sullo stack. La prima euristica utilizza il modello di memoria personalizzato e sfrutta le caratteristiche robuste degli oggetti per dedurre il tipo e la posizione degli oggetti sullo stack. In questo modo, genera un insieme di oggetti candidati, per i quali costruiamo una traccia che identifica il loro utilizzo e il loro ciclo di vita all'interno del binario. La seconda euristica migliora l'accuratezza del processo di riconoscimento degli oggetti rilevando i metodi inline, associati agli oggetti candidati, mediante l'analisi degli offset di accessi in memoria trovati nelle tracce. Il nostro strumento si basa su un sistema a due fasi composto dalla generazione di impronte digitali e dalla loro corrispondenza. In primo luogo, genera e analizza automaticamente binari appropriati per estrarre le caratteristiche rilevanti di oggetti e metodi e memorizzarle nelle impronte digitali. Successivamente, utilizza le euristiche insieme alle impronte digitali memorizzate per riconoscere gli oggetti in un determinato binario. Valutiamo il nostro strumento su un set di dati composto da 497 progetti C++ di GitHub compilati con diversi livelli di ottimizzazione. Otteniamo risultati promettenti, sebbene siano necessari ulteriori lavori per migliorare la precisione, soprattutto per le classi semplici. Riconosciamo con successo gli oggetti della classe std::string, con un'F1-score del 62% con il livello di ottimizzazione -O2, che è rimasta simile in -O3 e leggermente inferiore in -Os. Per la classe std::thread, l'F1-score raggiunge il 76% in -O2, con piccole fluttuazioni in -O3 e -Os. Tuttavia, per la classe std::vector, l'F1-score scende al 30% in -O2, con risultati simili in -O3 e leggermente superiori in -Os.
A hybrid approach for automatic recognition of C++ objects in optimized binaries
Negrini, Samuele
2022/2023
Abstract
In this study, we present a tool for the recognition of C++ objects in optimized binaries, where essential information like symbols and function calls is often missing. Existing approaches for recognizing C++ objects have limitations, as they rely on brittle information, do not effectively handle optimized binaries, or focus on specific classes and platforms. To address this, we propose a hybrid approach composed of a stack access model and two heuristics to recognize objects allocated on the stack. The first heuristic employs the stack access model and leverages robust objects' features to infer the type and location of objects on the stack. In this way, it generates a set of candidate objects for which we build a track that identifies their usage and lifecycle within the binary. The second heuristic improves the accuracy of the object recognition process by detecting inline methods, associated with the candidate objects, through the analysis of the memory access offsets found in the tracks. Our tool builds upon a two-phase system consisting of fingerprint generation and fingerprint matching. First, it automatically generates and analyzes appropriate binaries to extract relevant features of objects and methods and stores them in fingerprints. Then it utilizes the heuristics, along with the stored fingerprints, to recognize objects in a target binary. We evaluate our tool on a dataset of 497 GitHub C++ projects compiled with different optimization levels. We achieve promising results, although further work is required to improve the precision, especially for simple classes. We successfully recognize objects of the std::string class, with an F1-score of 62% with -O2 optimization level, which remains similar in -O3 and slightly lower in -Os. For the std::thread class, the F1-score reaches 76% in -O2, with small fluctuations in -O3 and -Os. However, for the std::vector class, the F1-score drops to 30% in -O2, showing similar results in -O3 and slightly higher results in -Os.File | Dimensione | Formato | |
---|---|---|---|
2023_07_Negrini_Thesis_01.pdf
Open Access dal 23/06/2024
Descrizione: Thesis
Dimensione
707.32 kB
Formato
Adobe PDF
|
707.32 kB | Adobe PDF | Visualizza/Apri |
2023_07_Negrini_Executive_Summary_02.pdf
Open Access dal 23/06/2024
Descrizione: Executive Summary
Dimensione
514.89 kB
Formato
Adobe PDF
|
514.89 kB | Adobe PDF | Visualizza/Apri |
I documenti in POLITesi sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.
https://hdl.handle.net/10589/212347