protected void Page_Load(object sender, EventArgs e)
        {
            string strdata = Request.Params["data"];
            string strmd5  = Request.Params["sign"];

            if (string.IsNullOrEmpty(strdata) || string.IsNullOrEmpty(strmd5))
            {
                ReturnLuaMsg("-1");//data is null
                return;
            }

            strdata = Encoding.Default.GetString(Convert.FromBase64String(strdata));

            if (strmd5 != AESHelper.MD5Encrypt(strdata + AES_KEY))
            {
                ReturnLuaMsg("-2");//sign error
                return;
            }

            Dictionary <string, object> data = JsonHelper.ParseFromStr <Dictionary <string, object> >(strdata);

            if (data == null || data.Count < 3)
            {
                ReturnLuaMsg("-3");//json error
                return;
            }
            try
            {
                CheckAccount(data);
            }
            catch (Exception)
            {
                ReturnLuaMsg("-4");
            }
        }
Ejemplo n.º 2
0
    private string modifyPwd(ParamModifyPlayerPwd p)
    {
        RSAHelper rsa = new RSAHelper();

        rsa.init();
        Dictionary <string, object> data = new Dictionary <string, object>();

        data["n1"] = p.m_playerAcc;
        string old = Tool.getMD5Hash(p.m_oldPwd);

        data["n2"] = AESHelper.AESEncrypt(old, AES_KEY);

        string newPwd = Tool.getMD5Hash(p.m_newPwd);

        data["n3"] = AESHelper.AESEncrypt(newPwd, AES_KEY);

        string jsonstr = JsonHelper.ConvertToStr(data);
        string md5     = AESHelper.MD5Encrypt(jsonstr + AES_KEY);
        string urlstr  = Convert.ToBase64String(Encoding.Default.GetBytes(jsonstr));

        string fmt  = CONST.URL_MODIFY_PLAYER_PWD;
        string aspx = string.Format(fmt, urlstr, md5);
        var    ret  = HttpPost.Get(new Uri(aspx));

        if (ret != null)
        {
            string retStr = Encoding.UTF8.GetString(ret);
            return(retStr);
        }
        return("");
    }
