Git Product home page Git Product logo

sdk's Introduction

BinaryAI Python SDK

PUBLISH readthedocs Downloads Gitter

BinaryAI is a binary file security analysis platform. This SDK aims at providing a simple client to upload file and get analysis result. It also works as a demo on calling BinaryAI's GraphQL API directly.

To use SDK, you need a valid credential. Read BinaryAI docs about detailed instructions.

Dependency

Python >= 3.9

Download and install

python3 -m pip install binaryai

Quick start

See the SDK document for guide.

Internals

Endpoints

The default endpoint is https://api.binaryai.cn/v1/endpoint.

API Credentials

API Credentials are used for signing requests. We suggest you using our SDK or our library to sign it, but you can also have your own implementation. We are using the signing method TC3-HMAC-SHA256, same with the Tencent Cloud. You can read their document about how to sign requests. BinaryAI would require following fields:

Region  = "ap-shanghai"
service = "binaryai"
Action  = "BinaryAI"
Version = "2023-04-15"

Additional Reading

Read the Changelog of our product, and hope you can also have fun reading papers related to our job:

  1. Yu, Zeping, et al. "Codecmr: Cross-modal retrieval for function-level binary source code matching." Advances in Neural Information Processing Systems 33 (2020): 3872-3883.
  2. Yu, Zeping, et al. "Order matters: Semantic-aware neural networks for binary code similarity detection." Proceedings of the AAAI conference on artificial intelligence. Vol. 34. No. 01. 2020.
  3. Li, Zongjie, et al. "Unleashing the power of compiler intermediate representation to enhance neural program embeddings." Proceedings of the 44th International Conference on Software Engineering. 2022.
  4. Wong, Wai Kin, et al. "Deceiving Deep Neural Networks-Based Binary Code Matching with Adversarial Programs." 2022 IEEE International Conference on Software Maintenance and Evolution (ICSME). IEEE, 2022.
  5. Wang, Huaijin, et al. "Enhancing DNN-Based Binary Code Function Search With Low-Cost Equivalence Checking." IEEE Transactions on Software Engineering 49.1 (2022): 226-250.
  6. Jia, Ang, et al. "1-to-1 or 1-to-n? Investigating the Effect of Function Inlining on Binary Similarity Analysis." ACM Transactions on Software Engineering and Methodology 32.4 (2023): 1-26.
  7. Wang, Huaijin, et al. "sem2vec: Semantics-aware Assembly Tracelet Embedding." ACM Transactions on Software Engineering and Methodology 32.4 (2023): 1-34.
  8. Jiang, Ling, et al. "Third-Party Library Dependency for Large-Scale SCA in the C/C++ Ecosystem: How Far Are We?." Proceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis. 2023.

sdk's People

Contributors

agfn avatar davendu avatar dependabot[bot] avatar dogewatch avatar marcograss avatar matthewshao avatar michellehong avatar nforest avatar uesupergate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk's Issues

烦死了

怎么不维护了,你干嘛!哎哟~

try to upload source function by "upload_fucntion"

Hi, I'm using the command-line tool of v0.2.8 and try to create a function set. I try to upload source files and source functions. But it seems that I can only upload binary functions. And when I look into function.py, the function "upload_fucntion" has some arguments about source code.
How can I use it in version 0.2.8? Or will it useable in future versions?

about adjacency matrices

The size of adjacency matrices are varient in traning phase, how did you address this problem, or any strategy?

Open Source

Hello, do you plan to open source the bert pre-training model and training code in the paper 《Order Matters: Semantic-Aware Neural
Networks for Binary Code Similarity Detection》
in the future?

using ida_plugin retrieve _functions meet a error

when I use the ida_plugin to retrieve functions, an error occurred.

401B00: restored microcode from idb
401B00: restored pseudocode from idb
Traceback (most recent call last):
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\client.py", line 77, in execute
    jdata = json.loads(response.content)
  File "json_<em>init</em><em>.py", line 357, in loads
  File "json\decoder.py", line 337, in decode
  File "json\decoder.py", line 355, in raw</em>decode
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida<em>binaryai.py", line 513, in retrieve
    targets = self.mgr.retrieve(ea, bai</em>config['topk'], funcset<em>ids)
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida</em>binaryai.py", line 243, in retrieve
    func<em>id = self.upload(ea, None)
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida</em>binaryai.py", line 257, in upload
    func<em>id = bai.function.upload</em>function(
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\function.py", line 45, in upload<em>function
    r = client.execute(q</em>create<em>function, var)
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\client.py", line 79, in execute
    raise BinaryAIException("SDK</em>ERROR", "Invalid response: {}".format(response.content))
binaryai.error.BinaryAIException: SDK<em>ERROR: Invalid response: b'<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body>\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>ias/1.3.5</em>1.17.3</center>\r\n</body>\r\n</html>\r\n'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida<em>binaryai.py", line 711, in activate
    self.callback(ctx)
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida</em>binaryai.py", line 760, in retrieve<em>callback
    self.operations.retrieve(func</em>ea, self.cview)
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida<em>binaryai.py", line 517, in retrieve
    BinaryAILog.fatal(e)
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida</em>binaryai.py", line 77, in fatal
    assert False, "[{}] {}".format(BinaryAILog.name, str(e))
AssertionError: [BinaryAI] SDK<em>ERROR: Invalid response: b'<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body>\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>ias/1.3.5</em>1.17.3</center>\r\n</body>\r\n</html>\r\n'
Traceback (most recent call last):
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\client.py", line 77, in execute
    jdata = json.loads(response.content)
  File "json_<em>init</em><em>.py", line 357, in loads
  File "json\decoder.py", line 337, in decode
  File "json\decoder.py", line 355, in raw</em>decode
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida<em>binaryai.py", line 513, in retrieve
    targets = self.mgr.retrieve(ea, bai</em>config['topk'], funcset<em>ids)
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida</em>binaryai.py", line 243, in retrieve
    func<em>id = self.upload(ea, None)
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida</em>binaryai.py", line 257, in upload
    func<em>id = bai.function.upload</em>function(
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\function.py", line 45, in upload<em>function
    r = client.execute(q</em>create<em>function, var)
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\client.py", line 79, in execute
    raise BinaryAIException("SDK</em>ERROR", "Invalid response: {}".format(response.content))
binaryai.error.BinaryAIException: SDK<em>ERROR: Invalid response: b'<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body>\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>ias/1.3.5</em>1.17.3</center>\r\n</body>\r\n</html>\r\n'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida<em>binaryai.py", line 711, in activate
    self.callback(ctx)
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida</em>binaryai.py", line 760, in retrieve<em>callback
    self.operations.retrieve(func</em>ea, self.cview)
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida<em>binaryai.py", line 517, in retrieve
    BinaryAILog.fatal(e)
  File "C:\Users\13742\AppData\Roaming\Hex-Rays\IDA Pro\python38\lib\site-packages\binaryai\ida</em>binaryai.py", line 77, in fatal
    assert False, "[{}] {}".format(BinaryAILog.name, str(e))
AssertionError: [BinaryAI] SDK<em>ERROR: Invalid response: b'<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body>\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>ias/1.3.5</em>1.17.3</center>\r\n</body>\r\n</html>\r\n'

Can you help me to fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.