PHP script generates download link for Google Play URL, download apk and automatically decompile to get Android version number

Source: Internet
Author: User
Requirements:

Get the Offer tracking link
Follow the redirect to get Google Play URL
Go to http://apps.evozi.com/apk-downloader/
Enter Google Play URL
Download APK File
decompile APK file using Https://code.google.com/p/android-apktool/wiki/ApktoolOptions#Decompile_Options
Extract This file
[App Name]/smali/com/kochava/android/tracker/global.smali
Extract this line
. field public static final sdk_version:ljava/lang/string; = "Android20141023"
This output of the Kochava SDK version Numbe

The purpose of the script is to automate the above steps

Apktool and Java environments must be installed in Linux before running scripts

Operation Demo:

The app's package name is entered above, and you can also enter the corresponding Google Play url:https://play.google.com/store/apps/details?hl=en&id= Com.priceline.android.negotiator

Here's the code:

1
 $value) {$value =str_replace (",", $value) $t [$key]= $value; Ken_value=explode (":", $t [1]); $t _value= $token _value[1]; $dtrken =explode (":", $t [2]);          $patten = "/var". $dtrken [1]. "= ' (. +) ';/"; Preg_match ($patten, $context, $daw); $dtrken [1]= $daw [1]; The return Array ("t" = = $t _value, "Dtrken" and "$dtrken"); The function Ajaxpost ($packagename) {$tk =getparameter (); $t = $tk [' t ']; $DTRK en_key= $tk [' Dtrken '][0]; $dtrken _value= $tk [' Dtrken '][1]; $post _url= ' http://api.evozi.com/apk-downloader/download '; $data = ' packagename= '. $packagename. ' &t= '. $t. ' & ' $dtrken _key. ' = '. $dtrken _value. ' &fetch=false '; $ch = Curl_init (); $headers = Array (' Content-type:application/x-www-form-urlencoded;charset=utf-8 '); Panax Notoginseng curl_setopt ($ch, Curlopt_url, $pOst_url);  curl_setopt ($ch, Curlopt_postfields, $data); curl_setopt ($ch, Curlopt_httpheader, $headers); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_returntransfer, 1); $results = curl_exec ($ch); Curl_close ($ch); $results = Json_decode ($results); return $results; GetVersion ($packagename) {$version = "/android[0-9]+/"; 49 $ Path= $packagename. " /smali/com/kochava/android/tracker "; $filename 1= "Global.smali"; Wuyi $filename 2= "A.smali"; if (Is_dir ($path)) {$file =scandir ($path), and A. foreach ($file as $ Key=> $value) {$filename = $value; Isset ($filename) &file_ Exists ($path. " /". $filename)" {=file_get_contents $context ($path. " /". $filename); Preg_match ($version, $context, $v);     if (!empty ($v)) {$vs = $v [0]; a break; (i) Sset ($vs)) {$info =array ("status" =>200, "description" = "Success detection in the" file: ". $ FileName, "version" = $vs); }else{$info =array ("status" =>203, "description" = "Failure Detect" Ion in all the. smal file: (". $file."), we can ' t find the Android version number "); }else{$info =array ("status" =>201, "description" = "th" Ere is no such directory: ". $path); =json_encode $info ($info); The return $info;  75} 76       function GetFile ($file _path, $file _name) {_name exec ("sudo wget-o $file _path $file"); 78} 79 function decompileapk ($file _name) {print_r ("++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++start decompile Apk,this may need a long time,please wait...++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++". PHP_EOL); Bayi exec ("sudo apktool d $file _name"); Print_r ("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++decompile en d++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ". PHP_EOL);                   The Delfile ($packagename, $file _name) {("sudo rm-f $file _name") {86 EXEC ("sudo rm-rf $packagename"); $result =ajaxpost ($packagename); if ($result->status== "Success") {$file _namE= $packagename. ".". " APK "; $DOWNLOADURL = $result->url; $downloadUrl =preg_replace ("/&/i", "\&", $DOWNLOADURL); GetFile ($DOWNLOADURL, $file _name); 94 decompileapk ($file _name); =getversion $info ($packagename); Delfile ($packagename, $file _name); }else{98 $tinfo =array ("status" =>204, "description" = "We can ' t generate Download Link from HT Tp://apps.evozi.com/apk-downloader/,please check your input of Google Play URL or app package name! "); $info =json_encode ($tinfo),}101 Print_r ($info. PHP_EOL); 102?>
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.