Ejemplo n.º 3
0
    public int isParamValid()
    {
        if (string.IsNullOrEmpty(m_strData) ||
            string.IsNullOrEmpty(m_sign))
        {
            return(HttpRetCode.RET_PARAM_NOT_VALID);
        }

        string strdata = Encoding.Default.GetString(Convert.FromBase64String(m_strData));
        string sign    = AESHelper.MD5Encrypt(strdata + DyOpPlayerSelfRegAcc.AES_KEY);

        if (sign != m_sign)
        {
            return(HttpRetCode.RET_SIGN_ERROR);
        }

        m_data = JsonHelper.ParseFromStr <Dictionary <string, object> >(strdata);
        if (m_data == null ||
            m_data.Count != 4)
        {
            return(HttpRetCode.RET_JSON_ERROR);
        }

        if (!m_data.ContainsKey("n1")) // Õ˺Å
        {
            return(HttpRetCode.RET_LACK_PARAM);
        }

        if (!m_data.ContainsKey("n2")) // ÃÜÂë
        {
            return(HttpRetCode.RET_LACK_PARAM);
        }

        if (!m_data.ContainsKey("n3")) // rsa modules
        {
            return(HttpRetCode.RET_LACK_PARAM);
        }

        if (!m_data.ContainsKey("n5")) // ´úÀíÕ˺Å
        {
            return(HttpRetCode.RET_LACK_PARAM);
        }

        string id = Convert.ToString(m_data["n5"]);

        if (!long.TryParse(id, out m_gmId))
        {
            return(HttpRetCode.RET_AGENT_ACC_ERROR);
        }

        return(0);
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.RequestType != "GET")
            {
                return;
            }

            CLOG.Info("注册账户");
            //结果用lua返回
            string retLua = Request.Params["returnLua"];

            if (!string.IsNullOrEmpty(retLua) && retLua == "true")
            {
                returnLua = true;
            }
            string strdata = Request.Params["data"];
            string strmd5  = Request.Params["sign"];

            if (string.IsNullOrEmpty(strdata) || string.IsNullOrEmpty(strmd5))
            {
                buildReturnMsg("-1");//data is null
                return;
            }

            strdata = Encoding.Default.GetString(Convert.FromBase64String(strdata));

            if (strmd5 != AESHelper.MD5Encrypt(strdata + AES_KEY))
            {
                buildReturnMsg("-2");//sign error
                return;
            }

            Dictionary <string, object> data = JsonHelper.ParseFromStr <Dictionary <string, object> >(strdata);

            if (data == null || data.Count < 3)
            {
                buildReturnMsg("-3");//json error
                return;
            }
            try
            {
                CheckAccount(data);
            }
            catch (Exception)
            {
                buildReturnMsg("-4");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.RequestType != "GET")
            {
                return;
            }

            string strdata = Request.Params["data"];
            string strmd5  = Request.Params["sign"];

            if (string.IsNullOrEmpty(strdata) || string.IsNullOrEmpty(strmd5))
            {
                return;
            }

            // 改密码的发起源
            string opSrc = Request.Params["opSrc"];

            strdata = Encoding.Default.GetString(Convert.FromBase64String(strdata));

            if (strmd5 != AESHelper.MD5Encrypt(strdata + AES_KEY))
            {
                Response.Write("err_sign_error");//sign error
                return;
            }

            Dictionary <string, object> data = JsonHelper.ParseFromStr <Dictionary <string, object> >(strdata);

            if (data == null || data.Count < 3)
            {
                Response.Write("err_data_error");//json error
                return;
            }
            try
            {
                UpdateAccount(data, opSrc);
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.RequestType != "GET")
            {
                return;
            }

            string strdata = Request.Params["data"];
            string strmd5  = Request.Params["sign"];

            if (string.IsNullOrEmpty(strdata) || string.IsNullOrEmpty(strmd5))
            {
                ReturnMsg(HttpRetCode.RET_PARAM_NOT_VALID.ToString());//data is null
                return;
            }

            strdata = Encoding.Default.GetString(Convert.FromBase64String(strdata));

            if (strmd5 != AESHelper.MD5Encrypt(strdata + AES_KEY))
            {
                ReturnMsg(HttpRetCode.RET_SIGN_ERROR.ToString());//sign error
                return;
            }

            Dictionary <string, object> data = JsonHelper.ParseFromStr <Dictionary <string, object> >(strdata);

            if (data == null || data.Count < 3)
            {
                ReturnMsg(HttpRetCode.RET_JSON_ERROR.ToString());//json error
                return;
            }
            try
            {
                CheckAccount(data);
            }
            catch (Exception)
            {
                ReturnMsg(HttpRetCode.RET_HAPPEN_EXCEPTION.ToString());
            }
        }
