public UmengMeta run(string apk)
        {
            var apkStruct = Apktool.Decode(apk);

            Meta.Appkey  = apkStruct.Appkey;
            Meta.Channel = apkStruct.Channel;

            parsePackge(apkStruct.Smali);

            return(Meta);
        }
示例#2
0
        public static void run(string apk)
        {
            var dfs = Apktool.Decode(apk);

            string[] smali = File.ReadAllLines(dfs.LogFile);

            for (int i = 0; i < smali.Length; i++)
            {
                string line = smali[i];

                if (line.Trim().Equals("const/4 v0, 0x0"))
                {
                    smali[i] = line.Replace("0x0", "0x1");
                    break;
                }
            }

            File.Delete(dfs.LogFile);
            File.WriteAllLines(dfs.LogFile, smali);

            //Debug_ap
            Apktool.Build("DEBUG_" + apk);
        }
示例#3
0
        public void Decompile()
        {
            if (this.Decompiling != null)
            {
                this.Decompiling();
            }

            var decompile = new BackgroundWorker();

            decompile.DoWork += (sender, args) => args.Result = Apktool.Decode(this.fileInfo, new DirectoryInfo(TempPath));

            decompile.RunWorkerCompleted += (sender, args) =>
            {
                var result = (Apktool.Command.RunResult)args.Result;
                Trace.TraceInformation(result.Error);
                Trace.TraceInformation(result.Output);

                // Parse apktool.yml
                var fileApktoolYml = new FileInfo(ApkToolYmlFileName);
                if (fileApktoolYml.Exists)
                {
                    string content = File.ReadAllText(fileApktoolYml.FullName);
                    this.isFrameworkApk = content.Contains("isFrameworkApk: true");
                    this.isSystemApp    = content.Contains("  - 2");
                }

                // Update icon
                this.defaultIcon = ConvertToImage(this.iconPath);

                // Check ApplicationNameInStringsXml;
                var xmlFile = new XmlDocument();
                xmlFile.Load(ManifestFileName);
                var selectSingleNode = xmlFile.SelectSingleNode("//manifest/application");
                if (selectSingleNode != null)
                {
                    if (selectSingleNode.Attributes != null)
                    {
                        var labelAttr  = selectSingleNode.Attributes["android:label"];
                        var labelValue = (labelAttr != null) ? labelAttr.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;

                        this.applicationNameInStringsXml = labelValue.StartsWith("@string");
                        this.applicationNameAttribute    = this.applicationNameInStringsXml ? labelValue.Replace("@string/", string.Empty) : string.Empty;
                    }
                }

                if (result.Error.Contains("Could not decode file"))
                {
                    throw new Exception("Could not decode file");
                }

                // Can't find framework resources for package of id: 2. You must install proper framework files, see project website for more info.
                if (result.Output.Contains("Can't find"))
                {
                    if (this.FrameworkMissing != null)
                    {
                        this.FrameworkMissing();
                    }
                }
                else
                {
                    if (this.Decompiled != null)
                    {
                        this.Decompiled();
                    }
                }
            };
            decompile.RunWorkerAsync();
        }