SDK REFERENCE

binaryai.client module

class binaryai.client.Client(token, url, timeout=1000)

Bases: object

BinaryAI api client

token

token used for query

Type

string

url

BinaryAI api endpoint url

Type

string

timeout

seconds of timeout, default is 1000

Type

int

execute(query, var, throw_duplicate_error=False)

Send request to API server and get response

Parameters
  • query (string) – graphql query

  • var (dict) – variables to send

Returns

response data of this request

Return type

dict

binaryai.function module

binaryai.function.clear_retrieve_list(client)

Clear all things in your retrieve list

Returns

None

binaryai.function.create_function_set(client, name, description='', function_ids=None, throw_duplicate_error=True)

Create a new function set and add functions if needed

Parameters
  • client (binaryai.client.Client) – Client instance

  • name (string) – Name of the new functionset

  • description (string) – Description of the new functionset. Can be empty string

  • function_ids (list) – Functions to be inserted into the new function set. Can be None if there are no functions to be added into the set.

Returns

  • id (string) – id of the function set

binaryai.function.insert_retrieve_list(client, function_ids=None, functionset_ids=None)

Insert functions into your retrieve list

Parameters
  • client (binaryai.client.Client) – Client instance

  • function_ids (list) – Functions to be inserted into the index list. Can be None if there are no functions to be added into the set.

  • functionset_ids (list) – Functionsets to be inserted into the index list. Can be None if there are no functions to be added into the set.

Returns

None

binaryai.function.query_created_function_set(client)

Get all function sets created by current user

Returns

  • functionSetIDs (list) – functionSet’s id

binaryai.function.query_function(client, function_id)

get function information by id

Parameters
Returns

  • function (dict) – Function’s information

binaryai.function.query_function_set(client, funcset_id)

get function set information by id

Parameters
Returns

  • functionSet (dict) – functionSet’s information

binaryai.function.query_retrieve_list_count(client)

query function count in the retrieve list

Parameters

client (binaryai.client.Client) – Client instance

Returns

  • total_count (int) – the total count of items in the retrieve list.

binaryai.function.saveto_function_set_members(client, setid, function_ids)

Save a function to the function set

Parameters
  • client (binaryai.client.Client) – Client instance

  • setid (string) – ID of the target

  • function_ids (list) – Functions to be inserted into the new function set. Can be None if there are no functions to be added into the set.

Returns

  • id (string) – id of the function set

binaryai.function.search_sim_funcs(client, function_id=None, feature=None, topk=1)

search top similar functions of the function in your retrieve list

Parameters
  • client (binaryai.client.Client) – Client instance

  • function_id (string) – id of the function

  • topk (int) – return first topk results, default value is 1.

Returns

list of the top similarity functions

Return type

  • similarity (list)

binaryai.function.upload_function(client, name, feature, source_code=None, source_file=None, source_line=None, binary_file=None, binary_sha256=None, fileoffset=None, _bytes=None, platform=None, throw_duplicate_error=False, pseudo_code=None, package_name=None)

upload function to BinaryAI server

Parameters
  • client (binaryai.client.Client) – Client instance

  • name (string) – name of the function

  • feature (string) – Feature of the function. Genertaed by feature extraction library. Encoding in base64.

  • source_code (string) – Source code of the function

  • source_file (string) – Source file of the function

  • source_line (int) – line number of the function

  • binary_file (string) – Name of the binary file which contains this function

  • binary_sha256 (string) – Hash (sha256) of the binary file

  • fileoffset (int) – File offset of the function

  • _bytes (string) – Binary data of the function

  • platform (string) – Platform of the binary file, for example, metapc64, or x86_64, or mipsel

  • throw_duplicate_error (bool) – If a duplicate error should be raised when two name equals

  • pseudo_code (string) – Pseudo code of the function

  • package_name (string) – Package name containing this function

Returns

  • id (string) – id of this function

binaryai.ida module