/// <summary>
        /// Search for apps
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchBox_TextChanged(object sender, EventArgs e)
        {
            string content = searchBox.Text.ToLower();

            folderList_DoubleClick(sender, e); // Fill.

            List <ListViewItem> collection = new List <ListViewItem>();

            foreach (ListViewItem itm in fileList.Items)
            {
                collection.Add(itm);
            }

            fileList.Items.Clear();
            fileList.BeginUpdate();
            foreach (ListViewItem itm in collection)
            {
                IPhoneFile file = itm.Tag as IPhoneFile;
                if (file.Path.ToLower().Contains(content) || string.IsNullOrWhiteSpace(content))
                {
                    fileList.Items.Add(itm);
                }
            }
            fileList.EndUpdate();
        }
        public MMSAnalyzer(IPhoneBackup backup, IPhoneFile file)
        {
            _backup = backup;
            _file   = file;

            InitializeComponent();
        }
Exemple #3
0
        /// <summary>
        /// This returns a random file in a temporary location with the file
        /// name as Tuple.
        ///
        /// Item1 = correct fileName
        /// Item2 = the fileInfo about the random file created
        /// </summary>
        /// <param name="backup"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        public Tuple <string, FileInfo> GetRandomFile(IPhoneBackup backup, IPhoneFile file)
        {
            FileInfo fileInfo = GetWorkingFile(backup, file, true);
            string   name     = GetFileName(file);

            return(Tuple.Create(name, fileInfo));
        }
Exemple #4
0
        /// <summary>
        /// Get a working file in the directory Temp/${InvokingClassName}/filename
        ///
        /// This to avoid confilcts but a will to retain the name
        /// </summary>
        /// <param name="backup"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        public FileInfo GetWorkingFileCurrentClass(IPhoneBackup backup, IPhoneFile file)
        {
            StackTrace trace = new StackTrace();
            StackFrame frame = trace.GetFrame(1);
            Type       klass = frame.GetMethod().ReflectedType;

            return(GetWorkingFile(string.Format("${0}", klass.Name), backup, file, false));
        }
        void show_Click(object sender, EventArgs e)
        {
            IPhoneBackup backup      = SelectedBackup;
            IPhoneApp    app         = backup.GetApps().FirstOrDefault(t => t.Name == "System");
            IPhoneFile   dbFile      = app.Files.FirstOrDefault(t => t.Path.Contains("sms.db"));
            MMSAnalyzer  mmsAnalyzer = new MMSAnalyzer(backup, dbFile);

            mmsAnalyzer.Show();
        }
        public HashInfo(IPhoneBackup backup, IPhoneFile file)
        {
            InitializeComponent();

            FileInfo fileInfo = FileManager.Current.GetOriginalFile(backup, file);

            Text             = "Hash information [" + file.Path + "]";
            lblFileName.Text = file.Path;
            lblMd5.Text      = Util.MD5File(fileInfo);
            lblSha1.Text     = Util.SHA1File(fileInfo);
        }
Exemple #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="backup"></param>
 /// <param name="file"></param>
 /// <param name="dest"></param>
 public void Copy(IPhoneBackup backup, IPhoneFile file, string dest)
 {
     lock (_lock)
     {
         string src = Path.Combine(backup.Path, file.Key);
         dest = Path.Combine(dest, GetFileName(file));
         if (src != dest)
         {
             File.Copy(src, dest, true);
         }
     }
 }
Exemple #8
0
        public Form Open()
        {
            IPhoneFile file = SelectedFiles.FirstOrDefault();

            if (file != null)
            {
                FileInfo path = FileManager.GetWorkingFile(SelectedBackup, file, true);
                return(new SQLiteBrowser(path.FullName));
            }

            return(null);
        }
Exemple #9
0
        /// <summary>
        /// Return a file copy from a temp folder
        ///
        /// The path will be /Temp/$$idb$/{dir}/{fileName} (or random i.e. Path.GetTempFileName())
        ///
        /// if verify == true the file from source and the destination hashes will be compared
        /// if the comparsion fail. An IOExcetion is raised.
        /// </summary>
        /// <param name="backup"></param>
        /// <param name="file"></param>
        /// <param name="random"></param>
        /// <param name="dir"></param>
        /// <param name="verify">Verify the files after copy (using md5)</param>
        /// <exception cref="IOException">
        /// Thrown if file copy failed or that the copy cannot be verified
        /// </exception>
        /// <returns></returns>
        public FileInfo GetWorkingFile(string dir, IPhoneBackup backup, IPhoneFile file, bool random, bool verify = true)
        {
            lock (_lock)
            {
                if (!_init)
                {
                    Init();
                }

                string tempPath = Path.Combine(Path.GetTempPath(), BasePath, dir);
                if (!Directory.Exists(tempPath))
                {
                    Directory.CreateDirectory(tempPath);
                }

                FileInfo dest = new FileInfo(Path.GetTempFileName());
                if (!random)
                {
                    dest = new FileInfo(Path.Combine(tempPath, GetFileName(file)));
                }

                FileInfo src = GetOriginalFile(backup, file);
                string   srcHash = "", destHash = "";
                if (verify)
                {
                    srcHash = Util.MD5File(src);
                }

                // Dont copy if it exist..
                if (File.Exists(dest.FullName) && Util.MD5File(dest) == srcHash)
                {
                    return(dest);
                }

                // if we dent copy to the src
                if (src != dest)
                {
                    File.Copy(src.FullName, dest.FullName, true);
                }

                if (verify)
                {
                    destHash = Util.MD5File(dest);
                    if (srcHash != destHash)
                    {
                        Clean(dest.FullName);
                        throw new IOException("File copy failed. Reason: Hashes do not match!!");
                    }
                }
                return(dest);
            }
        }
