Form1.cs 5.5 KB

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