The related scripts are in the folder dataset_generation.
- Start by specifying the
output_dirindecomp_for_unstripped.pyanddecomp_for_stripped.pyto define where the results will be saved. - Use
parallel_decomp.pyto decompile your binaries.- Use the
-uoption for unstripped binaries - Use the
-soption for stripped binaries.
- Use the
The related scripts are in the folder deduplication.
For generating a dataset (-d), we need combine the stripped functions with unstripped functions using DWARF.
For prediction of stripped binary (-p), it only needs to output the test set file containing all masked functions.
For generating a dataset:
python deduplication/process_decompiled_data.py -d \
--unstripped_path YOUR_UNSTRIPPED_DECOMP_DATA_PATH \
--stripped_path YOUR_STRIPPED_DECOMP_DATA_PATH \
--output_dir YOUR_OUTPUT_DIRFor prediction of stripped binary:
python deduplication/process_decompiled_data.py -p \
--stripped_path YOUR_STRIPPED_DECOMP_DATA_PATH \
--output_dir YOUR_OUTPUT_DIRUse divide_dataset.py to split the processed data into training, test, and validation sets. Duplicate entries are removed from the dataset based on the function name and function body. For more details, please refer to our paper.
python deduplication/divide_dataset.py \
--input_dir YOUR_PROCESSED_DECOMP_DIR \
--output_dir YOUR_OUTPUT_DIR \
--arch YOUR_BINARY_ARCH \
--opt YOUR_BINARY_OPTUse rand_replace.py to conduct self-transformation process. The default directory of dataset is dataset/ARCH/OPT.
python replace/rand_replace.py \
--arch YOUR_BINARY_ARCH \
--opt YOUR_BINARY_OPTThis step is implemented based on alpaca-lora.
We use the Code Llama prompt format (see templates/codellama.json).
The related scripts are in the folder scripts/.
To fine-tune the vLLM model using your decompiled training set, use the following command:
CUDA_VISIBLE_DEVICES=0 python script/finetune_codellama_var_dora.py \
--arch YOUR_BINARY_ARCH \
--opt YOUR_BINARY_OPTTo fine-tune the vLLM model using your decompiled training set, use the following command:
CUDA_VISIBLE_DEVICES=0 python script/finetune_codellama_dora.py \
--arch YOUR_BINARY_ARCH \
--opt YOUR_BINARY_OPTTo generate predictions using a fine-tuned vLLM model, execute the following command:
CUDA_VISIBLE_DEVICES=0 python script/codellama_script_var_single.py \
--arch YOUR_BINARY_ARCH \
--opt YOUR_BINARY_OPTTo replace the output of vLLM, execute the following command:
CUDA_VISIBLE_DEVICES=0 python script/var_replace/replace.py \
--arch YOUR_BINARY_ARCH \
--opt YOUR_BINARY_OPTTo generate predictions using a fine-tuned fLLM model, execute the following command:
CUDA_VISIBLE_DEVICES=0 python script/codellama_script_dora_single.py \
--arch YOUR_BINARY_ARCH \
--opt YOUR_BINARY_OPTThe related scripts are in the folder script/evaluation.
-
Extract the function name from the results and divide them into tokens:
python evaluation/divide_function_name.py \ --input_file YOUR_PRED_RESULTS_FILE \ --output_dir YOUR_OUTPUT_DIR -
To calculate the precision, recall and F1 score, use the following command:
python evaluation/calculate_score.py \ --input_file YOUR_PROCESSED_RESULTS_FILE
This project is licensed under the Apache License 2.0 (See LICENSE).
This project includes other components distributed under the Apache License 2.0:
- alpaca-lora (See scripts/model_training/LICENSE)