Ejemplo n.º 1
0
 public static String extractIPA(IPAInfo info)
 {
     using (ZipFile ipa = ZipFile.Read(info.Location))
     {
         Debug("IPALocation: " + info.Location);
         Debug("Payload location: " + info.BinaryLocation);
         foreach (ZipEntry e in ipa)
         {
             //Debug ("file:" + e.FileName);
             if (e.FileName.Contains(".sinf") || e.FileName.Contains(".supp"))
             {
                 //extract it
                 Debug(GetTemporaryDirectory());
                 e.Extract(GetTemporaryDirectory(), ExtractExistingFileAction.OverwriteSilently);
             }
             else if (e.FileName == info.BinaryLocation)
             {
                 Debug("found binary!!");
                 e.Extract(GetTemporaryDirectory(), ExtractExistingFileAction.OverwriteSilently);
             }
         }
     }
     //zip!
     String AppDirectory = Path.Combine(GetTemporaryDirectory(), "Payload");
     Debug("AppDirectory: " + AppDirectory);
     //return null;
     String ZipPath = Path.Combine(GetTemporaryDirectory(), "upload.ipa");
     using (ZipFile zip = new ZipFile())
     {
         zip.CompressionLevel = Ionic.Zlib.CompressionLevel.None;
         zip.AddDirectory(AppDirectory);
         zip.Save(ZipPath);
     }
     return ZipPath;
 }
Ejemplo n.º 2
0
        public static String repack(IPAInfo info, String binaryLocation)
        {
            String finalLocation = info.AppName + " " + info.AppVersion + ".ipa";

            File.Copy(info.Location, finalLocation, true);
            using (ZipFile ipa = ZipFile.Read(finalLocation))
            {
                Debug("found binary!!");
                try
                {
                    var binary = ipa.AddFile(binaryLocation).FileName = info.BinaryLocation;
                }
                catch (System.ArgumentException)
                {
                    //remove the existing binary and insert again :/
                    foreach (ZipEntry e in ipa)
                    {
                        if (e.FileName == info.BinaryLocation)
                        {
                            //Console.WriteLine ("binarylocation: " +);
                            Debug("found binary!!!!");
                            ipa.RemoveEntry(e);
                            var binary = ipa.AddFile(binaryLocation).FileName = info.BinaryLocation;
                            break;
                        }
                    }
                }

                Debug("binarylocation: " + binaryLocation + " " + info.BinaryLocation);
                //binary.FileName = info.BinaryLocation;
                ipa.Save();
            }
            return(finalLocation);
        }
Ejemplo n.º 3
0
        private void crackApp(IPAInfo ipaInfo)
        {
            CrackProcess cp = new CrackProcess(ipaInfo);
            cp.Show();
            crackThread = new Thread(new ThreadStart(cp.beginCracking));

            crackThread.Start();
            //cp.beginCracking();
        }
Ejemplo n.º 4
0
        private void crackIPA(IPAInfo ipaInfo)
        {
            log("beginning cracking process..");
            PercentStatus("Establishing SSH connection", 5);
            PercentStatus("Establishing SFTP connection", 10);

            log("Cracking " + ipaInfo.AppName);
            PercentStatus("Preparing IPA", 25);

            /*String ipalocation = AppHelper.extractIPA(ipaInfo);
             * using (var file = File.OpenRead(ipalocation))
             * {
             *  log("Uploading IPA to device..");
             *  PercentStatus("Uploading IPA", 40);
             *  sftp.UploadFile(file, "Upload.ipa");
             *
             * }*/
            log("Cracking! (This might take a while)");
            PercentStatus("Cracking", 50);
            String binaryLocation     = ipaInfo.BinaryLocation.Replace("Payload/", "");
            String TempDownloadBinary = Path.Combine(AppHelper.GetTemporaryDirectory(), "crackedBinary");
            var    crack = ssh.RunCommand("Clutch -i '" + ipaInfo.IPALocationOnDevice + "' " + binaryLocation + " /tmp/crackedBinary");

            log("Clutch -i '" + ipaInfo.IPALocationOnDevice + "' " + binaryLocation + " /tmp/crackedBinary");
            log("cracking output: " + crack.Result);

            using (var file = File.OpenWrite(TempDownloadBinary))
            {
                log("Downloading cracked binary..");
                PercentStatus("Downloading cracked binary", 80);
                try
                {
                    sftp.DownloadFile("/tmp/crackedBinary", file);
                }
                catch (SftpPathNotFoundException e)
                {
                    log("Could not find file, help!!!!!");
                    return;
                }
            }

            PercentStatus("Repacking IPA", 90);
            String repack = AppHelper.repack(ipaInfo, TempDownloadBinary);

            PercentStatus("Done!", 100);

            log("Cracking completed, file at " + repack);
        }