Exemple #10
0
        public Form Open()
        {
            IPhoneFile file = SelectedFiles.FirstOrDefault();

            if (file != null)
            {
                FileInfo  info = FileManager.GetWorkingFile(SelectedBackup, file, true);
                PListRoot root = PListRoot.Load(info.FullName);
                return(new PListBrowser(root));
            }

            return(null);
        }
        void start_Click(object sender, EventArgs e)
        {
            IPhoneBackup backup = SelectedBackup;

            if (backup == null)
            {
                return;
            }

            IPhoneApp  app      = backup.GetApps().FirstOrDefault(t => t.Name == "System");
            IPhoneFile dbFile   = app.Files.FirstOrDefault(t => t.Path.Contains("sms.db"));
            FileInfo   fileInfo = FileManager.GetWorkingFile(backup, dbFile, true);

            SMSAnalyzer analyzer = new SMSAnalyzer(backup, fileInfo.FullName);

            analyzer.Show();
        }
Exemple #12
0
        /// <summary>
        /// Get the filename of an iphone file
        ///
        /// excluding the directory hirarcy
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public string GetFileName(IPhoneFile file)
        {
            string fileName = "";

            int lastIndex = file.Path.LastIndexOf("/");

            if (lastIndex >= 0)
            {
                fileName = file.Path.Substring(lastIndex + 1, file.Path.Length - lastIndex - 1);
            }
            else
            {
                fileName = file.Path;
            }

            return(fileName);
        }
        private void lstMms_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            ListViewItem.ListViewSubItem itm = e.Item.SubItems[3];
            if (itm != null)
            {
                if (!String.IsNullOrWhiteSpace(itm.Text))
                {
                    string     rowId = itm.Tag.ToString();
                    string     file  = itm.Text;
                    IPhoneFile iFile = _backup.GetApps()
                                       .FirstOrDefault(x => x.Name == "System")
                                       .Files
                                       .FirstOrDefault(y => y.Path.Contains(file) || y.Path.Contains(rowId));
                    Tuple <string, FileInfo> tuple = null;
                    if (iFile != null)
                    {
                        tuple = FileManager.Current.GetRandomFile(_backup, iFile);
                    }

                    if (tuple != null && (tuple.Item1.ToLower().Contains(".jpg") || tuple.Item1.ToLower().Contains(".jpeg")))
                    {
                        FileInfo info  = tuple.Item2;
                        Bitmap   image = new Bitmap(info.FullName);
                        picContainer.Tag   = info;
                        picContainer.Image = image;
                    }
                    else
                    {
                        picContainer.Image = Properties.Resources.help;
                        picContainer.Tag   = null;
                    }
                }
                else
                {
                    picContainer.Image = Properties.Resources.help;
                    picContainer.Tag   = null;
                }
            }
        }
        /// <summary>
        /// View a file using a browser
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolShowBtn_Click(object sender, EventArgs e)
        {
            IPhoneFile   file   = (IPhoneFile)fileList.FocusedItem.Tag;
            IPhoneBackup backup = Model.Backup;

            FileManager filemanager = FileManager.Current;
            FileInfo    dest        = filemanager.GetWorkingFile(backup, file);

            IBrowsable browser = _browserManger.Get(dest.Extension);

            try
            {
                if (browser != null)
                {
                    Form form = browser.Open();
                    if (form != null)
                    {
                        if (browser.Modal)
                        {
                            form.ShowDialog(this);
                        }
                        else
                        {
                            form.Show();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.DebugException(ex.Message, ex);
                MessageBox.Show(string.Format("'{0}' could not be opened by '{1}'"
                                              + "\n\n'{2}'"
                                              + "\nStacktrace\n{3}", dest.Name, browser.Name,
                                              ex.Message, ex.StackTrace), ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="backup"></param>
 /// <param name="file"></param>
 /// <param name="random"></param>
 /// <returns></returns>
 public FileInfo GetWorkingFile(IPhoneBackup backup, IPhoneFile file, bool random)
 {
     return(GetWorkingFile("", backup, file, random));
 }
        void _analyze_Click(object sender, EventArgs e)
        {
            IPhoneBackup             backup = SelectedBackup;
            IPhoneApp                app    = backup.GetApps().FirstOrDefault(t => t.Name == "System");
            IPhoneFile               dbFile = app.Files.FirstOrDefault(t => t.Path.Contains("consolidated"));
            IEnumerable <IPhoneFile> imgs   = app.Files.Where(t => t.Path.Contains("DCIM/100APPLE") && t.Domain == "MediaDomain");
            FileInfo fileInfo = FileManager.GetWorkingFile(backup, dbFile);

            Model.InvokeAsync(delegate(object w, DoWorkEventArgs a)
            {
                BackgroundWorker worker = w as BackgroundWorker;
                if (!worker.CancellationPending)
                {
                    List <Location> locations = new List <Location>();
                    using (SQLiteConnection con = new SQLiteConnection(@"Data Source=" + fileInfo.FullName))
                    {
                        con.Open();
                        var cmd         = new SQLiteCommand();
                        cmd.Connection  = con;
                        cmd.CommandText = "SELECT * FROM WifiLocation;";

                        var reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            locations.Add(new Location
                            {
                                Name      = "[Wifi] MAC: " + reader.GetString(0),
                                Time      = new DateTime(2001, 1, 1, 0, 0, 0).AddSeconds(reader.GetDouble(1)),
                                Latitude  = reader.GetDouble(2),
                                Longitude = reader.GetDouble(3)
                            });
                        }
                        reader.Close();

                        worker.ReportProgress(33);

                        cmd.CommandText = "SELECT * FROM CellLocation";
                        reader          = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            locations.Add(new Location
                            {
                                Name = "[Cell] MCC: " + reader.GetInt32(0) + " MNC: " +
                                       reader.GetInt32(1) + " LAC: " +
                                       reader.GetInt32(2) + " CELL ID:" +
                                       reader.GetInt32(3),
                                Time      = new DateTime(2001, 1, 1, 0, 0, 0).AddSeconds(reader.GetDouble(4)),
                                Latitude  = reader.GetDouble(5),
                                Longitude = reader.GetDouble(6)
                            });
                        }

                        worker.ReportProgress(33);
                    }

                    //Gives incorrect results.. FIXIT
                    //int count = imgs.Count() + 66, current = 66;
                    //foreach (IPhoneFile file in imgs)
                    //{
                    //    FileInfo info = FileManager.GetWorkingFile(backup, file);
                    //    ExifTagCollection er = new ExifTagCollection(info.FullName);

                    //    //not working...
                    //    Location location = new Location();
                    //    double lat = 0, lon = 0;
                    //    foreach (ExifTag tag in er)
                    //    {
                    //        if (tag.FieldName == "GPSLatitude")
                    //        {
                    //            string dec = Regex.Match(tag.Value, @"\d+\.\d+").ToString();
                    //            double.TryParse(dec, out lat);
                    //        }
                    //        else if (tag.FieldName == "GPSLongitude")
                    //        {
                    //            string dec = Regex.Match(tag.Value, @"\d+\.\d+").ToString();
                    //            double.TryParse(dec, out lon);
                    //        }
                    //    }
                    //    location.Latitude = lat;
                    //    location.Longitude = lon;
                    //    location.Name = "[Image] " + info.Name;
                    //    locations.Add(location);

                    //    worker.ReportProgress(Util.Percent(current++, count));
                    //}

                    geKML kml = Location.ToKML(locations.OrderBy(x => x.Time));
                    a.Result  = kml;
                }
                else
                {
                    a.Cancel = true;
                    return;
                }
            },
                              delegate(object w, RunWorkerCompletedEventArgs a)
            {
                geKML kml = a.Result as geKML;

                FileDialog dialog = new SaveFileDialog();
                dialog.DefaultExt = "kmz";
                dialog.FileName   = "locations.kmz";
                dialog.Filter     = "Google earth|*.kmz";
                if (dialog.ShowDialog(Model.Window) == DialogResult.OK)
                {
                    using (FileStream s = new FileStream(dialog.FileName, FileMode.Create))
                    {
                        using (BinaryWriter wr = new BinaryWriter(s))
                        {
                            wr.Write(kml.ToKMZ());
                        }
                    }
                }
            }, "Analyzing location", false);
        }
Exemple #17
0
 /// <summary>
 /// Returns a non random file
 /// </summary>
 /// <param name="backup"></param>
 /// <param name="file"></param>
 /// <returns></returns>
 public FileInfo GetWorkingFile(IPhoneBackup backup, IPhoneFile file)
 {
     return(GetWorkingFile(backup, file, false));
 }
Exemple #18
0
        public FileInfo GetOriginalFile(IPhoneBackup backup, IPhoneFile file)
        {
            string src = Path.Combine(backup.Path, file.Key);

            return(new FileInfo(src));
        }
Exemple #19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="backup"></param>
 /// <param name="file"></param>
 /// <param name="dest"></param>
 public void Copy(IPhoneBackup backup, IPhoneFile file, FileInfo dest)
 {
     Copy(backup, file, dest.FullName);
 }