├── output └── .gitignore ├── requirements.txt ├── README.md └── apkpure_get.py /output/.gitignore: -------------------------------------------------------------------------------- 1 | *.apk 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | progressbar2 2 | requests 3 | bs4 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # apkpure_get 2 | 3 | This is a super simple tool for yanking APK's to reverse engineer from the APKPure service. 4 | It is not well written and has a zillion bugs but it works. 5 | It is designed to be ran from other scripts. For example... If you have a list of the top 100 apps on the app store like "com.whatever.blah", do this... 6 | 7 | ``` 8 | cat top_apps.txt | parallel -j 20 python apkpure_get.py 9 | ``` 10 | 11 | I am hoping to pipeline this with automatic decompilation and analysis sometime, probably by feeding the apps downloaded to MobiSF or Jeb2 or something? idk. 12 | -------------------------------------------------------------------------------- /apkpure_get.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | from __future__ import print_function 4 | from bs4 import BeautifulSoup 5 | import progressbar 6 | import requests 7 | import sys 8 | ### XXX: hack to skip some stupid beautifulsoup warnings that I'll fix when refactoring 9 | import warnings 10 | warnings.filterwarnings("ignore", category=UserWarning, module='bs4') 11 | 12 | def get_apk(app_name): # XXX: this function needs refactoring/cleaning. 13 | print("{+} getting download link for %s" %(app_name)) 14 | site = "https://apkpure.com" 15 | url = "https://apkpure.com/search?q=%s" %(app_name) 16 | html = requests.get(url) 17 | parse = BeautifulSoup(html.text) 18 | for i in parse.find("p"): 19 | a_url = i["href"] 20 | app_url = site + a_url + "/download?from=details" 21 | html2 = requests.get(app_url) 22 | parse2 = BeautifulSoup(html2.text) 23 | for link in parse2.find_all("a",id="download_link"): 24 | download_link = link["href"] 25 | download_apk(app_name, download_link) 26 | 27 | def make_progress_bar(): 28 | return progressbar.ProgressBar( 29 | redirect_stdout=True, 30 | redirect_stderr=True, 31 | widgets=[ 32 | progressbar.Percentage(), 33 | progressbar.Bar(), 34 | ' (', 35 | progressbar.AdaptiveTransferSpeed(), 36 | ' ', 37 | progressbar.ETA(), 38 | ') ', 39 | ]) 40 | 41 | def download_apk(app_name, download_link): 42 | print("{+} downloading %s" %(app_name)) 43 | output_file = "output/" + app_name + ".apk" 44 | r = requests.get(url=download_link, stream=True) 45 | with open(output_file, 'wb') as f: 46 | total_length = int(r.headers.get('content-length')) 47 | bar = make_progress_bar() 48 | bar.start(total_length) 49 | readsofar = 0 50 | for chunk in r.iter_content(chunk_size=1024): 51 | if chunk: 52 | readsofar += len(chunk) 53 | bar.update(readsofar) 54 | f.write(chunk) 55 | f.flush() 56 | bar.finish() 57 | print("{+} done. file saved to %s" %(output_file)) 58 | 59 | def main(args): 60 | if len(args) != 2: 61 | sys.exit("use: %s com.blah.blah" %(args[0])) 62 | get_apk(args[1]) 63 | 64 | if __name__ == "__main__": 65 | main(args=sys.argv) 66 | --------------------------------------------------------------------------------