Ejemplo n.º 5
0
        private void crack(List <int> list)
        {
            if ((crackThread != null) && (crackThread.IsAlive))
            {
                MessageBox.Show("Already cracking an app, please wait!");
                return;
            }

            crackProcess = new CrackProcess();

            foreach (int tag in list)
            {
                IPAInfo info = xml.IPAItems[tag];
                Console.WriteLine("selected " + info.AppBundle + " " + info.Location);
                crackProcess.queueIPA(info);
            }
            beginCrackProcess();
        }
Ejemplo n.º 6
0
        public static String extractIPA(IPAInfo info)
        {
            using (ZipFile ipa = ZipFile.Read(info.Location))
            {
                Debug("IPALocation: " + info.Location);
                Debug("Payload location: " + info.BinaryLocation);
                foreach (ZipEntry e in ipa)
                {
                    //Debug ("file:" + e.FileName);
                    if (e.FileName.Contains(".sinf") || e.FileName.Contains(".supp"))
                    {
                        //extract it
                        Debug(GetTemporaryDirectory());
                        e.Extract(GetTemporaryDirectory(), ExtractExistingFileAction.OverwriteSilently);
                    }
                    else if (e.FileName == info.BinaryLocation)
                    {
                        Debug("found binary!!");
                        e.Extract(GetTemporaryDirectory(), ExtractExistingFileAction.OverwriteSilently);
                    }
                    else if (e.FileName == "iTunesMetadata")
                    {
                        e.Extract(GetWorkingDirectory(), ExtractExistingFileAction.OverwriteSilently);
                        string plistLocation = Path.Combine(GetTemporaryDirectory(), e.FileName);
                        info.iTunesMetadata = (Dictionary <string, object>)Plist.readPlist(plistLocation);
                    }
                }
            }
            //zip!
            String AppDirectory = Path.Combine(GetTemporaryDirectory(), "Payload");

            Debug("AppDirectory: " + AppDirectory);
            //return null;
            String ZipPath = Path.Combine(GetWorkingDirectory(), info.AppBundle + ".ipa");

            using (ZipFile zip = new ZipFile())
            {
                zip.CompressionLevel = Ionic.Zlib.CompressionLevel.None;
                zip.AddDirectory(AppDirectory);
                zip.Save(ZipPath);
            }
            DeleteDirectory(GetTemporaryDirectory());
            return(ZipPath);
        }
Ejemplo n.º 7
0
        public static String extractIPA(IPAInfo info)
        {
            using (ZipFile ipa = ZipFile.Read(info.Location))
            {
                Debug("IPALocation: " + info.Location);
                Debug("Payload location: " + info.BinaryLocation);
                foreach (ZipEntry e in ipa)
                {
                    //Debug ("file:" + e.FileName);
                    if (e.FileName.Contains (".sinf") || e.FileName.Contains (".supp")) {
                        //extract it
                        Debug (GetTemporaryDirectory ());
                        e.Extract (GetTemporaryDirectory (), ExtractExistingFileAction.OverwriteSilently);
                    } else if (e.FileName == info.BinaryLocation) {
                        Debug ("found binary!!");
                        e.Extract (GetTemporaryDirectory (), ExtractExistingFileAction.OverwriteSilently);
                    } else if (e.FileName == "iTunesMetadata") {
                        e.Extract (GetWorkingDirectory (), ExtractExistingFileAction.OverwriteSilently);
                        string plistLocation = Path.Combine(GetTemporaryDirectory(), e.FileName);
                        info.iTunesMetadata =  (Dictionary<string, object>)Plist.readPlist (plistLocation);

                    }
                }
            }
            //zip!
            String AppDirectory = Path.Combine(GetTemporaryDirectory(), "Payload");
            Debug("AppDirectory: " + AppDirectory);
            //return null;
            String ZipPath = Path.Combine(GetWorkingDirectory(), info.AppBundle + ".ipa");
            using (ZipFile zip = new ZipFile())
            {
                zip.CompressionLevel = Ionic.Zlib.CompressionLevel.None;
                zip.AddDirectory(AppDirectory);
                zip.Save(ZipPath);
            }
            DeleteDirectory(GetTemporaryDirectory());
            return ZipPath;
        }
Ejemplo n.º 8
0
        public static void getIPAs(String location)
        {
            DirectoryInfo di = new DirectoryInfo(location);
            Container container = Container.getContainer();
            container.IPAItems = new List<IPAInfo>();
            FileInfo[] files;
            //byte[] data;

            if (!di.Exists)
            {
                Console.WriteLine("Error: Directory not found?");
                return;
            }
            try
            {
                files = di.GetFiles("*.ipa", SearchOption.TopDirectoryOnly);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: Exception occured, perhaps no permissions for directory?");
                Console.WriteLine(e.ToString());
                return;
            }
            foreach (FileInfo file in files)
            {
                Debug("IPA found: " + file.Name);
                using (ZipFile ipa = ZipFile.Read(file.FullName))
                {
                    foreach (ZipEntry e in ipa)
                    {
                        //Debug ("ZipEntry: " + e.FileName);
                        if (e.FileName.Contains(".app/Info.plist"))
                        {
                            Debug("INFO.PLIST FOUND!!!!! " + GetTemporaryDirectory());
                            e.Extract(GetTemporaryDirectory(), ExtractExistingFileAction.OverwriteSilently);
                            string plistLocation = Path.Combine(GetTemporaryDirectory(), e.FileName);
                            //unpackDirectory + "/" + e.FileName;
                            Debug("yo yo yo");
                            Dictionary<string, object> plist = (Dictionary<string, object>)Plist.readPlist(plistLocation);
                            Debug("plist data: " + plist.ToString());
                            Debug("Bundle Name: " + plist["CFBundleExecutable"]);
                            IPAInfo info = new IPAInfo();
                            info.AppBundle = (string)plist["CFBundleExecutable"];
                            if (plist.ContainsKey("CFBundleDisplayName"))
                            {
                                info.AppName = (string)plist["CFBundleDisplayName"];
                            }
                            else
                            {
                                info.AppName = (string)plist["CFBundleName"];
                            }
                            info.AppVersion = (string)plist["CFBundleVersion"];
                            info.Location = file.FullName;
                            info.BinaryLocation = e.FileName.Replace("Info.plist", "") + info.AppBundle;
                            container.IPAItems.Add(info);
                        }
                    }
                }

            }
            /*using (StreamWriter writer = new StreamWriter("Brake.xml")) {
                XmlSerializer serializer = new XmlSerializer (typeof(Container));
                serializer.Serialize (writer, container);
                Debug ("serializing data");
            }*/
            container.SaveXML();
            DeleteDirectory(GetTemporaryDirectory());
        }
Ejemplo n.º 9
0
        public static String repack(IPAInfo info, String binaryLocation)
        {
            String finalLocation = info.AppName + " " + info.AppVersion + ".ipa";
            File.Copy(info.Location, finalLocation, true);
            using (ZipFile ipa = ZipFile.Read(finalLocation))
            {
                Debug("found binary!!");
                try
                {

                    var binary = ipa.AddFile(binaryLocation).FileName = info.BinaryLocation;
                }
                catch (System.ArgumentException)
                {
                    //remove the existing binary and insert again :/
                    foreach (ZipEntry e in ipa)
                    {
                        if (e.FileName == info.BinaryLocation)
                        {
                            //Console.WriteLine ("binarylocation: " +);
                            Debug("found binary!!!!");
                            ipa.RemoveEntry(e);
                            var binary = ipa.AddFile(binaryLocation).FileName = info.BinaryLocation;
                            break;
                        }
                    }
                }

                Debug("binarylocation: " + binaryLocation + " " + info.BinaryLocation);
                //binary.FileName = info.BinaryLocation;
                ipa.Save();
            }
            return finalLocation;
        }
