doomedraven / VirusTotalApi

VirusTotal Full api
MIT License
294 stars 85 forks source link

Unable to scan / upload #10

Closed rmenessec closed 8 years ago

rmenessec commented 8 years ago

Unfortunately, I can't provide a sample of the file that's failing. I can only provide Python output. Test environment is Ubuntu 16.04.

On one machine, output is:

Calculating hash for: ab.zip
Traceback (most recent call last):
  File "/usr/local/bin/vt", line 9, in <module>
    load_entry_point('vt==2.2.3', 'console_scripts', 'vt')()
  File "/usr/local/lib/python2.7/dist-packages/vt/vt.py", line 3038, in main
    vt.fileScan(**options)
  File "/usr/local/lib/python2.7/dist-packages/vt/vt.py", line 1626, in fileScan
    method="post"
  File "/usr/local/lib/python2.7/dist-packages/vt/vt.py", line 456, in get_response
    response = getattr(requests, method)(url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 110, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 595, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 363, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python2.7/httplib.py", line 1057, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1097, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 1053, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 897, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 873, in send
    self.sock.sendall(data)
  File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 253, in sendall
    sent = self._send_until_done(data[total_sent:total_sent + SSL_WRITE_BLOCKSIZE])
  File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 242, in _send_until_done
    return self.connection.send(data)
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 1271, in send
    self._raise_ssl_error(self._ssl, result)
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 1178, in _raise_ssl_error
    raise SysCallError(errno, errorcode.get(errno))
OpenSSL.SSL.SysCallError: (32, 'EPIPE')

On another 16.04 machine, the output is:

Calculating hash for: ab.apk

[!] Can't resolv hostname, check your internet conection

Traceback (most recent call last):
  File "/usr/local/bin/vt", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/vt/vt.py", line 3038, in main
    vt.fileScan(**options)
  File "/usr/local/lib/python2.7/dist-packages/vt/vt.py", line 1640, in fileScan
    self.simple_print(jdata, simple_list)
  File "/usr/local/lib/python2.7/dist-packages/vt/vt.py", line 82, in simple_print
    if block.get(key) and block[key]:
AttributeError: 'str' object has no attribute 'get'

Both machines are able to process other files normally.

doomedraven commented 8 years ago
  1. OpenSSL.SSL.SysCallError: (32, 'EPIPE') <- is not vt script problem, probably pyOpenssl
  2. the second one filed, as you got another error Can't resolv hostname, check your internet conection, it can't connect to vt
  3. Both machines are able to process other files normally., i think that 2 bugs just related to some network problem
rmenessec commented 8 years ago

There's no problem with my Internet connection.

I'm sorry, I should have been clearer: I have one file that is failing repeatably on every machine I have with vt installed. For some reason, it's manifesting as two different errors. The host resolution error appears to be bogus.

Can you suggest a reason that host resolution would be working normally, with no Internet connection problems at all, and vt would always fail when attempting to scan one given file?

doomedraven commented 8 years ago

nop is a very strange error, can you share file to test?

rmenessec commented 8 years ago

I can't.

I did find the reason vt was failing differently, though: on one of the test machines, the pyOpenSSL system package was being overridden by a locally installed copy. After removing it, the file is causing vt to fail with the same error in all cases, on all machines.

[!] Can't resolv hostname, check your internet conection

Traceback (most recent call last):
  File "/usr/local/bin/vt", line 9, in <module>
    load_entry_point('vt==2.2.3', 'console_scripts', 'vt')()
  File "/usr/local/lib/python2.7/dist-packages/vt/vt.py", line 3038, in main
    vt.fileScan(**options)
  File "/usr/local/lib/python2.7/dist-packages/vt/vt.py", line 1640, in fileScan
    self.simple_print(jdata, simple_list)
  File "/usr/local/lib/python2.7/dist-packages/vt/vt.py", line 82, in simple_print
    if block.get(key) and block[key]:
AttributeError: 'str' object has no attribute 'get'
doomedraven commented 8 years ago

your error

except requests.exceptions.ConnectionError:
            print '\n[!] Can\'t resolv hostname, check your internet conection\n'
            return '', ''

i will add post check to not show the AttributeError, but without sample i can't help you sorry

doomedraven commented 8 years ago

https://github.com/doomedraven/VirusTotalApi/commit/3ed9141263827881d66b7a8a37f3793e12566558 this commit wont trigger anymore AttribeError