1

I am working on a Python Script which reads the APK file which is stored in a folder on the same server on which the Script is running.

here is the code I am using:

apk_path = "/var/fibo-dev/public/uploads/apks/TvBox-release-signed-latest.apk"

apkf = APK(apk_path)
is_valid = apkf.is_valid_APK()
package  = apkf.get_package()
version  = apkf.androidversion
version  = version['Name']

APK Parsing Package:
https://github.com/androguard/androguard

The Script reads the content of the APK like it's version, package name etc and then store the info in a csv.

As you can see the APK I am reading is stored on the same server on which the script is placed.

But now the thing is I want to read the APK which is placed on a different server. i.e. https://fibo.network/uploads/apks/18243602447plus_v4.3.4.apk

and when I try to do the same thing for the given url it doesn't work.

for example:

url = urllib2.urlopen("https://fibo.network/uploads/apks/18243602447plus_v4.3.4.apk")
apkf = APK(url.read())

It gives the error:

file() argument 1 must be encoded string without null bytes, not str

I tried to use a different methods like:

urlopen , requests.get

and more But none of those worked for me.

So I am requesting you to help me to get this thing worked out.

Thanks.

Amrinder Singh
  • 82
  • 1
  • 1
  • 10
  • 1
    In the first case, you're passing a string of a filename (which is presumably then opened and read). In the second, you're passing the *contents* of a file. What is the APK parsing package you're using? – jedwards Jul 02 '18 at 11:19
  • @jedwards thanks for your quick response, here is the package info: https://github.com/androguard/androguard – Amrinder Singh Jul 02 '18 at 11:20
  • 2
    Try adding `raw=True` to the constructor parameters as shown here: https://github.com/androguard/androguard/blob/master/androguard/core/bytecodes/apk.py#L78 (e.g. `apkf = APK(url.read(), raw=True)`). – jedwards Jul 02 '18 at 11:22
  • you may want to download APK file to your server before processing it. – Vladyslav Matviienko Jul 02 '18 at 11:26
  • 1
    @jedwards Oh! man you saved my time, it's working perfectly Thanks a lot :) :) – Amrinder Singh Jul 02 '18 at 11:26
  • @AmrinderSingh, did you import anything when you started to use this package? I'm following the example, but I always get name APK is not defined. How did you solve this? – Keselme Sep 26 '18 at 13:39

0 Answers0