Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Overview
|
2 |
+
|
3 |
+
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.
|
4 |
+
|
5 |
+
## Dataset Description
|
6 |
+
|
7 |
+
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.
|
8 |
+
|
9 |
+
## Usage
|
10 |
+
|
11 |
+
### Requirements
|
12 |
+
|
13 |
+
- Python 3
|
14 |
+
|
15 |
+
### Generating Dataset
|
16 |
+
|
17 |
+
Use `genDataset.py` to process the `.txt` files in `OriAsmFile.zip`.
|
18 |
+
|
19 |
+
### Loading the Dataset
|
20 |
+
|
21 |
+
- The dataset data structure is defined as:`{'Function':"",'Code':[{'PLcode':"",'ASMcode':""}]}`
|
22 |
+
|
23 |
+
~~~python
|
24 |
+
import json
|
25 |
+
jsondir = './CMRL-paper/json-TestData.txt'
|
26 |
+
with open(jsondir, 'r+') as f:
|
27 |
+
data = json.loads(f.read())
|
28 |
+
for func in data:
|
29 |
+
for pair in func['Code']:
|
30 |
+
print(pair['PLcode'],pair['ASMcode'])
|
31 |
+
print('===============================')
|
32 |
+
~~~
|
33 |
+
|
34 |
+
~~~
|
35 |
+
[{
|
36 |
+
"Function": "<alpn2alpnid>",
|
37 |
+
"Code": [{
|
38 |
+
"PLcode": "{\n",
|
39 |
+
"ASMcode": "\tpush rbx\n\tmov rbx,rdi\n"
|
40 |
+
}, {
|
41 |
+
"PLcode": " if(strcasecompare(name, "h1"))\n",
|
42 |
+
"ASMcode": "\tcall fb40 <curl_strequal@plt>\n\ttest eax,eax\n\tjne fdf4 <alpn2alpnid+0x41>\n"
|
43 |
+
}, {
|
44 |
+
"PLcode": " if(strcasecompare(name, "h2"))\n",
|
45 |
+
"ASMcode": "\tmov rdi,rbx\n\tcall fb40 <curl_strequal@plt>\n\ttest eax,eax\n\tjne fdfb <alpn2alpnid+0x48>\n"
|
46 |
+
}, {
|
47 |
+
"PLcode": " if(strcasecompare(name, H3VERSION))\n",
|
48 |
+
"ASMcode": "\tmov rdi,rbx\n\tcall fb40 <curl_strequal@plt>\n\ttest eax,eax\n\tje fdf9 <alpn2alpnid+0x46>\n"
|
49 |
+
}, {
|
50 |
+
"PLcode": " return ALPN_h3;\n",
|
51 |
+
"ASMcode": "\tmov eax,0x20\n\tjmp fdf9 <alpn2alpnid+0x46>\n"
|
52 |
+
}, {
|
53 |
+
"PLcode": " return ALPN_h1;\n",
|
54 |
+
"ASMcode": "\tmov eax,0x8\n"
|
55 |
+
}, {
|
56 |
+
"PLcode": "}\n",
|
57 |
+
"ASMcode": "\tpop rbx\n\tret \n"
|
58 |
+
}, {
|
59 |
+
"PLcode": " return ALPN_h2;\n",
|
60 |
+
"ASMcode": "\tmov eax,0x10\n\tjmp fdf9 <alpn2alpnid+0x46>\n"
|
61 |
+
}, {
|
62 |
+
"PLcode": "",
|
63 |
+
"ASMcode": ""
|
64 |
+
}]
|
65 |
+
}, {
|
66 |
+
"Function": "<altsvc_createid>",
|
67 |
+
"Code": [{
|
68 |
+
..................................
|
69 |
+
~~~
|
70 |
+
|
71 |
+
- Load all datasets
|
72 |
+
|
73 |
+
~~~python
|
74 |
+
import os
|
75 |
+
import json
|
76 |
+
jsondir = '/home/lucky/experiments/dataset/jsonDataSet/'
|
77 |
+
jsonfile = os.listdir(jsondir)
|
78 |
+
for file in jsonfile:
|
79 |
+
pairnum = 0
|
80 |
+
with open(jsondir+file,'r+') as f:
|
81 |
+
data = f.read()
|
82 |
+
data = json.loads(data)
|
83 |
+
for func in data:
|
84 |
+
pairnum += len(func['Code'])
|
85 |
+
print(file,' func_num: ',len(data)," pair_num: ",pairnum)
|
86 |
+
~~~
|
87 |
+
|
88 |
+
~~~
|
89 |
+
output:
|
90 |
+
json-newopensslasm.txt func_num: 15669 pair_num: 242968
|
91 |
+
json-newffmpegasm.txt func_num: 28560 pair_num: 750129
|
92 |
+
json-newcoreutilsasm.txt func_num: 20043 pair_num: 263348
|
93 |
+
json-testasm.txt func_num: 2 pair_num: 35
|
94 |
+
json-newcurlasm.txt func_num: 1887 pair_num: 41551
|
95 |
+
~~~
|
96 |
+
|
97 |
+
## Contact
|
98 |
+
|
99 |
+
No contact information is available yet.
|