├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── example.config.toml
├── make_release.bat
├── requirements.txt
├── run.py
├── tools
├── README.md
├── convernt_old_config.py
└── manual_login.py
└── utils
├── __init__.py
├── config.py
├── email.py
├── ftqq.py
├── log.py
└── version.py
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 | accounts.json
10 | settings.json
11 | config.toml
12 |
13 |
14 | # User-specific files (MonoDevelop/Xamarin Studio)
15 | *.userprefs
16 |
17 | # Build results
18 | [Dd]ebug/
19 | [Dd]ebugPublic/
20 | [Rr]elease/
21 | [Rr]eleases/
22 | x64/
23 | x86/
24 | xhh_reserve/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | [Ll]og/
29 |
30 | # Visual Studio 2015 cache/options directory
31 | .vs/
32 | # Uncomment if you have tasks that create the project's static files in wwwroot
33 | #wwwroot/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # DNX
49 | project.lock.json
50 | project.fragment.lock.json
51 | artifacts/
52 |
53 | *_i.c
54 | *_p.c
55 | *_i.h
56 | *.ilk
57 | *.meta
58 | *.obj
59 | *.pch
60 | *.pdb
61 | *.pgc
62 | *.pgd
63 | *.rsp
64 | *.sbr
65 | *.tlb
66 | *.tli
67 | *.tlh
68 | *.tmp
69 | *.tmp_proj
70 | *.log
71 | *.vspscc
72 | *.vssscc
73 | .builds
74 | *.pidb
75 | *.svclog
76 | *.scc
77 |
78 | # Chutzpah Test files
79 | _Chutzpah*
80 |
81 | # Visual C++ cache files
82 | ipch/
83 | *.aps
84 | *.ncb
85 | *.opendb
86 | *.opensdf
87 | *.sdf
88 | *.cachefile
89 | *.VC.db
90 | *.VC.VC.opendb
91 |
92 | # Visual Studio profiler
93 | *.psess
94 | *.vsp
95 | *.vspx
96 | *.sap
97 |
98 | # TFS 2012 Local Workspace
99 | $tf/
100 |
101 | # Guidance Automation Toolkit
102 | *.gpState
103 |
104 | # ReSharper is a .NET coding add-in
105 | _ReSharper*/
106 | *.[Rr]e[Ss]harper
107 | *.DotSettings.user
108 |
109 | # JustCode is a .NET coding add-in
110 | .JustCode
111 |
112 | # TeamCity is a build add-in
113 | _TeamCity*
114 |
115 | # DotCover is a Code Coverage Tool
116 | *.dotCover
117 |
118 | # NCrunch
119 | _NCrunch_*
120 | .*crunch*.local.xml
121 | nCrunchTemp_*
122 |
123 | # MightyMoose
124 | *.mm.*
125 | AutoTest.Net/
126 |
127 | # Web workbench (sass)
128 | .sass-cache/
129 |
130 | # Installshield output folder
131 | [Ee]xpress/
132 |
133 | # DocProject is a documentation generator add-in
134 | DocProject/buildhelp/
135 | DocProject/Help/*.HxT
136 | DocProject/Help/*.HxC
137 | DocProject/Help/*.hhc
138 | DocProject/Help/*.hhk
139 | DocProject/Help/*.hhp
140 | DocProject/Help/Html2
141 | DocProject/Help/html
142 |
143 | # Click-Once directory
144 | publish/
145 |
146 | # Publish Web Output
147 | *.[Pp]ublish.xml
148 | *.azurePubxml
149 | # TODO: Comment the next line if you want to checkin your web deploy settings
150 | # but database connection strings (with potential passwords) will be unencrypted
151 | #*.pubxml
152 | *.publishproj
153 |
154 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
155 | # checkin your Azure Web App publish settings, but sensitive information contained
156 | # in these scripts will be unencrypted
157 | PublishScripts/
158 |
159 | # NuGet Packages
160 | *.nupkg
161 | # The packages folder can be ignored because of Package Restore
162 | **/packages/*
163 | # except build/, which is used as an MSBuild target.
164 | !**/packages/build/
165 | # Uncomment if necessary however generally it will be regenerated when needed
166 | #!**/packages/repositories.config
167 | # NuGet v3's project.json files produces more ignoreable files
168 | *.nuget.props
169 | *.nuget.targets
170 |
171 | # Microsoft Azure Build Output
172 | csx/
173 | *.build.csdef
174 |
175 | # Microsoft Azure Emulator
176 | ecf/
177 | rcf/
178 |
179 | # Windows Store app package directories and files
180 | AppPackages/
181 | BundleArtifacts/
182 | Package.StoreAssociation.xml
183 | _pkginfo.txt
184 |
185 | # Visual Studio cache files
186 | # files ending in .cache can be ignored
187 | *.[Cc]ache
188 | # but keep track of directories ending in .cache
189 | !*.[Cc]ache/
190 |
191 | # Others
192 | ClientBin/
193 | ~$*
194 | *~
195 | *.dbmdl
196 | *.dbproj.schemaview
197 | *.jfm
198 | *.pfx
199 | *.publishsettings
200 | node_modules/
201 | orleans.codegen.cs
202 |
203 | # Since there are multiple workflows, uncomment next line to ignore bower_components
204 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
205 | #bower_components/
206 |
207 | # RIA/Silverlight projects
208 | Generated_Code/
209 |
210 | # Backup & report files from converting an old project file
211 | # to a newer Visual Studio version. Backup files are not needed,
212 | # because we have git ;-)
213 | _UpgradeReport_Files/
214 | Backup*/
215 | UpgradeLog*.XML
216 | UpgradeLog*.htm
217 |
218 | # SQL Server files
219 | *.mdf
220 | *.ldf
221 |
222 | # Business Intelligence projects
223 | *.rdl.data
224 | *.bim.layout
225 | *.bim_*.settings
226 |
227 | # Microsoft Fakes
228 | FakesAssemblies/
229 |
230 | # GhostDoc plugin setting file
231 | *.GhostDoc.xml
232 |
233 | # Node.js Tools for Visual Studio
234 | .ntvs_analysis.dat
235 |
236 | # Visual Studio 6 build log
237 | *.plg
238 |
239 | # Visual Studio 6 workspace options file
240 | *.opt
241 |
242 | # Visual Studio LightSwitch build output
243 | **/*.HTMLClient/GeneratedArtifacts
244 | **/*.DesktopClient/GeneratedArtifacts
245 | **/*.DesktopClient/ModelManifest.xml
246 | **/*.Server/GeneratedArtifacts
247 | **/*.Server/ModelManifest.xml
248 | _Pvt_Extensions
249 |
250 | # Paket dependency manager
251 | .paket/paket.exe
252 | paket-files/
253 |
254 | # FAKE - F# Make
255 | .fake/
256 |
257 | # JetBrains Rider
258 | .idea/
259 | *.sln.iml
260 |
261 | # CodeRush
262 | .cr/
263 |
264 | # Python Tools for Visual Studio (PTVS)
265 | __pycache__/
266 | *.pyc
267 | .vscode/
268 | debug.py
269 | *.zip
270 | test.py
271 | test/
272 | roll.py
273 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 更新日志
2 |
3 | ## 2021-11-19 v0.93
4 |
5 | * 改为使用Frida RPC计算hkey, 需要在config.toml中heybox节内定义rpc_server, 并部署RPC server
6 | * 模拟小黑盒版本为1.3.191
7 | * `pyxiaoheihe`版本需要>=1.0.11
8 |
9 | ## 2020-09-04 v0.91
10 |
11 | * 支持为每个账号配置不同的请求头, 方便多设备用户使用
12 | * 添加了对`点赞次数用尽`这个错误的处理
13 | * 稍微修改了下消息汇报格式
14 | * `pyxiaoheihe`版本需要>=1.0.8
15 |
16 | ## 2020-08-28 v0.90
17 |
18 | * `pyxiaoheihe`作为模块从本项目中独立出去, 可以使用`pip install pyxiaoheihe --upgrade`安装和更新.
19 | * 修复了几个小问题.
20 |
21 | ## 2020-08-21 v0.90
22 |
23 | * 配置文件有更新, 详细内容请查看`example.config.toml`
24 |
25 | * 适配小黑盒`1.3.121`客户端的加密算法
26 | * 增加了数据上报模块, 模拟正常客户端行为
27 | * 增加了随机延时机制(可以在`config.toml`中修改延时倍率)
28 | * 修正数个小问题
29 |
30 | ## 2020-08-07 v0.85
31 |
32 | * 修复上个版本的几处错误
33 | * 添加了发送评论的方法
34 | * 隐藏用法请加群
35 |
36 | ## 2020-08-05 v0.84
37 |
38 | ### 注意事项
39 |
40 | * 该版本新增了2个依赖库, 请使用命令 `pip isntall -r requirements.txt` 重新安装依赖
41 | * 该版本修改了配置文件, 建议对比 `example.config.toml` 手动更新
42 |
43 | ### 更新内容
44 |
45 | * 全面支持小黑盒加密协议, 隐藏用法请加群
46 | * 从该版本开始发行版中不再附带 `convernt_old_config.py`
47 | * 新支持了几条API
48 |
49 | ## 2020-08-04 v0.83
50 |
51 | * 修复了拉取动态不能正确判断有没有点过赞的问题
52 | * 更新提醒现在会附在执行结果后面而不是单独推送
53 |
54 | ## 2020-08-01 v0.82
55 |
56 | * 重构了原来的代码, 更加简洁高效
57 | * 使用全新的配置文件格式, 可以使用 `convernt_old_config.py` 进行转换
58 | * 当前 `pyxiaoheihe` 只实现了完成每日任务所必须的API, 待完成度比较高以后将成为独立的模块
59 | * `xhh_auto` 这个项目将专注于自动化运行, `pyxiaoheihe` 将专注于完整实现手机客户端的功能
60 | * 推出了 `xhhauto互助计划` , 具体信息请参考 `README.md`
61 | * 有问题欢迎提交issues, 或者在[我的博客](https://blog.chrxw.com)上留言
62 |
63 | ## 2020-07-29 v0.79
64 |
65 | * 更新新版hkey机制
66 | * 大部分沿用旧版代码, 后续将进行重构
67 |
68 | ## 【以下版本均已失效, 仅作存档】
69 |
70 | ## 2019-11-23 v0.70
71 |
72 | * 新增 `get_user_comment_list` 函数, 可以拉取用户评论, **暂不能判断是否已赞**
73 | * 新增 `batch_like_commentlist` 函数, 可以批量点赞评论列表
74 | * 默认不解析HTML, 手机端执行不会因为缺少lxml报错
75 | * 修改了几个批量拉取函数, 执行速度提升约20%
76 | * 修改了 `start.py` 中的几处语法错误
77 | * 小幅调整控制台的了输出样式
78 | * ~~下一个大版本将会重构~~
79 |
80 | ## 2019-10-18 v0.60
81 |
82 | * 修改了一处输出错误
83 | * 新增 `get_news_comments` 函数, 可以批量拉取文章评论
84 | * 新增 `share_comment` 函数, 用于分享文章评论
85 | * 函数修改 `get_daily_task_detail` , 现在能正确检测4项每日任务是否完成
86 | * 函数更名 `share` -> `share_news` , 原函数将被删除
87 | * 函数更名 `get_follower_list` -> `get_follower_list_by_userid` , 原函数将被删除, 新函数支持获取他人的粉丝列表
88 | * 函数更名 `get_following_list` -> `get_following_list_by_userid` , 原函数将被删除, 新函数支持获取他人的关注列表
89 | * 现在可以完成小黑盒新的每日任务了(分享评论), 每日经验+10
90 |
91 | ## 2019-10-04 v0.50
92 |
93 | * 增加了更新检测的开关( `UpdateCheck` ), 不过不建议关闭
94 | * 修复了直接运行脚本时读取配置文件的路径不正确的问题
95 | * 增加了运行结束后的提示, 使用参数-N禁用
96 | * 修复了几个bug
97 |
98 | ## 2019-9-29 v0.48
99 |
100 | * 修复了检查脚本更新会闪退的bug
101 | * 加了一层错误捕获机制
102 | * 增加了方糖推送的开关(EnableFtqq)
103 |
104 | ## 2019-9-26 v0.45
105 |
106 | * 修复了几个错误(然而还是没修完)
107 | * 小幅修改了输出格式
108 |
109 | ## 2019-9-25 v0.4
110 |
111 | * 重构了全部代码, 根据功能拆分模块
112 | * 文档注释规范化, 为所有函数添加了统一的注释
113 | * 完善了错误处理, 精简了log输出
114 | * 可以获取指定用户的动态、发帖、评论
115 | * 修改部分API入口地址
116 | * 重命名部分常量, 使描述更加清晰
117 | * 精简了一些只能单次操作的函数, 用能批量操作的函数替代
118 | * 更加友好的输出格式
119 |
120 | ## 2019-8-9 v0.3
121 |
122 | * 可以自动关注推荐关注列表中的用户, 并且可以过滤关注数和粉丝数差距过大的用户
123 | * 可以清理单向关注的用户(只清理关注数和粉丝数差距过大的用户)
124 | * 可以对好友发送私信(只能发)
125 | * ~~添加了N个没什么存在感被我忘记的的函数~~
126 |
127 | ## 2019-7-30 v0.2
128 |
129 | * 添加了对方糖(Server酱)的支持, 可以将脚本结果推送给微信
130 | * 可以自动关注自己的粉丝
131 | * 逆向出了hkey的计算方法~~(之前是瞎算的)~~, 正确的hkey应该能减少被检测到的概率
132 |
133 | ## 2019-7-22 v0.1
134 |
135 | * 简单支持多账号
136 | * 可以自动完成每日任务(签到, 点赞, 分享)
137 | * 可以自动给好友动态点赞
138 | * 可以获取账户详细数据, 拉取小黑盒新闻
139 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for
11 | software and other kinds of works, specifically designed to ensure
12 | cooperation with the community in the case of network server software.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | our General Public Licenses are intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users.
19 |
20 | When we speak of free software, we are referring to freedom, not
21 | price. Our General Public Licenses are designed to make sure that you
22 | have the freedom to distribute copies of free software (and charge for
23 | them if you wish), that you receive source code or can get it if you
24 | want it, that you can change the software or use pieces of it in new
25 | free programs, and that you know you can do these things.
26 |
27 | Developers that use our General Public Licenses protect your rights
28 | with two steps: (1) assert copyright on the software, and (2) offer
29 | you this License which gives you legal permission to copy, distribute
30 | and/or modify the software.
31 |
32 | A secondary benefit of defending all users' freedom is that
33 | improvements made in alternate versions of the program, if they
34 | receive widespread use, become available for other developers to
35 | incorporate. Many developers of free software are heartened and
36 | encouraged by the resulting cooperation. However, in the case of
37 | software used on network servers, this result may fail to come about.
38 | The GNU General Public License permits making a modified version and
39 | letting the public access it on a server without ever releasing its
40 | source code to the public.
41 |
42 | The GNU Affero General Public License is designed specifically to
43 | ensure that, in such cases, the modified source code becomes available
44 | to the community. It requires the operator of a network server to
45 | provide the source code of the modified version running there to the
46 | users of that server. Therefore, public use of a modified version, on
47 | a publicly accessible server, gives the public access to the source
48 | code of the modified version.
49 |
50 | An older license, called the Affero General Public License and
51 | published by Affero, was designed to accomplish similar goals. This is
52 | a different license, not a version of the Affero GPL, but Affero has
53 | released a new version of the Affero GPL which permits relicensing under
54 | this license.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | TERMS AND CONDITIONS
60 |
61 | 0. Definitions.
62 |
63 | "This License" refers to version 3 of the GNU Affero General Public License.
64 |
65 | "Copyright" also means copyright-like laws that apply to other kinds of
66 | works, such as semiconductor masks.
67 |
68 | "The Program" refers to any copyrightable work licensed under this
69 | License. Each licensee is addressed as "you". "Licensees" and
70 | "recipients" may be individuals or organizations.
71 |
72 | To "modify" a work means to copy from or adapt all or part of the work
73 | in a fashion requiring copyright permission, other than the making of an
74 | exact copy. The resulting work is called a "modified version" of the
75 | earlier work or a work "based on" the earlier work.
76 |
77 | A "covered work" means either the unmodified Program or a work based
78 | on the Program.
79 |
80 | To "propagate" a work means to do anything with it that, without
81 | permission, would make you directly or secondarily liable for
82 | infringement under applicable copyright law, except executing it on a
83 | computer or modifying a private copy. Propagation includes copying,
84 | distribution (with or without modification), making available to the
85 | public, and in some countries other activities as well.
86 |
87 | To "convey" a work means any kind of propagation that enables other
88 | parties to make or receive copies. Mere interaction with a user through
89 | a computer network, with no transfer of a copy, is not conveying.
90 |
91 | An interactive user interface displays "Appropriate Legal Notices"
92 | to the extent that it includes a convenient and prominently visible
93 | feature that (1) displays an appropriate copyright notice, and (2)
94 | tells the user that there is no warranty for the work (except to the
95 | extent that warranties are provided), that licensees may convey the
96 | work under this License, and how to view a copy of this License. If
97 | the interface presents a list of user commands or options, such as a
98 | menu, a prominent item in the list meets this criterion.
99 |
100 | 1. Source Code.
101 |
102 | The "source code" for a work means the preferred form of the work
103 | for making modifications to it. "Object code" means any non-source
104 | form of a work.
105 |
106 | A "Standard Interface" means an interface that either is an official
107 | standard defined by a recognized standards body, or, in the case of
108 | interfaces specified for a particular programming language, one that
109 | is widely used among developers working in that language.
110 |
111 | The "System Libraries" of an executable work include anything, other
112 | than the work as a whole, that (a) is included in the normal form of
113 | packaging a Major Component, but which is not part of that Major
114 | Component, and (b) serves only to enable use of the work with that
115 | Major Component, or to implement a Standard Interface for which an
116 | implementation is available to the public in source code form. A
117 | "Major Component", in this context, means a major essential component
118 | (kernel, window system, and so on) of the specific operating system
119 | (if any) on which the executable work runs, or a compiler used to
120 | produce the work, or an object code interpreter used to run it.
121 |
122 | The "Corresponding Source" for a work in object code form means all
123 | the source code needed to generate, install, and (for an executable
124 | work) run the object code and to modify the work, including scripts to
125 | control those activities. However, it does not include the work's
126 | System Libraries, or general-purpose tools or generally available free
127 | programs which are used unmodified in performing those activities but
128 | which are not part of the work. For example, Corresponding Source
129 | includes interface definition files associated with source files for
130 | the work, and the source code for shared libraries and dynamically
131 | linked subprograms that the work is specifically designed to require,
132 | such as by intimate data communication or control flow between those
133 | subprograms and other parts of the work.
134 |
135 | The Corresponding Source need not include anything that users
136 | can regenerate automatically from other parts of the Corresponding
137 | Source.
138 |
139 | The Corresponding Source for a work in source code form is that
140 | same work.
141 |
142 | 2. Basic Permissions.
143 |
144 | All rights granted under this License are granted for the term of
145 | copyright on the Program, and are irrevocable provided the stated
146 | conditions are met. This License explicitly affirms your unlimited
147 | permission to run the unmodified Program. The output from running a
148 | covered work is covered by this License only if the output, given its
149 | content, constitutes a covered work. This License acknowledges your
150 | rights of fair use or other equivalent, as provided by copyright law.
151 |
152 | You may make, run and propagate covered works that you do not
153 | convey, without conditions so long as your license otherwise remains
154 | in force. You may convey covered works to others for the sole purpose
155 | of having them make modifications exclusively for you, or provide you
156 | with facilities for running those works, provided that you comply with
157 | the terms of this License in conveying all material for which you do
158 | not control copyright. Those thus making or running the covered works
159 | for you must do so exclusively on your behalf, under your direction
160 | and control, on terms that prohibit them from making any copies of
161 | your copyrighted material outside their relationship with you.
162 |
163 | Conveying under any other circumstances is permitted solely under
164 | the conditions stated below. Sublicensing is not allowed; section 10
165 | makes it unnecessary.
166 |
167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168 |
169 | No covered work shall be deemed part of an effective technological
170 | measure under any applicable law fulfilling obligations under article
171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 | similar laws prohibiting or restricting circumvention of such
173 | measures.
174 |
175 | When you convey a covered work, you waive any legal power to forbid
176 | circumvention of technological measures to the extent such circumvention
177 | is effected by exercising rights under this License with respect to
178 | the covered work, and you disclaim any intention to limit operation or
179 | modification of the work as a means of enforcing, against the work's
180 | users, your or third parties' legal rights to forbid circumvention of
181 | technological measures.
182 |
183 | 4. Conveying Verbatim Copies.
184 |
185 | You may convey verbatim copies of the Program's source code as you
186 | receive it, in any medium, provided that you conspicuously and
187 | appropriately publish on each copy an appropriate copyright notice;
188 | keep intact all notices stating that this License and any
189 | non-permissive terms added in accord with section 7 apply to the code;
190 | keep intact all notices of the absence of any warranty; and give all
191 | recipients a copy of this License along with the Program.
192 |
193 | You may charge any price or no price for each copy that you convey,
194 | and you may offer support or warranty protection for a fee.
195 |
196 | 5. Conveying Modified Source Versions.
197 |
198 | You may convey a work based on the Program, or the modifications to
199 | produce it from the Program, in the form of source code under the
200 | terms of section 4, provided that you also meet all of these conditions:
201 |
202 | a) The work must carry prominent notices stating that you modified
203 | it, and giving a relevant date.
204 |
205 | b) The work must carry prominent notices stating that it is
206 | released under this License and any conditions added under section
207 | 7. This requirement modifies the requirement in section 4 to
208 | "keep intact all notices".
209 |
210 | c) You must license the entire work, as a whole, under this
211 | License to anyone who comes into possession of a copy. This
212 | License will therefore apply, along with any applicable section 7
213 | additional terms, to the whole of the work, and all its parts,
214 | regardless of how they are packaged. This License gives no
215 | permission to license the work in any other way, but it does not
216 | invalidate such permission if you have separately received it.
217 |
218 | d) If the work has interactive user interfaces, each must display
219 | Appropriate Legal Notices; however, if the Program has interactive
220 | interfaces that do not display Appropriate Legal Notices, your
221 | work need not make them do so.
222 |
223 | A compilation of a covered work with other separate and independent
224 | works, which are not by their nature extensions of the covered work,
225 | and which are not combined with it such as to form a larger program,
226 | in or on a volume of a storage or distribution medium, is called an
227 | "aggregate" if the compilation and its resulting copyright are not
228 | used to limit the access or legal rights of the compilation's users
229 | beyond what the individual works permit. Inclusion of a covered work
230 | in an aggregate does not cause this License to apply to the other
231 | parts of the aggregate.
232 |
233 | 6. Conveying Non-Source Forms.
234 |
235 | You may convey a covered work in object code form under the terms
236 | of sections 4 and 5, provided that you also convey the
237 | machine-readable Corresponding Source under the terms of this License,
238 | in one of these ways:
239 |
240 | a) Convey the object code in, or embodied in, a physical product
241 | (including a physical distribution medium), accompanied by the
242 | Corresponding Source fixed on a durable physical medium
243 | customarily used for software interchange.
244 |
245 | b) Convey the object code in, or embodied in, a physical product
246 | (including a physical distribution medium), accompanied by a
247 | written offer, valid for at least three years and valid for as
248 | long as you offer spare parts or customer support for that product
249 | model, to give anyone who possesses the object code either (1) a
250 | copy of the Corresponding Source for all the software in the
251 | product that is covered by this License, on a durable physical
252 | medium customarily used for software interchange, for a price no
253 | more than your reasonable cost of physically performing this
254 | conveying of source, or (2) access to copy the
255 | Corresponding Source from a network server at no charge.
256 |
257 | c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 |
263 | d) Convey the object code by offering access from a designated
264 | place (gratis or for a charge), and offer equivalent access to the
265 | Corresponding Source in the same way through the same place at no
266 | further charge. You need not require recipients to copy the
267 | Corresponding Source along with the object code. If the place to
268 | copy the object code is a network server, the Corresponding Source
269 | may be on a different server (operated by you or a third party)
270 | that supports equivalent copying facilities, provided you maintain
271 | clear directions next to the object code saying where to find the
272 | Corresponding Source. Regardless of what server hosts the
273 | Corresponding Source, you remain obligated to ensure that it is
274 | available for as long as needed to satisfy these requirements.
275 |
276 | e) Convey the object code using peer-to-peer transmission, provided
277 | you inform other peers where the object code and Corresponding
278 | Source of the work are being offered to the general public at no
279 | charge under subsection 6d.
280 |
281 | A separable portion of the object code, whose source code is excluded
282 | from the Corresponding Source as a System Library, need not be
283 | included in conveying the object code work.
284 |
285 | A "User Product" is either (1) a "consumer product", which means any
286 | tangible personal property which is normally used for personal, family,
287 | or household purposes, or (2) anything designed or sold for incorporation
288 | into a dwelling. In determining whether a product is a consumer product,
289 | doubtful cases shall be resolved in favor of coverage. For a particular
290 | product received by a particular user, "normally used" refers to a
291 | typical or common use of that class of product, regardless of the status
292 | of the particular user or of the way in which the particular user
293 | actually uses, or expects or is expected to use, the product. A product
294 | is a consumer product regardless of whether the product has substantial
295 | commercial, industrial or non-consumer uses, unless such uses represent
296 | the only significant mode of use of the product.
297 |
298 | "Installation Information" for a User Product means any methods,
299 | procedures, authorization keys, or other information required to install
300 | and execute modified versions of a covered work in that User Product from
301 | a modified version of its Corresponding Source. The information must
302 | suffice to ensure that the continued functioning of the modified object
303 | code is in no case prevented or interfered with solely because
304 | modification has been made.
305 |
306 | If you convey an object code work under this section in, or with, or
307 | specifically for use in, a User Product, and the conveying occurs as
308 | part of a transaction in which the right of possession and use of the
309 | User Product is transferred to the recipient in perpetuity or for a
310 | fixed term (regardless of how the transaction is characterized), the
311 | Corresponding Source conveyed under this section must be accompanied
312 | by the Installation Information. But this requirement does not apply
313 | if neither you nor any third party retains the ability to install
314 | modified object code on the User Product (for example, the work has
315 | been installed in ROM).
316 |
317 | The requirement to provide Installation Information does not include a
318 | requirement to continue to provide support service, warranty, or updates
319 | for a work that has been modified or installed by the recipient, or for
320 | the User Product in which it has been modified or installed. Access to a
321 | network may be denied when the modification itself materially and
322 | adversely affects the operation of the network or violates the rules and
323 | protocols for communication across the network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders of
351 | that material) supplement the terms of this License with terms:
352 |
353 | a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 |
356 | b) Requiring preservation of specified reasonable legal notices or
357 | author attributions in that material or in the Appropriate Legal
358 | Notices displayed by works containing it; or
359 |
360 | c) Prohibiting misrepresentation of the origin of that material, or
361 | requiring that modified versions of such material be marked in
362 | reasonable ways as different from the original version; or
363 |
364 | d) Limiting the use for publicity purposes of names of licensors or
365 | authors of the material; or
366 |
367 | e) Declining to grant rights under trademark law for use of some
368 | trade names, trademarks, or service marks; or
369 |
370 | f) Requiring indemnification of licensors and authors of that
371 | material by anyone who conveys the material (or modified versions of
372 | it) with contractual assumptions of liability to the recipient, for
373 | any liability that these contractual assumptions directly impose on
374 | those licensors and authors.
375 |
376 | All other non-permissive additional terms are considered "further
377 | restrictions" within the meaning of section 10. If the Program as you
378 | received it, or any part of it, contains a notice stating that it is
379 | governed by this License along with a term that is a further
380 | restriction, you may remove that term. If a license document contains
381 | a further restriction but permits relicensing or conveying under this
382 | License, you may add to a covered work material governed by the terms
383 | of that license document, provided that the further restriction does
384 | not survive such relicensing or conveying.
385 |
386 | If you add terms to a covered work in accord with this section, you
387 | must place, in the relevant source files, a statement of the
388 | additional terms that apply to those files, or a notice indicating
389 | where to find the applicable terms.
390 |
391 | Additional terms, permissive or non-permissive, may be stated in the
392 | form of a separately written license, or stated as exceptions;
393 | the above requirements apply either way.
394 |
395 | 8. Termination.
396 |
397 | You may not propagate or modify a covered work except as expressly
398 | provided under this License. Any attempt otherwise to propagate or
399 | modify it is void, and will automatically terminate your rights under
400 | this License (including any patent licenses granted under the third
401 | paragraph of section 11).
402 |
403 | However, if you cease all violation of this License, then your
404 | license from a particular copyright holder is reinstated (a)
405 | provisionally, unless and until the copyright holder explicitly and
406 | finally terminates your license, and (b) permanently, if the copyright
407 | holder fails to notify you of the violation by some reasonable means
408 | prior to 60 days after the cessation.
409 |
410 | Moreover, your license from a particular copyright holder is
411 | reinstated permanently if the copyright holder notifies you of the
412 | violation by some reasonable means, this is the first time you have
413 | received notice of violation of this License (for any work) from that
414 | copyright holder, and you cure the violation prior to 30 days after
415 | your receipt of the notice.
416 |
417 | Termination of your rights under this section does not terminate the
418 | licenses of parties who have received copies or rights from you under
419 | this License. If your rights have been terminated and not permanently
420 | reinstated, you do not qualify to receive new licenses for the same
421 | material under section 10.
422 |
423 | 9. Acceptance Not Required for Having Copies.
424 |
425 | You are not required to accept this License in order to receive or
426 | run a copy of the Program. Ancillary propagation of a covered work
427 | occurring solely as a consequence of using peer-to-peer transmission
428 | to receive a copy likewise does not require acceptance. However,
429 | nothing other than this License grants you permission to propagate or
430 | modify any covered work. These actions infringe copyright if you do
431 | not accept this License. Therefore, by modifying or propagating a
432 | covered work, you indicate your acceptance of this License to do so.
433 |
434 | 10. Automatic Licensing of Downstream Recipients.
435 |
436 | Each time you convey a covered work, the recipient automatically
437 | receives a license from the original licensors, to run, modify and
438 | propagate that work, subject to this License. You are not responsible
439 | for enforcing compliance by third parties with this License.
440 |
441 | An "entity transaction" is a transaction transferring control of an
442 | organization, or substantially all assets of one, or subdividing an
443 | organization, or merging organizations. If propagation of a covered
444 | work results from an entity transaction, each party to that
445 | transaction who receives a copy of the work also receives whatever
446 | licenses to the work the party's predecessor in interest had or could
447 | give under the previous paragraph, plus a right to possession of the
448 | Corresponding Source of the work from the predecessor in interest, if
449 | the predecessor has it or can get it with reasonable efforts.
450 |
451 | You may not impose any further restrictions on the exercise of the
452 | rights granted or affirmed under this License. For example, you may
453 | not impose a license fee, royalty, or other charge for exercise of
454 | rights granted under this License, and you may not initiate litigation
455 | (including a cross-claim or counterclaim in a lawsuit) alleging that
456 | any patent claim is infringed by making, using, selling, offering for
457 | sale, or importing the Program or any portion of it.
458 |
459 | 11. Patents.
460 |
461 | A "contributor" is a copyright holder who authorizes use under this
462 | License of the Program or a work on which the Program is based. The
463 | work thus licensed is called the contributor's "contributor version".
464 |
465 | A contributor's "essential patent claims" are all patent claims
466 | owned or controlled by the contributor, whether already acquired or
467 | hereafter acquired, that would be infringed by some manner, permitted
468 | by this License, of making, using, or selling its contributor version,
469 | but do not include claims that would be infringed only as a
470 | consequence of further modification of the contributor version. For
471 | purposes of this definition, "control" includes the right to grant
472 | patent sublicenses in a manner consistent with the requirements of
473 | this License.
474 |
475 | Each contributor grants you a non-exclusive, worldwide, royalty-free
476 | patent license under the contributor's essential patent claims, to
477 | make, use, sell, offer for sale, import and otherwise run, modify and
478 | propagate the contents of its contributor version.
479 |
480 | In the following three paragraphs, a "patent license" is any express
481 | agreement or commitment, however denominated, not to enforce a patent
482 | (such as an express permission to practice a patent or covenant not to
483 | sue for patent infringement). To "grant" such a patent license to a
484 | party means to make such an agreement or commitment not to enforce a
485 | patent against the party.
486 |
487 | If you convey a covered work, knowingly relying on a patent license,
488 | and the Corresponding Source of the work is not available for anyone
489 | to copy, free of charge and under the terms of this License, through a
490 | publicly available network server or other readily accessible means,
491 | then you must either (1) cause the Corresponding Source to be so
492 | available, or (2) arrange to deprive yourself of the benefit of the
493 | patent license for this particular work, or (3) arrange, in a manner
494 | consistent with the requirements of this License, to extend the patent
495 | license to downstream recipients. "Knowingly relying" means you have
496 | actual knowledge that, but for the patent license, your conveying the
497 | covered work in a country, or your recipient's use of the covered work
498 | in a country, would infringe one or more identifiable patents in that
499 | country that you have reason to believe are valid.
500 |
501 | If, pursuant to or in connection with a single transaction or
502 | arrangement, you convey, or propagate by procuring conveyance of, a
503 | covered work, and grant a patent license to some of the parties
504 | receiving the covered work authorizing them to use, propagate, modify
505 | or convey a specific copy of the covered work, then the patent license
506 | you grant is automatically extended to all recipients of the covered
507 | work and works based on it.
508 |
509 | A patent license is "discriminatory" if it does not include within
510 | the scope of its coverage, prohibits the exercise of, or is
511 | conditioned on the non-exercise of one or more of the rights that are
512 | specifically granted under this License. You may not convey a covered
513 | work if you are a party to an arrangement with a third party that is
514 | in the business of distributing software, under which you make payment
515 | to the third party based on the extent of your activity of conveying
516 | the work, and under which the third party grants, to any of the
517 | parties who would receive the covered work from you, a discriminatory
518 | patent license (a) in connection with copies of the covered work
519 | conveyed by you (or copies made from those copies), or (b) primarily
520 | for and in connection with specific products or compilations that
521 | contain the covered work, unless you entered into that arrangement,
522 | or that patent license was granted, prior to 28 March 2007.
523 |
524 | Nothing in this License shall be construed as excluding or limiting
525 | any implied license or other defenses to infringement that may
526 | otherwise be available to you under applicable patent law.
527 |
528 | 12. No Surrender of Others' Freedom.
529 |
530 | If conditions are imposed on you (whether by court order, agreement or
531 | otherwise) that contradict the conditions of this License, they do not
532 | excuse you from the conditions of this License. If you cannot convey a
533 | covered work so as to satisfy simultaneously your obligations under this
534 | License and any other pertinent obligations, then as a consequence you may
535 | not convey it at all. For example, if you agree to terms that obligate you
536 | to collect a royalty for further conveying from those to whom you convey
537 | the Program, the only way you could satisfy both those terms and this
538 | License would be to refrain entirely from conveying the Program.
539 |
540 | 13. Remote Network Interaction; Use with the GNU General Public License.
541 |
542 | Notwithstanding any other provision of this License, if you modify the
543 | Program, your modified version must prominently offer all users
544 | interacting with it remotely through a computer network (if your version
545 | supports such interaction) an opportunity to receive the Corresponding
546 | Source of your version by providing access to the Corresponding Source
547 | from a network server at no charge, through some standard or customary
548 | means of facilitating copying of software. This Corresponding Source
549 | shall include the Corresponding Source for any work covered by version 3
550 | of the GNU General Public License that is incorporated pursuant to the
551 | following paragraph.
552 |
553 | Notwithstanding any other provision of this License, you have
554 | permission to link or combine any covered work with a work licensed
555 | under version 3 of the GNU General Public License into a single
556 | combined work, and to convey the resulting work. The terms of this
557 | License will continue to apply to the part which is the covered work,
558 | but the work with which it is combined will remain governed by version
559 | 3 of the GNU General Public License.
560 |
561 | 14. Revised Versions of this License.
562 |
563 | The Free Software Foundation may publish revised and/or new versions of
564 | the GNU Affero General Public License from time to time. Such new versions
565 | will be similar in spirit to the present version, but may differ in detail to
566 | address new problems or concerns.
567 |
568 | Each version is given a distinguishing version number. If the
569 | Program specifies that a certain numbered version of the GNU Affero General
570 | Public License "or any later version" applies to it, you have the
571 | option of following the terms and conditions either of that numbered
572 | version or of any later version published by the Free Software
573 | Foundation. If the Program does not specify a version number of the
574 | GNU Affero General Public License, you may choose any version ever published
575 | by the Free Software Foundation.
576 |
577 | If the Program specifies that a proxy can decide which future
578 | versions of the GNU Affero General Public License can be used, that proxy's
579 | public statement of acceptance of a version permanently authorizes you
580 | to choose that version for the Program.
581 |
582 | Later license versions may give you additional or different
583 | permissions. However, no additional obligations are imposed on any
584 | author or copyright holder as a result of your choosing to follow a
585 | later version.
586 |
587 | 15. Disclaimer of Warranty.
588 |
589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597 |
598 | 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 | SUCH DAMAGES.
609 |
610 | 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 | How to Apply These Terms to Your New Programs
622 |
623 | If you develop a new program, and you want it to be of the greatest
624 | possible use to the public, the best way to achieve this is to make it
625 | free software which everyone can redistribute and change under these terms.
626 |
627 | To do so, attach the following notices to the program. It is safest
628 | to attach them to the start of each source file to most effectively
629 | state the exclusion of warranty; and each file should have at least
630 | the "copyright" line and a pointer to where the full notice is found.
631 |
632 |
633 | Copyright (C)
634 |
635 | This program is free software: you can redistribute it and/or modify
636 | it under the terms of the GNU Affero General Public License as published
637 | by the Free Software Foundation, either version 3 of the License, or
638 | (at your option) any later version.
639 |
640 | This program is distributed in the hope that it will be useful,
641 | but WITHOUT ANY WARRANTY; without even the implied warranty of
642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 | GNU Affero General Public License for more details.
644 |
645 | You should have received a copy of the GNU Affero General Public License
646 | along with this program. If not, see .
647 |
648 | Also add information on how to contact you by electronic and paper mail.
649 |
650 | If your software can interact with users remotely through a computer
651 | network, you should also make sure that it provides a way for users to
652 | get its source. For example, if your program is a web application, its
653 | interface could display a "Source" link that leads users to an archive
654 | of the code. There are many ways you could offer source, and different
655 | solutions will be better for different programs; see section 13 for the
656 | specific requirements.
657 |
658 | You should also get your employer (if you work as a programmer) or school,
659 | if any, to sign a "copyright disclaimer" for the program, if necessary.
660 | For more information on this, and how to apply and follow the GNU AGPL, see
661 | .
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Xhh_Auto
2 |
3 | [![Codacy Badge][codacy_b]][Codacy] [![release][release_b]][Release] [![PyPI][pypi_v_b]][pypi] [![Download][download_b]][Release] [![License][license_b]][License]
4 |
5 | ## 声明
6 |
7 | 本项目仅供学习交流使用, 用户如何使用该脚本与作者无关
8 |
9 | > 本项目已经停止更新, 交流群 `916945024`, 另一个半弃坑的工程: [Xiaoheihe_CShape](https://github.com/chr233/Xiaoheihe_CShape)
10 |
11 | * 请从这里下载稳定版: [Releases][release], 仓库中的代码未经测试, 可能会有问题.
12 |
13 | ## Frida_RPC服务部署方法
14 |
15 | 
16 |
17 | * Frida RPC简介:[这篇文章](https://blog.chrxw.com/archives/2021/11/19/1640.html)
18 |
19 | * RPC Server获取:[frida_project](https://github.com/chr233/frida_project)
20 |
21 | ## 安装与使用方法
22 |
23 | 本项目使用`Python3.8`编写,理论上支持`3.4`及以后的版本
24 |
25 | 1. 从[releases][release]下载最新版本.
26 | 2. 解压,并切换到脚本所在目录.
27 | 3. 复制 `example.config.toml` , 为 `config.toml`,并填写配置.
28 | > 账号凭据获取方法参考下一节.
29 | 4. 在脚本目录打开命令行.
30 | 5. 执行 `pip install -r ./requirements.txt`.
31 | 6. 运行脚本: windows `python run.py`, linux: `python3 run.py`
32 | 7. 本脚本没有定时运行的功能,如有需要,请参考下文
33 |
34 | ## 账号凭据获取方法
35 |
36 | 当前版本暂不支持直接登录,需要手动抓包获取账号凭据,抓取后只要不主动退出可以永久登录
37 |
38 | * [安卓手机端抓取教程【新】][jiaocheng1]【推荐】
39 |
40 | * [安卓手机抓取教程][jiaocheng2]
41 |
42 | * [Fiddler抓取教程][jiaocheng3]
43 |
44 | * 抓取小黑盒数据后, 填入`config.toml`即可使用本脚本.
45 |
46 | ## 旧版脚本配置文件转换
47 |
48 | * 运行`python convernt_old_config.py`,根据提示操作即可.
49 |
50 | ## 定时运行方法
51 |
52 | 因为本脚本没有必要常驻后台,所以没有自动运行的功能,不过可以配合系统工具达到自动运行的效果
53 |
54 | * Windows下可以使用`任务计划程序`
55 | 1. 开始菜单搜索`任务计划程序`
56 | 2. 点右侧`创建基本任务…`
57 | 3. `名称`和`描述`任意填
58 | 4. `触发器`选择`每天`,并设置运行时间
59 | 5. `操作`选择`启动程序`,`程序或脚本`填`python [脚本路径]\run.py`
60 | 6. 点`完成`
61 |
62 | * Linux下可以使用`crontab`
63 | 1. 打开终端,输入`corntab -e`
64 | 2. 按`i`进入编辑模式,将光标定位到文件尾
65 | 3. 插入`0 1 * * * python3 [脚本绝对路径]/run.py > /dev/null 2>&1 &`
66 | > 这个配置的意思是每天1点0分执行脚本
67 | 4. 按`ESC`,然后输入`:wq`保存
68 |
69 | ## XHH_AUTO 互助计划
70 |
71 | 参与互助计划以后,会自动关注我的账号以及关注我的粉丝的账号,也就是让使用本脚本的用户都能互相关注,再配合动态点赞功能,让所有用户都能快速获赞,涨粉,升级
72 |
73 | > 退出方法:在`config.toml`中将`join_xhhauto`的值改为`false`即可.
74 |
75 | [codacy_b]: https://app.codacy.com/project/badge/grade/dfb3196838bf4431a8914736f103afeb
76 | [codacy]: https://www.codacy.com/manual/chr233/xhh_auto?utm_source=github.com&utm_medium=referral&utm_content=chr233/xhh_auto&utm_campaign=badge_grade
77 | [download_b]: https://img.shields.io/github/downloads/chr233/xhh_auto/total
78 | [release]: https://github.com/chr233/xhh_auto/releases
79 | [release_b]: https://img.shields.io/github/v/release/chr233/xhh_auto
80 | [license]: https://github.com/chr233/xhh_auto/blob/master/license
81 | [license_b]: https://img.shields.io/github/license/chr233/xhh_auto
82 | [pypi_v_b]: https://img.shields.io/pypi/v/pyxiaoheihe?label=pyxiaoheihe
83 | [pypi]: https://pypi.org/project/pyxiaoheihe/
84 | [jiaocheng1]: https://blog.chrxw.com/archives/2020/08/10/1353.html
85 | [jiaocheng2]: https://blog.chrxw.com/archives/2019/10/19/390.html
86 | [jiaocheng3]: https://blog.chrxw.com/archives/2019/10/20/437.html
87 |
--------------------------------------------------------------------------------
/example.config.toml:
--------------------------------------------------------------------------------
1 | # 配置文件,"[]"中的值为默认配置
2 |
3 | # ====账号信息======================================
4 | # 说明:三个参数都可以抓包得到,抓包教程:
5 | # [安卓手机端抓取教程【新】【推荐】](https://blog.chrxw.com/archives/2020/08/10/1353.html)
6 | # [安卓手机端抓取教程](https://blog.chrxw.com/archives/2019/10/19/390.html)
7 | # [Fiddler抓取教程](https://blog.chrxw.com/archives/2019/10/20/437.html)
8 |
9 | [[accounts]]
10 | heybox_id = 0
11 | imei = ""
12 | pkey = ""
13 | # 为每个账号独立配置请求头, 不设置的话使用[heybox]节的全局配置
14 | # channel = "heybox_xiaomi"
15 | # os_type = 1
16 | # os_version = "8.1"
17 |
18 | # 如果有多个账号,像这样多写几组即可(记得去除下面4行前面的#号)
19 |
20 | # [[accounts]]
21 | # heybox_id = 0
22 | # imei = ""
23 | # pkey = ""
24 |
25 | # ====其他配置======================================
26 | [main]
27 | # 是否检查更新, [true]
28 | check_update = true
29 | # 是否开启调试模式, [false]
30 | debug = false
31 | # 是否参与互助计划, [true]
32 | join_xhhauto = true
33 | # 互助计划说明:
34 | # 开启后会自动关注我的账号和我的粉丝的账号
35 | # 也就是让使用本脚本的用户都能互相关注
36 | # 再配合动态点赞功能,让所有人都能快速获赞
37 | # 如果不想参加改成false即可
38 |
39 | # ====推送设置======================================
40 | [ftqq]
41 | # 方糖气球模块,用于推送运行结果到微信
42 | # 是否开启方糖气球模块,开启后会将结果推送至微信, [false]
43 | enable = false
44 | # 方糖气球SKEY,获取地址:(http://sc.ftqq.com/)
45 | skey = ""
46 | # 设置为true后只会在程序出错时才会推送消息, [false]
47 | only_on_error = false
48 |
49 | [email]
50 | # 邮件模块,用于推送结果到邮箱
51 | # 是否开启邮箱模块, [false]
52 | enable = false
53 | # SMTP服务器设置
54 | port = 465
55 | server = "smtp.qq.com"
56 | # SMTP登陆凭据
57 | password = ''
58 | user = 'example@mail.com'
59 | # 收发信箱设置
60 | recvaddr = 'recv@example.com'
61 | sendaddr = 'send@example.com'
62 | # 设置为true后只会在程序出错时才会推送消息,[false]
63 | only_on_error = false
64 |
65 | # ====高级配置======================================
66 | # 这里是全局配置, 也可以在[accounts]节为每个账户单独配置
67 | # 支持独立配置的有os_type,channel,os_version
68 | [heybox]
69 | # 自定义请求头数据,如果担心被风控请自行修改修改, [1]
70 | # 表示模拟哪种客户端, 1:Android, 2:iOS,
71 | os_type = 1
72 | # 表明客户端来自哪个渠道,仅安卓客户端有效, ["heybox_yingyongbao"]
73 | channel = "heybox_yingyongbao"
74 | # 系统版本,对应Android或者IOS版本, ["8.1"]
75 | os_version = "8.1"
76 | # 随机延时倍数, [1.0]
77 | # 设为0.5代表延时时间缩短一半,以此类推
78 | # 如果需要手动控制延时就设为0
79 | sleep_interval = 1.0
80 | # 开启后自动发送report流量,伪装正常客户端, [true]
81 | auto_report = true
82 | # 远程RPC服务器地址
83 | rpc_server = 'http://192.168.50.184:9000/encode'
--------------------------------------------------------------------------------
/make_release.bat:
--------------------------------------------------------------------------------
1 | rd /Q /S utils\__pycache__
2 |
3 | 7z a xhh_auto.zip utils pyxiaoheihe LICENSE example.config.toml README.md requirements.txt CHANGELOG.md run.py
4 |
5 | pause
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | pyxiaoheihe>=1.0.8
2 | requests
3 | toml
--------------------------------------------------------------------------------
/run.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | '''
4 | # @Author : Chr_
5 | # @Date : 2020-07-14 16:36:33
6 | # @LastEditors : Chr_
7 | # @LastEditTime : 2021-11-19 11:55:54
8 | # @Description : 启动入口
9 | '''
10 |
11 | import os
12 | import sys
13 | import time
14 | import traceback
15 |
16 | print(r'''
17 | ██╗ ██╗██╗ ██╗██╗ ██╗ █████╗ ██╗ ██╗████████╗ ██████╗
18 | ╚██╗██╔╝██║ ██║██║ ██║ ██╔══██╗██║ ██║╚══██╔══╝██╔═══██╗
19 | ╚███╔╝ ███████║███████║ ███████║██║ ██║ ██║ ██║ ██║
20 | ██╔██╗ ██╔══██║██╔══██║ ██╔══██║██║ ██║ ██║ ██║ ██║
21 | ██╔╝ ██╗██║ ██║██║ ██║ ██║ ██║╚██████╔╝ ██║ ╚██████╔╝
22 | ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝
23 | By Chr_
24 | ''')
25 |
26 |
27 | try:
28 | from utils import cliwait
29 | from utils.config import load_config
30 | from utils.version import check_script_update, check_pyxiaoheihe_version
31 | from utils.version import SCRIPT_VERSION, MINI_CORE_VERSION
32 | from utils.log import get_logger
33 | from utils.ftqq import send_to_ftqq
34 | from utils.email import send_to_email
35 |
36 | from pyxiaoheihe import HeyBoxClient
37 | from pyxiaoheihe.static import PYXIAOHEIHE_VERSION, RelationType, ReportType
38 | from pyxiaoheihe.error import UnknownError, HeyboxException, TokenError, AccountLimited
39 | from pyxiaoheihe.utils import user_relation_filter
40 | except ImportError as e:
41 | print(e)
42 | print('导入模块出错,请执行 pip install -r requirements.txt 安装所需的依赖库')
43 | print('或者尝试升级核心 pip install pyxiaoheihe --upgrade')
44 | cliwait()
45 | exit()
46 |
47 |
48 | logger = get_logger('Run')
49 |
50 |
51 | def main():
52 | '''
53 | 示例程序,可以根据需要自行修改
54 | '''
55 |
56 | # 动态点赞数量
57 | EVENT = 5
58 |
59 | start_time = time.time()
60 | total = 0
61 | success = 0
62 | accounts = CFG['accounts']
63 | hbxcfg = CFG['heybox']
64 | mcfg = CFG['main']
65 |
66 | if not accounts:
67 | raise ValueError('未定义有效账号信息')
68 |
69 | ac = len(accounts)
70 | logger.info(f'成功读取[{ac}]个账号')
71 | data = []
72 | for i, account in enumerate(accounts, 1):
73 | try:
74 | limited = False
75 | logger.info(str(f'==[{i}/{ac}]').ljust(40, '='))
76 | data.append(f'#### {str(f"==[{i}/{ac}]").ljust(30, "=")}')
77 | hbc = HeyBoxClient(
78 | account, hbxcfg, mcfg['debug'])
79 |
80 | # 读取每日任务详情
81 | qd, fxxw, fxpl, dz = hbc.get_daily_task()
82 | # qd, fxxw, fxpl, dz = False, False, False, False
83 |
84 | logger.info(f'任务[签到{qd}|分享{fxxw}{fxpl}|点赞{dz}]')
85 | if not qd:
86 | hbc.logger.info('签到……')
87 | hbc.sign()
88 |
89 | try:
90 | if not dz or not fxxw or not fxpl:
91 | hbc.logger.info('获取首页新闻列表……')
92 | idlist = hbc.get_news_id(6, -1)
93 | hbc.logger.info(f'获取[{len(idlist)}]条内容')
94 | if not fxxw or not fxpl:
95 | hbc.logger.info('分享新闻……')
96 | linkid = idlist[0]
97 | hbc.get_news_content(linkid, 1)
98 | hbc.get_comments(linkid, 1, i, False)
99 | hbc.share_news(linkid, 1)
100 | hbc.random_sleep(0, 1)
101 | hbc.share_comment()
102 | hbc.random_sleep(0, 1)
103 | if not dz:
104 | for i, linkid in enumerate(idlist, 1):
105 | # 伪装正常流量
106 | hbc.logger.info(f'模拟浏览新闻{linkid}')
107 | hbc.get_news_content(linkid)
108 | hbc.get_comments(linkid, 1, i, False)
109 | hbc.like_news(linkid, i, True)
110 | hbc.random_sleep(1, 5)
111 | else:
112 | hbc.logger.info('已完成点赞和分享任务,跳过')
113 |
114 | # xhh_auto 互助计划,如果想要退出可以在配置文件中关闭
115 | if mcfg['join_xhhauto']:
116 | hbc.logger.info('感谢加入Xhh_Auto互助计划')
117 | rs = hbc.get_user_relation(20400942)
118 | if rs == RelationType.NoRelation:
119 | hbc.follow_user(20400942)
120 | ulist = hbc.get_user_fans(20400942)
121 | target = user_relation_filter(
122 | ulist, RelationType.NoRelation)
123 | if target:
124 | for i in target[:2]:
125 | hbc.follow_user(i, True)
126 | hbc.random_sleep(0, 2)
127 |
128 | ulist = hbc.get_new_fans()
129 | if ulist:
130 | for i in ulist:
131 | hbc.follow_user(i, True)
132 | hbc.random_sleep(0, 5)
133 | hbc.logger.info(f'关注了[{len(ulist)}]个新粉丝')
134 | else:
135 | hbc.logger.info('没有新粉丝')
136 | if not mcfg['join_xhhauto']:
137 | hbc.logger.info('[!] 试试加入xhh_auto互助计划?')
138 |
139 | eventlist = hbc.get_subscrib_events(EVENT, True)
140 | hbc.logger.info(f'获取[{len(eventlist)}]条动态')
141 | if eventlist:
142 | for linkid, ftype, _ in eventlist:
143 | hbc.logger.info(f'点赞动态 {linkid}')
144 | hbc.like_event(linkid, ftype, True)
145 | hbc.random_sleep(0, 1)
146 | else:
147 | hbc.logger.info('没有新动态')
148 |
149 | except AccountLimited:
150 | hbc.logger.info('当前账号点赞或关注已受限, 终止任务')
151 | limited = True
152 |
153 | logger.info('-' * 40)
154 |
155 | logger.info('生成统计数据')
156 | uname, uid, coin, level, sign = hbc.get_my_data()
157 |
158 | logger.info(f'昵称[{uname}] @{uid} {"[受限]" if limited else ""}')
159 | logger.info(
160 | f'等级[{level[0]}级]==>{int((level[1]*100)/level[2])}%==>[{level[0]+1}级]')
161 | logger.info(f'盒币[{coin}]签到[{sign}]天')
162 | logger.info(
163 | f'等级[{level[0]}级]==>{int((level[1]*100)/level[2])}%==>[{level[0]+1}级]')
164 |
165 | follow, fan, awd = hbc.get_user_profile()
166 | logger.info(f'关注[{follow}]粉丝[{fan}]获赞[{awd}]')
167 |
168 | qd, fxxw, fxpl, dz = hbc.get_daily_task()
169 | finish = qd and fxxw and fxpl and dz
170 |
171 | logger.info(f'签到[{qd}]分享[{fxxw}{fxpl}]点赞[{dz}]')
172 |
173 | data.append(f'#### {uname} @{uid} {"[受限]" if limited else ""}\n'
174 | f'#### 盒币[{coin}]签到[{sign}]天\n'
175 | f'#### 等级[{level[0]}级]==>{int((level[1]*100)/level[2])}%==>[{level[0]+1}级]\n'
176 | f'#### 关注[{follow}]粉丝[{fan}]获赞[{awd}]\n'
177 | f'#### 签到[{qd}]分享[{fxxw}{fxpl}]点赞[{dz}]\n'
178 | f'#### 状态[{"全部完成" if finish else "**有任务未完成**"}]')
179 |
180 | hbc.data_report(ReportType.Quit, None) # 模拟客户端关闭消息
181 |
182 | success += 1
183 | except TokenError as e:
184 | logger.error(f'第[{i}]个账号信息有问题,请检查:[{e}]')
185 | data.append(f'#### 账号信息有问题,请检查:[{e}]')
186 | except UnknownError as e:
187 | logger.error(f'第[{i}]个账号遇到了未知错误:[{e}]')
188 | data.append(f'#### 遇到了未知错误:[{e}]')
189 | except HeyboxException as e:
190 | logger.error(f'第[{i}]个账号遇到了未知错误:[{e}]')
191 | data.append(f'#### 遇到了未知错误:[{e}]')
192 | finally:
193 | total += 1
194 |
195 | logger.info('=' * 40)
196 | if (success < total):
197 | logger.warning(f'[{total-success}]个任务执行出错')
198 | data.append(f'#### {"=" * 30 }\n'
199 | f'#### **[{total-success}]个任务执行出错**')
200 | logger.info(f'脚本版本:[{SCRIPT_VERSION}],核心版本:[{PYXIAOHEIHE_VERSION}]')
201 | data.append(f'#### {"=" * 30 }\n'
202 | f'#### 脚本版本:[{SCRIPT_VERSION}],核心版本:[{PYXIAOHEIHE_VERSION}]')
203 |
204 | end_time = time.time()
205 | logger.info(f'脚本耗时:[{round(end_time-start_time,4)}]s')
206 | data.append(f'#### 任务耗时:[{round(end_time-start_time,4)}]s')
207 |
208 | message = '\n'.join(data)
209 |
210 | title = '小黑盒自动脚本'
211 | if mcfg['check_update']:
212 | logger.info('检查脚本更新……')
213 | result = check_script_update()
214 | if result:
215 | latest_version, detail, download_url = result
216 | logger.info(f'-->脚本有更新<--'
217 | f'最新版本[{latest_version}]'
218 | f'更新内容[{detail}]'
219 | f'下载地址[{download_url}]')
220 | data.append('')
221 | data.append = (f'### 脚本有更新\n'
222 | f'#### 最新版本[{latest_version}]\n'
223 | f'#### 下载地址:[GitHub]({download_url})\n'
224 | f'#### 更新内容\n'
225 | f'{detail}\n'
226 | f'> 如果碰到问题欢迎加群**916945024**')
227 | title += '【有更新】'
228 | else:
229 | logger.info(f'脚本已是最新,当前版本{SCRIPT_VERSION}')
230 | else:
231 | logger.info('检查脚本更新已禁用,当前版本{SCRIPT_VERSION}')
232 |
233 | logger.info('推送统计信息……')
234 | message_push(title, message, success != total)
235 | logger.info('脚本执行完毕')
236 |
237 |
238 | def message_push(title: str, message: str, error: bool = False):
239 | '''
240 | 推送通知
241 | '''
242 | ftqq = CFG['ftqq']
243 | email = CFG['email']
244 | if ftqq['enable']:
245 | if (ftqq['only_on_error'] == True and error) or (ftqq['only_on_error'] == False):
246 | result = send_to_ftqq(title, message, ftqq)
247 | if result:
248 | logger.info('FTQQ推送成功')
249 | else:
250 | logger.warning('[*] FTQQ推送失败')
251 | if email['enable']:
252 | if (email['only_on_error'] == True and error) or (email['only_on_error'] == False):
253 | result = send_to_email(title, message, email)
254 | if result:
255 | logger.info('邮件推送成功')
256 | else:
257 | logger.warning('[*] 邮件推送失败')
258 |
259 |
260 | if __name__ == '__main__':
261 | try:
262 | logger.info('载入配置文件')
263 | CFG = load_config()
264 | except FileNotFoundError:
265 | logger.error('[*] 配置文件[config.toml]不存在,请参考[README.md]生成配置')
266 | cliwait()
267 | except ValueError:
268 | logger.error('[*] 尚未配置有效的账户凭据,请添加到[config.toml]中')
269 | cliwait()
270 | except Exception as e:
271 | logger.error(f'[*] 载入配置文件出错,请检查[config.toml] [{e}]')
272 | cliwait()
273 | exit()
274 |
275 | try:
276 | if check_pyxiaoheihe_version():
277 | main()
278 | else:
279 | logger.error(
280 | f'[*] Pyxiaoheihe版本太低,无法继续运行 [当前{PYXIAOHEIHE_VERSION} < 要求{MINI_CORE_VERSION}]')
281 | logger.error('[*] 可以使用 pip3 install pyxiaoheihe --upgrade 命令升级')
282 | cliwait()
283 | except KeyboardInterrupt:
284 | logger.info('[*] 手动终止运行')
285 | cliwait()
286 | except Exception as e:
287 | logger.error(f'遇到未知错误 [{e}]', exc_info=True)
288 | title = '脚本执行遇到未知错误'
289 | message = (f'#### 脚本版本:[{SCRIPT_VERSION}],核心版本:[{PYXIAOHEIHE_VERSION}]\n'
290 | f'#### 系统信息:[{os.name}]\n'
291 | f'#### Python版本: [{sys.version}]\n'
292 | f'#### {"=" * 30}\n'
293 | f'#### 错误信息: {traceback.format_exc()}\n'
294 | f'#### {"=" * 30}\n'
295 | '#### 联系信息:\n'
296 | '* QQ群: 916945024\n'
297 | '* TG群: https://t.me/xhh_auto\n'
298 | '* 邮箱: chr@chrxw.com\n'
299 | '> 如果需要帮助请附带上错误信息')
300 | message_push(title, message, True)
301 | cliwait()
302 |
--------------------------------------------------------------------------------
/tools/README.md:
--------------------------------------------------------------------------------
1 | # 文件说明
2 |
3 | > 请放到tools目录外使用
4 |
5 | |文件名|描述|
6 | |-|-|
7 | |convernt_old_config.py|旧配置文件转换(json格式的配置文件转换为toml格式)|
8 |
--------------------------------------------------------------------------------
/tools/convernt_old_config.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | '''
3 | # @Author : Chr_
4 | # @Date : 2020-07-29 14:09:15
5 | # @LastEditors : Chr_
6 | # @LastEditTime : 2020-08-06 22:33:46
7 | # @Description : 旧版配置文件转换
8 | '''
9 |
10 | import toml
11 | import json
12 | import os
13 |
14 | print(r'''
15 | ██████╗ ██████╗ ███╗ ██╗██╗ ██╗███████╗████████╗███╗ ██╗████████╗
16 | ██╔════╝██╔═══██╗████╗ ██║██║ ██║██╔════╝╚══██╔══╝████╗ ██║╚══██╔══╝
17 | ██║ ██║ ██║██╔██╗ ██║██║ ██║█████╗ ██║ ██╔██╗ ██║ ██║
18 | ██║ ██║ ██║██║╚██╗██║╚██╗ ██╔╝██╔══╝ ██║ ██║╚██╗██║ ██║
19 | ╚██████╗╚██████╔╝██║ ╚████║ ╚████╔╝ ███████╗ ██║ ██║ ╚████║ ██║
20 | ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═══╝ ╚══════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝
21 | By Chr_
22 | ''')
23 |
24 |
25 | def read_old_config(path: str) -> dict:
26 |
27 | '''读取旧的config文件
28 |
29 | 返回:
30 | dict: 配置字典
31 | '''
32 | cfg = {}
33 | print('> 读取[settings.json]……')
34 | cfg['email'] = {'enable': False, 'port': 465, 'server': '', 'password': '',
35 | 'user': '', 'recvaddr': '', 'sendaddr': '', 'only_on_error': False}
36 | cfg['heybox'] = {'channel': 'heybox_yingyongbao', 'os_type': 1,
37 | 'os_version': '9'}
38 | try:
39 | with open(f'{path}settings.json', 'r', encoding='utf-8') as f:
40 | jd = json.loads(f.read())
41 | cfg['main'] = {'debug': bool(jd.get('Debug', False)),
42 | 'check_update': bool(jd.get('UpdateCheck', True)),
43 | 'join_xhhauto': True}
44 | cfg['ftqq'] = {'enable': bool(jd.get('EnableFtqq', False)),
45 | 'skey': jd.get('FtqqSKEY', ''),
46 | 'only_on_error': False}
47 | except (json.JSONDecodeError, FileNotFoundError) as e:
48 | if isinstance(e, json.JSONDecodeError):
49 | print('[*] 读取[settings.json]失败,格式有误,使用默认配置……')
50 | elif isinstance(e, FileNotFoundError):
51 | print('[*] 缺失[settings.json],使用默认配置……')
52 | else:
53 | print(f'[*] 读取[settings.json]失败,使用默认配置…… [{e}]')
54 | cfg['main'] = {'debug': False, 'check_update': True,
55 | 'join_xhhauto': True}
56 | cfg['ftqq'] = {'enable': False, 'skey': '', 'only_on_error': False}
57 | print('< 完成')
58 | print('> 读取[accounts.json]……')
59 | try:
60 | with open(f'{path}accounts.json', 'r', encoding='utf-8') as f:
61 | jd = json.loads(f.read())
62 | accounts = jd['accounts']
63 | vaccounts = []
64 | for i, ai in enumerate(accounts, 1):
65 | try:
66 | heybox_id = int(ai['heybox_id'])
67 | imei = ai['imei']
68 | pkey = ai['pkey']
69 | if heybox_id and imei and pkey:
70 | vaccounts.append({'heybox_id': heybox_id,
71 | 'imei': imei,
72 | 'pkey': pkey})
73 | except (KeyError, ValueError):
74 | print(f'[*] 第[{i}]个账户实例配置出错,跳过该账户 [{ai}]')
75 | if vaccounts:
76 | print(f'> 成功读取了[{len(vaccounts)}]个账号')
77 | cfg['accounts'] = vaccounts
78 | else:
79 | raise ValueError
80 | except (FileNotFoundError, json.JSONDecodeError, KeyError, ValueError) as e:
81 | if isinstance(e, json.JSONDecodeError) or isinstance(e, KeyError):
82 | print('[*] 读取[accounts.json]失败,格式有误,添加示例配置……')
83 | elif isinstance(e, FileNotFoundError):
84 | print('[*] 缺失[accounts.json],添加示例配置……')
85 | elif isinstance(e, ValueError):
86 | print('[*] 有效账号列表为空,添加示例配置……')
87 | else:
88 | print(f'[*] 读取[accounts.json]失败,添加示例配置…… [{e}]')
89 | cfg['accounts'] = [{'heybox_id': 0, 'imei': '', 'pkey': ''}]
90 | print('[*] 未识别到有效的账号信息,请稍后修改[config.toml]自行添加')
91 | print('< 完成')
92 | return(cfg)
93 |
94 |
95 | def write_new_config(path: str, cfg: dict):
96 | '''
97 | 写入新的配置文件
98 |
99 | 参数:
100 | path: 配置文件目录
101 | cfg: 配置字典
102 | '''
103 | fpath = f'{path}config.toml'
104 | if os.path.exists(fpath):
105 | answer = input(('\n'
106 | '[*] 配置文件[config.toml]已经存在\n'
107 | '[*] 接下来的操作将会覆盖该文件\n'
108 | '[*] 确定要继续吗?【输入 y 继续】:')).strip().lower()
109 | if answer != 'y':
110 | print('> 写入[config.toml]被取消')
111 | return
112 |
113 | print('> 写入[config.toml]……')
114 | try:
115 | with open(fpath, 'w', encoding='utf-8') as f:
116 | toml.dump(cfg, f)
117 | except IOError as e:
118 | print(f'[*] 写入[config.toml]出错 {e}')
119 | print('< 完成')
120 |
121 |
122 | if __name__ == '__main__':
123 | answer = input(('[*] 即将进行配置文件转换,原配置将保留\n'
124 | '[*] 将使用【config.toml】代替原来的【accounts.json】和【settings.json】\n'
125 | '[*] 确定要继续吗?【输入 y 继续】:')).strip().lower()
126 | if answer == 'y':
127 | print('> 转换开始')
128 | path = f'{os.path.split(os.path.realpath(__file__))[0]}{os.sep}'
129 | cfg = read_old_config(path)
130 | write_new_config(path, cfg)
131 | print('< 转换完成')
132 | else:
133 | print('< 操作取消')
134 |
--------------------------------------------------------------------------------
/tools/manual_login.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | '''
3 | # @Author : Chr_
4 | # @Date : 2020-08-11 00:45:24
5 | # @LastEditors : Chr_
6 | # @LastEditTime : 2021-11-18 22:00:33
7 | # @Description : 手动登陆
8 | '''
9 |
10 | import sys
11 | sys.path.append('..')
12 |
13 | print(r'''
14 | ██╗ ██████╗ ██████╗ ██╗███╗ ██╗
15 | ██║ ██╔═══██╗██╔════╝ ██║████╗ ██║
16 | ██║ ██║ ██║██║ ███╗██║██╔██╗ ██║
17 | ██║ ██║ ██║██║ ██║██║██║╚██╗██║
18 | ███████╗╚██████╔╝╚██████╔╝██║██║ ╚████║
19 | ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝
20 | 【未完成,请不要使用】 By Chr_
21 | ''')
22 |
23 |
24 | # try:
25 | # import pyxiaoheihe
26 | # from pyxiaoheihe import HeyBoxClient
27 | # from pyxiaoheihe.static import PYXIAOHEIHE_VERSION, RollSort
28 | # from pyxiaoheihe.error import HeyboxException
29 | # from pyxiaoheihe.utils import ex_extend,cliwait
30 | # except ImportError as e:
31 | # print(e)
32 | # print('导入模块出错,请执行 pip install -r requirements.txt 安装所需的依赖库')
33 | # cliwait()
34 | # exit()
35 |
36 |
37 | # 未完成
38 |
--------------------------------------------------------------------------------
/utils/__init__.py:
--------------------------------------------------------------------------------
1 |
2 | '''
3 | # @Author : Chr_
4 | # @Date : 2020-07-16 15:54:14
5 | # @LastEditors : Chr_
6 | # @LastEditTime : 2020-08-11 00:54:49
7 | # @Description : 功能模块
8 | '''
9 |
10 | def cliwait():
11 | '''
12 | 等待用户输入,防止控制台消失
13 | '''
14 | input("按回车键退出……")
--------------------------------------------------------------------------------
/utils/config.py:
--------------------------------------------------------------------------------
1 |
2 | '''
3 | # @Author : Chr_
4 | # @Date : 2020-07-29 14:21:39
5 | # @LastEditors : Chr_
6 | # @LastEditTime : 2021-11-19 11:56:29
7 | # @Description : 读取并验证配置
8 | '''
9 |
10 | import os
11 | import toml
12 | import chardet
13 | from .log import get_logger, init_logger
14 |
15 | logger = get_logger('Setting')
16 |
17 | SCRIPT_PATH = f'{os.path.split(os.path.realpath(__file__))[0][:-5]}'
18 |
19 | DEFAULT_PATH = f'{SCRIPT_PATH}config.toml'
20 |
21 | CFG = {}
22 |
23 |
24 | def get_script_path() -> str:
25 | '''
26 | 获取脚本所在路径
27 |
28 | 返回:
29 | str: 脚本所在路径
30 | '''
31 | return(SCRIPT_PATH)
32 |
33 |
34 | def get_config(key: str) -> dict:
35 | '''
36 | 获取某一项配置
37 |
38 | 参数:
39 | key: 要获取的设置键名
40 | 返回:
41 | dict: 配置信息字典
42 | '''
43 | return(CFG.get(key))
44 |
45 |
46 | def get_all_config() -> dict:
47 | '''
48 | 获取全部配置
49 |
50 | 返回:
51 | dict: 配置信息字典
52 | '''
53 | return(CFG)
54 |
55 |
56 | def load_config(path: str = DEFAULT_PATH) -> dict:
57 | '''
58 | 读取并验证配置
59 |
60 | 参数:
61 | [path]: 配置文件路径,默认为config.toml
62 | 返回:
63 | dict: 验证过的配置字典
64 | '''
65 | global CFG
66 | try:
67 | logger.debug('开始读取配置')
68 | with open(path, 'rb') as f:
69 | content = f.read()
70 | detect = chardet.detect(content)
71 | encode = detect.get('encode', 'utf-8')
72 | raw_cfg = dict(toml.loads(content.decode(encode)))
73 | CFG = verify_config(raw_cfg)
74 | debug = os.environ.get('mode', 'release').lower()
75 | level = 0 if debug == 'debug' else 20
76 | init_logger(level)
77 | logger.debug('配置验证通过')
78 | return(CFG)
79 |
80 | except FileNotFoundError:
81 | logger.error(f'[*] 配置文件[{path}]不存在')
82 | raise FileNotFoundError(f'[*] 配置文件[{path}]不存在')
83 | except ValueError as e:
84 | logger.error(f'[*] 配置文件验证失败 [{e}]', exc_info=True)
85 |
86 |
87 | def verify_config(cfg: dict) -> dict:
88 | '''
89 | 验证配置
90 |
91 | 参数:
92 | cfg: 配置字典
93 | 返回:
94 | dict: 验证过的配置字典,剔除错误的和不必要的项目
95 | '''
96 | vcfg = {'main': {'check_update': True, 'debug': False, 'join_xhhauto': True},
97 | 'ftqq': {'enable': False, 'skey': '', 'only_on_error': False},
98 | 'email': {'port': 465, 'server': '', 'password': '', 'user': '',
99 | 'recvaddr': '', 'sendaddr': '', 'only_on_error': False},
100 | 'heybox': {'channel': 'heybox_yingyongbao', 'os_type': 'Android',
101 | 'os_version': '9', 'sleep_interval': 1.0, 'auto_report': True},
102 | 'accounts': []}
103 |
104 | main = cfg.get('main', {})
105 | if main and isinstance(main, dict):
106 | check_update = bool(main.get('check_update', True))
107 | debug = bool(main.get('debug', False))
108 | join_xhhauto = bool(main.get('join_xhhauto', True))
109 | vcfg['main'] = {'check_update': check_update, 'debug': debug,
110 | 'join_xhhauto': join_xhhauto}
111 | else:
112 | logger.debug('[main]节配置有误或者未配置,将使用默认配置')
113 |
114 | ftqq = cfg.get('ftqq', {})
115 | if ftqq and isinstance(ftqq, dict):
116 | enable = bool(ftqq.get('enable', False))
117 | skey = ftqq.get('skey', "")
118 | only_on_error = bool(ftqq.get('only_on_error', False))
119 | if enable and not skey:
120 | raise ValueError('开启了FTQQ模块,但是未指定SKEY,请检查配置文件')
121 | vcfg['ftqq'] = {'enable': enable, 'skey': skey,
122 | 'only_on_error': only_on_error}
123 | else:
124 | logger.debug('[ftqq]节配置有误或者未配置,将使用默认配置')
125 |
126 | email = cfg.get('email', {})
127 | if email and isinstance(email, dict):
128 | enable = bool(email.get('enable', False))
129 | try:
130 | port = int(email.get('port', 0))
131 | except ValueError:
132 | port = 465
133 | logger.warning('[*] [email]节port必须为数字')
134 | server = email.get('server', '')
135 | password = email.get('password', '')
136 | user = email.get('user', '')
137 | recvaddr = email.get('recvaddr', '')
138 | sendaddr = email.get('sendaddr', '')
139 | only_on_error = bool(email.get('only_on_error', False))
140 | if enable and not (port and server
141 | and password and user and recvaddr and sendaddr):
142 | raise ValueError('开启了email模块,但是配置不完整,请检查配置文件')
143 | vcfg['email'] = {'enable': enable, 'port': port, 'server': server,
144 | 'password': password, 'user': user,
145 | 'recvaddr': recvaddr, 'sendaddr': sendaddr,
146 | 'only_on_error': only_on_error}
147 | else:
148 | logger.debug('[email]节配置有误或者未配置,将使用默认配置')
149 |
150 | heybox = cfg.get('heybox', {})
151 | if heybox and isinstance(heybox, dict):
152 | channel = heybox.get('channel', "heybox_yingyongbao")
153 | try:
154 | os_type = int(heybox.get('os_type', 1))
155 | if os_type not in (1, 2):
156 | raise ValueError
157 | except ValueError:
158 | os_type = 1
159 | logger.warning('[*] [heybox]节os_type只能为1或者2')
160 | os_version = heybox.get('os_version', "9")
161 | try:
162 | sleep = float(heybox.get('sleep_interval', 1))
163 | except ValueError:
164 | sleep = 1.0
165 | logger.warning('[*] [heybox]节sleep_interval必须为数字')
166 | auto_report = bool(heybox.get('auto_report', False))
167 | rpc_server = heybox.get('rpc_server', 'http://localhost:9000/encode')
168 |
169 | vcfg['heybox'] = {'channel': channel, 'os_type': os_type,
170 | 'os_version': os_version, 'sleep_interval': sleep,
171 | 'auto_report': auto_report, 'rpc_server': rpc_server}
172 | else:
173 | logger.debug('[heybox]节配置有误或者未配置,将使用默认配置')
174 |
175 | accounts = cfg.get('accounts', [])
176 | if accounts and isinstance(accounts, list):
177 | vcfg['accounts'] = []
178 | for i, account in enumerate(accounts, 1):
179 | try:
180 | heybox_id = int(account['heybox_id'])
181 | imei = account['imei']
182 | pkey = account['pkey']
183 | i_os_type = account.get('os_type') or os_type
184 | i_channel = account.get('channel') or channel
185 | i_os_version = account.get('os_version') or os_version
186 |
187 | if heybox_id and imei and pkey:
188 | vcfg['accounts'].append({'heybox_id': heybox_id, 'imei': imei,
189 | 'pkey': pkey, 'os_type': i_os_type,
190 | 'channel': i_channel, 'os_version': i_os_version})
191 | else:
192 | raise ValueError
193 | except (ValueError, AttributeError):
194 | logger.warning(f'[*] 第{i}项账号配置有误,已忽略该项')
195 | logger.debug(f'[*] 配置项为{account}')
196 |
197 | if not vcfg['accounts']:
198 | logger.error('[*] 不存在有效的账号信息,请检查config.toml')
199 | return(vcfg)
200 |
--------------------------------------------------------------------------------
/utils/email.py:
--------------------------------------------------------------------------------
1 |
2 | '''
3 | # @Author : Chr_
4 | # @Date : 2020-08-01 22:26:25
5 | # @LastEditors : Chr_
6 | # @LastEditTime : 2021-11-18 22:00:22
7 | # @Description : 邮件推送模块
8 | '''
9 |
10 | import smtplib
11 | from email.header import Header
12 | from email.mime.text import MIMEText
13 | from email.mime.multipart import MIMEMultipart
14 | from email.utils import formataddr
15 |
16 | from .log import get_logger
17 |
18 | logger = get_logger('EMail')
19 |
20 |
21 | def send_to_email(title: str, data: str, emailcfg: dict) -> bool:
22 | '''
23 | 发送消息到电子邮箱
24 |
25 | 参数:
26 | title: 标题
27 | text: 内容
28 | emailcfg: 电邮配置
29 | 返回:
30 | bool: 是否成功
31 | '''
32 | mailobj = MIMEMultipart()
33 |
34 | sendaddr = emailcfg.get('sendaddr')
35 | recvaddr = emailcfg.get('recvaddr')
36 | server = emailcfg.get('server')
37 | port = emailcfg.get('port')
38 | user = emailcfg.get('user')
39 | password = emailcfg.get('password')
40 |
41 | data = data.replace('#### ', '')
42 | data = data.replace('### ', '')
43 |
44 | mailobj['From'] = formataddr(["小黑盒自动脚本", sendaddr])
45 | mailobj['To'] = Header(recvaddr, 'utf-8')
46 | mailobj['Subject'] = Header(title, 'utf-8')
47 | mailobj.attach(MIMEText(data, 'plain', 'utf-8'))
48 |
49 | try:
50 | with smtplib.SMTP_SSL(host=server, port=port) as smtpObj:
51 | smtpObj.connect(host=server, port=port)
52 | smtpObj.login(user=user, password=password)
53 | smtpObj.sendmail(sendaddr, recvaddr, mailobj.as_string())
54 | logger.debug('电子邮件发送成功')
55 | return(True)
56 | except Exception as e:
57 | logger.error(f'SMTP服务器连接失败,请检查配置 [{e}]')
58 | return(False)
59 |
--------------------------------------------------------------------------------
/utils/ftqq.py:
--------------------------------------------------------------------------------
1 |
2 | '''
3 | # @Author : Chr_
4 | # @Date : 2020-07-29 14:08:11
5 | # @LastEditors : Chr_
6 | # @LastEditTime : 2020-09-05 00:09:06
7 | # @Description : 方糖气球模块
8 | '''
9 |
10 | import requests
11 | from .log import get_logger
12 | from json import JSONDecodeError
13 |
14 | logger = get_logger('FTQQ')
15 |
16 |
17 | def send_to_ftqq(title: str, text: str, ftqqcfg: dict) -> bool:
18 | '''
19 | 发送消息到方糖气球
20 |
21 | 参数:
22 | title: 标题
23 | text: 内容
24 | ftqqcfg: 方糖气球配置节
25 | 返回:
26 | bool: 是否成功
27 | '''
28 | url = f'https://sc.ftqq.com/{ftqqcfg.get("skey")}.send'
29 | data = {'text': str(title), 'desp': str(text)}
30 | resp = requests.post(url=url, data=data)
31 | try:
32 | jd = resp.json()
33 | code = int(jd.get('errno', 1))
34 | if code == 0:
35 | logger.debug('FTQQ推送成功')
36 | return(True)
37 | else:
38 | msg = jd.get('errmsg', '空')
39 | raise ValueError(f'{msg}')
40 | except (ValueError, JSONDecodeError) as e:
41 | logger.error(f'[*] FTQQ推送出错 [{e}]')
42 | logger.error('[*] 请检查SKEY是否配置正确')
43 | return(False)
44 |
--------------------------------------------------------------------------------
/utils/log.py:
--------------------------------------------------------------------------------
1 |
2 | '''
3 | # @Author : Chr_
4 | # @Date : 2020-07-29 14:24:11
5 | # @LastEditors : Chr_
6 | # @LastEditTime : 2020-08-08 15:43:13
7 | # @Description : 控制日志输出
8 | '''
9 |
10 | import logging
11 |
12 | DEFAULT_LEVEL = logging.INFO
13 | DEFAULT_FORMAT = '%(asctime)s [%(levelname)s][%(name)s]%(message)s'
14 | DEFAULT_TIME = '%H:%M:%S' # '%m-%d %H:%M:%S'
15 |
16 |
17 | def init_logger(level: int = DEFAULT_LEVEL):
18 | '''
19 | 初始化logger对象
20 |
21 | 参数:
22 | [level]: 日志等级,默认为DEBUG
23 | '''
24 | logging.basicConfig(level=level,
25 | format=DEFAULT_FORMAT,
26 | datefmt=DEFAULT_TIME)
27 | logging.debug(f'logger初始化完成,日志等级 - {level}')
28 |
29 |
30 | def get_logger(tag: str = 'Null') -> logging.Logger:
31 | '''
32 | 获取logger对象
33 |
34 | 参数:
35 | tag: logger的标签
36 | 返回:
37 | Logger: Logger对象
38 | '''
39 | return(logging.getLogger(tag))
40 |
--------------------------------------------------------------------------------
/utils/version.py:
--------------------------------------------------------------------------------
1 |
2 | '''
3 | # @Author : Chr_
4 | # @Date : 2020-07-29 14:32:40
5 | # @LastEditors : Chr_
6 | # @LastEditTime : 2021-11-19 11:55:20
7 | # @Description : 检查脚本更新
8 | '''
9 |
10 | from typing import Tuple
11 | import requests
12 | from pyxiaoheihe.static import PYXIAOHEIHE_VERSION
13 |
14 | from .log import get_logger
15 |
16 |
17 | SCRIPT_VERSION = "0.93"
18 |
19 | MINI_CORE_VERSION = "1.0.11"
20 |
21 | logger = get_logger('Version')
22 |
23 |
24 | def get_script_version() -> str:
25 | '''
26 | 获取脚本版本
27 |
28 | 返回:
29 | str: 脚本版本号
30 | '''
31 | return(SCRIPT_VERSION)
32 |
33 |
34 | def check_pyxiaoheihe_version() -> bool:
35 | '''
36 | 检查PYxiaoheihe版本是否达到要求
37 |
38 | 返回:
39 | bool: 是否达到最低版本要求
40 | '''
41 | core = tuple(int(x) for x in PYXIAOHEIHE_VERSION.split('.'))
42 | mini = tuple(int(x) for x in MINI_CORE_VERSION.split('.'))
43 | if core >= mini:
44 | logger.debug(
45 | f'满足最低版本要求 [当前{PYXIAOHEIHE_VERSION} >= 要求{MINI_CORE_VERSION}]')
46 | return(True)
47 | else:
48 | logger.debug(
49 | f'pyxiaoheihe版本太低,无法继续运行 [当前{PYXIAOHEIHE_VERSION} < 要求{MINI_CORE_VERSION}]')
50 | return(False)
51 |
52 |
53 | def check_script_update() -> Tuple[str, str, str]:
54 | '''
55 | 检查脚本更新
56 |
57 | 返回:
58 | False: 无更新
59 | (str,str,str): 有更新,最新版本,更新信息,下载链接
60 | '''
61 | url = 'https://api.github.com/repos/chr233/xhh_auto/releases/latest'
62 | try:
63 | resp = requests.get(url=url)
64 | jd = resp.json()
65 | current_version = float(SCRIPT_VERSION)
66 | latest_version = float(str(jd['tag_name'])[1:])
67 | update_info = jd['body']
68 | download_url = jd['assets'][0]['browser_download_url']
69 | if (current_version == latest_version):
70 | logger.debug(f'当前为最新版本,版本号{current_version}')
71 | return(False)
72 | elif (current_version > latest_version):
73 | logger.debug(
74 | f'当前版本号比发行版高,版本号[{current_version}<-{latest_version}]')
75 | return(False)
76 | else:
77 | logger.debug(f'脚本有更新,版本号[{current_version}->{latest_version}]')
78 | return((latest_version, update_info, download_url))
79 | except Exception as e:
80 | logger.error(f'[*] 检测脚本更新出错 [{e}]')
81 | return(False)
82 |
--------------------------------------------------------------------------------