Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting python struct.error: unpack requires a string argument of length #1

Open
StephenQuirolgico opened this issue Jul 9, 2013 · 11 comments

Comments

@StephenQuirolgico
Copy link

For some apps, we are getting a python struct error. I don't know if this is a problem with androwarn, python, or the APK file itself. Below is an example error message. How can we fix this?

Traceback (most recent call last):
File "/home/blive/androwarn/androwarn-master/androwarn.py", line 116, in
main(options, arguments)
File "/home/blive/androwarn/androwarn-master/androwarn.py", line 95, in main
a, d, x = AnalyzeAPK(APK_FILE)
File "/home/blive/androwarn/androwarn-master/androwarn/analysis/analysis.py", line 48, in AnalyzeAPK
a = APK(filename, raw)
File "/home/blive/androwarn/androwarn-master/androguard/core/bytecodes/apk.py", line 156, in init
self.zip = zipfile.ZipFile( StringIO.StringIO( self.raw ), mode=mode )
File "/usr/lib/python2.7/zipfile.py", line 714, in __init

self._GetContents()
File "/usr/lib/python2.7/zipfile.py", line 748, in _GetContents
self._RealGetContents()
File "/usr/lib/python2.7/zipfile.py", line 807, in _RealGetContents
x._decodeExtra()
File "/usr/lib/python2.7/zipfile.py", line 373, in _decodeExtra
tp, ln = unpack('<HH', extra[:4])
struct.error: unpack requires a string argument of length 4

Thanks,
Steve Quirolgico

@maaaaz
Copy link
Owner

maaaaz commented Jul 13, 2013

Hello Steve,

Would it possible for you to give me an example of an APK file leading to the crashes you reported ?
If you do not want it to appear publicly, consider sending me a message : tdebize (at) mail (dot) com

Best regards.

@StephenQuirolgico
Copy link
Author

We used QuranAndroid which is on Google Play. Also, we have found a workaround for this error by unpacking and repacking the APK using zip/unzip on Ubuntu. However, it should probably still be fixed in androwarn.

@maaaaz
Copy link
Owner

maaaaz commented Dec 30, 2018

Hello @StephenQuirolgico,

Could you test again and tell me if the bug stills exists ?
FYI I just tested with the current QuranAndroid application on the Play Store (version 2.9.1-p1) and I haven't encountered that issue.

I'm in that environment:

  • Kali Rolling
  • Python 2.7.15+
  • External dependencies
asn1crypto==0.24.0
beautifulsoup4==4.6.1
certifi==2018.11.29
cffi==1.11.5
chardet==3.0.4
cryptography==2.4.2
enum34==1.1.6
futures==3.2.0
idna==2.7
ipaddress==1.0.22
Jinja2==2.10
lxml==4.2.4
MarkupSafe==1.1.0
play-scraper==0.5.0
pycparser==2.19
pyOpenSSL==18.0.0
requests==2.20.0
requests-futures==0.9.7
six==1.12.0
urllib3==1.24.1

@StephenQuirolgico
Copy link
Author

StephenQuirolgico commented Dec 30, 2018 via email

@StephenQuirolgico
Copy link
Author

StephenQuirolgico commented Jan 22, 2019 via email

@maaaaz
Copy link
Owner

maaaaz commented Jan 22, 2019

Hello @StephenQuirolgico,

The minimum androguard version is documented in the requirements.txt file, to date it's >= 3.2.1.

Could you try a simple pip install androwarn ?

@StephenQuirolgico
Copy link
Author

StephenQuirolgico commented Jan 22, 2019 via email

@maaaaz
Copy link
Owner

maaaaz commented Jan 23, 2019

Okay, androwarn is, for the moment, a Python 2-only program.

@StephenQuirolgico
Copy link
Author

StephenQuirolgico commented Jan 23, 2019 via email

@maaaaz
Copy link
Owner

maaaaz commented May 30, 2019

Hello @StephenQuirolgico,

Androwarn now works with Python 3.

Cheers.

@StephenQuirolgico
Copy link
Author

StephenQuirolgico commented May 31, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants