예제 #1
0
        private static void Main(string[] args)
        {
            SetUpConsole();

            // HardCoded tests ...
            ClientVersion.SetVersion(ClientVersionBuild.V5_3_0_17128);
            Thread.Sleep(8000);

            //byte[] updateObject1 = { 0x5C, 0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x04, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x02, 0xCB, 0x00, 0x00, 0xA4, 0x58, 0x45, 0xDB, 0x0F, 0x49, 0x40, 0x80, 0x82, 0x31, 0x40, 0x00, 0x00, 0x90, 0x40, 0x6D, 0x1C, 0x97, 0x40, 0xCD, 0xAC, 0x35, 0x43, 0x00, 0x00, 0xE0, 0x40, 0x00, 0x00, 0xE0, 0x40, 0x00, 0x00, 0x20, 0x40, 0xDB, 0x0F, 0x49, 0x40, 0x00, 0x00, 0x90, 0x40, 0x71, 0xF5, 0xB7, 0x44, 0x00, 0x00, 0x20, 0x40, 0x3F, 0xDF, 0x00, 0x00, 0xC0, 0x82, 0x00, 0x80, 0x23, 0x78, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xC0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x01, 0x00, 0x00, 0x00, 0x18, 0x0A, 0x01, 0x00, 0x7B, 0x00, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5B, 0x09, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x2B, 0xC7, 0x3E, 0x00, 0x00, 0xC0, 0x3F, 0x98, 0x96, 0x00, 0x00, 0x98, 0x96, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x80, 0x3F, 0x0B, 0x07, 0x04, 0x0B, 0x05, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x89, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 };
            //byte[] spellCast1 = { 0x23, 0x32, 0x00, 0x00, 0x40, 0x1D, 0xE0, 0x43, 0x8A, 0x00, 0x00, 0xF0, 0x04, 0x31, 0x9E, 0x09, 0xF6, 0xDC, 0x08 };
            //byte[] spellStart1 = { 0x6E, 0xF6, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x3E, 0x80, 0x00, 0x02, 0xE0, 0x00, 0x00, 0x7D, 0xE0, 0x00, 0x04, 0x00, 0x08, 0xF0, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x00, 0x0C, 0x23, 0x00, 0x00, 0x00, 0x00, 0x81, 0x79, 0x07, 0x16, 0x65, 0x00, 0x00, 0x6B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xEA, 0x00, 0x00, 0x07, 0x79, 0x23, 0x02, 0x81, 0x56, 0xD2, 0x6A, 0x05, 0x00, 0x81, 0x02, 0x04, 0xDC, 0x09, 0x31, 0x9E, 0xF0, 0xF6, 0x02, 0x44, 0x07, 0x02, 0x00, 0x04, 0x00, 0x56, 0x43, 0x8A, 0x00, 0x00, 0x79, 0x56, 0x23 };
            //WowPacketParser.Parsing.Handler.Parse(new Packet(spellStart1, 7191, new DateTime(), Direction.ServerToClient, 1, ""));

            var files = args.ToList();

            if (files.Count == 0)
            {
                PrintUsage();
                return;
            }

            // config options are handled in Misc.Settings
            Utilities.RemoveConfigOptions(ref files);

            if (!Utilities.GetFiles(ref files))
            {
                EndPrompt();
                return;
            }

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            if (Settings.FilterPacketNumLow < 0)
            {
                throw new ConstraintException("FilterPacketNumLow must be positive");
            }

            if (Settings.FilterPacketNumHigh < 0)
            {
                throw new ConstraintException("FilterPacketNumHigh must be positive");
            }

            if (Settings.FilterPacketNumLow > 0 && Settings.FilterPacketNumHigh > 0 &&
                Settings.FilterPacketNumLow > Settings.FilterPacketNumHigh)
            {
                throw new ConstraintException("FilterPacketNumLow must be less or equal than FilterPacketNumHigh");
            }

            // Disable DB when we don't need its data (dumping to a binary file)
            if (Settings.DumpFormat == DumpFormatType.None || Settings.DumpFormat == DumpFormatType.Pkt ||
                Settings.DumpFormat == DumpFormatType.PktSplit || Settings.DumpFormat == DumpFormatType.SniffDataOnly)
            {
                SQLConnector.Enabled = false;
                SSHTunnel.Enabled    = false;
            }
            else
            {
                Filters.Initialize();
            }

            SQLConnector.ReadDB();

            var count = 0;

            foreach (var file in files)
            {
                SessionHandler.z_streams.Clear();
                ClientVersion.SetVersion(Settings.ClientBuild);
                new SniffFile(file, Settings.DumpFormat, Tuple.Create(++count, files.Count)).ProcessFile();
            }

            if (!String.IsNullOrWhiteSpace(Settings.SQLFileName))
            {
                Builder.DumpSQL("Dumping global sql", Settings.SQLFileName, "# multiple files\n");
            }

            SQLConnector.Disconnect();
            SSHTunnel.Disconnect();
            Logger.WriteErrors();

            EndPrompt();
        }
