Example #1
0
        static int Main(string[] args)
        {
            StringArgument ss     = new StringArgument("ss", "Screenshot", "Path to destination image file");
            StringArgument hw     = new StringArgument("hw", "Hide Window", "Process name to hide main process window");
            StringArgument cs     = new StringArgument("cs", "Send Close Signal", "Process name to send a close signal");
            ArgumentParser parser = new ArgumentParser("ViniSandboxTools", "This application is able to take screenshots, hide main window from a process and send close signal to a process.");

            parser.Add("\\", "ss", ss);
            parser.Add("\\", "hw", hw);
            parser.Add("\\", "cs", cs);

            if (parser.HelpMode)
            {
                parser.WriteLongArgumentsUsage();
                return(0);
            }

            try
            {
                parser.Parse(args);
            }
            catch (Exception ex)
            {
                parser.WriteShortArgumentsUsage();
                return(-1);
            }

            try
            {
                if (hw.Defined)
                {
                    HideWindow(hw.Value);
                }
                if (cs.Defined)
                {
                    SendCloseSignal(cs.Value);
                }
                if (ss.Defined)
                {
                    takeScreenshot(ss.Value);
                }
                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(-1);
            }
        }
Example #2
0
        public static int Main(string[] vargs)
        {
            int timeout = 648000;

            ArgumentParser parser   = new ArgumentParser("VirusTotal.NET", "This application perform a scan of a file on virustotal.com");
            StringArgument outPath  = new StringArgument("out", "output file", "output file to store scan result");
            StringArgument filePath = new StringArgument("f", "File", "File to be scanned");

            parser.Add("\\", "out", outPath);
            parser.Add("\\", "file", filePath);

            if (parser.HelpMode)
            {
                parser.WriteLongArgumentsUsage();
                return(0);
            }

            try
            {
                parser.Parse(vargs);
                if (!filePath.Defined)
                {
                    throw new Exception();
                }
                try
                {
                    string outFile = "";
                    if (outPath.Defined)
                    {
                        outFile = outPath.Value;
                    }
                    var report = VirusTotalScanner.Scan(filePath.Value, timeout);
                    printResult(report, outFile);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                return(0);
            }
            catch (Exception e)
            {
                parser.WriteShortArgumentsUsage();
                return(-1);
            }
        }
Example #3
0
        static void ParseArguments(ref string[] args)
        {
            ArgumentParser parser   = new ArgumentParser("CameraTrackSolver", "Uses track files generated by the CameraTrack app and solves a camera animation from that.");
            Regex          cmdRegex = new Regex(@"'?(?<val>.*?)(?:'|$)");

            parser.AboutTitleText         = "CameraTrack Solver";
            parser.AboutText              = "Uses track files generated by the CameraTrack app and solves a camera animation from that.";
            parser.AboutTextLong          = "foo";
            parser.CreditsText            = "Copyright (C) 2016 Stefan Hahn";
            parser.LegalText              = "BSD License";
            parser.HasApplicationDocument = true;

            parser.Add("/", "track", "Track", trackFileArgument);
            parser.Add("/", "chan", "Chan", chanFileArgument);
            parser.Add("/", "fps", "Fps", fpsArgument);

            parser.Parse(args);

            if (!parser.HelpMode)
            {
                if (!fpsArgument.Defined)
                {
                    throw new ArgumentException("FPS argument missing", "fps");
                }

                if (!trackFileArgument.Defined)
                {
                    throw new ArgumentException("Track file argument missing", "track");
                }

                if (!chanFileArgument.Defined)
                {
                    throw new ArgumentException("Chan file argument missing", "chan");
                }

                fps           = double.Parse(cmdRegex.Match(fpsArgument.Value).Groups["val"].Value);
                trackFilepath = cmdRegex.Match(trackFileArgument.Value).Groups["val"].Value;
                chanFilepath  = cmdRegex.Match(chanFileArgument.Value).Groups["val"].Value;
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ArgumentParser parser = new ArgumentParser("FakeDnsServer", "This application simulate a DNS Server, log all DNS queries and answer always to the specified ip address");

            parser.Add("\\", "ip", IpArg);
            parser.Add("\\", "log", logFile);

            frmMain frm = null;

            try
            {
                parser.Parse(args);
                frm = new frmMain(IpArg.Value, logFile.Value);
            }
            catch (Exception)
            {
                parser.WriteShortArgumentsUsage();
                frm = new frmMain();
            }
            Application.Run(frm);
        }
Example #5
0
        public void setParameters()
        {
            Parser.Add("-", "i", "i", InputFileArgument);
            Parser.Add("-", "o", "o", OutputFileArgument);
            Parser.Add("-", "t", "t", TaxFileArgument);
            Parser.Add("-", "if", "if", FormatInputFile);
            Parser.Add("-", "of", "of", FormatOutputFile);
            Parser.Add("-", "tf", "tf", FormatTaxFile);

            Parser.AboutText   = "Payroll calculator is a tool to easy calculate your payroll!\\n If you have a custom provider, please attach your assembly with the implementataion of IFormatHelper, the program will load it automatically";
            Parser.CreditsText = "David Cohan";
            Parser.UsageText   = "payrollConsole -i /path/to/input/file -o /path/to/output/file -if CSV - of JSON";
        }
        static void Main(string[] args)
        {
            ConsoleColorState state = RC.ColorState;

            // create the argument parser
            ArgumentParser parser = new ArgumentParser("SettingsObjectModelCodeGenerator", "Generates settings object model code for the ImuApi project");

            StringArgument XmlArg           = new StringArgument("XML", "The path of the settings XML file", "The path of the settings XML file");
            StringArgument CodeArg          = new StringArgument("Code", "The destination code .cs file", "The destination code .cs file");
            StringArgument DocumentationArg = new StringArgument("Documentation", "The documentation .XML file", "The documentation .XML file");

            // add the arguments to the parser
            parser.Add("/", "XML", XmlArg);
            parser.Add("/", "Code", CodeArg);
            parser.Add("/", "Documentation", DocumentationArg);

            try
            {
                RC.IsBuildMode = true;
                RC.Verbosity   = ConsoleVerbosity.Debug;
                RC.ApplicationBuildReportPrefix = "SGEN";

                RC.Theme = ConsoleColorTheme.Load(ConsoleColorDefaultThemes.Colorful);

                RC.WriteLine(ConsoleThemeColor.TitleText, "Settings Object Model Code Generator");

                // parse arguemnts
                parser.Parse(args);

                // did the parser detect a /? arguemnt
                if (parser.HelpMode == true)
                {
                    return;
                }

                if (XmlArg.Defined == false)
                {
                    RC.WriteError(001, "No settings XML file supplied.");
                    return;
                }

                if (CodeArg.Defined == false)
                {
                    RC.WriteError(001, "No destination file supplied.");
                    return;
                }

                if (DocumentationArg.Defined == false)
                {
                    RC.WriteError(001, "No documentation file supplied.");
                    return;
                }

                string xmlFilePath = XmlArg.Value;

                if (File.Exists(xmlFilePath) == false)
                {
                    RC.WriteError(002, "Settings XML file does not exist.");
                    return;
                }

                string codeFilePath = CodeArg.Value;

                try
                {
                    FileInfo info = new FileInfo(codeFilePath);
                }
                catch
                {
                    RC.WriteError(002, "Settings destination file is not valid.");
                    return;
                }

                string documentationFilePath = DocumentationArg.Value;

                try
                {
                    FileInfo info = new FileInfo(documentationFilePath);
                }
                catch
                {
                    RC.WriteError(002, "Settings documentation file is not valid.");
                    return;
                }

                Generate(xmlFilePath, codeFilePath, documentationFilePath);
            }
            catch (Exception ex)
            {
                RC.WriteException(04, System.Reflection.Assembly.GetExecutingAssembly().Location, 0, 0, ex);
            }
            finally
            {
                //RC.PromptForKey("Press any key to exit..", true, false);

                RC.ColorState = state;
            }
        }
Example #7
0
        public static void Main(string[] args)
        {
            if (IsSingleInstance())
            {
                StringArgument silentArg  = new StringArgument("quiet", "Hide application window", "Run application in background");
                StringArgument logFileArg = new StringArgument("log", "Log File", "Path to log file");
                StringArgument verbArg    = new StringArgument("verbose", "Verbose level", "3 - Debug\r\n2 - Normal\r\n1 - Error");
                ArgumentParser argParser  = new ArgumentParser("Vinisandbox", "Analyze static and dynamically file");
                argParser.Add("\\", "quiet", silentArg);
                argParser.Add("\\", "log", logFileArg);
                argParser.Add("\\", "verbose", verbArg);

                LogManager.VerboseLevel = LogManager.EVerboseLevel.Normal;

                try
                {
                    if (args.Contains("\\quiet"))
                    {
                        var aux = args.ToList();
                        aux.Remove("\\quiet");
                        args = aux.ToArray();
                        HideWindow();
                    }
                    argParser.Parse(args);
                    if (argParser.HelpMode)
                    {
                        argParser.WriteLongArgumentsUsage();
                        Console.Read();
                        return;
                    }
                    if (logFileArg.Defined)
                    {
                        LogManager.LogPath = (string)logFileArg.ObjectValue;
                        try
                        {
                            if (!File.Exists(LogManager.LogPath))
                            {
                                File.Create(LogManager.LogPath).Close();
                            }
                        }
                        catch (Exception)
                        {
                            LogManager.WriteLine("Invalid Log File", LogManager.EVerboseLevel.Error);
                            argParser.WriteShortArgumentsUsage();
                            Console.Read();
                            return;
                        }
                    }
                    if (verbArg.Defined)
                    {
                        try
                        {
                            LogManager.VerboseLevel = (LogManager.EVerboseLevel)Enum.ToObject(typeof(LogManager.EVerboseLevel), Convert.ToInt32((string)verbArg.ObjectValue));
                        }
                        catch (Exception)
                        {
                            LogManager.WriteLine("Invalid Verbose level", LogManager.EVerboseLevel.Error);
                            argParser.WriteShortArgumentsUsage();
                            Console.Read();
                            return;
                        }
                    }
                    LogManager.WriteLine("Arguments Parsed", LogManager.EVerboseLevel.Debug);
                }
                catch (Exception)
                {
                }

                vinisandboxContext cx = null;
                try
                {
                    cx = new vinisandboxContext();
                    LogManager.WriteLine("DbContext created", LogManager.EVerboseLevel.Debug);
                }
                catch (Exception ex)
                {
                    LogManager.WriteLine("Error on create DbContext: " + ex.ToString(), LogManager.EVerboseLevel.Error);
                    return;
                }
                //cx.Configuration.ProxyCreationEnabled = true;
                //cx.Configuration.LazyLoadingEnabled = true;
                Configuration config = null;
                try
                {
                    config = LoadConfiguration();
                    LogManager.WriteLine("Configuration Loaded", LogManager.EVerboseLevel.Debug);
                }
                catch (Exception ex)
                {
                    LogManager.WriteLine("Error on load configurations:" + ex.ToString(), LogManager.EVerboseLevel.Error);
                    return;
                }

                Sandbox sandbox = null;
                try
                {
                    sandbox = new Sandbox(config);
                    LogManager.WriteLine("Sandbox instanciated", LogManager.EVerboseLevel.Debug);
                }
                catch (Exception ex)
                {
                    LogManager.WriteLine("Error on instanciate Sandbox: " + ex.ToString(), LogManager.EVerboseLevel.Error);
                    return;
                }

                try
                {
                    DirectoryInfo di = new DirectoryInfo(config.TempFolder);
                    di.Create();
                    LogManager.WriteLine("Temporary directory created", LogManager.EVerboseLevel.Debug);
                }
                catch (Exception ex)
                {
                    LogManager.WriteLine("Error on create temporary directory: " + ex.ToString(), LogManager.EVerboseLevel.Error);
                    return;
                }

                /*string pat = @"C:\Users\Vinicius\Downloads\sed-4.2.1-setup.exe";
                 * file_detail fd = new file_detail();
                 * fd.data = File.ReadAllBytes(pat);
                 * fd.files = new List<file>();
                 * fd.files.Add(new file() { name = "sed-4.2.1-setup.exe" });
                 * cx.file_detail.Add(fd);
                 * cx.SaveChanges();*/

                LogManager.WriteLine("Waiting for files", LogManager.EVerboseLevel.Normal);
                while (true)
                {
                    foreach (var file_det in cx.file_detail.Where(p => !p.analyzed.HasValue || !p.analyzed.Value).Include("files").ToList())
                    {
                        sandbox.Analyze(file_det);

                        /*foreach (var file in file_det.files)
                         * {
                         *  file.analyzed = true;
                         * }*/
                        file_det.analyzed = true;
                        try
                        {
                            cx.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                        }
                    }
                    Thread.Sleep(config.CheckFrequence);
                }
            }
            else
            {
                Console.WriteLine("Ja existe outra instancia do programa rodando.");
            }
        }
Example #8
0
        //private static bool checkFile(string path)
        //{
        //    return File.Exists(path);
        //}

        public static void Main(string[] args)
        {
            if (IsSingleInstance())
            {
                StringArgument silentArg  = new StringArgument("quiet", "Hide application window", "Run application in background");
                StringArgument logFileArg = new StringArgument("log", "Log File", "Path to log file");
                StringArgument verbArg    = new StringArgument("verbose", "Verbose level", "3 - Debug\r\n2 - Normal\r\n1 - Error");
                ArgumentParser argParser  = new ArgumentParser("Vinisandbox", "Analyze static and dynamically file");
                argParser.Add("\\", "\\quiet", silentArg);
                argParser.Add("\\", "\\log", logFileArg);
                argParser.Add("\\", "\\v", verbArg);

                LogManager.VerboseLevel = LogManager.EVerboseLevel.Normal;

                try
                {
                    argParser.Parse(args);

                    if (silentArg.Defined)
                    {
                        HideWindow();
                    }
                    if (logFileArg.Defined)
                    {
                        LogManager.LogPath = (string)logFileArg.ObjectValue;
                        try
                        {
                            File.Create(LogManager.LogPath);
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Invalid Log File");
                            argParser.WriteShortArgumentsUsage();
                            Console.Read();
                            return;
                        }
                    }
                    if (verbArg.Defined)
                    {
                        try
                        {
                            LogManager.VerboseLevel = (LogManager.EVerboseLevel)Enum.ToObject(typeof(LogManager.EVerboseLevel), (string)verbArg.ObjectValue);
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Invalid Verbose level");
                            argParser.WriteShortArgumentsUsage();
                            Console.Read();
                            return;
                        }
                    }
                }
                catch (Exception)
                {
                }

                vinisandboxContext cx = new vinisandboxContext();
                cx.Configuration.ProxyCreationEnabled = true;
                cx.Configuration.LazyLoadingEnabled   = true;


                Configuration config  = LoadConfiguration();
                Sandbox       sandbox = new Sandbox(config);

                DirectoryInfo di = new DirectoryInfo(config.TempFolder);
                di.Create();

                /*string pat = @"C:\Users\Vinicius\Downloads\sed-4.2.1-setup.exe";
                 * file_detail fd = new file_detail();
                 * fd.data = File.ReadAllBytes(pat);
                 * fd.files = new List<file>();
                 * fd.files.Add(new file() { name = "sed-4.2.1-setup.exe" });
                 * cx.file_detail.Add(fd);
                 * cx.SaveChanges();*/
                while (true)
                {
                    foreach (var file_det in cx.file_detail.Where(p => p.files.Count(j => j.analyzed == false) > 0).Include("files").ToList())
                    {
                        sandbox.Analyze(file_det);
                        foreach (var file in file_det.files)
                        {
                            file.analyzed = true;
                        }
                        try
                        {
                            cx.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                        }
                    }
                    Thread.Sleep(10000);
                }
            }
            else
            {
                Console.WriteLine("Ja existe outra instancia do programa rodando.");
            }
            //if (args.Length != 1)
            //{
            //    //Erro
            //    Console.WriteLine("Parametros errados.");
            //    return;
            //}
            //if (!checkFile(args[0]))
            //{
            //    Console.WriteLine(args[0] + " não foi encontrado.");
            //    return;
            //}
            //if (IsSingleInstance())
            //{
            //    StartServer();
            //    Sandbox s = new Sandbox(LoadConfiguration());
            //    listMutex.WaitOne();
            //    files.Add(args[0]);
            //    while (files.Count != 0)
            //    {
            //        listMutex.ReleaseMutex();
            //        s.Analyze(files[0]);
            //        files.RemoveAt(0);
            //        //faz analise
            //        listMutex.WaitOne();
            //    }
            //    ServerRunning = false;
            //    programMutex.Close();
            //}
            //else
            //{
            //    SendPath(args[0]);
            //}
        }
Example #9
0
        static RpxInterface()
        {
            Title = Strings.App_Title + " " + typeof(Program).Assembly.GetName().Version.ToString();

            Parser = new ArgumentParser("Rpx", Title + "\n" + Strings.App_AboutText);

            Parser.AboutTitleText         = Title;
            Parser.AboutText              = Strings.App_AboutText;
            Parser.AboutTextLong          = Strings.App_AboutTextLong;
            Parser.CreditsText            = Strings.App_CreditsText;
            Parser.LegalText              = Strings.App_LegalText;
            Parser.HasApplicationDocument = true;

            PathString = new StringArgument(Strings.Arg_PathString_Name, Strings.Arg_PathString_ShortHelp, Strings.Arg_PathString_Help);
            FileList   = new StringListArgument(Strings.Arg_FileList_Name, "", Strings.Arg_FileList_Help);

            Parser.FirstArgument   = PathString;
            Parser.DefaultArgument = FileList;

            AssemblyInfoPath = new StringArgument(Strings.Arg_AssemblyInfoPath_Name, Strings.Arg_AssemblyInfoPath_ShortHelp, Strings.Arg_AssemblyInfoPath_Help);
            IconPath         = new StringArgument(Strings.Arg_IconPath_Name, Strings.Arg_IconPath_ShortHelp, Strings.Arg_IconPath_Help);
            OutputPath       = new StringArgument(Strings.Arg_OutputPath_Name, Strings.Arg_OutputPath_ShortHelp, Strings.Arg_OutputPath_Help);
            ConsoleSwitch    = new PlusMinusSwitch(Strings.Arg_ConsoleSwitch_ShortHelp, Strings.Arg_ConsoleSwitch_Help, true);
            PassArgsSwitch   = new BoolSwitch(Strings.Arg_PassArgsSwitch_ShortHelp, Strings.Arg_PassArgsSwitch_Help);
            DecorateSwitch   = new BoolSwitch(Strings.Arg_Decorate_ShortHelp, Strings.Arg_Decorate_Help);
            ProtectZipSwitch = new OptionalStringArgument(Strings.Arg_Hide_Name, Strings.Arg_Hide_ShortHelp, Strings.Arg_Hide_Help);

            ToolsCsv = new CsvArgument(Strings.Arg_Toolkit_Name, Strings.Arg_Toolkit_ShortHelp, Strings.Arg_Toolkit_Help);

            Parser.Add(PlusMinusSwitch.KeyPrefix, Strings.Arg_ConsoleSwitch_Symbol, Strings.Arg_ConsoleSwitch_Key, ConsoleSwitch);
            Parser.Add("/", Strings.Arg_PassArgsSwitch_Symbol, Strings.Arg_PassArgsSwitch_Key, PassArgsSwitch);
            Parser.Add("/", Strings.Arg_Toolkit_Key, ToolsCsv);
            Parser.Add("/", Strings.Arg_OutputPath_Symbol, Strings.Arg_OutputPath_Key, OutputPath);
            Parser.Add("/", Strings.Arg_Decorate_Key, DecorateSwitch);
            Parser.Add("/", Strings.Arg_IconPath_Symbol, Strings.Arg_IconPath_Key, IconPath);
            Parser.Add("/", Strings.Arg_AssemblyInfoPath_Symbol, Strings.Arg_AssemblyInfoPath_Key, AssemblyInfoPath);
            Parser.Add("/", Strings.Arg_Hide_Key, ProtectZipSwitch);


            BuildSwitch   = new BoolSwitch(Strings.Arg_BuildSwitch_ShortHelp, Strings.Arg_BuildSwitch_Help);
            QuietSwitch   = new BoolSwitch(Strings.Arg_QuietSwitch_ShortHelp, Strings.Arg_QuietSwitch_Help);
            VerboseSwitch = new EnumSwitch(Strings.Arg_Verbose_ShortHelp, Strings.Arg_Verbose_Help, typeof(ConsoleVerbosity));

            Parser.Add("/", Strings.Arg_BuildSwitch_Key, BuildSwitch);
            Parser.Add("/", Strings.Arg_QuietSwitch_Key, QuietSwitch);
            Parser.Add("/", Strings.Arg_Verbose_Key, VerboseSwitch);

            WarningsAsErrors = new PlusMinusSwitch(Strings.Arg_WarningsAsErrors_ShortHelp, Strings.Arg_WarningsAsErrors_Help, false);

            Parser.Add(PlusMinusSwitch.KeyPrefix, Strings.Arg_WarningsAsErrors_Key, WarningsAsErrors);
        }
Example #10
0
        static int Main(string[] args)
        {
            ArgumentParser parser   = new ArgumentParser("FileDetails", "This show some details of a file");
            StringArgument outPath  = new StringArgument("out", "output file", "output file to store result");
            StringArgument filePath = new StringArgument("f", "File", "input file");

            parser.Add("\\", "out", outPath);
            parser.Add("\\", "file", filePath);

            if (parser.HelpMode)
            {
                parser.WriteLongArgumentsUsage();
                return(0);
            }

            try
            {
                parser.Parse(args);

                string file = "";
                if (!filePath.Defined)
                {
                    throw new Exception();
                }
                file = filePath.Value;

                if (outPath.Defined)
                {
                    sw = new StreamWriter(outPath.Value);
                }

                FileInfo fi    = new FileInfo(file);
                byte[]   bfile = new byte[fi.Length];
                using (var sr = fi.OpenRead())
                {
                    sr.Read(bfile, 0, bfile.Length);
                }

                MD5    m  = MD5.Create();
                byte[] rm = m.ComputeHash(bfile);
                printResult("MD5: " + hashToString(rm));

                SHA1   s1  = SHA1.Create();
                byte[] rs1 = s1.ComputeHash(bfile);
                printResult("SHA1: " + hashToString(rs1));

                SHA256 s2  = SHA256.Create();
                byte[] rs2 = s2.ComputeHash(bfile);
                printResult("SHA256: " + hashToString(rs2));

                SHA512 s5  = SHA512.Create();
                byte[] rs5 = s5.ComputeHash(bfile);
                printResult("SHA512: " + hashToString(rs5));

                Crc32  c     = new Crc32();
                byte[] crc32 = c.ComputeHash(bfile);
                printResult("CRC32: " + hashToString(crc32));

                StringBuilder ssdeep = new StringBuilder(100);
                ssdeepWrapper.fuzzy_hash_filename(file, ssdeep);
                printResult("SSDEEP: " + ssdeep);

                var    a    = new FileInfo(file);
                byte[] data = new byte[a.Length];
                using (var aux = fi.OpenRead())
                {
                    aux.Read(data, 0, data.Length);
                }

                ProcessStartInfo si = new ProcessStartInfo("file.exe", "\"" + file + "\"");
                si.RedirectStandardOutput = true;
                si.UseShellExecute        = false;
                si.WindowStyle            = ProcessWindowStyle.Hidden;

                var    proc  = Process.Start(si);
                string saida = proc.StandardOutput.ReadToEnd();
                saida = Regex.Match(saida, ".+; (?<tipo>.+)\r").Groups["tipo"].Value;
                printResult("Type: " + saida);

                printResult("Creation Date: " + fi.CreationTime.ToString("dd/MM/yyyy HH:mm:ss"));
                printResult("Modification Date: " + fi.LastWriteTime.ToString("dd/MM/yyyy HH:mm:ss"));

                if (sw != null)
                {
                    sw.Close();
                }
            }
            catch (Exception)
            {
                parser.WriteShortArgumentsUsage();
                return(-1);
            }
            return(0);
        }