Ejemplo n.º 7
0
    private bool createAccToServer(string accName, string pwd, ref string error)
    {
        RSAHelper rsa = new RSAHelper();

        rsa.init();
        Dictionary <string, object> data = new Dictionary <string, object>();

        data["n1"] = accName;
        string md5Pwd = Tool.getMD5Hash(pwd);

        data["n2"] = AESHelper.AESEncrypt(md5Pwd, AES_KEY);
        data["n3"] = rsa.getModulus();

        string jsonstr = JsonHelper.ConvertToStr(data);
        string md5     = AESHelper.MD5Encrypt(jsonstr + AES_KEY);
        string urlstr  = Convert.ToBase64String(Encoding.Default.GetBytes(jsonstr));

        string fmt  = WebConfigurationManager.AppSettings["createAccount"];
        string aspx = string.Format(fmt, urlstr, md5);
        var    ret  = HttpPost.Get(new Uri(aspx));

        if (ret != null)
        {
            string retStr = Encoding.UTF8.GetString(ret);
            string oriStr = Encoding.Default.GetString(Convert.FromBase64String(retStr));
            Dictionary <string, object> retData =
                JsonHelper.ParseFromStr <Dictionary <string, object> >(oriStr);
            if (retData.ContainsKey("result"))
            {
                if (retData.ContainsKey("error"))
                {
                    error = Convert.ToString(retData["error"]);
                }
                return(Convert.ToBoolean(retData["result"]));
            }
        }
        return(false);
    }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            string pattern = @"^[0-9a-zA-z][^_]{6,20}$";

            if (!Regex.IsMatch("1234556547", pattern))
            {
                int i = 0;
            }



            TalkingGame.get_vca("3");
            //TalkingGame tg = new TalkingGame();
            //tg.adddata("test", "PB585615090914221334621",1,10);
            //tg.PostToTG();



            int    time1  = Environment.TickCount;
            string result = Encoding.UTF8.GetString(HttpPost.Get(new Uri("http://192.168.1.11:26004/ServerList.aspx"), true));
            int    time2  = Environment.TickCount;

            Console.WriteLine("time:" + (time2 - time1));
            if (result.StartsWith("error"))
            {
                Console.WriteLine(result);
            }
            else
            {
                Console.WriteLine(result);
                Console.WriteLine("");
            }

            /////////////////////////////////////////////////////////////

            RSAHelper rsa = new RSAHelper();

            rsa.init();
            Dictionary <string, object> data = new Dictionary <string, object>();

            data["n1"] = "test1";
            data["n2"] = AESHelper.AESEncrypt("123456", AES_KEY);
            data["n3"] = rsa.getModulus();


            string jsonstr = JsonHelper.ConvertToStr(data);
            string md5     = AESHelper.MD5Encrypt(jsonstr + AES_KEY);

            NameValueCollection nvc = new NameValueCollection();
            string urlstr           = Convert.ToBase64String(Encoding.Default.GetBytes(jsonstr));

            nvc.Add("data", urlstr);
            nvc.Add("sign", md5);
            nvc.Add("platform", "default");
            urlstr = string.Format("http://localhost:33820/SwitchLogin.aspx?data={0}&sign={1}&platform={2}", urlstr, md5, "default");

            time1  = Environment.TickCount;
            result = Encoding.Default.GetString(HttpPost.Get(new Uri(urlstr)));
            time2  = Environment.TickCount;
            Console.WriteLine("time:" + (time2 - time1));
            if (result.StartsWith("error"))
            {
                Console.WriteLine(result);
            }
            else
            {
                string jstr = Encoding.Default.GetString(Convert.FromBase64String(result));
                Console.WriteLine("login:"******"");
                Dictionary <string, object> retdata = JsonHelper.ParseFromStr <Dictionary <string, object> >(jstr);

                if (!Convert.ToBoolean(retdata["result"]))
                {
                    Console.Read();
                    return;
                }

                string logindata = rsa.RSADecryptStr(retdata["data"].ToString());
                Console.WriteLine("data:" + logindata);
                Console.WriteLine("");

                //////////////////////////////////////////////////////////////
                bool isok = Convert.ToBoolean(retdata["result"]);
                if (isok)
                {
                    nvc.Clear();
                    nvc.Add("acc", "test1");
                    time1  = Environment.TickCount;
                    result = Encoding.Default.GetString(HttpPost.Get(new Uri("http://192.168.1.11:12345/AccCheck.aspx?acc=test1")));
                    time2  = Environment.TickCount;
                    Console.WriteLine("time:" + (time2 - time1));
                    jstr = Encoding.Default.GetString(Convert.FromBase64String(result));
                    Console.WriteLine("check:" + jstr);
                    Dictionary <string, object> retdata2 = JsonHelper.ParseFromStr <Dictionary <string, object> >(jstr);

                    if (!Convert.ToBoolean(retdata2["result"]))
                    {
                        Console.Read();
                        return;
                    }
                    Dictionary <string, object> retdata3 = JsonHelper.ParseFromStr <Dictionary <string, object> >(retdata2["data"].ToString());
                }
            }


            Console.Read();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CLOG.Info("xk  ... Default Login11111111111111");
            if (Request.RequestType != "GET")
            {
                return;
            }

            CLOG.Info("xk  ... Default Login22222222222222");

            string xk_data = "";

            foreach (var v in Request.QueryString)
            {
                xk_data += v.ToString() + "," + Request.Params[v.ToString()] + " | ";
            }
            CLOG.Info("request params : " + xk_data);


            //结果用lua返回
            string retLua = Request.Params["returnLua"];

            if (!string.IsNullOrEmpty(retLua) && retLua == "true")
            {
                returnLua = true;
            }

            string strdata = Request.Params["data"];
            string strmd5  = Request.Params["sign"];

            if (string.IsNullOrEmpty(strdata) || string.IsNullOrEmpty(strmd5))
            {
                buildReturnMsg("-1");//data is null
                return;
            }

            strdata = Encoding.Default.GetString(Convert.FromBase64String(strdata));

            if (strmd5 != AESHelper.MD5Encrypt(strdata + AES_KEY))
            {
                buildReturnMsg("-2");//sign error
                return;
            }

            CLOG.Info("Account Info Json: " + strdata);
            Dictionary <string, object> data = JsonHelper.ParseFromStr <Dictionary <string, object> >(strdata);

            if (data == null || data.Count < 3)
            {
                buildReturnMsg("-3");//json error
                return;
            }

            string xk_data1 = "";

            foreach (var v in data)
            {
                xk_data1 += v.Key.ToString() + "," + v.Value + " | ";
            }
            CLOG.Info("data: " + xk_data1);

            try
            {
                CheckAccount(data);
            }
            catch (Exception)
            {
                buildReturnMsg("-4");
            }
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string platform = Request.Params["platform"];

            if (string.IsNullOrEmpty(platform))
            {
                Response.Write("local ret = {code = -1}; return ret;");
                return;
            }

            string table = ConfigurationManager.AppSettings["acc_" + platform];

            if (string.IsNullOrEmpty(table))
            {
                Response.Write("local ret = {code = -15}; return ret;");
                return;
            }

            string acc = BuildAccount.getAutoAccount(table);

            if (string.IsNullOrEmpty(acc))
            {
                Response.Write("local ret = {code = -12}; return ret;");
                return;
            }
            string encrypt     = Request.Params["encrypt"];
            bool   pwd_encrypt = false;

            if (!string.IsNullOrEmpty(encrypt) && encrypt == "true")
            {
                pwd_encrypt = true;
            }
            string pwd      = null;
            string out_pwd  = null;
            string save_pwd = null;

            if (pwd_encrypt)
            {
                pwd      = BuildAccount.getAutoPassword(6);
                out_pwd  = AESHelper.AESEncrypt(pwd, AES_KEY);
                save_pwd = AESHelper.MD5Encrypt(pwd);
            }
            else
            {
                out_pwd  = BuildAccount.getAutoPassword(20);
                pwd      = string.Format("{0}{1}{2}{3}{4}{5}", out_pwd[8], out_pwd[16], out_pwd[4], out_pwd[11], out_pwd[2], out_pwd[9]);//password
                save_pwd = AESHelper.MD5Encrypt(pwd);
            }
            string deviceID = Request.Params["deviceID"];

            Random rd      = new Random();
            int    randkey = rd.Next();
            Dictionary <string, object> updata = new Dictionary <string, object>();

            updata["acc"] = acc;
            updata["pwd"] = save_pwd;
            DateTime now = DateTime.Now;

            updata["randkey"]     = randkey;
            updata["lasttime"]    = now.Ticks;
            updata["regedittime"] = now;
            updata["regeditip"]   = Request.ServerVariables.Get("Remote_Addr").ToString();
            updata["updatepwd"]   = false;
            //updata["platform"] = Platform;

            string strerr = MongodbAccount.Instance.ExecuteStoreBykey(table, "acc", acc, updata);

            if (strerr != "")
            {
                Response.Write("local ret = {code = -11}; return ret;");
            }
            else
            {
                string channelID = Request.Params["channelID"];

                Dictionary <string, object> savelog = new Dictionary <string, object>();
                savelog["acc"]      = acc;
                savelog["acc_real"] = acc;
                if (!string.IsNullOrEmpty(deviceID))
                {
                    savelog["acc_dev"] = deviceID;
                }
                savelog["ip"]      = Request.ServerVariables.Get("Remote_Addr").ToString();
                savelog["time"]    = now;
                savelog["channel"] = channelID;
                MongodbAccount.Instance.ExecuteInsert("RegisterLog", savelog);

                //渠道每日注册
                if (string.IsNullOrEmpty(channelID) == false)
                {
                    MongodbAccount.Instance.ExecuteIncBykey("day_regedit", "date", DateTime.Now.Date, channelID, 0);
                }
                string ret = string.Format("local ret = {{code = 0, acc=\"{0}\", pwd=\"{1}\"}}; return ret;", acc, out_pwd);
                Response.Write(ret);
            }

            //Response.Write("local ret = {code = 0, acc=\"fish000001\", pwd=\"123456\"};");
        }
Ejemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            NameValueCollection req = Request.QueryString;

            if (req.Count <= 0)
            {
                Response.Write("param error");
                return;
            }

            Dictionary <string, object> data = new Dictionary <string, object>();

            foreach (string key in req)
            {
                data[key] = req[key];
            }

            if (!data.ContainsKey("orderid") || !data.ContainsKey("userid") || !data.ContainsKey("currencytype") ||
                !data.ContainsKey("currencycount") || !data.ContainsKey("vipexp") || !data.ContainsKey("sign"))
            {
                Response.Write("param error");
                return;
            }


            string url = "orderid=" + data["orderid"].ToString() + "&userid=" + data["userid"].ToString() + "&currencytype=" +
                         data["currencytype"].ToString() + "&currencycount=" + data["currencycount"].ToString() + "&vipexp=" + data["vipexp"].ToString();

            string checkmd5 = url + "&secretKey=" + secretKey;

            checkmd5 = AESHelper.MD5Encrypt(checkmd5);
            if (checkmd5 != data["sign"].ToString())
            {
                Response.Write("check error");
                return;
            }

            if (MongodbPayment.Instance.KeyExistsBykey("th_pay", "orderid", data["orderid"].ToString()))
            {
                Response.Write("orderid exist");
                return;
            }

            data["PayTime"] = DateTime.Now;
            data["Process"] = false;
            data.Remove("sign");

            if (!MongodbPayment.Instance.ExecuteInsert("th_pay", data))
            {
                Response.Write("db error");
                return;
            }


            string server_api = "http://" + ConfigurationManager.AppSettings["server_api"].ToString() + "/cmd=1&" + url;

            try
            {
                var ret = HttpPost.Post(new Uri(server_api));
                if (ret != null)
                {
                    string retstr = Encoding.UTF8.GetString(ret);
                    Response.Write(retstr);
                    return;
                }
            }
            catch (Exception)
            {
                //投递失败 玩家下次登录可以检测充值
            }

            Response.Write("success");
        }
        void BindAccount(Dictionary <string, object> data)
        {
            string HardwareID = data["n4"].ToString();//HardwareID

            if (string.IsNullOrEmpty(HardwareID))
            {
                buildReturnMsg("-12");//account error
                return;
            }

            string platform = Request.Params["platform"];

            string table = ConfigurationManager.AppSettings["acc_" + platform];

            if (string.IsNullOrEmpty(table))
            {
                buildReturnMsg("-15");//platform error
                return;
            }

            var retdata = MongodbAccount.Instance.ExecuteGetByQuery(table, Query.EQ("acc_dev", HardwareID), new string[] { "acc", "lasttime" });

            if (retdata != null)
            {
                string sacc = data["n1"].ToString();//account

                string pattern = @"^[0-9a-zA-Z]{6,30}$";

                if (!Regex.IsMatch(sacc, pattern))
                {
                    buildReturnMsg("-12");//account error
                    return;
                }

                //判断此账号已经被注册
                if (MongodbAccount.Instance.KeyExistsBykey(table, "acc", sacc))
                {
                    buildReturnMsg("-13");//account exists
                    return;
                }

                string spwd = AESHelper.AESDecrypt(data["n2"].ToString(), AES_KEY); //password
                if (spwd.Length != 32)                                              //md5
                {
                    buildReturnMsg("-14");                                          //pwd error
                    return;
                }

                //判断是否绑定过
                if (retdata.ContainsKey("acc"))
                {
                    string findacc = retdata["acc"].ToString();
                    if (!string.IsNullOrEmpty(findacc))
                    {
                        buildReturnMsg("-13");//account is error
                        return;
                    }
                }

                //校验玩家必须登录成功后才能绑定
                string token = data["n3"].ToString();
                if (retdata.ContainsKey("lasttime"))
                {
                    string lasttime = retdata["lasttime"].ToString();
                    lasttime = AESHelper.MD5Encrypt(lasttime + ACC_CHECK);
                    token    = AESHelper.AESDecrypt(token, ACC_CHECK);
                    if (token != lasttime || string.IsNullOrEmpty(lasttime))
                    {
                        buildReturnMsg("-14");//pwd error
                        return;
                    }
                }
                else
                {
                    buildReturnMsg("-14");//pwd error
                    return;
                }


                Dictionary <string, object> updata = new Dictionary <string, object>();
                DateTime now = DateTime.Now;
                updata["acc"]      = sacc;
                updata["pwd"]      = spwd;
                updata["bindtime"] = now;
                string strerr = MongodbAccount.Instance.ExecuteUpdate(table, "acc_dev", HardwareID, updata);
                if (strerr != "")
                {
                    buildReturnMsg("-11");//server error
                }
                else
                {
                    buildReturnMsg("ok", true);//login success

                    Dictionary <string, object> savelog = new Dictionary <string, object>();
                    savelog["acc_dev"] = HardwareID;
                    savelog["acc"]     = sacc;
                    savelog["time"]    = now;
                    savelog["ip"]      = Request.ServerVariables.Get("Remote_Addr").ToString();
                    MongodbAccount.Instance.ExecuteInsert("BindLog", savelog);
                }
            }
            else
            {
                // ReturnMsg("-10");//acc or pwd error
                buildReturnMsg("-12");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string phoneNum = Request.QueryString["phonenum"];

            if (string.IsNullOrEmpty(phoneNum))
            {
                Response.Write(Helper.buildLuaReturn(-2, "err_not_phone"));//号码错误
                return;
            }
            string phoneCode = Request.QueryString["phonecode"];

            if (string.IsNullOrEmpty(phoneCode))
            {
                Response.Write(Helper.buildLuaReturn(-2, "err_not_phone"));//号码错误
                return;
            }
            phoneNum  = Encoding.Default.GetString(Convert.FromBase64String(phoneNum));
            phoneNum  = AESHelper.AESDecrypt(phoneNum, AES_KEY);  //aes解密
            phoneCode = Encoding.Default.GetString(Convert.FromBase64String(phoneCode));
            phoneCode = AESHelper.AESDecrypt(phoneCode, AES_KEY); //aes解密

            List <IMongoQuery> lmq = new List <IMongoQuery>();

            lmq.Add(Query.EQ("phoneNum", phoneNum));
            lmq.Add(Query.EQ("phoneCode", phoneCode));

            Dictionary <string, object> data = MongodbAccount.Instance.ExecuteGetByQuery("BaiduPhoneCode", Query.And(lmq), new string[] { "lastSendTime" });

            if (data == null)
            {
                Response.Write(Helper.buildLuaReturn(-2, "err_not_phone"));//号码错误
                return;
            }

            string password    = BuildAccount.getAutoPassword(6);
            string passwordMD5 = AESHelper.MD5Encrypt(password);

            updateAccountInfos(phoneNum, passwordMD5);
            //获取帐号信息
            List <AccountInfo> accounts = getAccountInfos(phoneNum);

            //没有帐号
            if (accounts.Count == 0)
            {
                Response.Write(Helper.buildLuaReturn(-2, "err_not_phone"));//号码错误
                return;
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("local ret = {{}};");
                sb.Append("ret.code = 0;");
                sb.Append("ret.msg = \"\";");
                sb.Append("ret.data = {{}};");
                for (int i = 0; i < accounts.Count; i++)
                {
                    string pwd = AESHelper.AESEncrypt(password, AES_KEY);
                    sb.AppendFormat("ret.data[{0}] = {{acc=\"{1}\",pwd=\"{2}\"}};", i + 1, accounts[i].account, pwd);
                }
                sb.Append("return ret;");
                Response.Write(sb.ToString());
            }
        }