Last active
February 20, 2016 19:51
-
-
Save andrewaeva/2263542da1ca3f705b8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*-coding:utf-8-*- | |
import json | |
import pandas as pd | |
import r2pipe as r2 | |
dataframe = pd.DataFrame(columns=['name_function', 'opcodes']) | |
r2p = r2.open('example') | |
r2p.cmd('aaa') | |
afl = json.loads(r2p.cmd('aflj')) | |
functionNamesArray = [] | |
opcodesArray = [] | |
for i in xrange(len(afl)): | |
functionNamesArray.append(str(afl[i]['name'])) | |
opcodes = "" | |
for offset in json.loads(r2p.cmd('pdj @' + str(afl[i]['name']))): | |
try: | |
opcodes += offset['opcode'] + ':' | |
except KeyError: | |
pass | |
opcodesArray.append(opcodes) | |
dataframe = pd.DataFrame({'name_function': functionNamesArray, | |
'opcodes': opcodesArray}) | |
dataframe.to_csv('dataset.csv') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment