Exemplo n.º 1
0
        public void FromJson(Json jResponse)
        {
            if (jResponse.HasKey("headers"))
            {
                string[] lines = jResponse["headers"].ValueString.Split('\n');
                Status = "";
                foreach (string line in lines)
                {
                    string l = line.Trim();
                    if (l == "")
                    {
                        continue;
                    }

                    if (Status == "")
                    {
                        Status = l.Trim();
                    }
                    else
                    {
                        int posSep = l.IndexOfInv(":");
                        if (posSep != -1)
                        {
                            string k = "";
                            string v = "";
                            k = l.Substring(0, posSep).ToLowerInvariant().Trim();
                            v = l.Substring(posSep + 1).Trim();
                            if (k != "")
                            {
                                Headers.Add(new KeyValuePair <string, string>(k, v));
                            }
                        }
                    }
                }
            }

            if (jResponse.HasKey("body"))
            {
                BufferData = ExtensionsString.HexToBytes(jResponse["body"].ValueString);
            }

            if (jResponse.HasKey("response_code"))
            {
                ResponseCode = jResponse["response_code"].ValueInt;
            }
        }
Exemplo n.º 2
0
        public static void Init()
        {
            if (m_torDetection)
            {
                return;
            }

            ElevatedProcess.Command c = new ElevatedProcess.Command();
            c.Parameters["command"] = "tor-get-info";

            c.Parameters["name"] = "tor";
            string customPath = Engine.Instance.Storage.Get("proxy.tor.path");

            if (customPath != "")
            {
                c.Parameters["path"] = customPath;
            }
            c.Parameters["username"] = Environment.UserName;

            string torInfo = Engine.Instance.Elevated.DoCommandSync(c);

            foreach (string line in torInfo.Split('\n'))
            {
                if (line.StartsWithInv("Name:"))
                {
                    m_torProcessName = line.Substring("Name:".Length);
                }
                if (line.StartsWithInv("Path:"))
                {
                    m_torProcessPath = line.Substring("Path:".Length);
                }
                if (line.StartsWithInv("CookiePath:"))
                {
                    m_torCookiePath = line.Substring("CookiePath:".Length);
                }
                if (line.StartsWithInv("CookiePasswordHex:"))
                {
                    m_torCookiePassword = ExtensionsString.HexToBytes(line.Substring("CookiePasswordHex:".Length));
                }
            }

            m_torDetection = true;
        }