pombreda / androguard

Automatically exported from code.google.com/p/androguard
Apache License 2.0
0 stars 0 forks source link

TypeError: CkCert_LoadFromBinary() takes exactly 2 arguments (3 given) #120

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

1. Added androguard and chilkat to pythonpath (tried both in winodws and linux, 
same outcome)

2. Created a new phyton script (these are the relevant lines):
from androguard.core.bytecodes import apk
a = apk.APK(apkfilename)
status, cert = a.get_certificate("META-INF/CERT.RSA")

Got the following error:
Traceback (most recent call last):
  File "C:\Users\retracted\workspace\androguard\test.py", line 53, in <module>
    status, cert = a.get_certificate("META-INF/CERT.RSA")
  File "C:\androguard-1.9\androguard\core\bytecodes\apk.py", line 542, in get_certificate
    success = cert.LoadFromBinary(f, len(f))
  File "C:\Python27\lib\site-packages\chilkat.py", line 1928, in LoadFromBinary
    def LoadFromBinary(self, *args): return _chilkat.CkCert_LoadFromBinary(self, *args)
TypeError: CkCert_LoadFromBinary() takes exactly 2 arguments (3 given)

This is Python 2.7 on Winodws 7.

I don't know much about Python but the error seems to be with the apk.py since 
it gives the wrong amount of arguments, correct?

Original issue reported on code.google.com by kabb...@web.de on 6 Jun 2013 at 4:23

GoogleCodeExporter commented 9 years ago
I found the problem: in Androguard 1.9, CkCert.LoadFromBinary() is called, but 
LoadFromBinary2() is the correct method. This seems to be fixed in the 
repository already.

Original comment by kabb...@googlemail.com on 22 Jun 2013 at 11:09

GoogleCodeExporter commented 9 years ago
I cloned the latest repository and the LoadFromBinary2() is used, but another 
TypeError occured:

TypeError                                 Traceback (most recent call last)
/usr/lib/python2.7/site-packages/androguard-1.5-py2.7.egg/EGG-INFO/scripts/andro
lyze.py in <module>()
----> 1 a.get_certificate('META-INF/CERT.RSA')

/usr/lib/python2.7/site-packages/androguard-1.5-py2.7.egg/androguard/core/byteco
des/apk.pyc in get_certificate(self, filename)
    563         cert = chilkat.CkCert()
    564         f = self.get_file(filename)
--> 565         success = cert.LoadFromBinary2(f, len(f))
    566 
    567         return success, cert

/usr/lib/python2.7/site-packages/chilkat.py in LoadFromBinary2(self, *args)
   1972     def LoadFromBase64(self, *args): return _chilkat.CkCert_LoadFromBase64(self, *args)
   1973     def LoadFromBinary(self, *args): return _chilkat.CkCert_LoadFromBinary(self, *args)
-> 1974     def LoadFromBinary2(self, *args): return 
_chilkat.CkCert_LoadFromBinary2(self, *args)
   1975     def LoadFromFile(self, *args): return _chilkat.CkCert_LoadFromFile(self, *args)
   1976     def LoadPfxData(self, *args): return _chilkat.CkCert_LoadPfxData(self, *args)

TypeError: in method 'CkCert_LoadFromBinary2', argument 2 of type 'unsigned 
char const *'

Original comment by shangu...@gmail.com on 28 Jan 2014 at 11:42

GoogleCodeExporter commented 9 years ago
I got the same error as #2

Original comment by shaoy...@gmail.com on 5 Feb 2014 at 9:01

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I think we can fix the problem as following : 

    def get_certificate(self, filename):
 558         """
 559             Return a certificate object by giving the name in the apk file
 560         """
 561         import chilkat
 562 
 563         cert = chilkat.CkCert()
 564         f = self.get_file(filename)
 565         data = chilkat.CkByteData()
 566         data.append2(f, len(f))
 567         success = cert.LoadFromBinary(data)
 568 
 569         return success, cert

Original comment by shangu...@gmail.com on 10 Feb 2014 at 7:34

GoogleCodeExporter commented 9 years ago
It works! Thanks!

Original comment by miles.li...@gmail.com on 11 Feb 2014 at 4:20