Advertisement
Guest User

error

a guest
Aug 31st, 2018
4,549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.Data;
  5. using System.Text;
  6. using System.Web;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Data.SqlClient;
  10. using System.Net.Mail;
  11. using System.Configuration;
  12.  
  13. public partial class api_Login : WOApiWebPage
  14. {
  15. void RegisterLoginIP(int CustomerID)
  16. {
  17. SqlCommand sqcmd = new SqlCommand();
  18. sqcmd.CommandType = CommandType.StoredProcedure;
  19. sqcmd.CommandText = "WZ_ACCOUNT_RegisterLoginIP";
  20. sqcmd.Parameters.AddWithValue("@in_CustomerID", CustomerID);
  21. sqcmd.Parameters.AddWithValue("@in_IP", LastIP);
  22.  
  23. if (!CallWOApi(sqcmd))
  24. return;
  25.  
  26. reader.Read();
  27. int IsNew = getInt("IsNew");
  28. string email = getString("email");
  29. if (IsNew == 0)
  30. return;
  31.  
  32. // we have new ip, send email to devs about that
  33. string GeoCode = IPLocationCheck.GetCountryCode(LastIP);
  34.  
  35. /*try
  36. {
  37. MailMessage mail = new MailMessage("loginwarning@thewarz.com", "ptumik@thewarinc.com");
  38. SmtpClient client = new SmtpClient();
  39. client.DeliveryMethod = SmtpDeliveryMethod.Network;
  40. client.Host = "smtp.mandrillapp.com";
  41. client.Port = 25;
  42. client.UseDefaultCredentials = false;
  43. client.Credentials = new System.Net.NetworkCredential("billing@playwarz.comm", "a216ff3e-8cee-431a-a111-3c151803ac5b");
  44. mail.Subject = "WarZ Developer Account Login IP detected";
  45. mail.Body = string.Format(
  46. "Developer Account {0} {1} was logged from IP {2}, country:{3}",
  47. CustomerID, email, LastIP, GeoCode);
  48. client.Send(mail);
  49. }
  50. catch (System.Exception ex)
  51. {
  52. throw new ApiExitException("can't send dev login email: " + ex.Message);
  53. }*/
  54. }
  55.  
  56. void SendLockEmail(string email, string countryIP, string token)
  57. {
  58. //string url = "http://127.0.0.1:56016/Site/api_AccUnlock.aspx?token=" + token;
  59. //string url = "http://202.162.78.185/WarZ/api/api_AccUnlock.aspx?token=" + token;
  60. string url = "http://127.0.0.1/WarZ/api/api_AccUnlock.aspx?token=" + token;
  61.  
  62. string subj = "Infestation: Survivor Stories Account Lock Notice";
  63. string body = "";
  64. body += string.Format("Unusual login attempt was detected from {0} ({1}).\n", LastIP, countryIP);
  65. body += string.Format("To unlock your account please visit the following page: {0}\n", url);
  66.  
  67. // check if we can read correct email
  68. try
  69. {
  70. string fname = HttpContext.Current.Server.MapPath("~/App_Data") + "/lock_email.html";
  71. body = System.IO.File.ReadAllText(fname);
  72. body = body.Replace("{IP}", string.Format("{0} ({1})", LastIP, countryIP));
  73. body = body.Replace("{URL}", url);
  74. }
  75. catch
  76. {
  77. }
  78.  
  79. /*try
  80. {
  81. //MailMessage mail = new MailMessage("support@202.162.78.185.com", email);
  82. MailMessage mail = new MailMessage("support@127.0.0.1.com", email);
  83. SmtpClient client = new SmtpClient();
  84. client.DeliveryMethod = SmtpDeliveryMethod.Network;
  85. client.Host = "smtp.mandrillapp.com";
  86. client.Port = 25;
  87. client.UseDefaultCredentials = false;
  88. client.Credentials = new System.Net.NetworkCredential("billing@playwarz.comm", "a216ff3e-8cee-431a-a111-3c151803ac5b");
  89. mail.IsBodyHtml = true;
  90. mail.Subject = subj;
  91. mail.Body = body;
  92. client.Send(mail);
  93. }
  94. catch
  95. {
  96. // fail silently, shit happens.
  97. // throw new ApiExitException("can't send dev login email: " + ex.Message);
  98. }*/
  99. }
  100.  
  101. protected override void Execute()
  102. {
  103. string username = web.Param("username332563");
  104. string password = web.Param("password554249");
  105. string computerid = web.Param("computerid");
  106. string mac = web.Param("mac");
  107.  
  108. string countryIP = "";
  109. if (!String.IsNullOrEmpty(Request["HTTP_CF_IPCOUNTRY"]))
  110. countryIP = Request["HTTP_CF_IPCOUNTRY"];
  111.  
  112. SqlCommand sqcmd = new SqlCommand();
  113. sqcmd.CommandType = CommandType.StoredProcedure;
  114. sqcmd.CommandText = "WZ_ACCOUNT_LOGIN";
  115. sqcmd.Parameters.AddWithValue("@in_IP", LastIP);
  116. sqcmd.Parameters.AddWithValue("@in_EMail", username);
  117. sqcmd.Parameters.AddWithValue("@in_Password", password);
  118. sqcmd.Parameters.AddWithValue("@in_Country", countryIP);
  119. sqcmd.Parameters.AddWithValue("@in_HardwareID", computerid);
  120. sqcmd.Parameters.AddWithValue("@in_Mac", mac);
  121.  
  122. if (!CallWOApi(sqcmd))
  123. return;
  124.  
  125. reader.Read();
  126. int CustomerID = getInt("CustomerID");
  127. int AccountStatus = getInt("AccountStatus");
  128. int SessionID = 0;
  129. int IsDeveloper = 0;
  130.  
  131. if (CustomerID > 0)
  132. {
  133. SessionID = getInt("SessionID");
  134. IsDeveloper = getInt("IsDeveloper");
  135.  
  136. // if this is a steam user, check if he own game
  137. string SteamUserID = getString("SteamUserID");
  138. if (SteamUserID != "0")
  139. {
  140. SteamApi api = new SteamApi();
  141. bool Have_Game = api.CheckAppOwnership(SteamUserID, "226700"); // base game
  142. if (!Have_Game)
  143. {
  144. // special 1001 code for running under steam but without game.
  145. Response.Write("WO_0");
  146. Response.Write(string.Format("{0} {1} {2}",
  147. 0, 0, 1001));
  148. return;
  149. }
  150. }
  151.  
  152. if (AccountStatus == 103)
  153. {
  154. // first time account lock, send email and override status to normal lock
  155. AccountStatus = 102;
  156. string LockToken = getString("LockToken");
  157. SendLockEmail(username, countryIP, LockToken);
  158. }
  159.  
  160. if (IsDeveloper > 0)
  161. {
  162. RegisterLoginIP(CustomerID);
  163. }
  164. }
  165.  
  166. GResponse.Write("WO_0");
  167. GResponse.Write(string.Format("{0} {1} {2}",
  168. CustomerID, SessionID, AccountStatus));
  169. }
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement