Exemplo n.º 1
0
        public List <MetaAddressBookEntry> GetMetaAddressBookEntry(ViterbiField field, List <MetaResult> metaResults)
        {
            string        name        = null;
            List <string> numbers     = new List <string>();
            long          startOffset = long.MaxValue;

            for (int i = 0; i < field.Raw.Length; i++)
            {
                if (field.Raw[i] == (byte)MetaMachine.Text && name == null)
                {
                    name = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }
                else if (field.Raw[i] == (byte)MetaMachine.Text)
                {
                    name += " " + metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }
                else if (field.Raw[i] == (byte)MetaMachine.PhoneNumber)
                {
                    numbers.Add(metaResults[(int)field.OffsetFile + i].Field.FieldString);
                }
                if (i == 0)
                {
                    startOffset = Math.Min(startOffset, metaResults[(int)field.OffsetFile + i].Field.OffsetFile);
                }
            }

            var entries = new List <MetaAddressBookEntry>();

            for (int i = 0; i < numbers.Count; i++)
            {
                var entry = new MetaAddressBookEntry
                {
                    Name       = name,
                    Number     = numbers[i],
                    SevenDigit = Utilities.GetLastSevenDigits(numbers[i]),
                    Offset     = startOffset
                };


                if (entry.Name == null)
                {
                    entry.Name = MetaField.DEFAULT_STRING;
                }

                if (entry.Number == null)
                {
                    entry.Number = MetaField.DEFAULT_STRING;
                }

                if (entry.SevenDigit == null)
                {
                    entry.SevenDigit = MetaField.DEFAULT_STRING;
                }

                entries.Add(entry);
            }

            return(entries);
        }
Exemplo n.º 2
0
        private List <MetaResult> CreateMetaInfo(List <ViterbiField> fields)
        {
            const int LONG_GAP_BYTES = 200;
            var       metaMachines   = new List <MetaResult>();

            long nextIndex = 0;

            //Run through the fields determining if it is a metafield, i.e. phone number, timestamp, text, etc.
            for (int i = 0; i < fields.Count; i++)
            {
                //Check if there are gaps
                bool isGap = fields[i].OffsetFile > nextIndex;

                if (isGap)
                {
                    //If there is a gap, then we need to add a binary or binary large field

                    long gap = fields[i].OffsetFile - nextIndex;

                    ViterbiField binary = new ViterbiField {
                        FieldString = ""
                    };

                    if (gap > LONG_GAP_BYTES)
                    {
                        metaMachines.Add(new MetaResult {
                            Name = MetaMachine.BinaryLarge, Field = binary
                        });
                    }
                    else
                    {
                        metaMachines.Add(new MetaResult {
                            Name = MetaMachine.Binary, Field = binary
                        });
                    }
                }

                nextIndex = fields[i].OffsetFile + fields[i].Length;

                var meta = GetMetaMachine(fields[i].MachineName);

                metaMachines.Add(new MetaResult {
                    Name = meta, Field = fields[i]
                });
            }

            return(metaMachines);
        }