예제 #2
0
        private static void Main(string[] args)
        {
            SetUpConsole();

            var files = args.ToList();

            if (files.Count == 0)
            {
                PrintUsage();
                return;
            }

            // config options are handled in Misc.Settings
            Utilities.RemoveConfigOptions(ref files);

            if (!Utilities.GetFiles(ref files))
            {
                EndPrompt();
                return;
            }

            Thread.CurrentThread.CurrentCulture     = CultureInfo.InvariantCulture;
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            if (Settings.UseDBC)
            {
                var startTime = DateTime.Now;

                DBC.DBC.Load();

                var span = DateTime.Now.Subtract(startTime);
                Trace.WriteLine($"DBC loaded in { span.ToFormattedString() }.");
            }

            // Disable DB when we don't need its data (dumping to a binary file)
            if (!Settings.DumpFormatWithSQL())
            {
                SQLConnector.Enabled = false;
                SSHTunnel.Enabled    = false;
            }
            else
            {
                Filters.Initialize();
            }

            SQLConnector.ReadDB();

            var count = 0;

            foreach (var file in files)
            {
                SessionHandler.ZStreams.Clear();
                if (Settings.ClientBuild != Enums.ClientVersionBuild.Zero)
                {
                    ClientVersion.SetVersion(Settings.ClientBuild);
                }

                try
                {
                    var sf = new SniffFile(file, Settings.DumpFormat, Tuple.Create(++count, files.Count));
                    sf.ProcessFile();
                }
                catch (IOException ex)
                {
                    Console.WriteLine($"Can't process {file}. Skipping. Message: {ex.Message}");
                }
            }

            if (!string.IsNullOrWhiteSpace(Settings.SQLFileName) && Settings.DumpFormatWithSQL())
            {
                Builder.DumpSQL("Dumping global sql", Settings.SQLFileName, SniffFile.GetHeader("multi"));
            }

            SQLConnector.Disconnect();
            SSHTunnel.Disconnect();

            if (Settings.LogErrors)
            {
                Logger.WriteErrors();
            }

            Trace.Listeners.Remove("ConsoleMirror");

            EndPrompt();
        }
예제 #3
0
        private static void Main(string[] args)
        {
            SetUpConsole();

            var files = args.ToList();

            if (files.Count == 0)
            {
                PrintUsage();
                return;
            }

            // config options are handled in Misc.Settings
            Utilities.RemoveConfigOptions(ref files);

            if (!Utilities.GetFiles(ref files))
            {
                EndPrompt();
                return;
            }

            Thread.CurrentThread.CurrentCulture     = CultureInfo.InvariantCulture;
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            // Disable DB when we don't need its data (dumping to a binary file)
            if (!Settings.DumpFormatWithSQL())
            {
                SQLConnector.Enabled = false;
                SSHTunnel.Enabled    = false;
            }
            else
            {
                Filters.Initialize();
            }

            SQLConnector.ReadDB();

            var count = 0;

            foreach (var file in files)
            {
                SessionHandler.ZStreams.Clear();
                ClientVersion.SetVersion(Settings.ClientBuild);
                var sf = new SniffFile(file, Settings.DumpFormat, Tuple.Create(++count, files.Count));
                sf.ProcessFile();
            }

            if (!String.IsNullOrWhiteSpace(Settings.SQLFileName) && Settings.DumpFormatWithSQL())
            {
                Builder.DumpSQL("Dumping global sql", Settings.SQLFileName, SniffFile.GetHeader("multi"));
            }

            SQLConnector.Disconnect();
            SSHTunnel.Disconnect();

            if (Settings.LogErrors)
            {
                Logger.WriteErrors();
            }

            Trace.Listeners.Remove("ConsoleMirror");

            EndPrompt();
        }
