MainForm.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Net;
  9. using System.Runtime.InteropServices;
  10. using System.Text;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace SheepSheep
  15. {
  16. public partial class MainForm : Form
  17. {
  18. private int passWay = 0;
  19. private int stateGame = 0;
  20. private int stateTopic = 0;
  21. private string costTime = "10";
  22. public MainForm()
  23. {
  24. InitializeComponent();
  25. init();
  26. }
  27. private void init() {
  28. this.comboBox1.SelectedIndex = 0;
  29. getWechatToken();
  30. }
  31. private void getWechatToken() {
  32. string token = "";
  33. token = WcToken.GetTokenFromWechat();
  34. if (token.Equals("false"))
  35. {
  36. MessageBox.Show(this, "未检测到\"微信->羊了个羊\",请重新登陆微信并打开羊了个羊游戏。\n仍然显示此提示的话请自行抓包获取Token。", "Tips:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  37. }
  38. else
  39. {
  40. this.textBox1.Text = token;
  41. MessageBox.Show(this, "检测到Token,已自动填写,请直接\"羊它!\"即可", "Tips:", MessageBoxButtons.OK, MessageBoxIcon.Information);
  42. }
  43. }
  44. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  45. {
  46. this.passWay = this.comboBox1.SelectedIndex;
  47. if (this.passWay == 1) {
  48. string ret = string.Empty;
  49. InputDialog.Show(out ret, "请输入过关耗时: ");
  50. this.costTime = ret;
  51. Console.WriteLine(ret);
  52. }
  53. }
  54. private void passTopicGame(int passTimes)
  55. {
  56. string apiUrl = string.Format("https://cat-match.easygame2021.com/sheep/v1/game/topic_game_over?rank_score=1&rank_state=1&rank_time={0}&rank_role=1&skin=1", costTime);
  57. string json = "";
  58. for (int i = 0; i < passTimes; i++)
  59. {
  60. if (stateTopic == 0)
  61. {
  62. return;
  63. }
  64. if (passWay == 0)
  65. {
  66. try
  67. {
  68. Random r = new Random();
  69. costTime = r.Next(0, 3000).ToString();
  70. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl);
  71. request.Method = "GET";
  72. request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.33";
  73. request.Host = "cat-match.easygame2021.com";
  74. request.Headers.Add("t", this.textBox1.Text);
  75. request.Timeout = 5000;
  76. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  77. Stream myResponseStream = response.GetResponseStream();
  78. StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
  79. string retString = myStreamReader.ReadToEnd();
  80. myStreamReader.Close();
  81. myResponseStream.Close();
  82. if (retString.Contains("\"err_code\":0"))
  83. {
  84. this.Invoke(new Action(() =>
  85. {
  86. toolStripStatusLabel2.Text = "通关次数: " + (i + 1).ToString();
  87. }));
  88. Console.WriteLine(retString);
  89. }
  90. }
  91. catch (Exception ex)
  92. {
  93. //throw ex;
  94. }
  95. }
  96. if (i == passTimes - 1)
  97. {
  98. this.Invoke(new Action(() =>
  99. {
  100. if (stateGame == 0) {
  101. stateTopic = 0;
  102. this.button1.Text = "羊它!";
  103. }
  104. }));
  105. }
  106. }
  107. }
  108. private void passTheGame(int passTimes) {
  109. string apiUrl = string.Format("https://cat-match.easygame2021.com/sheep/v1/game/game_over?rank_score=1&rank_state=1&rank_time={0}&rank_role=1&skin=1", costTime);
  110. string json = "";
  111. for (int i = 0; i < passTimes; i++)
  112. {
  113. if (stateGame == 0) {
  114. return;
  115. }
  116. if (passWay == 0)
  117. {
  118. try
  119. {
  120. Random r = new Random();
  121. costTime = r.Next(0, 3000).ToString();
  122. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl);
  123. request.Method = "GET";
  124. request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.33";
  125. request.Host = "cat-match.easygame2021.com";
  126. request.Headers.Add("t", this.textBox1.Text);
  127. request.Timeout = 5000;
  128. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  129. Stream myResponseStream = response.GetResponseStream();
  130. StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
  131. string retString = myStreamReader.ReadToEnd();
  132. myStreamReader.Close();
  133. myResponseStream.Close();
  134. if (retString.Contains("\"err_code\":0"))
  135. {
  136. this.Invoke(new Action(() =>
  137. {
  138. toolStripStatusLabel1.Text = "加入次数: " + (i+1).ToString();
  139. }));
  140. Console.WriteLine(retString);
  141. }
  142. }
  143. catch (Exception ex) {
  144. //throw ex;
  145. }
  146. }
  147. if (i == passTimes - 1) {
  148. this.Invoke(new Action(() =>
  149. {
  150. if (stateTopic == 0)
  151. {
  152. stateGame = 0;
  153. this.button1.Text = "羊它!";
  154. }
  155. }));
  156. }
  157. }
  158. }
  159. private void button1_Click(object sender, EventArgs e)
  160. {
  161. if (!this.textBox1.Text.Equals(""))
  162. {
  163. if (stateGame == 0)
  164. {
  165. stateGame = 1;
  166. stateTopic = 1;
  167. Thread t = new Thread(() => passTheGame(int.Parse(this.textBox2.Text)));
  168. t.Start();
  169. Thread tt = new Thread(() => passTopicGame(int.Parse(this.textBox3.Text)));
  170. tt.Start();
  171. this.button1.Text = "停止羊!";
  172. MessageBox.Show(this, "开始羊咯!", "Tips:", MessageBoxButtons.OK, MessageBoxIcon.Information);
  173. }
  174. else
  175. {
  176. stateGame = 0;
  177. stateTopic = 0;
  178. this.button1.Text = "羊它!";
  179. }
  180. }
  181. else {
  182. MessageBox.Show(this, "未填写Token,请点击\"获取Token\"后再\"羊它!\"", "Tips:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  183. }
  184. }
  185. private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  186. {
  187. if (e.KeyChar != '\b')
  188. {
  189. if ((e.KeyChar < '0') || (e.KeyChar > '9'))
  190. {
  191. e.Handled = true;
  192. }
  193. }
  194. }
  195. private void label4_Click(object sender, EventArgs e)
  196. {
  197. getWechatToken();
  198. }
  199. }
  200. }