private static void Main(string[] args)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
CmdLine = new CommandLine(args);
string file;
string loader;
string filters;
string format;
string nodump;
try
{
file = CmdLine.GetValue("-file");
loader = CmdLine.GetValue("-loader");
filters = CmdLine.GetValue("-filters");
format = CmdLine.GetValue("-sql");
nodump = CmdLine.GetValue("-nodump");
}
catch (IndexOutOfRangeException)
{
PrintUsage("All command line options require an argument.");
return;
}
try
{
var packets = Reader.Read(loader, file);
if (packets == null)
{
PrintUsage("Could not open file " + file + " for reading.");
return;
}
if (packets.Count() > 0)
{
var fullPath = Utilities.GetPathFromFullPath(file);
Handler.InitializeLogFile(Path.Combine(fullPath, file + ".txt"), nodump);
SQLOutput.SQLOutput.Initialize(Path.Combine(fullPath, file + ".sql"), format);
var appliedFilters = filters.Split(',');
foreach (var packet in packets)
{
var opcode = packet.GetOpcode().ToString();
if (!string.IsNullOrEmpty(filters))
{
foreach (var opc in appliedFilters)
{
if (!opcode.Contains(opc))
continue;
Handler.Parse(packet);
break;
}
}
else
Handler.Parse(packet);
}
SQLOutput.SQLOutput.WriteToFile();
Handler.WriteToFile();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.GetType());
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
Console.ResetColor();
}