├── .gitignore ├── LICENSE ├── README.md ├── main.py ├── preview.gif └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/latest/usage/project/#working-with-version-control 110 | .pdm.toml 111 | .pdm-python 112 | .pdm-build/ 113 | 114 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 115 | __pypackages__/ 116 | 117 | # Celery stuff 118 | celerybeat-schedule 119 | celerybeat.pid 120 | 121 | # SageMath parsed files 122 | *.sage.py 123 | 124 | # Environments 125 | .env 126 | .venv 127 | env/ 128 | venv/ 129 | ENV/ 130 | env.bak/ 131 | venv.bak/ 132 | 133 | # Spyder project settings 134 | .spyderproject 135 | .spyproject 136 | 137 | # Rope project settings 138 | .ropeproject 139 | 140 | # mkdocs documentation 141 | /site 142 | 143 | # mypy 144 | .mypy_cache/ 145 | .dmypy.json 146 | dmypy.json 147 | 148 | # Pyre type checker 149 | .pyre/ 150 | 151 | # pytype static type analyzer 152 | .pytype/ 153 | 154 | # Cython debug symbols 155 | cython_debug/ 156 | 157 | # PyCharm 158 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 159 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 160 | # and can be added to the global gitignore or merged into this file. For a more nuclear 161 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 162 | #.idea/ 163 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 ph0ebus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XiaoYuanSolver 2 | 3 | > [!IMPORTANT] 4 | > 由于小猿口算已更新,无力维护,项目已废弃,可移步其他师傅的仓库看看 5 | 6 | ![Language](https://img.shields.io/badge/language-python-blue.svg) 7 | 8 | 小猿口算 pk一把梭脚本 9 | 10 | 采用mitm抓包获取题目和答案信息,然后adb shell模拟鼠标滑动输入。随便写的shi山代码,各位看官看个乐子就好 11 | 12 | > [!IMPORTANT] 13 | > 仅供学习交流使用,请勿用于非法用途 14 | 15 | ## Preview 16 | 17 | ![alt](./preview.gif) 18 | 19 | ## Usage 20 | 21 | 1. 安装依赖 22 | 23 | ```bash 24 | pip install -r requirements.txt 25 | ``` 26 | 27 | 2. 配置 adb 调试 28 | 29 | 3. 配置安卓代理,需要安装mitmproxy CA 证书,网上教程很多这里不再赘述 30 | 31 | 4. 运行, 可以用绝对路径,也可以配置环境变量 32 | 33 | ```bash 34 | mitmweb.exe -s main.py -p 8080 35 | ``` 36 | 37 | ## Star History 38 | 39 | [![Star History Chart](https://api.star-history.com/svg?repos=ph0ebus/XiaoYuanSolver&type=Date)](https://star-history.com/#ph0ebus/XiaoYuanSolver&Date) 40 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import threading 2 | 3 | from mitmproxy import http 4 | from mitmproxy import ctx 5 | import logging 6 | import random 7 | import subprocess 8 | import time 9 | 10 | # 禁用默认日志 11 | logging.getLogger("mitmproxy").setLevel(logging.CRITICAL) 12 | ctx.log.info("监听中...") 13 | 14 | status = 0 15 | answers = [] 16 | 17 | 18 | def request(flow: http.HTTPFlow) -> None: 19 | # 处理请求 20 | # ctx.log.info(f"Request: {flow.request.method} {flow.request.url}") 21 | pass 22 | 23 | 24 | def response(flow: http.HTTPFlow) -> None: 25 | global status 26 | global answers 27 | # 处理响应 28 | # ctx.log.info(f"Response: {flow.response.status_code} {flow.request.url}") 29 | if "/leo-game-pk/android/math/pk/match" in flow.request.url: 30 | ctx.log.info("你这局的对手是: " + flow.response.json()['otherUser']['userName']) 31 | answers = [] 32 | questions = flow.response.json()['examVO']['questions'] 33 | for question in questions: 34 | answers.append(question['answer']) 35 | ctx.log.info("成功获取到题目答案:" + ' '.join(answers)) 36 | status = 1 37 | thread = threading.Thread(target=answer_write, args=(answers,)) 38 | # 启动线程 39 | thread.start() 40 | 41 | 42 | def answer_write(arg): 43 | global status 44 | status = 0 45 | time.sleep(12.4) # 没想到更好的开局检测方案,不过每局延时差不多,这个延迟刚刚好 46 | cwd = r'F:\Program Files\Netease\MuMu Player 12\shell' # adb 所在目录 47 | swipe = r'.\adb.exe shell input swipe %d %d %d %d 0 ' # 模拟滑动 48 | jitter = round(random.random(), 2) 49 | for i in arg: 50 | ctx.log.info("正在作答:" + i) 51 | if i == '>': 52 | subprocess.Popen(swipe % (600 + jitter, 1355 + jitter, 680 - jitter, 1432 - jitter) 53 | + '&' + swipe % (680 + jitter, 1432 + jitter, 603 - jitter, 1506 - jitter), shell=True, 54 | cwd=cwd) 55 | elif i == '<': 56 | subprocess.Popen(swipe % (660 + jitter, 1360 + jitter, 600 - jitter, 1424 - jitter) 57 | + '&' + swipe % (600 + jitter, 1424 + jitter, 675 - jitter, 1495 - jitter), shell=True, 58 | cwd=cwd) 59 | elif i == '=': 60 | subprocess.Popen(swipe % (600 + jitter, 1380 + jitter, 640 - jitter, 1379 - jitter) 61 | + '&' + swipe % (600 + jitter, 1424 + jitter, 641 - jitter, 1425 - jitter), shell=True, 62 | cwd=cwd) 63 | else: 64 | ctx.log.info("尚不支持此答案:" + i) 65 | time.sleep(0.35) # 写太快会识别出错,目前这个还算稳定,大部分时间都能正常跑 66 | -------------------------------------------------------------------------------- /preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ph0ebus/XiaoYuanSolver/b1be10ee4e2be8fd0b4bf98fb6514a5e424b8134/preview.gif -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | mitmproxy --------------------------------------------------------------------------------