Exemplo n.º 1
0
        public void CleanSockets()
        {
            List <Socket> copy   = ctx.ListCopy(clientList);
            bool          result = true;

            foreach (Socket socket in copy)
            {
                try
                {
                    KillSocket(socket);
                }
                catch (Exception)
                {
                    console.Debug("Clean Sockets failed!");
                    result = false;
                }
            }

            if (result)
            {
                ctx.LogMod.Log("All clients disconnected from server", VLogger.LogLevel.information);
            }
            else
            {
                ctx.LogMod.Log("Some clients failed to disconnect from server!", VLogger.LogLevel.warning);
            }

            Array.Clear(copy.ToArray(), 0, copy.Count);
        }
Exemplo n.º 2
0
        public void SendHTTP(Request r, Socket browser)
        {
            try
            {
                string    code   = FormatRequest(r);
                Socket    bridge = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPAddress ip     = GetIPOfHost(r.headers["Host"]);
                if (ip == null)
                {
                    if (browser != null)
                    {
                        browser.Close();
                        browser.Dispose();
                        browser = null;
                    }

                    return;
                }
                bridge.Connect(ip, 80);
                RawObj ro = new RawObj()
                {
                    client = browser, data = new byte[2048], bridge = bridge
                };
                bridge.BeginReceive(ro.data, 0, 2048, SocketFlags.None, new AsyncCallback(ForwardRawHTTP), ro);
                bridge.Send(Encoding.ASCII.GetBytes(code));
            }
            catch (SocketException socketError)
            {
                console.Debug($"Failed to tunnel http traffic for {r.headers["Host"]}: {socketError.ToString()}");
            }
        }
Exemplo n.º 3
0
 private string Decrypt(string cipherText)
 {
     try
     {
         string EncryptionKey = "adbuuibsauvauzfbai3246378634985723zsdibfasfsuzfYGSGDFYGVB";
         byte[] cipherBytes   = Convert.FromBase64String(cipherText);
         using (Aes encryptor = Aes.Create())
         {
             Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76, 0x66, 0x42, 0x22, 0x47, 0x88 });
             encryptor.Key = pdb.GetBytes(32);
             encryptor.IV  = pdb.GetBytes(16);
             using (MemoryStream ms = new MemoryStream())
             {
                 using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
                 {
                     cs.Write(cipherBytes, 0, cipherBytes.Length);
                     cs.Close();
                 }
                 cipherText = Encoding.Unicode.GetString(ms.ToArray());
             }
         }
         return(cipherText);
     }
     catch (Exception e)
     {
         console.Debug("decryption error: " + e.Message);
         return(cipherText);
     }
 }
Exemplo n.º 4
0
        public byte[] GetMediaHijack(Request r)
        {
            string targetFile   = r.target;
            bool   canContinue  = false;
            string _lfilterName = "";

            foreach (string fname in mediaReplace.Keys)
            {
                string mode   = (fname.Contains("or")) ? "or" : "and";
                bool   result = (mode == "and") ? Manager.RunAllCompareAnd(fname, targetFile) : Manager.RunAllCompareOr(fname, targetFile);
                if (result)
                {
                    canContinue  = true;
                    _lfilterName = fname;
                    break;
                }
            }
            if (!canContinue)
            {
                return(null);
            }
            string newFile = mediaReplace[_lfilterName];

            if (IsLocalFile(newFile))
            {
                return(File.ReadAllBytes(newFile));
            }
            else
            {
                try
                {
                    WebClient wc = new WebClient
                    {
                        Proxy = null
                    };
                    byte[] file = wc.DownloadData(newFile);
                    return(file);
                }
                catch (Exception)
                {
                    console.Debug("Web Image Inject failed!");
                    return(null);
                }
            }
        }