MainForm.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 state = 0;
  20. private string costTime = "10";
  21. public MainForm()
  22. {
  23. InitializeComponent();
  24. init();
  25. }
  26. private void init() {
  27. this.comboBox1.SelectedIndex = 0;
  28. getWechatToken();
  29. }
  30. private void getWechatToken() {
  31. string token = "";
  32. token = WcToken.GetTokenFromWechat();
  33. if (token.Equals("false"))
  34. {
  35. MessageBox.Show(this, "未检测到\"微信->羊了个羊\",请重新登陆微信并打开羊了个羊游戏。\n仍然显示此提示的话请自行抓包获取Token。", "Tips:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  36. }
  37. else
  38. {
  39. this.textBox1.Text = token;
  40. MessageBox.Show(this, "检测到Token,已自动填写,请直接\"羊它!\"即可", "Tips:", MessageBoxButtons.OK, MessageBoxIcon.Information);
  41. }
  42. }
  43. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  44. {
  45. this.passWay = this.comboBox1.SelectedIndex;
  46. if (this.passWay == 1) {
  47. string ret = string.Empty;
  48. InputDialog.Show(out ret, "请输入过关耗时: ");
  49. this.costTime = ret;
  50. Console.WriteLine(ret);
  51. }
  52. }
  53. private void passTheGame(int passTimes) {
  54. 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);
  55. string json = "";
  56. for (int i = 0; i < passTimes; i++)
  57. {
  58. if (state == 0) {
  59. this.Invoke(new Action(() =>
  60. {
  61. MessageBox.Show(this, "已停止羊!", "Tips:", MessageBoxButtons.OK, MessageBoxIcon.Information);
  62. }));
  63. return;
  64. }
  65. if (passWay == 0)
  66. {
  67. try
  68. {
  69. Random r = new Random();
  70. costTime = r.Next(0, 3000).ToString();
  71. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl);
  72. request.Method = "GET";
  73. 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";
  74. request.Host = "cat-match.easygame2021.com";
  75. request.Headers.Add("t", this.textBox1.Text);
  76. request.Timeout = 5000;
  77. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  78. Stream myResponseStream = response.GetResponseStream();
  79. StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
  80. string retString = myStreamReader.ReadToEnd();
  81. myStreamReader.Close();
  82. myResponseStream.Close();
  83. if (retString.Contains("\"err_code\":0"))
  84. {
  85. this.Invoke(new Action(() =>
  86. {
  87. toolStripStatusLabel1.Text = "通关次数: " + i.ToString();
  88. }));
  89. Console.WriteLine(retString);
  90. }
  91. }
  92. catch (Exception ex) {
  93. //throw ex;
  94. }
  95. }
  96. if (i == passTimes - 1) {
  97. this.Invoke(new Action(() =>
  98. {
  99. state = 0;
  100. this.button1.Text = "羊它!";
  101. }));
  102. }
  103. }
  104. }
  105. private void button1_Click(object sender, EventArgs e)
  106. {
  107. if (!this.textBox1.Text.Equals(""))
  108. {
  109. if (state == 0)
  110. {
  111. state = 1;
  112. Thread t = new Thread(() => passTheGame(int.Parse(this.textBox2.Text)));
  113. t.Start();
  114. this.button1.Text = "停止羊!";
  115. MessageBox.Show(this, "开始羊咯!", "Tips:", MessageBoxButtons.OK, MessageBoxIcon.Information);
  116. }
  117. else
  118. {
  119. state = 0;
  120. this.button1.Text = "羊它!";
  121. }
  122. }
  123. else {
  124. MessageBox.Show(this, "未填写Token,请点击\"获取Token\"后再\"羊它!\"", "Tips:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  125. }
  126. }
  127. private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  128. {
  129. if (e.KeyChar != '\b')
  130. {
  131. if ((e.KeyChar < '0') || (e.KeyChar > '9'))
  132. {
  133. e.Handled = true;
  134. }
  135. }
  136. }
  137. private void label4_Click(object sender, EventArgs e)
  138. {
  139. getWechatToken();
  140. }
  141. }
  142. }