예제 #4
0
        private static void Main(string[] args)
        {
            SetUpConsole();

            var files = args.ToList();

            if (files.Count == 0)
            {
                PrintUsage();
                return;
            }

            // config options are handled in Misc.Settings
            Utilities.RemoveConfigOptions(ref files);

            if (!Utilities.GetFiles(ref files))
            {
                EndPrompt();
                return;
            }

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            if (Settings.FilterPacketNumLow < 0)
            {
                throw new ConstraintException("FilterPacketNumLow must be positive");
            }

            if (Settings.FilterPacketNumHigh < 0)
            {
                throw new ConstraintException("FilterPacketNumHigh must be positive");
            }

            if (Settings.FilterPacketNumLow > 0 && Settings.FilterPacketNumHigh > 0 &&
                Settings.FilterPacketNumLow > Settings.FilterPacketNumHigh)
            {
                throw new ConstraintException("FilterPacketNumLow must be less or equal than FilterPacketNumHigh");
            }

            // Disable DB when we don't need its data (dumping to a binary file)
            if (Settings.DumpFormat == DumpFormatType.Pkt)
            {
                SQLConnector.Enabled = false;
                SSHTunnel.Enabled    = false;
            }
            else
            {
                Filters.Initialize();
            }

            SQLConnector.ReadDB();

            var count = 0;

            foreach (var file in files)
            {
                ClientVersion.SetVersion(Settings.ClientBuild);
                new SniffFile(file, Settings.DumpFormat, Settings.SplitOutput, Tuple.Create(++count, files.Count),
                              Settings.SQLOutput).ProcessFile();
            }

            SQLConnector.Disconnect();
            SSHTunnel.Disconnect();
            Logger.WriteErrors();

            EndPrompt();
        }
예제 #5
0
        private static void Main(string[] args)
        {
            Utilities.SetUpListeners();
            var files = args.ToList();

            if (!Utilities.GetFiles(ref files))
            {
                EndPrompt();
                return;
            }

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            ClientVersion.SetVersion(Settings.ClientBuild);

            if (Settings.FilterPacketNumLow < 0)
            {
                throw new ConstraintException("FilterPacketNumLow must be positive");
            }

            if (Settings.FilterPacketNumHigh < 0)
            {
                throw new ConstraintException("FilterPacketNumHigh must be positive");
            }

            if (Settings.FilterPacketNumLow > Settings.FilterPacketNumHigh)
            {
                throw new ConstraintException("FilterPacketNumLow must be less or equal than FilterPacketNumHigh");
            }

            // Disable DB when we don't need its data (dumping to a binary file)
            if (Settings.DumpFormat == DumpFormatType.Pkt)
            {
                SQLConnector.Enabled = false;
                SSHTunnel.Enabled    = false;
            }
            else
            {
                Filters.Initialize();
            }

            SQLConnector.ReadDB();

            var numberOfThreadsRead  = Settings.ThreadsRead != 0 ? Settings.ThreadsRead.ToString(CultureInfo.InvariantCulture) : "a recommended number of";
            var numberOfThreadsParse = Settings.ThreadsParse != 0 ? Settings.ThreadsParse.ToString(CultureInfo.InvariantCulture) : "a recommended number of";

            Trace.WriteLine(string.Format("Using {0} threads to process {1} files", numberOfThreadsRead, files.Count));

            var startTime = DateTime.Now;
            var count     = 0;

            if (Settings.ThreadsRead == 0) // Number of threads is automatically choosen by the Parallel library
            {
                files.AsParallel().SetCulture()
                .ForAll(file =>
                        ReadFile(file, "[" + (++count).ToString(CultureInfo.InvariantCulture) + "/" + files.Count + " " + file + "]"));
            }
            else
            {
                files.AsParallel().SetCulture().WithDegreeOfParallelism(Settings.ThreadsRead)
                .ForAll(file => ReadFile(file, "[" + (++count).ToString(CultureInfo.InvariantCulture) + "/" + files.Count + " " + file + "]"));
            }

            if (Settings.StatsOutput.HasAnyFlag(StatsOutputFlags.Global))
            {
                var span = DateTime.Now.Subtract(startTime);
                Trace.WriteLine(string.Format("Parsed {0} packets from {1} files: {2:F3}% successfully, {3:F3}% with errors and skipped {4:F3}% in {5} Minutes, {6} Seconds and {7} Milliseconds using {8} threads",
                                              GlobalStatsTotal, files.Count, (double)GlobalStatsOk / GlobalStatsTotal * 100,
                                              (double)GlobalStatsError / GlobalStatsTotal * 100, (double)GlobalStatsSkip / GlobalStatsTotal * 100,
                                              span.Minutes, span.Seconds, span.Milliseconds, numberOfThreadsParse));
            }

            if (Settings.SQLOutput != 0)
            {
                string sqlFileName;
                if (String.IsNullOrWhiteSpace(Settings.SQLFileName))
                {
                    sqlFileName = files.Aggregate(string.Empty, (current, file) => current + Path.GetFileNameWithoutExtension(file)) + ".sql";
                }
                else
                {
                    sqlFileName = Settings.SQLFileName;
                }

                Builder.DumpSQL("Dumping global sql", sqlFileName, Settings.SQLOutput);
            }

            SQLConnector.Disconnect();
            SSHTunnel.Disconnect();
            Logger.WriteErrors();
            EndPrompt();
        }