Beispiel #1
0
        private static void RunDec0de()
        {
            RunType runType;

            try
            {
                if(String.IsNullOrEmpty(_options.Run))
                    runType = RunType.GeneralParse;
                else
                    runType = (RunType)Enum.Parse(typeof(RunType), _options.Run, true);
            }
            catch (Exception)
            {
                Console.WriteLine("Unrecognized RunType.");
                return;
            }

            var blocklist = (new NoFilter(_options.Image, 32768)).Filter().UnfilteredBlocks;

            var viterbi = new ThreadedViterbi(blocklist, runType, null, _options.Image, null);
            var results = viterbi.RunThreadedViterbi();

            for (int i = 0; i < results.Fields.Count; i++)
            {
                Console.WriteLine("{0} ({2}): {1}",
                    results.Fields[i].MachineName,
                    results.Fields[i].FieldString,
                    results.Fields[i].Length);
            }
        }
Beispiel #2
0
        private ViterbiResult RunViterbi(FilterResult filterResult, string fileSha1)
        {
            // Load any user-defined state machines.
            List<UserState> userStates;
            try
            {
                userStates = Loader.LoadUserStates(MainForm.Program.UserStatesEnabled,
                                                   MainForm.Program.UserStatesPath);
            }
            catch (Exception ex)
            {
                DisplayExceptionMessages(ex, "User-Defined States");
                return null;
            }
            ViterbiResult viterbiResultFields = null;

            try
            {
                write("Running Viterbi on fields");
                DateTime dt = DateTime.Now;
            #if _GENERALPARSE
                Viterbi viterbi = new Viterbi(RunType.GeneralParse, false);
                viterbiResultFields = viterbi.Run(filterResult.UnfilteredBlocks, this.filePath);
            #else
            #if SKIPREALWORK
                    viterbiResultFields = new ViterbiResult();
                    viterbiResultFields.Fields = new List<ViterbiField>();
            #else
                if (filterResult.UnfilteredBlocks.Count > 0)
                {
                    ThreadedViterbi tv = new ThreadedViterbi(filterResult.UnfilteredBlocks, RunType.GeneralParse, userStates, this.filePath, this.fileSha1);
                    viterbiResultFields = tv.RunThreadedViterbi();
                    TimeSpan ts = DateTime.Now.Subtract(dt);
                    write("Time elapsed for Viterbi fields: {0}", ts.ToString("c"));
                    write("Field count: {0}", viterbiResultFields.Fields.Count);
                }
            #endif
            #endif
                filterResult.UnfilteredBlocks.Clear(); // Allow gc to clean things up
            }
            catch (ThreadAbortException)
            {
                return null;
            }
            catch (Exception ex)
            {
                DisplayExceptionMessages(ex, "Viterbi Fields");
                return null;
            }
            return viterbiResultFields;
        }
Beispiel #3
0
 private ViterbiResult RunMetaViterbi(ViterbiResult viterbiResultFields, List<MetaField> addressBookEntries, List<MetaField> callLogs, List<MetaField> sms)
 {
     ViterbiResult viterbiResultRecord = null;
     try
     {
         if (viterbiResultFields != null)
         {
             write("Running Viterbi on records");
             DateTime dt = DateTime.Now;
             metaResults = CreateMetaInfo(viterbiResultFields.Fields);
             Block block = new Block()
             {
                 Bytes = metaResults.Select(r => (byte)r.Name).ToArray(),
                 OffsetFile = 0
             };
             var blockList = new List<Block> { block };
             List<UserState> user_state = new List<UserState>();
             ThreadedViterbi tv = new ThreadedViterbi(blockList, RunType.Meta, user_state, this.filePath, this.fileSha1);
             viterbiResultRecord = tv.RunThreadedViterbi();
     #if false
             TextWriter tw = null;
             try {
                 if (viterbiResultRecord == null) throw new Exception("No results");
                 tw = new StreamWriter(Path.Combine(@"C:\temp", String.Format("Records_{0}.csv", DateTime.Now.ToString("yyyyMMdd_HHmm"))));
                 foreach (ViterbiField f in viterbiResultRecord.Fields) {
                     tw.WriteLine("{0}\t{1}\t{2}", f.OffsetFile, f.FieldString, f.MachineName.ToString());
                 }
             } catch (Exception ex) {
             } finally {
                 if (tw != null) tw.Close();
             }
     #endif
             TimeSpan ts = DateTime.Now.Subtract(dt);
             write("Time elapsed for Viterbi records: {0}", ts.ToString("c"));
             InterpretResults(metaResults, viterbiResultRecord, addressBookEntries, callLogs, sms);
             write("Entries: call log = {0}, address book = {1}, sms = {2}", callLogs.Count,
                   addressBookEntries.Count,
                   sms.Count);
         }
     }
     catch (ThreadAbortException)
     {
         return null;
     }
     catch (Exception ex)
     {
         DisplayExceptionMessages(ex, "Viterbi Records");
         return null;
     }
     return viterbiResultRecord;
 }