示例#1
0
        void HandleCommands(object sender, IrcEventArgs ircEventArgs)
        {
            if (ircEventArgs.Data.Message[0] == _commandChar)
            {
                var authLevel = _authenticator.GetUserAuthLevel(ircEventArgs.Data.Host);
                var onCommand = new OnCommandArgs
                                (
                    authLevel,
                    ircEventArgs.Data.Channel,
                    ircEventArgs.Data.Host,
                    ircEventArgs.Data.Ident,
                    ircEventArgs.Data.Message,
                    ircEventArgs.Data.Nick
                                );

                DebugLog("Command; Nick:" + ircEventArgs.Data.Nick + " Authlevel:" + authLevel.ToString() + " Trailing:" + ircEventArgs.Data.Message);
                if (OnIrcCommand != null)
                {
                    OnIrcCommand.Invoke(onCommand);
                }
                if (ircEventArgs.Data.Message.Equals(".help"))
                {
                    PrintCommandHelp(ircEventArgs.Data.Channel);
                }
            }
        }
示例#2
0
        void IrcInterfaceOnOnIrcCommand(OnCommandArgs args)
        {
            var split = args.Message.Split();

            if (split[0].Contains(".encrypt"))
            {
                Encrypt(args, split);
            }
            if (split[0].Contains(".decrypt"))
            {
                Decrypt(args, split);
            }
        }
示例#3
0
 void IrcInterfaceOnOnIrcCommand(OnCommandArgs args)
 {
     if (args.AuthLevel == AuthLevel.Admin)
     {
         if (args.Message == ".flushcache")
         {
             RefreshResponses();
             const string logMsg = "Response cache manually flushed and reloaded successfully.";
             _ircInterface.Client.SendMessage(SendType.Message, args.Source, logMsg);
             _ircInterface.DebugLog(logMsg);
         }
     }
 }
示例#4
0
 void IrcInterfaceOnOnIrcCommand(OnCommandArgs args)
 {
     if (args.AuthLevel == AuthLevel.Admin){
         if (args.Message == ".disconnect"){
             _ircInterface.Client.RfcQuit("Manual disconnect request recv.d");
             Thread.Sleep(300);
             _ircInterface.DebugLog("Manually disconnected from the server.");
             _ircInterface.KillClient = true;
         }
         if (args.Message == ".redeploy"){
             _ircInterface.Client.RfcQuit("Deploying to new production build.");
             Thread.Sleep(300);
             _ircInterface.DebugLog("Deploying to new production build, manually disconnected from the server.");
             _ircInterface.KillClient = true;
         }
     }
 }
示例#5
0
        void Encrypt(OnCommandArgs args, string[] inMsg)
        {
            if (inMsg.Length < 3)
            {
                _ircInterface.Client.SendMessage(SendType.Message, args.Source, args.Nick + " the syntax for this command is .encrypt <key> <data>");
                return;
            }
            try{
                var key = AsciiToBase10(inMsg[1].ToCharArray());
                var msg = AssembleMessage(inMsg.Skip(2).ToList());
                msg = msg.Remove(msg.Length - 1);
                var msgByte = AsciiToBase10(msg.ToCharArray());

                if (msgByte.Length % 16 != 0)
                {
                    var paddedLen = (msgByte.Length / 16 + 1) * 16;
                    msgByte = PKCS7(msgByte, paddedLen);
                }


                var aes = new AesManaged();
                aes.KeySize = 128;
                aes.Mode    = CipherMode.CBC;
                aes.Key     = PKCS7(key, 16);
                aes.Padding = PaddingMode.None;
                aes.IV      = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

                var memStrm   = new MemoryStream(msgByte.Length);
                var cryptStrm = new CryptoStream(memStrm, aes.CreateEncryptor(), CryptoStreamMode.Write);
                cryptStrm.Write(msgByte, 0, msgByte.Length);

                var ret = memStrm.ToArray();
                aes.Dispose();
                cryptStrm.Dispose();
                memStrm.Dispose();

                var retb10 = new string(Convert.ToBase64String(ret).ToCharArray());
                _ircInterface.Client.SendMessage(SendType.Message, args.Source, args.Nick + ": " + retb10);
            }
            catch {
                _ircInterface.Client.SendMessage(SendType.Message, args.Source, args.Nick + ": something went wrong during encryption.");
            }
        }
