Form1.cs 5.1 KB

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