Example #1
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;
        }
Example #2
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;
        }
Example #3
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;
        }
Example #4
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;
        }
Example #5
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;
        }
        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;
        }
        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;
        }
        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;
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="index"></param>
        /// <returns>The first index after the end of the field</returns>
        private ViterbiField ExtractField(List <State> path, int index)
        {
            int         startIndex  = index;
            MachineList machineName = path[index].ParentStateMachine.Name;
            string      fieldHex    = "0x";
            string      fieldAscii  = "";
            List <byte> fieldBytes  = new List <byte>();

            while (index < path.Count && machineName == path[index].ParentStateMachine.Name)
            {
                fieldBytes.Add(_observations[index]);

                //If this is an anchor run, no need to print fields
                if (!_isAnchor)
                {
                    string observation = Convert.ToString(_observations[index], 16).PadLeft(2, '0');

                    fieldHex   += observation;
                    fieldAscii += (char)_observations[index];

#if PRINT_ALL
                    Console.WriteLine("{0}\t:\t{1}\t{2}", path[index], observation, (char)_observations[index]);
#endif
                }
                index++;

                //Allows us to distinguish between adjacent fields of the same type
                if (path[index - 1].IsSplitState)
                {
                    break;
                }
            }

            string fieldString;
            if (!_isAnchor && ((machineName == MachineList.PhoneNumber_User) ||
                               (machineName == MachineList.TimeStamp_User) ||
                               (machineName == MachineList.TimeStamp_User)))
            {
                // If we're printing a user-defined field then we need to use the user-defined
                // methods.
                try {
                    UserDefinedState udState = path[index - 1] as UserDefinedState;
                    fieldString = Printer.GetUserField(machineName, fieldBytes.ToArray(), udState.UserStateObj);
                } catch {
                    fieldString = "???";
                }
            }
            else
            {
                fieldString = _isAnchor ? "" : Printer.GetField(machineName, fieldBytes.ToArray());
            }

            var field = new ViterbiField
            {
                OffsetPath  = startIndex,
                OffsetFile  = _fileOffset + startIndex,
                HexString   = fieldHex,
                AsciiString = fieldAscii,
                FieldString = fieldString,
                MachineName = machineName,
                Raw         = fieldBytes.ToArray()
            };

            _textList.Add(fieldString);
            _fieldList.Add(field);

            #if PRINT_FIELD
            Console.WriteLine(field);
            #endif

            return(field);
        }
Example #10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <param name="index"></param>
        /// <returns>The first index after the end of the field</returns>
        private ViterbiField ExtractField(List<State> path, int index)
        {
            int startIndex = index;
            MachineList machineName = path[index].ParentStateMachine.Name;
            string fieldHex = "0x";
            string fieldAscii = "";
            List<byte> fieldBytes = new List<byte>();

            while (index < path.Count && machineName == path[index].ParentStateMachine.Name)
            {
                fieldBytes.Add(_observations[index]);

                //If this is an anchor run, no need to print fields
                if (!_isAnchor)
                {
                    string observation = Convert.ToString(_observations[index], 16).PadLeft(2, '0');

                    fieldHex += observation;
                    fieldAscii += (char) _observations[index];

            #if PRINT_ALL
                Console.WriteLine("{0}\t:\t{1}\t{2}", path[index], observation, (char)_observations[index]);
            #endif

                }
                index++;

                //Allows us to distinguish between adjacent fields of the same type
                if (path[index-1].IsSplitState)
                    break;
            }

            string fieldString;
            if (!_isAnchor && ((machineName == MachineList.PhoneNumber_User) ||
                               (machineName == MachineList.TimeStamp_User) ||
                               (machineName == MachineList.TimeStamp_User))) {
                // If we're printing a user-defined field then we need to use the user-defined
                // methods.
                try {
                    UserDefinedState udState = path[index - 1] as UserDefinedState;
                    fieldString = Printer.GetUserField(machineName, fieldBytes.ToArray(), udState.UserStateObj);
                } catch {
                    fieldString = "???";
                }
            } else {
                fieldString = _isAnchor ? "" : Printer.GetField(machineName, fieldBytes.ToArray());
            }

            var field = new ViterbiField
                            {
                                OffsetPath = startIndex,
                                OffsetFile = _fileOffset + startIndex,
                                HexString = fieldHex,
                                AsciiString = fieldAscii,
                                FieldString = fieldString,
                                MachineName = machineName,
                                Raw = fieldBytes.ToArray()
                            };

            _textList.Add(fieldString);
            _fieldList.Add(field);

            #if PRINT_FIELD

            Console.WriteLine(field);

            #endif

            return field;
        }