示例#6
0
 void IrcInterfaceOnOnIrcCommand(OnCommandArgs args)
 {
     if (args.AuthLevel == AuthLevel.Admin)
     {
         if (args.Message == ".disconnect")
         {
             _ircInterface.Client.RfcQuit("Manual disconnect request recv.d");
             Thread.Sleep(300);
             _ircInterface.DebugLog("Manually disconnected from the server.");
             _ircInterface.KillClient = true;
         }
         if (args.Message == ".redeploy")
         {
             _ircInterface.Client.RfcQuit("Deploying to new production build.");
             Thread.Sleep(300);
             _ircInterface.DebugLog("Deploying to new production build, manually disconnected from the server.");
             _ircInterface.KillClient = true;
         }
     }
 }
示例#7
0
 void ClientOnOnIrcCommand(OnCommandArgs args)
 {
     try{
         if (args.Message == ".bicker"){
             var tickerStr = GenerateBtceTicker("usd", "btc");
             _client.Client.SendMessage(SendType.Message, args.Source, tickerStr);
         }
         if (args.Message == ".licker"){
             var tickerStr = GenerateBtceTicker("usd", "ltc");
             _client.Client.SendMessage(SendType.Message, args.Source, tickerStr);
         }
         if (args.Message == ".dicker"){
             var tickerStr = GenerateVircurexTicker("btc", "doge");
             _client.Client.SendMessage(SendType.Message, args.Source, tickerStr);
         }
     }
     catch{
         _client.Client.SendMessage(SendType.Message, args.Source, "Exchange API is non-responsive, try again later");
     }
 }
示例#8
0
 void ClientOnOnIrcCommand(OnCommandArgs args)
 {
     try{
         if (args.Message == ".bicker")
         {
             var tickerStr = GenerateBtceTicker("usd", "btc");
             _client.Client.SendMessage(SendType.Message, args.Source, tickerStr);
         }
         if (args.Message == ".licker")
         {
             var tickerStr = GenerateBtceTicker("usd", "ltc");
             _client.Client.SendMessage(SendType.Message, args.Source, tickerStr);
         }
         if (args.Message == ".dicker")
         {
             var tickerStr = GenerateVircurexTicker("btc", "doge");
             _client.Client.SendMessage(SendType.Message, args.Source, tickerStr);
         }
     }
     catch {
         _client.Client.SendMessage(SendType.Message, args.Source, "Exchange API is non-responsive, try again later");
     }
 }
示例#9
0
        void Decrypt(OnCommandArgs args, string[] inMsg)
        {
            if (inMsg.Length < 3)
            {
                _ircInterface.Client.SendMessage(SendType.Message, args.Source, args.Nick + " the syntax for this command is .decrypt <key> <data>");
                return;
            }
            try{
                var key     = AsciiToBase10(inMsg[1].ToCharArray());
                var msgByte = Convert.FromBase64CharArray(inMsg[2].ToCharArray(), 0, inMsg[2].Length);

                var aes = new AesManaged();
                aes.Mode    = CipherMode.CBC;
                aes.IV      = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
                aes.KeySize = 128;
                var keyPad = PKCS7(key, 16);
                aes.Key     = keyPad;
                aes.Padding = PaddingMode.None;

                var memStrm   = new MemoryStream(msgByte.Length);
                var cryptStrm = new CryptoStream(memStrm, aes.CreateDecryptor(), CryptoStreamMode.Write);
                cryptStrm.Write(msgByte, 0, msgByte.Length);

                var ret = memStrm.ToArray();
                aes.Dispose();
                cryptStrm.Dispose();
                memStrm.Dispose();
                ret = StripPKCS7(ret);
                var retStr = new string(Base10ToAscii(ret));
                _ircInterface.Client.SendMessage(SendType.Message, args.Source, args.Nick + ": " + retStr);
            }
            catch {
                _ircInterface.Client.SendMessage
                    (SendType.Message, args.Source, args.Nick + ": something went wrong during decryption. did you change the encrypted string?");
            }
        }
示例#10
0
        void IrcInterfaceOnOnIrcCommand(OnCommandArgs args)
        {
            var split = args.Message.Split();

            if (split[0].Contains(".encrypt")){
                Encrypt(args, split);
            }
            if (split[0].Contains(".decrypt")){
                Decrypt(args, split);
            }
        }
