Created
January 19, 2016 17:42
-
-
Save aakashns/ee95fdba8657c1eb41b7 to your computer and use it in GitHub Desktop.
Script to download and decompile an apk using just the package name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
from subprocess import call | |
import sys | |
# Script to download and decompile an apk using the package name. | |
# Install the jadx decompiler before running this. | |
# | |
# JADX installation : | |
# $ git clone https://github.com/skylot/jadx.git | |
# $ cd jadx | |
# $ ./gradlew dist | |
# $ ln -s <path_to_jadx_repository>/build/jadx/bin/jadx /usr/local/bin/jadx | |
BASE_URL = "https://apkpure.com/app/" | |
if len(sys.argv) < 2: | |
print "Usage :\n$ python apk_decompiler.py <package_name>" | |
exit(-1) | |
pkg_name = sys.argv[1] | |
s = requests.Session(); | |
initial_res = s.get(BASE_URL + pkg_name) | |
if initial_res.status_code != 200: | |
print 'Package no found on APKPure' | |
exit(-2) | |
print pkg_name, 'found on apkpure.com' | |
initial_soup = BeautifulSoup(initial_res.content, 'html.parser') | |
DOWNLOAD_BASE_URL = 'download.apkpure.com'; | |
all_links = [x.get('href') for x in initial_soup.find_all('a')] | |
download_link = (x for x in all_links if DOWNLOAD_BASE_URL in x and pkg_name in x).next() | |
print 'Donwloading apk from', download_link; | |
apk_res = s.get(download_link) | |
print apk_res.status_code | |
fname = pkg_name + ".apk" | |
fo = open(fname, "w") | |
fo.write(apk_res.content) | |
fo.close() | |
print fname, 'saved locally, now decompiling..' | |
call(['jadx', fname]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment