WOC


SUBMITTED BY: dbzdivik

DATE: Nov. 25, 2015, 12:55 p.m.

FORMAT: C

SIZE: 8.5 kB

HITS: 15836

  1. using System;
  2. using System.IO;
  3. using System.Net;
  4. using System.Text;
  5. namespace WOCBOT_3
  6. {
  7. public static class Web
  8. {
  9. private static CookieContainer loginCookies;
  10. private static CookieCollection cookie;
  11. private static string loginURL;
  12. static Web()
  13. {
  14. Web.loginCookies = new CookieContainer();
  15. Web.cookie = new CookieCollection();
  16. Web.loginURL = "http://www.warofclicks.com/User/Login";
  17. }
  18. public static void downloadFile(string url, string path)
  19. {
  20. try
  21. {
  22. (new WebClient()).DownloadFile(url, path);
  23. }
  24. catch (Exception exception)
  25. {
  26. App.writeLog(string.Concat("(ERROR) Unable to download file : ", exception.ToString()));
  27. }
  28. }
  29. public static void getCookies(string url = "https://www.warofclicks.com")
  30. {
  31. try
  32. {
  33. HttpWebRequest cookieContainer = (HttpWebRequest)WebRequest.Create(url);
  34. cookieContainer.CookieContainer = new CookieContainer();
  35. cookieContainer.CookieContainer.Add(Web.cookie);
  36. Web.cookie = ((HttpWebResponse)cookieContainer.GetResponse()).Cookies;
  37. Web.loginCookies.Add(Web.cookie);
  38. }
  39. catch (Exception exception1)
  40. {
  41. Exception exception = exception1;
  42. App.writeLog(string.Concat("(ERROR) Unable to get cookies from ", url, " : ", exception.ToString()));
  43. }
  44. }
  45. public static string getPage(string url)
  46. {
  47. string end;
  48. try
  49. {
  50. HttpWebRequest cookieContainer = (HttpWebRequest)WebRequest.Create(url);
  51. cookieContainer.CookieContainer = new CookieContainer();
  52. cookieContainer.CookieContainer = Web.loginCookies;
  53. HttpWebResponse response = (HttpWebResponse)cookieContainer.GetResponse();
  54. Web.loginCookies.Add(response.Cookies);
  55. using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
  56. {
  57. end = streamReader.ReadToEnd();
  58. }
  59. }
  60. catch (Exception exception1)
  61. {
  62. Exception exception = exception1;
  63. App.writeLog(string.Concat("(ERROR) Unable to get page ", url, " : ", exception.ToString()));
  64. end = null;
  65. }
  66. return end;
  67. }
  68. public static string login(string email, string password)
  69. {
  70. string end;
  71. Web.getCookies("https://www.warofclicks.com");
  72. try
  73. {
  74. string str = string.Format("ReturnUrl=%2F&Email={0}&Password={1}&RememberMe=true&RememberMe=false", email, password);
  75. HttpWebRequest cookieContainer = (HttpWebRequest)WebRequest.Create(Web.loginURL);
  76. cookieContainer.CookieContainer = new CookieContainer();
  77. cookieContainer.CookieContainer.Add(Web.cookie);
  78. cookieContainer.Method = "POST";
  79. cookieContainer.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0";
  80. cookieContainer.AllowWriteStreamBuffering = true;
  81. cookieContainer.KeepAlive = true;
  82. cookieContainer.Host = "www.warofclicks.com";
  83. cookieContainer.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
  84. cookieContainer.Referer = "http://www.warofclicks.com/";
  85. cookieContainer.ProtocolVersion = HttpVersion.Version11;
  86. cookieContainer.AllowAutoRedirect = true;
  87. cookieContainer.ContentType = "application/x-www-form-urlencoded";
  88. byte[] bytes = Encoding.ASCII.GetBytes(str);
  89. cookieContainer.ContentLength = (long)((int)bytes.Length);
  90. Stream requestStream = cookieContainer.GetRequestStream();
  91. requestStream.Write(bytes, 0, (int)bytes.Length);
  92. requestStream.Close();
  93. HttpWebResponse response = (HttpWebResponse)cookieContainer.GetResponse();
  94. Web.loginCookies = cookieContainer.CookieContainer;
  95. using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
  96. {
  97. end = streamReader.ReadToEnd();
  98. }
  99. }
  100. catch (Exception exception)
  101. {
  102. App.writeLog(string.Concat("(ERROR) Unable to login : ", exception.ToString()));
  103. end = null;
  104. }
  105. return end;
  106. }
  107. public static string postCaptcha(string currentLink, string captchaID, string ADV)
  108. {
  109. string end;
  110. try
  111. {
  112. byte[] bytes = Encoding.UTF8.GetBytes(string.Concat(new string[] { "{\"img\":\"", captchaID, "\",\"adv\":\"", ADV, "\"}" }));
  113. HttpWebRequest length = (HttpWebRequest)WebRequest.Create("http://www.warofclicks.com/Security/CheckSecurityImage");
  114. length.CookieContainer = Web.loginCookies;
  115. length.Method = "POST";
  116. length.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0";
  117. length.AllowWriteStreamBuffering = true;
  118. length.KeepAlive = true;
  119. length.Host = "www.warofclicks.com";
  120. length.Accept = "application/json, text/javascript, */*; q=0.01";
  121. length.Referer = currentLink;
  122. length.ContentType = "application/json; charset=UTF-8";
  123. length.ContentLength = (long)((int)bytes.Length);
  124. Stream requestStream = length.GetRequestStream();
  125. requestStream.Write(bytes, 0, (int)bytes.Length);
  126. requestStream.Close();
  127. using (StreamReader streamReader = new StreamReader(((HttpWebResponse)length.GetResponse()).GetResponseStream()))
  128. {
  129. end = streamReader.ReadToEnd();
  130. }
  131. }
  132. catch (Exception exception)
  133. {
  134. App.writeLog(string.Concat("(ERROR) Unable to post captcha : ", exception.ToString()));
  135. end = Web.postCaptcha(currentLink, captchaID, ADV);
  136. }
  137. return end;
  138. }
  139. public static string postData(string url, string data, params object[] args)
  140. {
  141. string end;
  142. try
  143. {
  144. string str = string.Format(data, args);
  145. HttpWebRequest version11 = (HttpWebRequest)WebRequest.Create(url);
  146. version11.CookieContainer = Web.loginCookies;
  147. version11.Method = "POST";
  148. version11.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0";
  149. version11.AllowWriteStreamBuffering = true;
  150. version11.KeepAlive = true;
  151. version11.Host = "www.warofclicks.com";
  152. version11.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
  153. version11.Referer = url;
  154. version11.ProtocolVersion = HttpVersion.Version11;
  155. version11.AllowAutoRedirect = true;
  156. version11.ContentType = "application/x-www-form-urlencoded";
  157. byte[] bytes = Encoding.ASCII.GetBytes(str);
  158. version11.ContentLength = (long)((int)bytes.Length);
  159. Stream requestStream = version11.GetRequestStream();
  160. requestStream.Write(bytes, 0, (int)bytes.Length);
  161. requestStream.Close();
  162. using (StreamReader streamReader = new StreamReader(((HttpWebResponse)version11.GetResponse()).GetResponseStream()))
  163. {
  164. end = streamReader.ReadToEnd();
  165. }
  166. }
  167. catch (Exception exception1)
  168. {
  169. Exception exception = exception1;
  170. App.writeLog(string.Concat("(ERROR) Can't connect to ", url, " : ", exception.ToString()));
  171. end = null;
  172. }
  173. return end;
  174. }
  175. }
  176. }

comments powered by Disqus