Ejemplo n.º 10
0
        private void crackIPA(IPAInfo ipaInfo)
        {
            log("beginning cracking process..");
            PercentStatus("Establishing SSH connection", 5);
            PercentStatus("Establishing SFTP connection", 10);

            log("Cracking " + ipaInfo.AppName);
            PercentStatus("Preparing IPA", 25);
            /*String ipalocation = AppHelper.extractIPA(ipaInfo);
            using (var file = File.OpenRead(ipalocation))
            {
                log("Uploading IPA to device..");
                PercentStatus("Uploading IPA", 40);
                sftp.UploadFile(file, "Upload.ipa");

            }*/
            log("Cracking! (This might take a while)");
            PercentStatus("Cracking", 50);
            String binaryLocation = ipaInfo.BinaryLocation.Replace("Payload/", "");
            String TempDownloadBinary = Path.Combine(AppHelper.GetTemporaryDirectory(), "crackedBinary");
            var crack = ssh.RunCommand("Clutch -i '" + ipaInfo.IPALocationOnDevice +"' " + binaryLocation + " /tmp/crackedBinary");
            log("Clutch -i '" + ipaInfo.IPALocationOnDevice +"' " + binaryLocation + " /tmp/crackedBinary");
            log("cracking output: " + crack.Result);

            using (var file = File.OpenWrite(TempDownloadBinary))
            {
                log("Downloading cracked binary..");
                PercentStatus("Downloading cracked binary", 80);
                try
                {
                    sftp.DownloadFile("/tmp/crackedBinary", file);
                }
                catch (SftpPathNotFoundException e)
                {
                    log("Could not find file, help!!!!!");
                    return;
                }
            }

            PercentStatus("Repacking IPA", 90);
            String repack = AppHelper.repack(ipaInfo, TempDownloadBinary);
            PercentStatus("Done!", 100);

            log("Cracking completed, file at " + repack);
        }
Ejemplo n.º 11
0
 public void queueIPA(IPAInfo ipaInfo)
 {
     queue.Enqueue(ipaInfo);
 }
Ejemplo n.º 12
0
 public void queueIPA(IPAInfo ipaInfo)
 {
     queue.Enqueue(ipaInfo);
 }
Ejemplo n.º 13
0
        public static void getIPAs(String location)
        {
            DirectoryInfo di        = new DirectoryInfo(location);
            Container     container = Container.getContainer();

            container.IPAItems = new List <IPAInfo>();
            FileInfo[] files;
            //byte[] data;

            if (!di.Exists)
            {
                Console.WriteLine("Error: Directory not found?");
                return;
            }
            try
            {
                files = di.GetFiles("*.ipa", SearchOption.TopDirectoryOnly);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: Exception occured, perhaps no permissions for directory?");
                Console.WriteLine(e.ToString());
                return;
            }
            foreach (FileInfo file in files)
            {
                try {
                    Debug("IPA found: " + file.Name);
                    using (ZipFile ipa = ZipFile.Read(file.FullName))
                    {
                        foreach (ZipEntry e in ipa)
                        {
                            Debug("ZipEntry: " + e.FileName);
                            if (e.FileName.Contains(".app/Info.plist"))
                            {
                                Debug("INFO.PLIST FOUND!!!!! " + GetTemporaryDirectory());
                                e.Extract(GetTemporaryDirectory(), ExtractExistingFileAction.OverwriteSilently);
                                string plistLocation = Path.Combine(GetTemporaryDirectory(), e.FileName);
                                //unpackDirectory + "/" + e.FileName;
                                Debug("yo yo yo");
                                Dictionary <string, object> plist = (Dictionary <string, object>)Plist.readPlist(plistLocation);
                                Debug("plist data: " + plist.ToString());
                                Debug("Bundle Name: " + plist["CFBundleExecutable"]);
                                IPAInfo info = new IPAInfo();
                                info.AppBundle = (string)plist["CFBundleExecutable"];
                                if (plist.ContainsKey("CFBundleDisplayName"))
                                {
                                    info.AppName = (string)plist["CFBundleDisplayName"];
                                }
                                else
                                {
                                    info.AppName = (string)plist["CFBundleName"];
                                }
                                info.AppVersion     = (string)plist["CFBundleVersion"];
                                info.Location       = file.FullName;
                                info.BinaryLocation = e.FileName.Replace("Info.plist", "") + info.AppBundle;
                                container.IPAItems.Add(info);
                            }
                        }
                    }
                }
                catch (Exception ex) {
                    Debug("Error: could not analyze " + file.Name);
                    Debug("Error: " + ex.ToString());
                }
            }

            /*using (StreamWriter writer = new StreamWriter("Brake.xml")) {
             *  XmlSerializer serializer = new XmlSerializer (typeof(Container));
             *  serializer.Serialize (writer, container);
             *  Debug ("serializing data");
             * }*/
            container.SaveXML();
            DeleteDirectory(GetTemporaryDirectory());
        }
Ejemplo n.º 14
0
 public CrackProcess(IPAInfo ipaInfo)
 {
     xml = Brake.Container.getContainer();
     this.ipaInfo = ipaInfo;
     InitializeComponent();
 }