public override int Process(AsyncUser user, byte[] buffer, int size) { // \valid\\email\[email protected]\final\ Dictionary <string, string> d = new Dictionary <string, string>(); Utils.GetArguments(buffer, size, ref d); if (d.ContainsKey("valid") && d.ContainsKey("email")) { if (GsService.ContainsEmail(d["email"])) { Write(user, _data[1], 0, _data[1].Length); } else { Write(user, _data[2], 0, _data[2].Length); } return(1); } return(0); }
public override int Process(AsyncUser user, byte[] buffer, int size) { Contract.Requires(user != null); Dictionary <string, string> d = new Dictionary <string, string>(); Utils.GetArguments(buffer, size, ref d); // \newuser\\email\[email protected]\nick\JohnDoe2\password\sfcrulz\id\1\final\ if (d.ContainsKey("newuser") && d.ContainsKey("email") && d.ContainsKey("nick") && d.ContainsKey("password")) { if (GsService.ContainsEmail(d["email"])) { Write(user, _data[2], 0, _data[2].Length); } else if (GsService.ContainsNick(d["nick"])) { Write(user, _data[3], 0, _data[3].Length); } else { GsService.AddProfile(d["email"], d["nick"], d["password"], out GsProfile profile); // \nur\\userid\12617\profileid\19465\id\1\final\ StringBuilder s = new StringBuilder(1024); s.Append("\\nur\\\\userid\\"); s.Append(profile.Id); s.Append("\\profileid\\"); s.Append(profile.Id); s.Append("\\id\\1\\final\\"); byte[] b = Encoding.ASCII.GetBytes(s.ToString()); Write(user, b, 0, b.Length); } return(1); } /* * \login\\challenge\IoWIbSnjMf2pv9iUioRgF9ySYLV2r72p\user\JohnDoe2@[email protected]\userid\12617\profileid\19465\response\08eeb76f1241ac0777a18aac726c03d1\firewall\1\port\0\id\1\final\ * \login\\challenge\PKPNiLeCH1D71pCwSndbT36zrkQLaG2w\user\JohnDoe2@[email protected]\response\a7d6e62a66f96565966f96ab475a44cf\firewall\1\port\0\id\1\final\ */ if (d.ContainsKey("login") && d.ContainsKey("challenge") && d.ContainsKey("user") && d.ContainsKey("response")) { GsService.GetProfile(d["user"], out GsProfile profile); if (profile != null) { using MD5 md5 = MD5.Create(); string password = GetHash(md5, profile.Password); string userData = password + " " + profile.Username; string clientChallenge = d["challenge"]; string clientResponse = GetHash(md5, userData + clientChallenge + _serverChallenge + password); string serviceResponse = GetHash(md5, userData + _serverChallenge + clientChallenge + password); if (clientResponse.Equals(d["response"], StringComparison.Ordinal)) { // \lc\2\sesskey\239289\proof\8f1295968d534a3c6816d24dc172d92e\userid\12617\profileid\19465\uniquenick\JohnDoe2@[email protected]\lt\x4TGX3[SbkAk]NIJt3Hc4N__\id\1\final\ StringBuilder s = new StringBuilder(1024); s.Append("\\lc\\2\\sesskey\\"); s.Append(user.Id); s.Append("\\proof\\"); s.Append(serviceResponse); s.Append("\\userid\\"); s.Append(profile.Id); s.Append("\\profileid\\"); s.Append(profile.Id); s.Append("\\uniquenick\\"); s.Append(profile.Username); s.Append("\\lt\\x4TGX3[SbkAk]NIJt3Hc4N__\\id\\1\\final\\"); byte[] b = Encoding.ASCII.GetBytes(s.ToString()); Write(user, b, 0, b.Length); if (d.ContainsKey("userid") && d.ContainsKey("profileid")) { return(1); } else { return(0); } } } Write(user, _data[4], 0, _data[4].Length); return(1); } // \logout\\sesskey\239288\final\ if (d.ContainsKey("logout")) { return(1); } return(0); }