示例#11
0
        void Encrypt(OnCommandArgs args, string[] inMsg)
        {
            if (inMsg.Length < 3){
                _ircInterface.Client.SendMessage(SendType.Message, args.Source, args.Nick + " the syntax for this command is .encrypt <key> <data>");
                return;
            }
            try{
                var key = AsciiToBase10(inMsg[1].ToCharArray());
                var msg = AssembleMessage(inMsg.Skip(2).ToList());
                msg = msg.Remove(msg.Length - 1);
                var msgByte = AsciiToBase10(msg.ToCharArray());

                if (msgByte.Length%16 != 0){
                    var paddedLen = (msgByte.Length/16 + 1)*16;
                    msgByte = PKCS7(msgByte, paddedLen);
                }

                var aes = new AesManaged();
                aes.KeySize = 128;
                aes.Mode = CipherMode.CBC;
                aes.Key = PKCS7(key, 16);
                aes.Padding = PaddingMode.None;
                aes.IV = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};

                var memStrm = new MemoryStream(msgByte.Length);
                var cryptStrm = new CryptoStream(memStrm, aes.CreateEncryptor(), CryptoStreamMode.Write);
                cryptStrm.Write(msgByte, 0, msgByte.Length);

                var ret = memStrm.ToArray();
                aes.Dispose();
                cryptStrm.Dispose();
                memStrm.Dispose();

                var retb10 = new string(Convert.ToBase64String(ret).ToCharArray());
                _ircInterface.Client.SendMessage(SendType.Message, args.Source, args.Nick + ": " + retb10);
            }
            catch{
                _ircInterface.Client.SendMessage(SendType.Message, args.Source, args.Nick + ": something went wrong during encryption.");
            }
        }
示例#12
0
        void Decrypt(OnCommandArgs args, string[] inMsg)
        {
            if (inMsg.Length < 3){
                _ircInterface.Client.SendMessage(SendType.Message, args.Source, args.Nick + " the syntax for this command is .decrypt <key> <data>");
                return;
            }
            try{
                var key = AsciiToBase10(inMsg[1].ToCharArray());
                var msgByte = Convert.FromBase64CharArray(inMsg[2].ToCharArray(), 0, inMsg[2].Length);

                var aes = new AesManaged();
                aes.Mode = CipherMode.CBC;
                aes.IV = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
                aes.KeySize = 128;
                var keyPad = PKCS7(key, 16);
                aes.Key = keyPad;
                aes.Padding = PaddingMode.None;

                var memStrm = new MemoryStream(msgByte.Length);
                var cryptStrm = new CryptoStream(memStrm, aes.CreateDecryptor(), CryptoStreamMode.Write);
                cryptStrm.Write(msgByte, 0, msgByte.Length);

                var ret = memStrm.ToArray();
                aes.Dispose();
                cryptStrm.Dispose();
                memStrm.Dispose();
                ret = StripPKCS7(ret);
                var retStr = new string(Base10ToAscii(ret));
                _ircInterface.Client.SendMessage(SendType.Message, args.Source, args.Nick + ": " + retStr);
            }
            catch{
                _ircInterface.Client.SendMessage
                    (SendType.Message, args.Source, args.Nick + ": something went wrong during decryption. did you change the encrypted string?");
            }
        }
示例#13
0
        void HandleCommands(object sender, IrcEventArgs ircEventArgs)
        {
            if (ircEventArgs.Data.Message[0] == _commandChar){
                var authLevel = _authenticator.GetUserAuthLevel(ircEventArgs.Data.Host);
                var onCommand = new OnCommandArgs
                    (
                    authLevel,
                    ircEventArgs.Data.Channel,
                    ircEventArgs.Data.Host,
                    ircEventArgs.Data.Ident,
                    ircEventArgs.Data.Message,
                    ircEventArgs.Data.Nick
                    );

                DebugLog("Command; Nick:" + ircEventArgs.Data.Nick + " Authlevel:" + authLevel.ToString() + " Trailing:" + ircEventArgs.Data.Message);
                if (OnIrcCommand != null){
                    OnIrcCommand.Invoke(onCommand);
                }
                if (ircEventArgs.Data.Message.Equals(".help")){
                    PrintCommandHelp(ircEventArgs.Data.Channel);
                }
            }
        }