Form1.cs 5.3 KB

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