Php scripts generate a googleplayurl download link. download the apk and obtain the android version number after automatic decompilation.

Source: Internet
Author: User
Php scripts generate a googleplayurl download link. download the apk and obtain the android version number after automatic decompilation. 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; = "android20151120.23"
This output the Kochava SDK version numbe

The purpose of the script is to automate the above steps.

Before running the script, you must install apktool and java in linux.

Operation demonstration:

The package name of the application is entered above, you can also enter the corresponding google play url: https://play.google.com/store/apps/details? Hl = en & id = com. priceline. android. negotiator

The following code is used:

  1 
 $value){ 17              $value=str_replace(' ','',$value); 18              $t[$key]=$value; 19          } 20          $token_value=explode(":",$t[1]); 21          $t_value=$token_value[1]; 22          $dtrken=explode(":",$t[2]); 23          $patten="/var ".$dtrken[1]." = '(.+)';/";          24          preg_match($patten,$context,$daw); 25          $dtrken[1]=$daw[1]; 26          return array("t"=>$t_value,"dtrken"=>$dtrken); 27    } 28    function ajaxPost($packagename) { 29          $tk=getParameter(); 30          $t=$tk['t']; 31          $dtrken_key=$tk['dtrken'][0]; 32          $dtrken_value=$tk['dtrken'][1]; 33             $post_url='http://api.evozi.com/apk-downloader/download'; 34           $data = 'packagename='.$packagename.'&t='.$t.'&'.$dtrken_key.'='.$dtrken_value.'&fetch=false'; 35             $ch = curl_init(); 36             $headers = array('content-type: application/x-www-form-urlencoded;charset=UTF-8'); 37             curl_setopt($ch, CURLOPT_URL, $post_url); 38             curl_setopt($ch, CURLOPT_POSTFIELDS, $data);  39             curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 40             curl_setopt($ch, CURLOPT_POST, 1); 41             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 42             $results = curl_exec($ch); 43             curl_close($ch); 44             $results = json_decode($results); 45             return $results; 46         } 47         function getVersion($packagename){ 48               $version="/Android[0-9]+/"; 49               $path=$packagename."/smali/com/kochava/android/tracker"; 50               $filename1="Global.smali"; 51               $filename2="a.smali"; 52               if(is_dir($path)){ 53                     $file=scandir($path); 54                     foreach($file as $key=>$value){ 55                           $filename=$value; 56                           if(isset($filename)&file_exists($path."/".$filename)){ 57                                     $context=file_get_contents($path."/".$filename); 58                                     preg_match($version,$context,$v); 59                                     if(!empty($v)){ 60                                        $vs=$v[0];     61                                        break; 62                                     } 63                         } 64                     } 65                     if(isset($vs)){ 66                           $info=array("status"=>200,"description"=>"success detection in the file:".$filename,"version"=>$vs); 67                      }else{ 68                           $info=array("status"=>203,"description"=>"failure detection in all the .smal file:(".$file."),we can't find the android version number"); 69                      } 70               }else{ 71                    $info=array("status"=>201,"description"=>"there is no such directory:".$path); 72               } 73               $info=json_encode($info); 74               return $info; 75         } 76         function getFile($file_path,$file_name){ 77             exec("sudo wget -O $file_name $file_path"); 78         } 79         function deCompileApk($file_name){ 80                   print_r("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++start decompile apk,this may need a long time,please wait...++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++".PHP_EOL); 81                   exec("sudo apktool d $file_name"); 82                   print_r("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++decompile end++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++".PHP_EOL); 83         } 84         function delFile($packagename,$file_name){ 85                   exec("sudo rm -f $file_name"); 86                   exec("sudo rm -rf $packagename"); 87         } 88         $result=ajaxPost($packagename); 89         if($result->status=="success"){ 90              $file_name=$packagename."."."apk"; 91            $downloadUrl=$result->url; 92            $downloadUrl=preg_replace("/&/i", "\&", $downloadUrl); 93        getFile($downloadUrl,$file_name); 94        deCompileApk($file_name); 95        $info=getVersion($packagename); 96        delFile($packagename,$file_name); 97         }else{ 98              $tinfo=array("status"=>204,"description"=>"we can't generate Download Link from http://apps.evozi.com/apk-downloader/,please check your input of google play url or app package name!"); 99              $info=json_encode($tinfo);100         }101         print_r($info.PHP_EOL);102 ?>

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.