Overview
This repository contains a dataset designed for binary code similarity detection, focusing on the semantic alignment between assembly instructions and programming language code snippets. The dataset is created to facilitate the training and evaluation of models in tasks related to binary function similarity detection, code reuse analysis, and software security.
Dataset Description
The dataset consists of pairs of assembly instructions and corresponding programming language code snippets extracted from various open-source projects. It is curated to ensure high-quality, semantically aligned pairs that can be used for supervised and unsupervised learning tasks.
Usage
Requirements
- Python 3
Generating Dataset
Use genDataset.py
to process the .txt
files in OriAsmFile.zip
.
Loading the Dataset
- The dataset data structure is defined as:
{'Function':"",'Code':[{'PLcode':"",'ASMcode':""}]}
import json
jsondir = './CMRL-paper/json-TestData.txt'
with open(jsondir, 'r+') as f:
data = json.loads(f.read())
for func in data:
for pair in func['Code']:
print(pair['PLcode'],pair['ASMcode'])
print('===============================')
[{
"Function": "<alpn2alpnid>",
"Code": [{
"PLcode": "{\n",
"ASMcode": "\tpush rbx\n\tmov rbx,rdi\n"
}, {
"PLcode": " if(strcasecompare(name, "h1"))\n",
"ASMcode": "\tcall fb40 <curl_strequal@plt>\n\ttest eax,eax\n\tjne fdf4 <alpn2alpnid+0x41>\n"
}, {
"PLcode": " if(strcasecompare(name, "h2"))\n",
"ASMcode": "\tmov rdi,rbx\n\tcall fb40 <curl_strequal@plt>\n\ttest eax,eax\n\tjne fdfb <alpn2alpnid+0x48>\n"
}, {
"PLcode": " if(strcasecompare(name, H3VERSION))\n",
"ASMcode": "\tmov rdi,rbx\n\tcall fb40 <curl_strequal@plt>\n\ttest eax,eax\n\tje fdf9 <alpn2alpnid+0x46>\n"
}, {
"PLcode": " return ALPN_h3;\n",
"ASMcode": "\tmov eax,0x20\n\tjmp fdf9 <alpn2alpnid+0x46>\n"
}, {
"PLcode": " return ALPN_h1;\n",
"ASMcode": "\tmov eax,0x8\n"
}, {
"PLcode": "}\n",
"ASMcode": "\tpop rbx\n\tret \n"
}, {
"PLcode": " return ALPN_h2;\n",
"ASMcode": "\tmov eax,0x10\n\tjmp fdf9 <alpn2alpnid+0x46>\n"
}, {
"PLcode": "",
"ASMcode": ""
}]
}, {
"Function": "<altsvc_createid>",
"Code": [{
..................................
- Load all datasets
import os
import json
jsondir = '/home/lucky/experiments/dataset/jsonDataSet/'
jsonfile = os.listdir(jsondir)
for file in jsonfile:
pairnum = 0
with open(jsondir+file,'r+') as f:
data = f.read()
data = json.loads(data)
for func in data:
pairnum += len(func['Code'])
print(file,' func_num: ',len(data)," pair_num: ",pairnum)
output:
json-newopensslasm.txt func_num: 15669 pair_num: 242968
json-newffmpegasm.txt func_num: 28560 pair_num: 750129
json-newcoreutilsasm.txt func_num: 20043 pair_num: 263348
json-testasm.txt func_num: 2 pair_num: 35
json-newcurlasm.txt func_num: 1887 pair_num: 41551
Contact
No contact information is available yet.