binaryai / sdk

Get results of binaryai.cn using our SDK
https://www.binaryai.cn/doc/
GNU General Public License v3.0
491 stars 75 forks source link

using ida_plugin retrieve _functions meet a error #115

Closed island255 closed 3 years ago

island255 commented 3 years ago

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?

davendu commented 3 years ago

@island255 Backend service configuration was not correctly configured during last refactor. Sorry for inconvenience. It should have been fixed now.

It should work now. BTW, I noticed you might using the latest version (from master, or v0.3.0-rcx). API and internal implementation of this version is significantly different from other versions, so be careful, and they might be adjusted at any time.

Feel free to reopen this issue if 502 happens again ;)

island255 commented 3 years ago

Thanks for your help. But I have tried again and met the same error. Reinstalling and installing with version v0.2.8 still cannot solve this problem.

island255 commented 3 years ago

@island255 Backend service configuration was not correctly configured during last refactor. Sorry for inconvenience. It should have been fixed now.

It should work now. BTW, I noticed you might using the latest version (from master, or v0.3.0-rcx). API and internal implementation of this version is significantly different from other versions, so be careful, and they might be adjusted at any time.

Feel free to reopen this issue if 502 happens again ;)

And it seems that I cannot reopen this issue actually. I can only create a new issue.

davendu commented 3 years ago

@island255 Looks like some regional issues. I re-applied configurations. Did it work?

island255 commented 3 years ago

It seems not to work on my computer. When I run the plugin, it will cost a lot of time until the error occurred. I will try it on another computer later to see whether it can work.

island255 commented 3 years ago

Maybe I have to mention that I first run this plugin and meet an error saying "ValueError: check_hostname requires server_hostname". To make it run, I reinstall urllib3 with version 1.25.11. I don't if this will affect the process.

davendu commented 3 years ago

Could you please share the endpoint you are accessing? Steps to get this config:

  1. Run this in your IDA console to get path of your configuration file: os.path.join(idaapi.get_user_idadir(), idaapi.CFG_SUBDIR)
  2. Open the config file, and find a line containing 'url'. This is the endpoint you are using.

Make sure NOT submitting your token! Just show me the url field and let me see which endpoint you are using.

island255 commented 3 years ago

Could you please share the endpoint you are accessing? Steps to get this config:

  1. Run this in your IDA console to get path of your configuration file: os.path.join(idaapi.get_user_idadir(), idaapi.CFG_SUBDIR)
  2. Open the config file, and find a line containing 'url'. This is the endpoint you are using.

Make sure NOT submitting your token! Just show me the url field and let me see which endpoint you are using.

https://api.binaryai.tencent.com/v1/endpoint

davendu commented 3 years ago

@island255 That's strange...Could you please open your browser and access this address? Without any additional settings, the correct response would be this. image

island255 commented 3 years ago

@island255 That's strange...Could you please open your browser and access this address? Without any additional settings, the correct response would be this. image

The response is the same on my computer ...

island255 commented 3 years ago

I don't know if this problem is specific to my computer. I will try on another computer and ask my friend to try it too. If there are new findings, I will present them.

davendu commented 3 years ago

@island255 I might found out the reason. Seems our GPU server is hanging, and not accepting new requests. I have send the restart request, and once it was finished I will notify you.

davendu commented 3 years ago

@island255 Server restart complete. Tell me if it works now ;)

And we are requesting new servers but the estimated time is not known yet...so feel free to ping me if 502 happens again. I also set up the monitor system so it would alert me if the server hangs again.

island255 commented 3 years ago

@davendu Thank you very much for your help. I can successfully run it now. :)