Exemplo n.º 3
0
        public void Write_CSV()
        {
            TextWriter tw = null;

            try
            {
                string dir = Path.GetDirectoryName(_filePath);
                string fn  = Path.GetFileNameWithoutExtension(_filePath);
                tw =
                    new StreamWriter(Path.Combine(dir,
                                                  String.Format("{0}_{1}.csv", fn,
                                                                DateTime.Now.ToString("yyyyMMdd_HHmm"))));

                foreach (KeyValuePair <int, List <ViterbiField> > pair in _fields_in_blocks /*_fields_of_interest*/)
                {
                    for (int i = 0; i < pair.Value.Count; i++)
                    {
                        ViterbiField field = pair.Value[i];
                        if (field.MachineName.ToString() == "Start")
                        {
                            /// happens with the Binary field.
                            field.FieldString = "???";
                        }
                        tw.WriteLine(pair.Key + "\t" + field.MachineName.ToString() + "\t" + field.OffsetFile.ToString() +
                                     "\t" + field.Length.ToString() + "\t" + field.FieldString.ToString() + "\t" + "NA");
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (tw != null)
                {
                    tw.Close();
                }
            }
        }
Exemplo n.º 4
0
        private MetaSms GetMetaSms(ViterbiField field, List <MetaResult> metaResults)
        {
            string   name        = null;
            string   number      = null;
            string   number2     = null;
            DateTime?timeStamp   = null;
            string   message     = null;
            long     startOffset = -1;

            FieldPaths path = new FieldPaths();

            for (int i = 0; i < field.Raw.Length; i++)
            {
                if (i == 0)
                {
                    path._path_beg_offset = metaResults[(int)field.OffsetFile].Field.OffsetFile;
                }
                if (i == field.Raw.Length - 1)
                {
                    path._path_end_offset = metaResults[(int)field.OffsetFile + i].Field.OffsetFile;
                }
                path._fields_in_path.Add(metaResults[(int)field.OffsetFile + i].Field.MachineName.ToString());

                //if (field.Raw[i] == (byte)MetaMachine.Text && name == null)
                //    name = metaResults[(int)field.OffsetFile + i].Field.FieldString;

                if (field.Raw[i] == (byte)MetaMachine.PhoneNumber && number == null)
                {
                    number = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                else if (field.Raw[i] == (byte)MetaMachine.PhoneNumber && number2 == null)
                {
                    number2 = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                else if (field.Raw[i] == (byte)MetaMachine.TimeStamp && timeStamp == null)
                {
                    timeStamp = DateTime.Parse(metaResults[(int)field.OffsetFile + i].Field.FieldString);
                }

                else if (field.Raw[i] == (byte)MetaMachine.Text && message == null)
                {
                    message = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                if (startOffset == -1)
                {
                    startOffset = metaResults[(int)field.OffsetFile + i].Field.OffsetFile;
                }
            }
            path.find_actual_path();
            fieldPaths.Add(path);


            var entry = new MetaSms()
            {
                Name            = name,
                Number          = number,
                Number2         = number2,
                SevenDigit      = Utilities.GetLastSevenDigits(number),
                SevenDigit2     = Utilities.GetLastSevenDigits(number2),
                TimeStamp       = timeStamp,
                Message         = message,
                Offset          = startOffset,
                MachineName     = field.MachineName,
                ProximityOffset = startOffset
            };

            if (entry.Name == null)
            {
                entry.Name = MetaField.DEFAULT_STRING;
            }

            if (entry.Number == null)
            {
                entry.Number = MetaField.DEFAULT_STRING;
            }

            if (entry.SevenDigit == null)
            {
                entry.SevenDigit = MetaField.DEFAULT_STRING;
            }

            if (entry.Number2 == null)
            {
                entry.Number2 = MetaField.DEFAULT_STRING;
            }

            if (entry.SevenDigit2 == null)
            {
                entry.SevenDigit2 = MetaField.DEFAULT_STRING;
            }

            if (entry.Message == null)
            {
                entry.Message = MetaField.DEFAULT_STRING;
            }

            if (entry.TimeStamp == null)
            {
                entry.TimeStamp = MetaField.DEFAULT_DATE;
            }

            return(entry);
        }
Exemplo n.º 5
0
        private List <MetaCallLog> GetMetaCallLog(ViterbiField field, List <MetaResult> metaResults)
        {
            string          name             = null;
            string          number           = null;
            List <DateTime> timeStamps       = new List <DateTime>();
            string          type             = null;
            long            startOffset      = -1;
            List <long>     proximityOffsets = new List <long>();

            FieldPaths path = new FieldPaths();

            for (int i = 0; i < field.Raw.Length; i++)
            {
                if (i == 0)
                {
                    path._path_beg_offset = metaResults[(int)field.OffsetFile].Field.OffsetFile;
                }
                if (i == field.Raw.Length - 1)
                {
                    path._path_end_offset = metaResults[(int)field.OffsetFile + i].Field.OffsetFile;
                }
                path._fields_in_path.Add(metaResults[(int)field.OffsetFile + i].Field.MachineName.ToString());

                if (field.Raw[i] == (byte)MetaMachine.Text && name == null)
                {
                    name = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                else if (field.Raw[i] == (byte)MetaMachine.PhoneNumber && number == null)
                {
                    number = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                else if (field.Raw[i] == (byte)MetaMachine.TimeStamp)
                {
                    timeStamps.Add(DateTime.Parse(metaResults[(int)field.OffsetFile + i].Field.FieldString));
                    proximityOffsets.Add(metaResults[(int)field.OffsetFile + i].Field.OffsetFile);
                }
                else if (field.Raw[i] == (byte)MetaMachine.CallLogType && type == null)
                {
                    type = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                if (startOffset == -1)
                {
                    startOffset = metaResults[(int)field.OffsetFile + i].Field.OffsetFile;
                }
            }
            path.find_actual_path();
            fieldPaths.Add(path);

            var entries = new List <MetaCallLog>();

            for (int i = 0; i < timeStamps.Count; i++)
            {
                var entry = new MetaCallLog()
                {
                    Name            = name,
                    Number          = number,
                    SevenDigit      = Utilities.GetLastSevenDigits(number),
                    TimeStamp       = timeStamps[i],
                    Type            = type,
                    Offset          = startOffset,
                    MachineName     = field.MachineName,
                    ProximityOffset = proximityOffsets[i]
                };

                if (entry.Name == null)
                {
                    entry.Name = MetaField.DEFAULT_STRING;
                }

                if (entry.Number == null)
                {
                    entry.Number = MetaField.DEFAULT_STRING;
                }

                if (entry.SevenDigit == null)
                {
                    entry.SevenDigit = MetaField.DEFAULT_STRING;
                }

                if (entry.Type == null)
                {
                    entry.Type = MetaField.DEFAULT_STRING;
                }

                if (entry.TimeStamp == null)
                {
                    entry.TimeStamp = MetaField.DEFAULT_DATE;
                }

                entries.Add(entry);
            }

            return(entries);
        }
Exemplo n.º 6
0
        private List <MetaCallLog> GetMetaCallLogNokia(ViterbiField field, List <MetaResult> metaResults)
        {
            string          name             = null;
            var             numbers          = new List <string>();
            List <DateTime> timeStamps       = new List <DateTime>();
            string          type             = null;
            long            startOffset      = -1;
            List <long>     proximityOffsets = new List <long>();

            var phoneIndex     = new List <string>();
            var timeStampIndex = new List <string>();

            FieldPaths path = new FieldPaths();

            for (int i = 0; i < field.Raw.Length; i++)
            {
                if (i == 0)
                {
                    path._path_beg_offset = metaResults[(int)field.OffsetFile].Field.OffsetFile;
                }
                if (i == field.Raw.Length - 1)
                {
                    path._path_end_offset = metaResults[(int)field.OffsetFile + i].Field.OffsetFile;
                }
                path._fields_in_path.Add(metaResults[(int)field.OffsetFile + i].Field.MachineName.ToString());

                if (field.Raw[i] == (byte)MetaMachine.Text && name == null)
                {
                    name = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                //There should be a binary field in between.
                else if (field.Raw[i] == (byte)MetaMachine.CallLogNumberIndex && field.Raw[i + 2] == (byte)MetaMachine.PhoneNumber)
                {
                    phoneIndex.Add(metaResults[(int)field.OffsetFile + i].Field.FieldString);

                    numbers.Add(metaResults[(int)field.OffsetFile + i + 2].Field.FieldString);

                    i += 2;
                }
                else if (field.Raw[i] == (byte)MetaMachine.TimeStamp && field.Raw[i + 1] == (byte)MetaMachine.CallLogNumberIndex)
                {
                    timeStamps.Add(DateTime.Parse(metaResults[(int)field.OffsetFile + i].Field.FieldString));
                    timeStampIndex.Add(metaResults[(int)field.OffsetFile + i + 1].Field.FieldString);
                    proximityOffsets.Add(metaResults[(int)field.OffsetFile + i].Field.OffsetFile);
                    i++;
                }
                else if (field.Raw[i] == (byte)MetaMachine.CallLogType && type == null)
                {
                    type = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                if (startOffset == -1)
                {
                    startOffset = metaResults[(int)field.OffsetFile + i].Field.OffsetFile;
                }
            }
            path.find_actual_path();
            fieldPaths.Add(path);

            var entries = new List <MetaCallLog>();

            for (int i = 0; i < timeStamps.Count; i++)
            {
                int numberI = -1;
                //Get phone number
                for (int j = 0; j < phoneIndex.Count; j++)
                {
                    if (timeStampIndex[i] == phoneIndex[j])
                    {
                        numberI = j;
                        break;
                    }
                }

                string number = (numberI != -1) ? numbers[numberI] : "*NONE*";

                var entry = new MetaCallLog()
                {
                    Name            = name,
                    Number          = number,
                    SevenDigit      = Utilities.GetLastSevenDigits(number),
                    TimeStamp       = timeStamps[i],
                    Type            = type,
                    Offset          = startOffset,
                    MachineName     = field.MachineName,
                    ProximityOffset = proximityOffsets[i]
                };

                if (entry.Name == null)
                {
                    entry.Name = MetaField.DEFAULT_STRING;
                }

                if (entry.Number == null)
                {
                    entry.Number = MetaField.DEFAULT_STRING;
                }

                if (entry.SevenDigit == null)
                {
                    entry.SevenDigit = MetaField.DEFAULT_STRING;
                }

                if (entry.Type == null)
                {
                    entry.Type = MetaField.DEFAULT_STRING;
                }

                if (entry.TimeStamp == null)
                {
                    entry.TimeStamp = MetaField.DEFAULT_DATE;
                }

                entries.Add(entry);
            }

            return(entries);
        }
Exemplo n.º 7
0
        private List <MetaAddressBookEntry> GetMetaAddressBookEntry(ViterbiField field, List <MetaResult> metaResults)
        {
            string        name             = null;
            List <string> numbers          = new List <string>();
            long          startOffset      = long.MaxValue;
            List <long>   proximityOffsets = new List <long>();

            FieldPaths path = new FieldPaths();

            for (int i = 0; i < field.Raw.Length; i++)
            {
                if (i == 0)
                {
                    path._path_beg_offset = metaResults[(int)field.OffsetFile].Field.OffsetFile;
                }
                if (i == field.Raw.Length - 1)
                {
                    path._path_end_offset = metaResults[(int)field.OffsetFile + i].Field.OffsetFile;
                }
                path._fields_in_path.Add(metaResults[(int)field.OffsetFile + i].Field.MachineName.ToString());

                if (field.Raw[i] == (byte)MetaMachine.Text && name == null)
                {
                    name = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }
                else if (field.Raw[i] == (byte)MetaMachine.Text)
                {
                    name += " " + metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }
                else if (field.Raw[i] == (byte)MetaMachine.PhoneNumber)
                {
                    numbers.Add(metaResults[(int)field.OffsetFile + i].Field.FieldString);
                    proximityOffsets.Add(metaResults[(int)field.OffsetFile + i].Field.OffsetFile);
                }
                if (i == 0)
                {
                    startOffset = Math.Min(startOffset, metaResults[(int)field.OffsetFile + i].Field.OffsetFile);
                }
            }
            path.find_actual_path();
            fieldPaths.Add(path);

            var entries = new List <MetaAddressBookEntry>();

            for (int i = 0; i < numbers.Count; i++)
            {
                var entry = new MetaAddressBookEntry
                {
                    Name            = name,
                    Number          = numbers[i],
                    SevenDigit      = Utilities.GetLastSevenDigits(numbers[i]),
                    Offset          = startOffset,
                    MachineName     = field.MachineName,
                    ProximityOffset = proximityOffsets[i]
                };


                if (entry.Name == null)
                {
                    entry.Name = MetaField.DEFAULT_STRING;
                }

                if (entry.Number == null)
                {
                    entry.Number = MetaField.DEFAULT_STRING;
                }

                if (entry.SevenDigit == null)
                {
                    entry.SevenDigit = MetaField.DEFAULT_STRING;
                }

                entries.Add(entry);
            }

            return(entries);
        }
Exemplo n.º 8
0
        public MetaSms GetMetaSms(ViterbiField field, List <MetaResult> metaResults)
        {
            string   name        = null;
            string   number      = null;
            string   number2     = null;
            DateTime?timeStamp   = null;
            string   message     = null;
            long     startOffset = -1;

            for (int i = 0; i < field.Raw.Length; i++)
            {
                //if (field.Raw[i] == (byte)MetaMachine.Text && name == null)
                //    name = metaResults[(int)field.OffsetFile + i].Field.FieldString;

                if (field.Raw[i] == (byte)MetaMachine.PhoneNumber && number == null)
                {
                    number = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                else if (field.Raw[i] == (byte)MetaMachine.PhoneNumber && number2 == null)
                {
                    number2 = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                else if (field.Raw[i] == (byte)MetaMachine.TimeStamp && timeStamp == null)
                {
                    timeStamp = DateTime.Parse(metaResults[(int)field.OffsetFile + i].Field.FieldString);
                }

                else if (field.Raw[i] == (byte)MetaMachine.Text && message == null)
                {
                    message = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                if (startOffset == -1)
                {
                    startOffset = metaResults[(int)field.OffsetFile + i].Field.OffsetFile;
                }
            }



            var entry = new MetaSms()
            {
                Name        = name,
                Number      = number,
                Number2     = number2,
                SevenDigit  = Utilities.GetLastSevenDigits(number),
                SevenDigit2 = Utilities.GetLastSevenDigits(number2),
                TimeStamp   = timeStamp,
                Message     = message,
                Offset      = startOffset
            };

            if (entry.Name == null)
            {
                entry.Name = MetaField.DEFAULT_STRING;
            }

            if (entry.Number == null)
            {
                entry.Number = MetaField.DEFAULT_STRING;
            }

            if (entry.SevenDigit == null)
            {
                entry.SevenDigit = MetaField.DEFAULT_STRING;
            }

            if (entry.Number2 == null)
            {
                entry.Number2 = MetaField.DEFAULT_STRING;
            }

            if (entry.SevenDigit2 == null)
            {
                entry.SevenDigit2 = MetaField.DEFAULT_STRING;
            }

            if (entry.Message == null)
            {
                entry.Message = MetaField.DEFAULT_STRING;
            }

            if (entry.TimeStamp == null)
            {
                entry.TimeStamp = MetaField.DEFAULT_DATE;
            }

            return(entry);
        }
Exemplo n.º 9
0
        public List <MetaCallLog> GetMetaCallLog(ViterbiField field, List <MetaResult> metaResults)
        {
            string          name        = null;
            string          number      = null;
            List <DateTime> timeStamps  = new List <DateTime>();
            string          type        = null;
            long            startOffset = -1;

            for (int i = 0; i < field.Raw.Length; i++)
            {
                if (field.Raw[i] == (byte)MetaMachine.Text && name == null)
                {
                    name = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                else if (field.Raw[i] == (byte)MetaMachine.PhoneNumber && number == null)
                {
                    number = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                else if (field.Raw[i] == (byte)MetaMachine.TimeStamp)
                {
                    timeStamps.Add(DateTime.Parse(metaResults[(int)field.OffsetFile + i].Field.FieldString));
                }

                else if (field.Raw[i] == (byte)MetaMachine.CallLogType && type == null)
                {
                    type = metaResults[(int)field.OffsetFile + i].Field.FieldString;
                }

                if (startOffset == -1)
                {
                    startOffset = metaResults[(int)field.OffsetFile + i].Field.OffsetFile;
                }
            }

            var entries = new List <MetaCallLog>();

            for (int i = 0; i < timeStamps.Count; i++)
            {
                var entry = new MetaCallLog()
                {
                    Name       = name,
                    Number     = number,
                    SevenDigit = Utilities.GetLastSevenDigits(number),
                    TimeStamp  = timeStamps[i],
                    Type       = type,
                    Offset     = startOffset
                };

                if (entry.Name == null)
                {
                    entry.Name = MetaField.DEFAULT_STRING;
                }

                if (entry.Number == null)
                {
                    entry.Number = MetaField.DEFAULT_STRING;
                }

                if (entry.SevenDigit == null)
                {
                    entry.SevenDigit = MetaField.DEFAULT_STRING;
                }

                if (entry.Type == null)
                {
                    entry.Type = MetaField.DEFAULT_STRING;
                }

                if (entry.TimeStamp == null)
                {
                    entry.TimeStamp = MetaField.DEFAULT_DATE;
                }

                entries.Add(entry);
            }

            return(entries);
        }