Esempio n. 1
0
 private static string getPasswordEnc(string sess)
 {
     return(SnkTool.toHex(Encrypt.aesEcbEnc(sess, AES_KEY_PASSWORD)));
 }
Esempio n. 2
0
        public override bool loadRedirect()
        {
            if (!string.IsNullOrWhiteSpace(this.RouterIpAddress))
            {
                //use client
                this.Host           = "58.53.196.165:8080";
                this.LocalIpAddress = this.RouterIpAddress;
                logger.log("[SnkHubei] 使用路由器IP地址[" + this.LocalIpAddress + "]");
                return(true);
            }

            HttpWebRequest hRequest = null;

            try
            {
                hRequest = (HttpWebRequest)HttpWebRequest.Create(REDIRECT_ADDR);
                hRequest.AllowAutoRedirect = false;
                hRequest.Timeout           = 5 * 1000;
            }
            catch (Exception)
            {
                logger.log("[SnkHubei] [Error] Create Http Failed.");
                LastErrorMsg = "(1/10) 获取NAS服务器失败。";
                return(false);
            }

            try
            {
                WebResponse hResp = hRequest.GetResponse();
                if (hResp != null && hResp is HttpWebResponse)
                {
                    HttpWebResponse hRespWeb = hResp as HttpWebResponse;
                    if (hRespWeb.StatusCode == HttpStatusCode.Found)
                    {
                        string location = hRespWeb.Headers["Location"];
                        this.RedirectUrl = location;

                        ////http://58.53.196.165:8080?userip=100.64.64.76&wlanacname=&nasip=59.175.245.211&usermac=74-c3-30-12-e5-d7
                        //get ip from link
                        int index = location.IndexOf("?");
                        if (index < 0)
                        {
                            throw new Exception("Redirect Url Invalid , url=" + location);
                        }

                        this.Host = location.Substring(7, location.IndexOf("?", 7) - 7);

                        string keyval = location.Substring(index + 1);
                        Dictionary <string, string> kv = SnkTool.getParamToDict(keyval);
                        if (kv == null || kv.Count == 0 || !kv.ContainsKey("userip"))
                        {
                            throw new Exception("Parameter invalid , url=" + location);
                        }

                        this.LocalIpAddress = kv["userip"];

                        logger.log("[SnkHubei] [Info] RedirUrl[" + location + "] IP[" + LocalIpAddress + "] HOST[" + Host + "]");
                        return(true);
                    }
                    else
                    {
                        LastErrorMsg = "(2/10) 你似乎已经连接了?状态 " + hRespWeb.StatusCode;
                        return(false);
                        //throw new Exception("Status Code Invalid , code=" + hRespWeb.StatusCode);
                    }
                }
            }
            catch (Exception e)
            {
                LastErrorMsg = "(2/10) 找不到登录服务器,请尝试重启路由器";
                logger.log("[SnkHubei] [Error] Redir " + e.Message);
            }
            return(false);
        }
Esempio n. 3
0
 private static string getSessionEnc(string session)
 {
     return(SnkTool.toHex(Encrypt.aesEcbEnc(session, AES_KEY_SESSION)));
 }