├── .gitignore ├── 37网游 └── rsa.js ├── LICENSE ├── QQ音乐 ├── test.js └── ttt.py ├── README.md ├── common.py ├── e网通 ├── login.py └── server.js ├── steam ├── main.py ├── rsa.js └── server.js ├── test.js ├── test.py ├── 三河政务服务 ├── main.py ├── server.js └── sign.js ├── 乐居 └── login.py ├── 刺猬猫 ├── decrypt.js ├── server.js └── spider.py ├── 咪咕 ├── login.py ├── rsa.js └── server.js ├── 安居客 ├── aes.js ├── brower_feature.js ├── browser.py ├── login.py ├── rsa.js ├── server.js ├── teemo_core.js └── test.py ├── 建筑市场监管平台 ├── decrypt.js ├── main.py └── server.js ├── 惠农网 └── main.py ├── 房天下 ├── login.py ├── rsa.js └── server.js ├── 新浪微博 ├── login.py ├── login_qr_code.py ├── server.js └── sinaSSOEncoder.js ├── 有道翻译 └── trans.py ├── 水信息系统 ├── server.js ├── water.py └── waterSecurity.js ├── 百度翻译 ├── server.js ├── sign.js └── trans.py ├── 空中网 ├── encrypt.js ├── eval.js ├── login.py └── server.js └── 网易云音乐 ├── netease.py └── qrcode.py /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | # Byte-compiled / optimized / DLL files 3 | __pycache__/ 4 | *.py[cod] 5 | *$py.class 6 | 7 | # C extensions 8 | *.so 9 | 10 | # Distribution / packaging 11 | .Python 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | pip-wheel-metadata/ 25 | share/python-wheels/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | MANIFEST 30 | 31 | # PyInstaller 32 | # Usually these files are written by a python script from a template 33 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 34 | *.manifest 35 | *.spec 36 | 37 | # Installer logs 38 | pip-log.txt 39 | pip-delete-this-directory.txt 40 | 41 | # Unit test / coverage reports 42 | htmlcov/ 43 | .tox/ 44 | .nox/ 45 | .coverage 46 | .coverage.* 47 | .cache 48 | nosetests.xml 49 | coverage.xml 50 | *.cover 51 | *.py,cover 52 | .hypothesis/ 53 | .pytest_cache/ 54 | 55 | # Translations 56 | *.mo 57 | *.pot 58 | 59 | # Django stuff: 60 | *.log 61 | local_settings.py 62 | db.sqlite3 63 | db.sqlite3-journal 64 | 65 | # Flask stuff: 66 | instance/ 67 | .webassets-cache 68 | 69 | # Scrapy stuff: 70 | .scrapy 71 | 72 | # Sphinx documentation 73 | docs/_build/ 74 | 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 | .python-version 87 | 88 | # pipenv 89 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 90 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 91 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 92 | # install all needed dependencies. 93 | #Pipfile.lock 94 | 95 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 96 | __pypackages__/ 97 | 98 | # Celery stuff 99 | celerybeat-schedule 100 | celerybeat.pid 101 | 102 | # SageMath parsed files 103 | *.sage.py 104 | 105 | # Environments 106 | .env 107 | .venv 108 | env/ 109 | venv/ 110 | ENV/ 111 | env.bak/ 112 | venv.bak/ 113 | 114 | # Spyder project settings 115 | .spyderproject 116 | .spyproject 117 | 118 | # Rope project settings 119 | .ropeproject 120 | 121 | # mkdocs documentation 122 | /site 123 | 124 | # mypy 125 | .mypy_cache/ 126 | .dmypy.json 127 | dmypy.json 128 | 129 | # Pyre type checker 130 | .pyre/ 131 | -------------------------------------------------------------------------------- /37网游/rsa.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rufeng-h/CrackJS/5f0a08cfd94355cd7043c90663603922aff524b0/37网游/rsa.js -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /QQ音乐/test.js: -------------------------------------------------------------------------------- 1 | const window = global; 2 | 3 | (function (e) { 4 | var n = "undefined" !== typeof e ? e : "undefined" !== typeof window ? window : "undefined" !== typeof self ? self : void 0; 5 | var r = function () { 6 | function e(t, n, r, i, o, a, u, l) { 7 | var c = !i; 8 | t = +t, 9 | n = n || [0], 10 | i = i || [[this], [{}]], 11 | o = o || {}; 12 | var s, f = [], p = null; 13 | Function.prototype.bind || (s = [].slice, 14 | Function.prototype.bind = function (e) { 15 | if ("function" != typeof this) 16 | throw new TypeError("bind101"); 17 | var t = s.call(arguments, 1) 18 | , n = t.length 19 | , r = this 20 | , i = function () { 21 | } 22 | , o = function () { 23 | return t.length = n, 24 | t.push.apply(t, arguments), 25 | r.apply(i.prototype.isPrototypeOf(this) ? this : e, t) 26 | }; 27 | return this.prototype && (i.prototype = this.prototype), 28 | o.prototype = new i, 29 | o 30 | } 31 | ); 32 | for (var d = [function () { 33 | i[i.length - 2] = i[i.length - 2] + i.pop() 34 | } 35 | , function () { 36 | for (var a = n[t++], u = [], l = n[t++], c = n[t++], s = [], f = 0; f < l; f++) 37 | u[n[t++]] = i[n[t++]]; 38 | for (f = 0; f < c; f++) 39 | s[f] = n[t++]; 40 | 41 | const getSign = function t() { 42 | var i = u.slice(0); 43 | i[0] = [this], 44 | i[1] = [arguments], 45 | i[2] = [t]; 46 | for (var l = 0; l < s.length && l < arguments.length; l++) 47 | 0 < s[l] && (i[s[l]] = [arguments[l]]); 48 | return e(a, n, r, i, o) 49 | } 50 | 51 | i.push(getSign); 52 | global.getSign = getSign; 53 | } 54 | , function () { 55 | i[i.length - 2] = i[i.length - 2] | i.pop() 56 | } 57 | , function () { 58 | i.push(i[n[t++]][0]) 59 | } 60 | , function () { 61 | var e = n[t++] 62 | , r = i[i.length - 2 - e]; 63 | i[i.length - 2 - e] = i.pop(), 64 | i.push(r) 65 | } 66 | , , function () { 67 | var e = n[t++] 68 | , r = e ? i.slice(-e) : []; 69 | i.length -= e, 70 | e = i.pop(), 71 | i.push(e[0][e[1]].apply(e[0], r)) 72 | } 73 | , , , function () { 74 | var e = n[t++]; 75 | i[i.length - 1] && (t = e) 76 | } 77 | , function () { 78 | var e = n[t++] 79 | , r = e ? i.slice(-e) : []; 80 | i.length -= e, 81 | r.unshift(null), 82 | i.push(function () { 83 | return function (e, t, n) { 84 | return new (Function.bind.apply(e, t)) 85 | } 86 | .apply(null, arguments) 87 | }(i.pop(), r)) 88 | } 89 | , function () { 90 | i[i.length - 2] = i[i.length - 2] - i.pop() 91 | } 92 | , function () { 93 | var e = i[i.length - 2]; 94 | e[0][e[1]] = i[i.length - 1] 95 | } 96 | , , function () { 97 | var e = n[t++]; 98 | i[e] = void 0 === i[e] ? [] : i[e] 99 | } 100 | , , function () { 101 | i.push(!i.pop()) 102 | } 103 | , , , , function () { 104 | i.push([n[t++]]) 105 | } 106 | , function () { 107 | i[i.length - 1] = r[i[i.length - 1]] 108 | } 109 | , , function () { 110 | i.push("") 111 | } 112 | , , function () { 113 | i[i.length - 2] = i[i.length - 2] << i.pop() 114 | } 115 | , , function () { 116 | var e = i.pop(); 117 | i.push([i[i.pop()][0], e]) 118 | } 119 | , function () { 120 | i.push(i[i.pop()[0]][0]) 121 | } 122 | , , function () { 123 | i[i.length - 1] = n[t++] 124 | } 125 | , function () { 126 | i[i.length - 2] = i[i.length - 2] >> i.pop() 127 | } 128 | , , function () { 129 | i.push(!1) 130 | } 131 | , function () { 132 | i[i.length - 2] = i[i.length - 2] > i.pop() 133 | } 134 | , , function () { 135 | i[i.length - 2] = i[i.length - 2] ^ i.pop() 136 | } 137 | , function () { 138 | i.push([i.pop(), i.pop()].reverse()) 139 | } 140 | , function () { 141 | i.pop() 142 | } 143 | , function () { 144 | i[i[i.length - 2][0]][0] = i[i.length - 1] 145 | } 146 | , , , , function () { 147 | i.push(i[i.length - 1]) 148 | } 149 | , , function () { 150 | return !0 151 | } 152 | , function () { 153 | i.push([r, i.pop()]) 154 | } 155 | , function () { 156 | var e = n[t++] 157 | , o = e ? i.slice(-e) : []; 158 | i.length -= e, 159 | i.push(i.pop().apply(r, o)) 160 | } 161 | , function () { 162 | i[i.length - 2] = i[i.length - 2] >= i.pop() 163 | } 164 | , , , function () { 165 | i.length = n[t++] 166 | } 167 | , , function () { 168 | var e = i.pop() 169 | , t = i.pop(); 170 | i.push([t[0][t[1]], e]) 171 | } 172 | , , function () { 173 | i[i.length - 2] = i[i.length - 2] & i.pop() 174 | } 175 | , function () { 176 | t = n[t++] 177 | } 178 | , , function () { 179 | i[i.length - 1] += String.fromCharCode(n[t++]) 180 | } 181 | , , , function () { 182 | i[i.length - 2] = i[i.length - 2] === i.pop() 183 | } 184 | , function () { 185 | i.push(void 0) 186 | } 187 | , function () { 188 | var e = i.pop(); 189 | i.push(e[0][e[1]]) 190 | } 191 | , , function () { 192 | i.push(!0) 193 | } 194 | , , function () { 195 | i[i.length - 2] = i[i.length - 2] * i.pop() 196 | } 197 | , function () { 198 | i.push(n[t++]) 199 | } 200 | , function () { 201 | i.push(typeof i.pop()) 202 | } 203 | ]; ;) 204 | try { 205 | for (var h = !1; !h;) { 206 | h = d[n[t++]](); 207 | } 208 | if (p) throw p; 209 | return c ? (i.pop(), i.slice(3 + e.v)) : i.pop() 210 | } catch (m) { 211 | console.log("fff"); 212 | var v = f.pop(); 213 | if (void 0 === v) 214 | throw m; 215 | p = m, 216 | t = v[0], 217 | i.length = v[1], 218 | v[2] && (i[v[2]][0] = p) 219 | } 220 | } 221 | 222 | return e.v = 5, 223 | e(0, function (e) { 224 | var t = e[1] 225 | , n = [] 226 | , r = function (e) { 227 | for (var t, n, r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""), i = String(e).replace(/[=]+$/, ""), o = 0, a = 0, u = ""; n = i.charAt(a++); ~n && (t = o % 4 ? 64 * t + n : n, 228 | o++ % 4) && (u += String.fromCharCode(255 & t >> (-2 * o & 6)))) 229 | n = function (e, t, n) { 230 | if ("function" == typeof Array.prototype.indexOf) 231 | return Array.prototype.indexOf.call(e, t, n); 232 | var r; 233 | if (null == e) 234 | throw new TypeError('"array" is null or not defined'); 235 | var i = Object(e) 236 | , o = i.length >>> 0; 237 | if (0 == o) 238 | return -1; 239 | if (o <= (n |= 0)) 240 | return -1; 241 | for (r = Math.max(0 <= n ? n : o - Math.abs(n), 0); r < o; r++) 242 | if (r in i && i[r] === t) 243 | return r; 244 | return -1 245 | }(r, n); 246 | return u 247 | }(e[0]) 248 | , i = t.shift() 249 | , o = t.shift() 250 | , a = 0; 251 | 252 | function u() { 253 | for (; a === i;) 254 | n.push(o), 255 | a++, 256 | i = t.shift(), 257 | o = t.shift() 258 | } 259 | 260 | for (var l = 0; l < r.length; l++) { 261 | var c = r.charAt(l).charCodeAt(0); 262 | u(), 263 | n.push(c), 264 | a++ 265 | } 266 | return u(), 267 | n 268 | }(["MwgOAg4DDgQOBQ4GDgc4fzozCQ4CDgMOBA4FDgYOBw4IFzpkOmU6ZjppOm46ZRVFFzpmOnU6bjpjOnQ6aTpvOm49CUc4XzomFzpkOmU6ZjppOm46ZS4XOmE6bTpkNT8JaSYDAy8AOHwJJhc6ZDplOmY6aTpuOmUuAwMGASY+LQERAAEDOAMzCg4CDgMOBA4FDgYOBw4IDgkUCDg8MwgOAg4DDgQOBQ4GDgcXOmc6bDpvOmI6YTpsFUUXOnU6bjpkOmU6ZjppOm46ZTpkPRAJ1iY45gQmFzpnOmw6bzpiOmE6bBUtFzp3Omk6bjpkOm86dxVFFzp1Om46ZDplOmY6aTpuOmU6ZD0QCSY4BiYXOnc6aTpuOmQ6bzp3FS0XOnM6ZTpsOmYVRRc6dTpuOmQ6ZTpmOmk6bjplOmQ9EAkmOAEmFzpzOmU6bDpmFS0+LQGeAAAvACcmJhQJOA0zIg4CDgMOBA4FDgYOBw4IDgkOCg4LDgwODQ4ODg8OEA4RDhIOEw4UDhUOFg4XDhgOGQ4aDhsOHA4dDh4OHw4gFAkXOk86YjpqOmU6Yzp0FQoAKxc6MCVEAAwmJisXOjElRAEMJiYrFzoyJUQCDCYmKxc6MyVEAwwmJisXOjQlRAQMJiYrFzo1JUQFDCYmKxc6NiVEBgwmJisXOjclRAcMJiYrFzo4JUQIDCYmKxc6OSVECQwmJisXOkElRAoMJiYrFzpCJUQLDCYmKxc6QyVEDAwmJisXOkQlRA0MJiYrFzpFJUQODCYmKxc6RiVEI0QUCwwmJicmJhQKFzpBOkI6QzpEOkU6RjpHOkg6STpKOks6TDpNOk46TzpQOlE6UjpTOlQ6VTpWOlc6WDpZOlo6YTpiOmM6ZDplOmY6ZzpoOmk6ajprOmw6bTpuOm86cDpxOnI6czp0OnU6djp3Ong6eTp6OjA6MToyOjM6NDo1OjY6Nzo4Ojk6KzovOj0nJiYUCxQhFzpfOl86czppOmc6bjpfOmg6YTpzOmg6XzoyOjA6MjowOjA6MzowOjUbPwk4MyYhFCEXOl86XzpzOmk6ZzpuOl86aDphOnM6aDpfOjI6MDoyOjA6MDozOjA6NRsDAwYBBAAmFzp0Om86VTpwOnA6ZTpyOkM6YTpzOmUlBgAnJiYUDBc6dzppOm46ZDpvOncVRRc6bzpiOmo6ZTpjOnQ9CTgBJhc6bjphOnY6aTpnOmE6dDpvOnIVRRc6bzpiOmo6ZTpjOnQ9CTgDJhc6bDpvOmM6YTp0Omk6bzpuFUUXOm86YjpqOmU6Yzp0PScmJhQNAwwJOAomFzpSOmU6ZzpFOng6cBUXOkg6ZTphOmQ6bDplOnM6cxc6aS8CFzp0OmU6czp0JRc6bjphOnY6aTpnOmE6dDpvOnIuFzp1OnM6ZTpyOkE6ZzplOm46dDU/BgEnJiYUDhQhFzpfOl86cTptOmY6ZTpfOnM6aTpnOm46XzpjOmg6ZTpjOmsbP0QBPQkmAwwJOAkmAw0QCTg4Jhc6bDpvOmM6YTp0Omk6bzpuLhc6aDpvOnM6dDUXOmk6bjpkOmU6eDpPOmY1FzpxOnE6LjpjOm86bQYBRABEAQsiJyYmFA9BFzpBOnI6cjphOnkVCgArRAAlRC5EGQsMJiYrRAElRAQMJiYrRAIlRAkMJiYrRAMlRDVEGwsMJiYrRAQlRANEDQAMJiYrRAUlRABEFAAMJiYrRAYlRC9EFAsMJiYrRAclRC9EEQsMJiYXOm06YTpwJTgBMwsOAg4DDgQOBQ4GDgcOCBQJAwoJJgMDRAEAOAomAwMbPy0BAgEJCwoOAwYBFzpqOm86aTpuJQQAJhcGAScmJhQQFzpBOnI6cjphOnkVCgArRAAlRAZEDAAMJiYrRAElRAsMJiYrRAIlRAMMJiYrRAMlRAIMJiYrRAQlRAEMJiYrRAUlRAcMJiYrRAYlRAYMJiYrRAclRDlEIAsMJiYXOm06YTpwJTgxMwsOAg4DDgQOBQ4GDgcOCBQJAwoJJgMDRAEAOAEmAwMbPy0BAgEJCwoOAwYBFzpqOm86aTpuJRcGAScmJhQRFzpBOnI6cjphOnkVCgArRAAlRAhEEUQMQwAMJiYrRAElRAtEIgAMJiYrRAIlRDREHAAMJiYrRAMlRDxECAAMJiYrRAQlRA1EDkQNQwAMJiYrRAUlRAdEDEQNQwAMJiYrRAYlRAdEDUQMQwAMJiYrRAclRAtEEEQMQwAMJiYrRAglRAVECEQTQwAMJiYrRAklRApEDkQPQwAMJiYrRAolRBBEEUQOQwAMJiYrRAslRB1EPgAMJiYrRAwlRAxEEUMMJiYrRA0lRApERQAMJiYrRA4lRAdEYQAMJiYrRDxELQslRAYMJiYnJiYDDhAJJjgeJhQRFzpBOnI6cjphOnkVCgArRAAlRBVEBAAMJiYrRAElRBtEJwAMJiYrRAIlRAEMJiYrRAMlRDhEAgAMJiYrRAQlRANEVwAMJiYrRAUlRDVEGQAMJiYrRAYlRDlEQgAMJiYrRAclRBpELQAMJiYrRAglRCVEBAsMJiYrRAklRAwMJiYrRAolRAhECkQRQwAMJiYrRAslRDJEKwAMJiYrRAwlRCFEBwAMJiYrRA0lRApEDEQNQwAMJiYrRA4lRC5EEAAMJiYrRBFEAgslRAhED0QPQwAMJiYnJiYUEhc6QTpyOnI6YTp5FQoAJyYmFBNEACcmJhQTHEQTRAMLMBAJJjgUJhQUFAkUCwMTRAJDGz8bP0Q2RCYLQxQJFAsDE0QCQ0QBABs/Gz8AJyYmFBUUEQMTGz8nJiYUEhc6cDp1OnM6aBsDFAMVJAYBJhQTKxwrBAEEAEQBACcmHgAEAAImOEQUERQLFAkhJwQAJicEACYnJiYUHRcnJiYUHkQAJyYmFB4cRAUwEAkmOBQmFBYUEgMeRANDGz8nJiYUFxQSAx5EA0NEAQAbPycmJhQYFBIDHkQDQ0QCABs/JyYmFBkDFkQCHycmJhQaAxZEAzdEBBkDF0QEHwInJiYUGwMXRAVECgA3RAIZAxhEBh8CJyYmFBwDGEQ1RAoANycmJhQdAx0UCgMZGz8AFAoDGhs/ABQKAxsbPwAUCgMcGz8AJyYmFB4rHCsEAQQARAEAJyYeAAQAAiY4LxQdAx0UChQSRAhEBwAbP0QCHxs/ABQKFBJEC0QEABs/RAM3RAQZGz8AJyYmFBIhJyYmFB8UHRc6cjplOnA6bDphOmM6ZRsXOlI6ZTpnOkU6eDpwFRc6WzpcOi86KzpdFzpnLwIXBgInJiYUIBc6ejp6OmIDDwADHwADEAAnJiYUDxQQFB8UHRQKIScEACYnBAAmJwQAJicEACYnJiYUIBc6dDpvOkw6bzp3OmU6cjpDOmE6czplGwYALQEBASEIAycmJhQIFzpfOmc6ZTp0OlM6ZTpjOnU6cjppOnQ6eTpTOmk6ZzpuGwMJDCYmPi0BhwAALwEmPi0=", [133, 2628, 156, 340, 267, 272, 270, 288, 321, 326, 324, 338, 352, 2575, 786, 790, 788, 869, 904, 908, 906, 944, 945, 949, 947, 983, 991, 995, 993, 1085, 1133, 1217, 1138, 1142, 1140, 1146, 1147, 1151, 1149, 1217, 1336, 1375, 1359, 1369, 1367, 1372, 1376, 1338, 1508, 1547, 1531, 1541, 1539, 1544, 1548, 1510, 1813, 1818, 1816, 2036, 2073, 2078, 2076, 2174, 2172, 2062, 2213, 2218, 2216, 2389, 2387, 2205, 2576, 354]]), n) 269 | }(); 270 | r.g = function () { 271 | return r.shift()[0] 272 | } 273 | , 274 | n.__sign_hash_20200305 = function (e) { 275 | function t(e, t) { 276 | var n = (65535 & e) + (65535 & t); 277 | return (e >> 16) + (t >> 16) + (n >> 16) << 16 | 65535 & n 278 | } 279 | 280 | function n(e, n, r, i, o, a) { 281 | return t((u = t(t(n, e), t(i, a))) << (l = o) | u >>> 32 - l, r); 282 | var u, l 283 | } 284 | 285 | function r(e, t, r, i, o, a, u) { 286 | return n(t & r | ~t & i, e, t, o, a, u) 287 | } 288 | 289 | function i(e, t, r, i, o, a, u) { 290 | return n(t & i | r & ~i, e, t, o, a, u) 291 | } 292 | 293 | function o(e, t, r, i, o, a, u) { 294 | return n(t ^ r ^ i, e, t, o, a, u) 295 | } 296 | 297 | function a(e, t, r, i, o, a, u) { 298 | return n(r ^ (t | ~i), e, t, o, a, u) 299 | } 300 | 301 | function u(e) { 302 | return function (e) { 303 | var t, n = ""; 304 | for (t = 0; t < 32 * e.length; t += 8) 305 | n += String.fromCharCode(e[t >> 5] >>> t % 32 & 255); 306 | return n 307 | }(function (e, n) { 308 | e[n >> 5] |= 128 << n % 32, 309 | e[14 + (n + 64 >>> 9 << 4)] = n; 310 | var u, l, c, s, f, p = 1732584193, d = -271733879, h = -1732584194, v = 271733878; 311 | for (u = 0; u < e.length; u += 16) 312 | l = p, 313 | c = d, 314 | s = h, 315 | f = v, 316 | p = r(p, d, h, v, e[u], 7, -680876936), 317 | v = r(v, p, d, h, e[u + 1], 12, -389564586), 318 | h = r(h, v, p, d, e[u + 2], 17, 606105819), 319 | d = r(d, h, v, p, e[u + 3], 22, -1044525330), 320 | p = r(p, d, h, v, e[u + 4], 7, -176418897), 321 | v = r(v, p, d, h, e[u + 5], 12, 1200080426), 322 | h = r(h, v, p, d, e[u + 6], 17, -1473231341), 323 | d = r(d, h, v, p, e[u + 7], 22, -45705983), 324 | p = r(p, d, h, v, e[u + 8], 7, 1770035416), 325 | v = r(v, p, d, h, e[u + 9], 12, -1958414417), 326 | h = r(h, v, p, d, e[u + 10], 17, -42063), 327 | d = r(d, h, v, p, e[u + 11], 22, -1990404162), 328 | p = r(p, d, h, v, e[u + 12], 7, 1804603682), 329 | v = r(v, p, d, h, e[u + 13], 12, -40341101), 330 | h = r(h, v, p, d, e[u + 14], 17, -1502002290), 331 | p = i(p, d = r(d, h, v, p, e[u + 15], 22, 1236535329), h, v, e[u + 1], 5, -165796510), 332 | v = i(v, p, d, h, e[u + 6], 9, -1069501632), 333 | h = i(h, v, p, d, e[u + 11], 14, 643717713), 334 | d = i(d, h, v, p, e[u], 20, -373897302), 335 | p = i(p, d, h, v, e[u + 5], 5, -701558691), 336 | v = i(v, p, d, h, e[u + 10], 9, 38016083), 337 | h = i(h, v, p, d, e[u + 15], 14, -660478335), 338 | d = i(d, h, v, p, e[u + 4], 20, -405537848), 339 | p = i(p, d, h, v, e[u + 9], 5, 568446438), 340 | v = i(v, p, d, h, e[u + 14], 9, -1019803690), 341 | h = i(h, v, p, d, e[u + 3], 14, -187363961), 342 | d = i(d, h, v, p, e[u + 8], 20, 1163531501), 343 | p = i(p, d, h, v, e[u + 13], 5, -1444681467), 344 | v = i(v, p, d, h, e[u + 2], 9, -51403784), 345 | h = i(h, v, p, d, e[u + 7], 14, 1735328473), 346 | p = o(p, d = i(d, h, v, p, e[u + 12], 20, -1926607734), h, v, e[u + 5], 4, -378558), 347 | v = o(v, p, d, h, e[u + 8], 11, -2022574463), 348 | h = o(h, v, p, d, e[u + 11], 16, 1839030562), 349 | d = o(d, h, v, p, e[u + 14], 23, -35309556), 350 | p = o(p, d, h, v, e[u + 1], 4, -1530992060), 351 | v = o(v, p, d, h, e[u + 4], 11, 1272893353), 352 | h = o(h, v, p, d, e[u + 7], 16, -155497632), 353 | d = o(d, h, v, p, e[u + 10], 23, -1094730640), 354 | p = o(p, d, h, v, e[u + 13], 4, 681279174), 355 | v = o(v, p, d, h, e[u], 11, -358537222), 356 | h = o(h, v, p, d, e[u + 3], 16, -722521979), 357 | d = o(d, h, v, p, e[u + 6], 23, 76029189), 358 | p = o(p, d, h, v, e[u + 9], 4, -640364487), 359 | v = o(v, p, d, h, e[u + 12], 11, -421815835), 360 | h = o(h, v, p, d, e[u + 15], 16, 530742520), 361 | p = a(p, d = o(d, h, v, p, e[u + 2], 23, -995338651), h, v, e[u], 6, -198630844), 362 | v = a(v, p, d, h, e[u + 7], 10, 1126891415), 363 | h = a(h, v, p, d, e[u + 14], 15, -1416354905), 364 | d = a(d, h, v, p, e[u + 5], 21, -57434055), 365 | p = a(p, d, h, v, e[u + 12], 6, 1700485571), 366 | v = a(v, p, d, h, e[u + 3], 10, -1894986606), 367 | h = a(h, v, p, d, e[u + 10], 15, -1051523), 368 | d = a(d, h, v, p, e[u + 1], 21, -2054922799), 369 | p = a(p, d, h, v, e[u + 8], 6, 1873313359), 370 | v = a(v, p, d, h, e[u + 15], 10, -30611744), 371 | h = a(h, v, p, d, e[u + 6], 15, -1560198380), 372 | d = a(d, h, v, p, e[u + 13], 21, 1309151649), 373 | p = a(p, d, h, v, e[u + 4], 6, -145523070), 374 | v = a(v, p, d, h, e[u + 11], 10, -1120210379), 375 | h = a(h, v, p, d, e[u + 2], 15, 718787259), 376 | d = a(d, h, v, p, e[u + 9], 21, -343485551), 377 | p = t(p, l), 378 | d = t(d, c), 379 | h = t(h, s), 380 | v = t(v, f); 381 | return [p, d, h, v] 382 | }(function (e) { 383 | var t, n = []; 384 | for (n[(e.length >> 2) - 1] = void 0, 385 | t = 0; t < n.length; t += 1) 386 | n[t] = 0; 387 | for (t = 0; t < 8 * e.length; t += 8) 388 | n[t >> 5] |= (255 & e.charCodeAt(t / 8)) << t % 32; 389 | return n 390 | }(e), 8 * e.length)) 391 | } 392 | 393 | function l(e) { 394 | return u(unescape(encodeURIComponent(e))) 395 | } 396 | 397 | return function (e) { 398 | var t, n, r = ""; 399 | for (n = 0; n < e.length; n += 1) 400 | t = e.charCodeAt(n), 401 | r += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); 402 | return r 403 | }(l(e)) 404 | } 405 | ; 406 | }).apply({}, global); 407 | 408 | const data = '{"comm":{"cv":4747474,"ct":24,"format":"json","inCharset":"utf-8","outCharset":"utf-8","notice":0,"platform":"yqq.json","needNewCode":1,"uin":0,"g_tk_new_20200303":5381,"g_tk":5381},"req_1":{"module":"music.musichallSinger.SingerList","method":"GetSingerListIndex","param":{"area":-100,"sex":-100,"genre":8,"index":-100,"sin":0,"cur_page":1}}}' 409 | console.log(getSign(data)); 410 | console.log(__sign_hash_20200305(data)) 411 | 412 | -------------------------------------------------------------------------------- /QQ音乐/ttt.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/23/21:09 4 | description 5 | """ 6 | '{"comm":{"cv":4747474,"ct":24,"format":"json","inCharset":"utf-8","outCharset":"utf-8","notice":0,"platform":"yqq.json","needNewCode":1,"uin":0,"g_tk_new_20200303":5381,"g_tk":5381},"req_1":{"module":"music.musichallSinger.SingerList","method":"GetSingerListIndex","param":{"area":3,"sex":1,"genre":4,"index":6,"sin":0,"cur_page":1}}}' -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CrackJS 2 | JS逆向分析 3 | 4 | 仅供学习和交流使用,如侵犯您的相关权益,请联系本人立即删除! 5 | 6 | [个人网站](http://windcf.com)有详细逆向过程 7 | -------------------------------------------------------------------------------- /common.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/15/20:45 4 | description 5 | """ 6 | headers = { 7 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 8 | 'Accept-Encoding': 'gzip, deflate, br', 9 | 'Accept-Language': 'zh-CN,zh;q=0.9', 10 | 'Cache-Control': 'no-cache', 11 | 'Connection': 'keep-alive', 12 | 'Pragma': 'no-cache', 13 | 'sec-ch-ua': '"Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"', 14 | 'sec-ch-ua-mobile': '?0', 15 | 'sec-ch-ua-platform': '"Windows"', 16 | 'Sec-Fetch-Dest': 'document', 17 | 'Sec-Fetch-Mode': 'navigate', 18 | 'Sec-Fetch-Site': 'none', 19 | 'Sec-Fetch-User': '?1', 20 | 'Upgrade-Insecure-Requests': '1', 21 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36', } 22 | -------------------------------------------------------------------------------- /e网通/login.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | import time 3 | 4 | from common import headers 5 | import requests 6 | 7 | session = requests.session() 8 | session.headers.update(headers) 9 | 10 | session.get('https://web.ewt360.com/register/#/login') 11 | 12 | password = session.post('http://127.0.0.1:8000', data={'password': '1234567890a'}).text 13 | 14 | username = '18280484271' 15 | 16 | t = int(time.time() * 1000) 17 | formdata = { 18 | 'autoLogin': True, 19 | 'password': password, 20 | 'platform': 1, 21 | 'userName': username 22 | } 23 | 24 | print(session.post('https://gateway.ewt360.com/api/authcenter/v2/oauth/login/account', headers={ 25 | 'secretid': '2', 26 | 'sign': hashlib.md5((str(t) + 'bdc739ff2dcf').encode()).hexdigest().upper(), 27 | 'timestamp': str(t), 28 | }, json=formdata).text) 29 | -------------------------------------------------------------------------------- /e网通/server.js: -------------------------------------------------------------------------------- 1 | const CryptoJS = require('crypto-js'); 2 | const express = require('express'); 3 | const bodyParser = require('body-parser'); 4 | const app = express(); 5 | const port = 8000; 6 | 7 | const key = CryptoJS 8 | .enc 9 | .Utf8 10 | .parse("20171109124536982017110912453698"); 11 | 12 | const iv = CryptoJS 13 | .enc 14 | .Utf8 15 | .parse('2017110912453698'); //十六位十六进制数作为密钥偏移量 16 | 17 | const encrypt = (word) => { 18 | let srcs = CryptoJS 19 | .enc 20 | .Utf8 21 | .parse(word); 22 | let encrypted = CryptoJS 23 | .AES 24 | .encrypt(srcs, key, { 25 | iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 26 | }); 27 | return encrypted 28 | .ciphertext 29 | .toString() 30 | .toUpperCase(); 31 | } 32 | 33 | app.use(bodyParser.urlencoded({limit: "2100000kb", extended: true})); 34 | 35 | app.post('/', (req, res) => { 36 | res.send(encrypt(req.body.password)); 37 | }); 38 | 39 | app.listen(port, () => { 40 | console.log(`Example app listening at http://localhost:${port}`) 41 | }); 42 | 43 | -------------------------------------------------------------------------------- /steam/main.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import requests 4 | from common import headers 5 | 6 | session = requests.session() 7 | session.headers.update(headers) 8 | 9 | session.get('https://store.steampowered.com/login') 10 | 11 | 12 | def get_rsa_key(username: str): 13 | formdata = { 14 | 'donotcache': int(time.time() * 1000), 15 | 'username': username, 16 | } 17 | response = session.post('https://store.steampowered.com/login/getrsakey/', data=formdata) 18 | rsa = response.json() 19 | 20 | return rsa['publickey_mod'], rsa['public_exp'], rsa['timestamp'] 21 | 22 | 23 | def login(username, password): 24 | data = {'donotcache': int(time.time() * 1000), 25 | 'password': password, 26 | 'username': username, 27 | 'twofactorcode': '', 28 | 'emailauth': '', 29 | 'loginfriendlyname': '', 30 | 'captchagid': -1, 31 | 'captcha_text': '', 32 | 'emailsteamid': '', 33 | 'rsatimestamp': '', 34 | 'remember_login': False} 35 | response = session.post('https://store.steampowered.com/login/dologin/', data=data) 36 | print(response.json()) 37 | 38 | 39 | if __name__ == '__main__': 40 | username, password = '182801', 'hyB3A~RBsbx.gx)' 41 | modulus, exponent, timestamp = get_rsa_key(username) 42 | print(session.post('http:127.0.0.1:8000', data={'modulus': modulus, 'password': password, 'exponent': exponent})) 43 | -------------------------------------------------------------------------------- /steam/rsa.js: -------------------------------------------------------------------------------- 1 | var RSAPublicKey = function ($modulus_hex, $encryptionExponent_hex) { 2 | this.modulus = new BigInteger($modulus_hex, 16); 3 | this.encryptionExponent = new BigInteger($encryptionExponent_hex, 16); 4 | }; 5 | 6 | var Base64 = { 7 | base64: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", 8 | encode: function ($input) { 9 | if (!$input) { 10 | return false; 11 | } 12 | var $output = ""; 13 | var $chr1, $chr2, $chr3; 14 | var $enc1, $enc2, $enc3, $enc4; 15 | var $i = 0; 16 | do { 17 | $chr1 = $input.charCodeAt($i++); 18 | $chr2 = $input.charCodeAt($i++); 19 | $chr3 = $input.charCodeAt($i++); 20 | $enc1 = $chr1 >> 2; 21 | $enc2 = (($chr1 & 3) << 4) | ($chr2 >> 4); 22 | $enc3 = (($chr2 & 15) << 2) | ($chr3 >> 6); 23 | $enc4 = $chr3 & 63; 24 | if (isNaN($chr2)) $enc3 = $enc4 = 64; 25 | else if (isNaN($chr3)) $enc4 = 64; 26 | $output += this.base64.charAt($enc1) + this.base64.charAt($enc2) + this.base64.charAt($enc3) + this.base64.charAt($enc4); 27 | } while ($i < $input.length); 28 | return $output; 29 | }, 30 | decode: function ($input) { 31 | if (!$input) return false; 32 | $input = $input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 33 | var $output = ""; 34 | var $enc1, $enc2, $enc3, $enc4; 35 | var $i = 0; 36 | do { 37 | $enc1 = this.base64.indexOf($input.charAt($i++)); 38 | $enc2 = this.base64.indexOf($input.charAt($i++)); 39 | $enc3 = this.base64.indexOf($input.charAt($i++)); 40 | $enc4 = this.base64.indexOf($input.charAt($i++)); 41 | $output += String.fromCharCode(($enc1 << 2) | ($enc2 >> 4)); 42 | if ($enc3 != 64) $output += String.fromCharCode((($enc2 & 15) << 4) | ($enc3 >> 2)); 43 | if ($enc4 != 64) $output += String.fromCharCode((($enc3 & 3) << 6) | $enc4); 44 | } while ($i < $input.length); 45 | return $output; 46 | } 47 | }; 48 | 49 | var Hex = { 50 | hex: "0123456789abcdef", 51 | encode: function ($input) { 52 | if (!$input) return false; 53 | var $output = ""; 54 | var $k; 55 | var $i = 0; 56 | do { 57 | $k = $input.charCodeAt($i++); 58 | $output += this.hex.charAt(($k >> 4) & 0xf) + this.hex.charAt($k & 0xf); 59 | } while ($i < $input.length); 60 | return $output; 61 | }, 62 | decode: function ($input) { 63 | if (!$input) return false; 64 | $input = $input.replace(/[^0-9abcdef]/g, ""); 65 | var $output = ""; 66 | var $i = 0; 67 | do { 68 | $output += String.fromCharCode(((this.hex.indexOf($input.charAt($i++)) << 4) & 0xf0) | (this.hex.indexOf($input.charAt($i++)) & 0xf)); 69 | } while ($i < $input.length); 70 | return $output; 71 | } 72 | }; 73 | 74 | var RSA = { 75 | 76 | getPublicKey: function ($modulus_hex, $exponent_hex) { 77 | return new RSAPublicKey($modulus_hex, $exponent_hex); 78 | }, 79 | 80 | encrypt: function ($data, $pubkey) { 81 | if (!$pubkey) return false; 82 | $data = this.pkcs1pad2($data, ($pubkey.modulus.bitLength() + 7) >> 3); 83 | if (!$data) return false; 84 | $data = $data.modPowInt($pubkey.encryptionExponent, $pubkey.modulus); 85 | if (!$data) return false; 86 | $data = $data.toString(16); 87 | if (($data.length & 1) == 1) 88 | $data = "0" + $data; 89 | return Base64.encode(Hex.decode($data)); 90 | }, 91 | 92 | pkcs1pad2: function ($data, $keysize) { 93 | if ($keysize < $data.length + 11) 94 | return null; 95 | var $buffer = []; 96 | var $i = $data.length - 1; 97 | while ($i >= 0 && $keysize > 0) 98 | $buffer[--$keysize] = $data.charCodeAt($i--); 99 | $buffer[--$keysize] = 0; 100 | while ($keysize > 2) 101 | $buffer[--$keysize] = Math.floor(Math.random() * 254) + 1; 102 | $buffer[--$keysize] = 2; 103 | $buffer[--$keysize] = 0; 104 | return new BigInteger($buffer); 105 | } 106 | }; 107 | 108 | module.exports = RSA; 109 | -------------------------------------------------------------------------------- /steam/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const app = express(); 3 | const port = 8000 4 | const RSA = require('./rsa') 5 | 6 | app.post("/", (req, res) => { 7 | const pubkey = RSA.getPublicKey(req.body.modulus, req.body.exponent) 8 | res.json(RSA.encrypt(req.body.password, pubkey)); 9 | }); 10 | 11 | app.listen(port, () => { 12 | console.log(`Example app listening at http://localhost:${port}`) 13 | }) -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | const p = {}; 2 | 3 | let name = 100; 4 | 5 | Object.defineProperty(p, 'name', { 6 | get: () => { 7 | console.log(this) 8 | return name; 9 | }, set: (value) => { 10 | console.log(this) 11 | this.name = value; 12 | } 13 | }) 14 | 15 | 16 | console.log(p.name); 17 | console.log(p.name); 18 | console.log(p) -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | from Crypto.Cipher import AES 2 | -------------------------------------------------------------------------------- /三河政务服务/main.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/12/27/16:39 4 | description 5 | """ 6 | 7 | import requests 8 | 9 | from common import headers 10 | 11 | session = requests.Session() 12 | 13 | session.headers.update(headers) 14 | session.headers.update({"Referer": "http://zwfw.san-he.gov.cn/icity/icity/guestbook/interact"}) 15 | 16 | if __name__ == '__main__': 17 | session.get("http://zwfw.san-he.gov.cn/icity/icity/guestbook/interact") 18 | params = {"start": 21, "limit": 7, "TYPE@=": "2", "OPEN@=": "1"} 19 | url = session.get("http://127.0.0.1:8000").text 20 | print(url) 21 | res = session.post(url, json=params) 22 | print(res.request.body) 23 | print(res.json()) 24 | print(res.request.headers) 25 | -------------------------------------------------------------------------------- /三河政务服务/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const app = express(); 3 | const port = 8000 4 | const authUrl = require('./sign') 5 | 6 | app.get("/", (req, res) => { 7 | res.send("http://zwfw.san-he.gov.cn" + authUrl("/icity/api-v2/app.icity.guestbook.WriteCmd/getList")) 8 | }); 9 | 10 | app.listen(port, () => { 11 | console.log(`Example app listening at http://localhost:${port}`) 12 | }) -------------------------------------------------------------------------------- /三河政务服务/sign.js: -------------------------------------------------------------------------------- 1 | const __signature = "b959871640593662154"; 2 | 3 | function authUrl(url) { 4 | var curUrl = url; 5 | var chars = "0123456789abcdef"; 6 | var sig = __signature; 7 | var key = ""; 8 | var keyIndex = -1; 9 | for (var i = 0; i < 6; i++) { 10 | var c = sig.charAt(keyIndex + 1); 11 | key += c; 12 | keyIndex = chars.indexOf(c); 13 | if (keyIndex < 0 || keyIndex >= sig.length) { 14 | keyIndex = i; 15 | } 16 | } 17 | 18 | var timestamp = parseInt(Math.random() * (9999 - 1000 + 1) + 1000) + "_" + key + "_" + Date.parse(new Date()); 19 | var t = timestamp; 20 | t = t.replace(/\+/g, "_"); 21 | 22 | var tkey = ""; 23 | var tkeyIndex = -1; 24 | for (var i = 0; i < 6; i++) { 25 | var c = timestamp.charAt(tkeyIndex + 1); 26 | tkey += c; 27 | tkeyIndex = chars.indexOf(c); 28 | if (tkeyIndex < 0 || tkeyIndex >= timestamp.length) { 29 | tkeyIndex = i; 30 | } 31 | } 32 | 33 | curUrl += "?s=" + sig; 34 | curUrl += "&t=" + t; 35 | curUrl += "&o=" + tkey; 36 | return curUrl; 37 | } 38 | 39 | // console.log(authUrl("/icity/api-v2/app.icity.govservice.GovProjectCmd/getPubContentList")) 40 | module.exports = authUrl -------------------------------------------------------------------------------- /乐居/login.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/05/17:58 4 | description 5 | """ 6 | 7 | import hashlib 8 | import base64 9 | import time 10 | import requests 11 | from scrapy import Selector 12 | 13 | headers = { 14 | 'Accept': '*/*', 15 | 'Accept-Encoding': 'gzip, deflate, br', 16 | 'Accept-Language': 'zh-CN,zh;q=0.9', 17 | 'Cache-Control': 'no-cache', 18 | 'Connection': 'keep-alive', 19 | 'Host': 'my.leju.com', 20 | 'Pragma': 'no-cache', 21 | 'sec-ch-ua': '"Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"', 22 | 'sec-ch-ua-mobile': '?0', 23 | 'sec-ch-ua-platform': '"Windows"', 24 | 'Sec-Fetch-Dest': 'document', 25 | 'Sec-Fetch-Mode': 'navigate', 26 | 'Sec-Fetch-Site': 'none', 27 | 'Sec-Fetch-User': '?1', 28 | 'Upgrade-Insecure-Requests': '1', 29 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36'} 30 | 31 | 32 | def encrypt(msg: str) -> str: 33 | h = hashlib.md5(msg.encode()).hexdigest() 34 | return base64.b64encode((h[0:8] + base64.b64encode(msg.encode()).decode() + 35 | h[10: 14]).encode()).decode() 36 | 37 | 38 | def timestamp(): 39 | return str(int(time.time() * 1000)) 40 | 41 | 42 | def get_key(response): 43 | selector = Selector(text=response.text) 44 | return selector.xpath('//form[@name="msgForm"]/div/input[@class="setKey"]/@value').extract_first() 45 | 46 | 47 | session = requests.session() 48 | 49 | if __name__ == '__main__': 50 | mobile, password = "", "" 51 | response = session.get("https://my.leju.com/web/sso/loginview", headers=headers) 52 | session.get( 53 | "https://my.leju.com/Settings/Findpwd/isReg", 54 | headers=headers, 55 | params={"mobile": encrypt(mobile), "noCache": timestamp()}) 56 | time.sleep(2) 57 | res = session.post("https://my.leju.com/web/sso/ssoLogin", headers=headers, 58 | data={"mobile": encrypt(mobile), "password": encrypt(password), "key": get_key(response), 59 | "originUrl": "https://my.leju.com/Settings/Index/index", 60 | "tid": "0", 61 | "ad_source": "", 62 | "oc_source": ""}) 63 | # for k, v in session.cookies.items(): 64 | # print(k, v) 65 | print(res.text) 66 | -------------------------------------------------------------------------------- /刺猬猫/decrypt.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const base64 = (function () { 3 | var _PADCHAR = "=" 4 | , _ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" 5 | , _VERSION = "1.0"; 6 | 7 | function _getbyte64(s, i) { 8 | var idx = _ALPHA.indexOf(s.charAt(i)); 9 | if (idx === -1) { 10 | throw "Cannot decode base64" 11 | } 12 | return idx 13 | } 14 | 15 | function _decode(s) { 16 | var pads = 0, i, b10, imax = s.length, x = []; 17 | s = String(s); 18 | if (imax === 0) { 19 | return s 20 | } 21 | if (imax % 4 !== 0) { 22 | throw "Cannot decode base64" 23 | } 24 | if (s.charAt(imax - 1) === _PADCHAR) { 25 | pads = 1; 26 | if (s.charAt(imax - 2) === _PADCHAR) { 27 | pads = 2 28 | } 29 | imax -= 4 30 | } 31 | for (i = 0; i < imax; i += 4) { 32 | b10 = (_getbyte64(s, i) << 18) | (_getbyte64(s, i + 1) << 12) | (_getbyte64(s, i + 2) << 6) | _getbyte64(s, i + 3); 33 | x.push(String.fromCharCode(b10 >> 16, (b10 >> 8) & 255, b10 & 255)) 34 | } 35 | switch (pads) { 36 | case 1: 37 | b10 = (_getbyte64(s, i) << 18) | (_getbyte64(s, i + 1) << 12) | (_getbyte64(s, i + 2) << 6); 38 | x.push(String.fromCharCode(b10 >> 16, (b10 >> 8) & 255)); 39 | break; 40 | case 2: 41 | b10 = (_getbyte64(s, i) << 18) | (_getbyte64(s, i + 1) << 12); 42 | x.push(String.fromCharCode(b10 >> 16)); 43 | break 44 | } 45 | return x.join("") 46 | } 47 | 48 | function _getbyte(s, i) { 49 | var x = s.charCodeAt(i); 50 | if (x > 255) { 51 | throw "INVALID_CHARACTER_ERR: DOM Exception 5" 52 | } 53 | return x 54 | } 55 | 56 | function _encode(s) { 57 | if (arguments.length !== 1) { 58 | throw "SyntaxError: exactly one argument required" 59 | } 60 | s = String(s); 61 | var i, b10, x = [], imax = s.length - s.length % 3; 62 | if (s.length === 0) { 63 | return s 64 | } 65 | for (i = 0; i < imax; i += 3) { 66 | b10 = (_getbyte(s, i) << 16) | (_getbyte(s, i + 1) << 8) | _getbyte(s, i + 2); 67 | x.push(_ALPHA.charAt(b10 >> 18)); 68 | x.push(_ALPHA.charAt((b10 >> 12) & 63)); 69 | x.push(_ALPHA.charAt((b10 >> 6) & 63)); 70 | x.push(_ALPHA.charAt(b10 & 63)) 71 | } 72 | switch (s.length - imax) { 73 | case 1: 74 | b10 = _getbyte(s, i) << 16; 75 | x.push(_ALPHA.charAt(b10 >> 18) + _ALPHA.charAt((b10 >> 12) & 63) + _PADCHAR + _PADCHAR); 76 | break; 77 | case 2: 78 | b10 = (_getbyte(s, i) << 16) | (_getbyte(s, i + 1) << 8); 79 | x.push(_ALPHA.charAt(b10 >> 18) + _ALPHA.charAt((b10 >> 12) & 63) + _ALPHA.charAt((b10 >> 6) & 63) + _PADCHAR); 80 | break 81 | } 82 | return x.join("") 83 | } 84 | 85 | return { 86 | decode: _decode, 87 | encode: _encode, 88 | VERSION: _VERSION 89 | } 90 | })(); 91 | const CryptoJS = require('crypto-js') 92 | const decrypt = function (s) { 93 | var n = s.chapter_content; 94 | var r = s.encryt_keys; 95 | var t = s.encryt_keys.length; 96 | var q = s.accessKey; 97 | var o = q.split(""); 98 | var m = o.length; 99 | var k = []; 100 | k.push(r[(o[m - 1].charCodeAt(0)) % t]); 101 | k.push(r[(o[0].charCodeAt(0)) % t]); 102 | for (let i = 0; i < k.length; i++) { 103 | n = base64.decode(n); 104 | var p = k[i]; 105 | var j = base64.encode(n.substr(0, 16)); 106 | var f = base64.encode(n.substr(16)); 107 | var h = CryptoJS.format.OpenSSL.parse(f); 108 | n = CryptoJS.AES.decrypt(h, CryptoJS.enc.Base64.parse(p), { 109 | iv: CryptoJS.enc.Base64.parse(j), 110 | format: CryptoJS.format.OpenSSL 111 | }); 112 | if (i < k.length - 1) { 113 | n = n.toString(CryptoJS.enc.Base64); 114 | n = base64.decode(n); 115 | } 116 | } 117 | return n.toString(CryptoJS.enc.Utf8) 118 | } 119 | 120 | module.exports = decrypt; -------------------------------------------------------------------------------- /刺猬猫/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const decrypt = require('./decrypt') 3 | const bodyParser = require('body-parser'); 4 | const app = express(); 5 | app.use(bodyParser.urlencoded({extended: true})); 6 | const port = 8000; 7 | 8 | app.post('/', (req, res) => { 9 | const content = decrypt(req.body); 10 | res.send(content); 11 | }); 12 | 13 | app.listen(port, () => { 14 | console.log(`Example app listening at http://localhost:${port}`) 15 | }); 16 | 17 | -------------------------------------------------------------------------------- /刺猬猫/spider.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/03/16:51 4 | description 5 | """ 6 | 7 | import requests 8 | 9 | session = requests.session() 10 | headers = { 11 | 'Accept': '*/*', 12 | 'Accept-Encoding': 'gzip, deflate, br', 13 | 'Accept-Language': 'zh-CN,zh;q=0.9', 14 | 'Cache-Control': 'no-cache', 15 | 'Connection': 'keep-alive', 16 | 'Host': 'www.ciweimao.com', 17 | 'Origin': 'https://www.ciweimao.com', 18 | 'Pragma': 'no-cache', 19 | 'Referer': 'https://www.ciweimao.com/chapter/107397586', 20 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36', 21 | } 22 | 23 | 24 | def get_acc_key(chapter_id: str) -> str: 25 | res = session.post("https://www.ciweimao.com/chapter/ajax_get_session_code", data={"chapter_id": chapter_id}, 26 | headers=headers) 27 | return res.json().get("chapter_access_key") 28 | 29 | 30 | def get_content(chapter_id: str, acc_key: str) -> str: 31 | formdata = {"chapter_id": chapter_id, "chapter_access_key": acc_key} 32 | res = session.post("https://www.ciweimao.com/chapter/get_book_chapter_detail_info", headers=headers, data=formdata) 33 | enc_data = res.json() 34 | enc_data["accessKey"] = acc_key 35 | return session.post("http://127.0.0.1:8000", data=enc_data).text 36 | 37 | 38 | if __name__ == '__main__': 39 | chapter_id = "107402429" 40 | session.get("https://www.ciweimao.com/", headers=headers) 41 | session.get("https://www.ciweimao.com/book/100259458", headers=headers) 42 | acc_key = get_acc_key(chapter_id) 43 | content = get_content(chapter_id, acc_key) 44 | print(content) 45 | -------------------------------------------------------------------------------- /咪咕/login.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/04/9:40 4 | description 5 | """ 6 | import requests 7 | from pprint import pprint 8 | 9 | session = requests.session() 10 | headers = { 11 | 'Accept': '*/*', 12 | 'Accept-Encoding': 'gzip, deflate, br', 13 | 'Accept-Language': 'zh-CN,zh;q=0.9', 14 | 'Cache-Control': 'no-cache', 15 | 'Connection': 'keep-alive', 16 | 'Host': 'passport.migu.cn', 17 | 'Referer': 'https://passport.migu.cn/portal', 18 | 'Pragma': 'no-cache', 19 | 'sec-ch-ua': '"Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"', 20 | 'sec-ch-ua-mobile': '?0', 21 | 'sec-ch-ua-platform': '"Windows"', 22 | 'Sec-Fetch-Dest': 'document', 23 | 'Sec-Fetch-Mode': 'navigate', 24 | 'Sec-Fetch-Site': 'none', 25 | 'Sec-Fetch-User': '?1', 26 | 'Upgrade-Insecure-Requests': '1', 27 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36'} 28 | 29 | if __name__ == '__main__': 30 | username, password = "", "" 31 | session.get("https://passport.migu.cn/portal", headers=headers) 32 | session.get( 33 | "https://passport.migu.cn/login?sourceid=100001&apptype=0&forceAuthn=false&isPassive=false&authType=MiguPassport&passwordControl=0&display=web&referer=https://passport.migu.cn/portal&logintype=1&qq=null&weibo=null&alipay=null&weixin=null&andPass=null&phoneNumber=&callbackURL=&relayState=&openPage=&hideRegister=&hideForgetPass=&sim=&needOneKey=0&hideps=0", 34 | headers=headers) 35 | session.post("https://passport.migu.cn/password/publickey", headers=headers) 36 | ret = requests.post("http://127.0.0.1:8000", data={"username": username, "password": password}) 37 | formdata = ret.json() 38 | formdata.update({"isAsync": "true", "sourceID": "100001", 39 | "appType": 0, 40 | "relayState": "", "captcha": "", 41 | "imgcodeType": 1}) 42 | pprint(session.post("https://passport.migu.cn/authn", data=formdata).json()) 43 | -------------------------------------------------------------------------------- /咪咕/rsa.js: -------------------------------------------------------------------------------- 1 | const window = global; 2 | const navigator = {"appName": 'Netscape'}; 3 | 4 | const rsa = (function () { 5 | function d(a, b, c) { 6 | null != a && ("number" == typeof a ? this.fromNumber(a, b, c) : null == b && "string" != typeof a ? this.fromString(a, 256) : this.fromString(a, b)) 7 | } 8 | 9 | function e() { 10 | return new d(null) 11 | } 12 | 13 | function f(a, b, c, d, e, f) { 14 | for (; --f >= 0;) { 15 | var g = b * this[a++] + c[d] + e; 16 | e = Math.floor(g / 67108864), 17 | c[d++] = 67108863 & g 18 | } 19 | return e 20 | } 21 | 22 | function g(a, b, c, d, e, f) { 23 | for (var g = 32767 & b, h = b >> 15; --f >= 0;) { 24 | var i = 32767 & this[a] 25 | , j = this[a++] >> 15 26 | , k = h * i + j * g; 27 | i = g * i + ((32767 & k) << 15) + c[d] + (1073741823 & e), 28 | e = (i >>> 30) + (k >>> 15) + h * j + (e >>> 30), 29 | c[d++] = 1073741823 & i 30 | } 31 | return e 32 | } 33 | 34 | function h(a, b, c, d, e, f) { 35 | for (var g = 16383 & b, h = b >> 14; --f >= 0;) { 36 | var i = 16383 & this[a] 37 | , j = this[a++] >> 14 38 | , k = h * i + j * g; 39 | i = g * i + ((16383 & k) << 14) + c[d] + e, 40 | e = (i >> 28) + (k >> 14) + h * j, 41 | c[d++] = 268435455 & i 42 | } 43 | return e 44 | } 45 | 46 | function i(a) { 47 | return nb.charAt(a) 48 | } 49 | 50 | function j(a, b) { 51 | var c = ob[a.charCodeAt(b)]; 52 | return null == c ? -1 : c 53 | } 54 | 55 | function k(a) { 56 | for (var b = this.t - 1; b >= 0; --b) 57 | a[b] = this[b]; 58 | a.t = this.t, 59 | a.s = this.s 60 | } 61 | 62 | function l(a) { 63 | this.t = 1, 64 | this.s = 0 > a ? -1 : 0, 65 | a > 0 ? this[0] = a : -1 > a ? this[0] = a + this.DV : this.t = 0 66 | } 67 | 68 | function m(a) { 69 | var b = e(); 70 | return b.fromInt(a), 71 | b 72 | } 73 | 74 | function n(a, b) { 75 | var c; 76 | if (16 == b) 77 | c = 4; 78 | else if (8 == b) 79 | c = 3; 80 | else if (256 == b) 81 | c = 8; 82 | else if (2 == b) 83 | c = 1; 84 | else if (32 == b) 85 | c = 5; 86 | else { 87 | if (4 != b) 88 | return void this.fromRadix(a, b); 89 | c = 2 90 | } 91 | this.t = 0, 92 | this.s = 0; 93 | for (var e = a.length, f = !1, g = 0; --e >= 0;) { 94 | var h = 8 == c ? 255 & a[e] : j(a, e); 95 | 0 > h ? "-" == a.charAt(e) && (f = !0) : (f = !1, 96 | 0 == g ? this[this.t++] = h : g + c > this.DB ? (this[this.t - 1] |= (h & (1 << this.DB - g) - 1) << g, 97 | this[this.t++] = h >> this.DB - g) : this[this.t - 1] |= h << g, 98 | g += c, 99 | g >= this.DB && (g -= this.DB)) 100 | } 101 | 8 == c && 0 != (128 & a[0]) && (this.s = -1, 102 | g > 0 && (this[this.t - 1] |= (1 << this.DB - g) - 1 << g)), 103 | this.clamp(), 104 | f && d.ZERO.subTo(this, this) 105 | } 106 | 107 | function o() { 108 | for (var a = this.s & this.DM; this.t > 0 && this[this.t - 1] == a;) 109 | --this.t 110 | } 111 | 112 | function p(a) { 113 | if (this.s < 0) 114 | return "-" + this.negate().toString(a); 115 | var b; 116 | if (16 == a) 117 | b = 4; 118 | else if (8 == a) 119 | b = 3; 120 | else if (2 == a) 121 | b = 1; 122 | else if (32 == a) 123 | b = 5; 124 | else { 125 | if (4 != a) 126 | return this.toRadix(a); 127 | b = 2 128 | } 129 | var c, d = (1 << b) - 1, e = !1, f = "", g = this.t, h = this.DB - g * this.DB % b; 130 | if (g-- > 0) 131 | for (h < this.DB && (c = this[g] >> h) > 0 && (e = !0, 132 | f = i(c)); g >= 0;) 133 | b > h ? (c = (this[g] & (1 << h) - 1) << b - h, 134 | c |= this[--g] >> (h += this.DB - b)) : (c = this[g] >> (h -= b) & d, 135 | 0 >= h && (h += this.DB, 136 | --g)), 137 | c > 0 && (e = !0), 138 | e && (f += i(c)); 139 | return e ? f : "0" 140 | } 141 | 142 | function q() { 143 | var a = e(); 144 | return d.ZERO.subTo(this, a), 145 | a 146 | } 147 | 148 | function r() { 149 | return this.s < 0 ? this.negate() : this 150 | } 151 | 152 | function s(a) { 153 | var b = this.s - a.s; 154 | if (0 != b) 155 | return b; 156 | var c = this.t; 157 | if (b = c - a.t, 158 | 0 != b) 159 | return this.s < 0 ? -b : b; 160 | for (; --c >= 0;) 161 | if (0 != (b = this[c] - a[c])) 162 | return b; 163 | return 0 164 | } 165 | 166 | function t(a) { 167 | var b, c = 1; 168 | return 0 != (b = a >>> 16) && (a = b, 169 | c += 16), 170 | 0 != (b = a >> 8) && (a = b, 171 | c += 8), 172 | 0 != (b = a >> 4) && (a = b, 173 | c += 4), 174 | 0 != (b = a >> 2) && (a = b, 175 | c += 2), 176 | 0 != (b = a >> 1) && (a = b, 177 | c += 1), 178 | c 179 | } 180 | 181 | function u() { 182 | return this.t <= 0 ? 0 : this.DB * (this.t - 1) + t(this[this.t - 1] ^ this.s & this.DM) 183 | } 184 | 185 | function v(a, b) { 186 | var c; 187 | for (c = this.t - 1; c >= 0; --c) 188 | b[c + a] = this[c]; 189 | for (c = a - 1; c >= 0; --c) 190 | b[c] = 0; 191 | b.t = this.t + a, 192 | b.s = this.s 193 | } 194 | 195 | function w(a, b) { 196 | for (var c = a; c < this.t; ++c) 197 | b[c - a] = this[c]; 198 | b.t = Math.max(this.t - a, 0), 199 | b.s = this.s 200 | } 201 | 202 | function x(a, b) { 203 | var c, d = a % this.DB, e = this.DB - d, f = (1 << e) - 1, g = Math.floor(a / this.DB), 204 | h = this.s << d & this.DM; 205 | for (c = this.t - 1; c >= 0; --c) 206 | b[c + g + 1] = this[c] >> e | h, 207 | h = (this[c] & f) << d; 208 | for (c = g - 1; c >= 0; --c) 209 | b[c] = 0; 210 | b[g] = h, 211 | b.t = this.t + g + 1, 212 | b.s = this.s, 213 | b.clamp() 214 | } 215 | 216 | function y(a, b) { 217 | b.s = this.s; 218 | var c = Math.floor(a / this.DB); 219 | if (c >= this.t) 220 | return void (b.t = 0); 221 | var d = a % this.DB 222 | , e = this.DB - d 223 | , f = (1 << d) - 1; 224 | b[0] = this[c] >> d; 225 | for (var g = c + 1; g < this.t; ++g) 226 | b[g - c - 1] |= (this[g] & f) << e, 227 | b[g - c] = this[g] >> d; 228 | d > 0 && (b[this.t - c - 1] |= (this.s & f) << e), 229 | b.t = this.t - c, 230 | b.clamp() 231 | } 232 | 233 | function z(a, b) { 234 | for (var c = 0, d = 0, e = Math.min(a.t, this.t); e > c;) 235 | d += this[c] - a[c], 236 | b[c++] = d & this.DM, 237 | d >>= this.DB; 238 | if (a.t < this.t) { 239 | for (d -= a.s; c < this.t;) 240 | d += this[c], 241 | b[c++] = d & this.DM, 242 | d >>= this.DB; 243 | d += this.s 244 | } else { 245 | for (d += this.s; c < a.t;) 246 | d -= a[c], 247 | b[c++] = d & this.DM, 248 | d >>= this.DB; 249 | d -= a.s 250 | } 251 | b.s = 0 > d ? -1 : 0, 252 | -1 > d ? b[c++] = this.DV + d : d > 0 && (b[c++] = d), 253 | b.t = c, 254 | b.clamp() 255 | } 256 | 257 | function A(a, b) { 258 | var c = this.abs() 259 | , e = a.abs() 260 | , f = c.t; 261 | for (b.t = f + e.t; --f >= 0;) 262 | b[f] = 0; 263 | for (f = 0; f < e.t; ++f) 264 | b[f + c.t] = c.am(0, e[f], b, f, 0, c.t); 265 | b.s = 0, 266 | b.clamp(), 267 | this.s != a.s && d.ZERO.subTo(b, b) 268 | } 269 | 270 | function B(a) { 271 | for (var b = this.abs(), c = a.t = 2 * b.t; --c >= 0;) 272 | a[c] = 0; 273 | for (c = 0; c < b.t - 1; ++c) { 274 | var d = b.am(c, b[c], a, 2 * c, 0, 1); 275 | (a[c + b.t] += b.am(c + 1, 2 * b[c], a, 2 * c + 1, d, b.t - c - 1)) >= b.DV && (a[c + b.t] -= b.DV, 276 | a[c + b.t + 1] = 1) 277 | } 278 | a.t > 0 && (a[a.t - 1] += b.am(c, b[c], a, 2 * c, 0, 1)), 279 | a.s = 0, 280 | a.clamp() 281 | } 282 | 283 | function C(a, b, c) { 284 | var f = a.abs(); 285 | if (!(f.t <= 0)) { 286 | var g = this.abs(); 287 | if (g.t < f.t) 288 | return null != b && b.fromInt(0), 289 | void (null != c && this.copyTo(c)); 290 | null == c && (c = e()); 291 | var h = e() 292 | , i = this.s 293 | , j = a.s 294 | , k = this.DB - t(f[f.t - 1]); 295 | k > 0 ? (f.lShiftTo(k, h), 296 | g.lShiftTo(k, c)) : (f.copyTo(h), 297 | g.copyTo(c)); 298 | var l = h.t 299 | , m = h[l - 1]; 300 | if (0 != m) { 301 | var n = m * (1 << this.F1) + (l > 1 ? h[l - 2] >> this.F2 : 0) 302 | , o = this.FV / n 303 | , p = (1 << this.F1) / n 304 | , q = 1 << this.F2 305 | , r = c.t 306 | , s = r - l 307 | , u = null == b ? e() : b; 308 | for (h.dlShiftTo(s, u), 309 | c.compareTo(u) >= 0 && (c[c.t++] = 1, 310 | c.subTo(u, c)), 311 | d.ONE.dlShiftTo(l, u), 312 | u.subTo(h, h); h.t < l;) 313 | h[h.t++] = 0; 314 | for (; --s >= 0;) { 315 | var v = c[--r] == m ? this.DM : Math.floor(c[r] * o + (c[r - 1] + q) * p); 316 | if ((c[r] += h.am(0, v, c, s, 0, l)) < v) 317 | for (h.dlShiftTo(s, u), 318 | c.subTo(u, c); c[r] < --v;) 319 | c.subTo(u, c) 320 | } 321 | null != b && (c.drShiftTo(l, b), 322 | i != j && d.ZERO.subTo(b, b)), 323 | c.t = l, 324 | c.clamp(), 325 | k > 0 && c.rShiftTo(k, c), 326 | 0 > i && d.ZERO.subTo(c, c) 327 | } 328 | } 329 | } 330 | 331 | function D(a) { 332 | var b = e(); 333 | return this.abs().divRemTo(a, null, b), 334 | this.s < 0 && b.compareTo(d.ZERO) > 0 && a.subTo(b, b), 335 | b 336 | } 337 | 338 | function E(a) { 339 | this.m = a 340 | } 341 | 342 | function F(a) { 343 | return a.s < 0 || a.compareTo(this.m) >= 0 ? a.mod(this.m) : a 344 | } 345 | 346 | function G(a) { 347 | return a 348 | } 349 | 350 | function H(a) { 351 | a.divRemTo(this.m, null, a) 352 | } 353 | 354 | function I(a, b, c) { 355 | a.multiplyTo(b, c), 356 | this.reduce(c) 357 | } 358 | 359 | function J(a, b) { 360 | a.squareTo(b), 361 | this.reduce(b) 362 | } 363 | 364 | function K() { 365 | if (this.t < 1) 366 | return 0; 367 | var a = this[0]; 368 | if (0 == (1 & a)) 369 | return 0; 370 | var b = 3 & a; 371 | return b = b * (2 - (15 & a) * b) & 15, 372 | b = b * (2 - (255 & a) * b) & 255, 373 | b = b * (2 - ((65535 & a) * b & 65535)) & 65535, 374 | b = b * (2 - a * b % this.DV) % this.DV, 375 | b > 0 ? this.DV - b : -b 376 | } 377 | 378 | function L(a) { 379 | this.m = a, 380 | this.mp = a.invDigit(), 381 | this.mpl = 32767 & this.mp, 382 | this.mph = this.mp >> 15, 383 | this.um = (1 << a.DB - 15) - 1, 384 | this.mt2 = 2 * a.t 385 | } 386 | 387 | function M(a) { 388 | var b = e(); 389 | return a.abs().dlShiftTo(this.m.t, b), 390 | b.divRemTo(this.m, null, b), 391 | a.s < 0 && b.compareTo(d.ZERO) > 0 && this.m.subTo(b, b), 392 | b 393 | } 394 | 395 | function N(a) { 396 | var b = e(); 397 | return a.copyTo(b), 398 | this.reduce(b), 399 | b 400 | } 401 | 402 | function O(a) { 403 | for (; a.t <= this.mt2;) 404 | a[a.t++] = 0; 405 | for (var b = 0; b < this.m.t; ++b) { 406 | var c = 32767 & a[b] 407 | , d = c * this.mpl + ((c * this.mph + (a[b] >> 15) * this.mpl & this.um) << 15) & a.DM; 408 | for (c = b + this.m.t, 409 | a[c] += this.m.am(0, d, a, b, 0, this.m.t); a[c] >= a.DV;) 410 | a[c] -= a.DV, 411 | a[++c]++ 412 | } 413 | a.clamp(), 414 | a.drShiftTo(this.m.t, a), 415 | a.compareTo(this.m) >= 0 && a.subTo(this.m, a) 416 | } 417 | 418 | function P(a, b) { 419 | a.squareTo(b), 420 | this.reduce(b) 421 | } 422 | 423 | function Q(a, b, c) { 424 | a.multiplyTo(b, c), 425 | this.reduce(c) 426 | } 427 | 428 | function R() { 429 | return 0 == (this.t > 0 ? 1 & this[0] : this.s) 430 | } 431 | 432 | function S(a, b) { 433 | if (a > 4294967295 || 1 > a) 434 | return d.ONE; 435 | var c = e() 436 | , f = e() 437 | , g = b.convert(this) 438 | , h = t(a) - 1; 439 | for (g.copyTo(c); --h >= 0;) 440 | if (b.sqrTo(c, f), 441 | (a & 1 << h) > 0) 442 | b.mulTo(f, g, c); 443 | else { 444 | var i = c; 445 | c = f, 446 | f = i 447 | } 448 | return b.revert(c) 449 | } 450 | 451 | function T(a, b) { 452 | var c; 453 | return c = 256 > a || b.isEven() ? new E(b) : new L(b), 454 | this.exp(a, c) 455 | } 456 | 457 | function U() { 458 | this.i = 0, 459 | this.j = 0, 460 | this.S = new Array 461 | } 462 | 463 | function V(a) { 464 | var b, c, d; 465 | for (b = 0; 256 > b; ++b) 466 | this.S[b] = b; 467 | for (c = 0, 468 | b = 0; 256 > b; ++b) 469 | c = c + this.S[b] + a[b % a.length] & 255, 470 | d = this.S[b], 471 | this.S[b] = this.S[c], 472 | this.S[c] = d; 473 | this.i = 0, 474 | this.j = 0 475 | } 476 | 477 | function W() { 478 | var a; 479 | return this.i = this.i + 1 & 255, 480 | this.j = this.j + this.S[this.i] & 255, 481 | a = this.S[this.i], 482 | this.S[this.i] = this.S[this.j], 483 | this.S[this.j] = a, 484 | this.S[a + this.S[this.i] & 255] 485 | } 486 | 487 | function X() { 488 | return new U 489 | } 490 | 491 | function Y(a) { 492 | qb[rb++] ^= 255 & a, 493 | qb[rb++] ^= a >> 8 & 255, 494 | qb[rb++] ^= a >> 16 & 255, 495 | qb[rb++] ^= a >> 24 & 255, 496 | rb >= sb && (rb -= sb) 497 | } 498 | 499 | function Z() { 500 | Y((new Date).getTime()) 501 | } 502 | 503 | function $() { 504 | if (null == pb) { 505 | for (Z(), 506 | pb = X(), 507 | pb.init(qb), 508 | rb = 0; rb < qb.length; ++rb) 509 | qb[rb] = 0; 510 | rb = 0 511 | } 512 | return pb.next() 513 | } 514 | 515 | function _(a) { 516 | var b; 517 | for (b = 0; b < a.length; ++b) 518 | a[b] = $() 519 | } 520 | 521 | function ab() { 522 | } 523 | 524 | function bb(a, b) { 525 | return new d(a, b) 526 | } 527 | 528 | function cb(a, b) { 529 | if (b < a.length + 11) 530 | return alert("Message too long for RSA"), 531 | null; 532 | for (var c = new Array, e = a.length - 1; e >= 0 && b > 0;) { 533 | var f = a.charCodeAt(e--); 534 | 128 > f ? c[--b] = f : f > 127 && 2048 > f ? (c[--b] = 63 & f | 128, 535 | c[--b] = f >> 6 | 192) : (c[--b] = 63 & f | 128, 536 | c[--b] = f >> 6 & 63 | 128, 537 | c[--b] = f >> 12 | 224) 538 | } 539 | c[--b] = 0; 540 | for (var g = new ab, h = new Array; b > 2;) { 541 | for (h[0] = 0; 0 == h[0];) 542 | g.nextBytes(h); 543 | c[--b] = h[0] 544 | } 545 | return c[--b] = 2, 546 | c[--b] = 0, 547 | new d(c) 548 | } 549 | 550 | function db() { 551 | this.n = null, 552 | this.e = 0, 553 | this.d = null, 554 | this.p = null, 555 | this.q = null, 556 | this.dmp1 = null, 557 | this.dmq1 = null, 558 | this.coeff = null 559 | } 560 | 561 | function eb(a, b) { 562 | null != a && null != b && a.length > 0 && b.length > 0 ? (this.n = bb(a, 16), 563 | this.e = parseInt(b, 16)) : alert("网络异常,请点击登录重试") 564 | } 565 | 566 | function fb(a) { 567 | return a.modPowInt(this.e, this.n) 568 | } 569 | 570 | function gb(a) { 571 | var b = cb(a, this.n.bitLength() + 7 >> 3); 572 | if (null == b) 573 | return null; 574 | var c = this.doPublic(b); 575 | if (null == c) 576 | return null; 577 | var d = c.toString(16); 578 | return 0 == (1 & d.length) ? d : "0" + d 579 | } 580 | 581 | var hb, ib = 0xdeadbeefcafe, jb = 15715070 == (16777215 & ib); 582 | jb && "Microsoft Internet Explorer" == navigator.appName ? (d.prototype.am = g, 583 | hb = 30) : jb && "Netscape" != navigator.appName ? (d.prototype.am = f, 584 | hb = 26) : (d.prototype.am = h, 585 | hb = 28), 586 | d.prototype.DB = hb, 587 | d.prototype.DM = (1 << hb) - 1, 588 | d.prototype.DV = 1 << hb; 589 | var kb = 52; 590 | d.prototype.FV = Math.pow(2, kb), 591 | d.prototype.F1 = kb - hb, 592 | d.prototype.F2 = 2 * hb - kb; 593 | var lb, mb, nb = "0123456789abcdefghijklmnopqrstuvwxyz", ob = []; 594 | for (lb = "0".charCodeAt(0), 595 | mb = 0; 9 >= mb; ++mb) 596 | ob[lb++] = mb; 597 | for (lb = "a".charCodeAt(0), 598 | mb = 10; 36 > mb; ++mb) 599 | ob[lb++] = mb; 600 | for (lb = "A".charCodeAt(0), 601 | mb = 10; 36 > mb; ++mb) 602 | ob[lb++] = mb; 603 | 604 | function rsaFingerprint() { 605 | if (this.n == null || this.e === 0) { 606 | throw "SetPublic first!"; 607 | } 608 | var c = '{"user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54","language":"zh-CN","color_depth":"24","pixel_ratio":"1.25","hardware_concurrency":"8","resolution":"1536,864","available_resolution":"1536,824","timezone_offset":"-480","session_storage":"1","local_storage":"1","indexed_db":"1","open_database":"1","cpu_class":"unknown","navigator_platform":"Win32","do_not_track":"unknown","regular_plugins":"PDF Viewer::Portable Document Format::application/pdf~pdf,text/pdf~pdf,Chrome PDF Viewer::Portable D","webgl_vendor":"Google Inc. (Intel)~ANGLE (Intel, Intel(R) UHD Graphics 620 Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.10","adblock":"false","has_lied_languages":"false","has_lied_resolution":"false","has_lied_os":"false","has_lied_browser":"false","touch_support":"0,false,false","js_fonts":"Arial,Arial Black,Arial Narrow,Book Antiqua,Bookman Old Style,Calibri,Cambria,Cambria Math,Century,C"}' 609 | , d = "9e8ac234f590726c2565a8784075fe97" 610 | , e = c.length 611 | , f = "" 612 | for (var h = this.encrypt(d), i = 0; e > i; i += 117) 613 | f += this.encrypt(c.substr(i, 117)); 614 | return { 615 | details: f, 616 | result: h 617 | } 618 | } 619 | 620 | E.prototype.convert = F, 621 | E.prototype.revert = G, 622 | E.prototype.reduce = H, 623 | E.prototype.mulTo = I, 624 | E.prototype.sqrTo = J, 625 | L.prototype.convert = M, 626 | L.prototype.revert = N, 627 | L.prototype.reduce = O, 628 | L.prototype.mulTo = Q, 629 | L.prototype.sqrTo = P, 630 | d.prototype.copyTo = k, 631 | d.prototype.fromInt = l, 632 | d.prototype.fromString = n, 633 | d.prototype.clamp = o, 634 | d.prototype.dlShiftTo = v, 635 | d.prototype.drShiftTo = w, 636 | d.prototype.lShiftTo = x, 637 | d.prototype.rShiftTo = y, 638 | d.prototype.subTo = z, 639 | d.prototype.multiplyTo = A, 640 | d.prototype.squareTo = B, 641 | d.prototype.divRemTo = C, 642 | d.prototype.invDigit = K, 643 | d.prototype.isEven = R, 644 | d.prototype.exp = S, 645 | d.prototype.toString = p, 646 | d.prototype.negate = q, 647 | d.prototype.abs = r, 648 | d.prototype.compareTo = s, 649 | d.prototype.bitLength = u, 650 | d.prototype.mod = D, 651 | d.prototype.modPowInt = T, 652 | d.ZERO = m(0), 653 | d.ONE = m(1), 654 | U.prototype.init = V, 655 | U.prototype.next = W; 656 | var pb, qb, rb, sb = 256; 657 | if (null == qb) { 658 | qb = [], 659 | rb = 0; 660 | var tb; 661 | if (window.crypto && window.crypto.getRandomValues) { 662 | var ub = new Uint8Array(32); 663 | for (window.crypto.getRandomValues(ub), 664 | tb = 0; 32 > tb; ++tb) 665 | qb[rb++] = ub[tb] 666 | } 667 | if ("Netscape" == navigator.appName && navigator.appVersion < "5" && window.crypto) { 668 | var vb = window.crypto.random(32); 669 | for (tb = 0; tb < vb.length; ++tb) 670 | qb[rb++] = 255 & vb.charCodeAt(tb) 671 | } 672 | for (; sb > rb;) 673 | tb = Math.floor(65536 * Math.random()), 674 | qb[rb++] = tb >>> 8, 675 | qb[rb++] = 255 & tb; 676 | rb = 0, 677 | Z() 678 | } 679 | ab.prototype.nextBytes = _; 680 | db.prototype.doPublic = fb; 681 | db.prototype.setPublic = eb; 682 | db.prototype.encrypt = gb; 683 | db.prototype.rsaFingerPrint = rsaFingerprint; 684 | return db; 685 | }()) 686 | module.exports = rsa; -------------------------------------------------------------------------------- /咪咕/server.js: -------------------------------------------------------------------------------- 1 | const RSA = require('./rsa') 2 | const express = require('express'); 3 | const bodyParser = require('body-parser'); 4 | const app = express(); 5 | const rsa = new RSA(); 6 | const port = 8000 7 | 8 | /* 设置传输大小限制 */ 9 | app.use(bodyParser.urlencoded({limit: "2100000kb"})); 10 | app.use(bodyParser.json({limit: "2100000kb"})); 11 | /* 公钥直接写死 */ 12 | rsa.setPublic("00833c4af965ff7a8409f8b5d5a83d87f2f19d7c1eb40dc59a98d2346cbb145046b2c6facc25b5cc363443f0f7ebd9524b7c1e1917bf7d849212339f6c1d3711b115ecb20f0c89fc2182a985ea28cbb4adf6a321ff7e715ba9b8d7261d1c140485df3b705247a70c28c9068caabbedbf9510dada6d13d99e57642b853a73406817", "010001"); 13 | 14 | app.post("/", (req, res) => { 15 | const retJson = {}; 16 | const finger = rsa.rsaFingerPrint(); 17 | retJson.loginID = rsa.encrypt(req.body.username) 18 | retJson.enpassword = rsa.encrypt(req.body.password); 19 | retJson.fingerPrint = finger.result; 20 | retJson.fingerPrintDetail = finger.details; 21 | res.json(retJson); 22 | }); 23 | 24 | app.listen(port, () => { 25 | console.log(`Example app listening at http://localhost:${port}`) 26 | }) -------------------------------------------------------------------------------- /安居客/aes.js: -------------------------------------------------------------------------------- 1 | const CryptoJS = require("crypto-js") 2 | const appkey = "gk1leqzjj6u65bd2zbal" 3 | 4 | function parseParams(e) { 5 | try { 6 | var t, a = []; 7 | for (t in e) { 8 | var n = e[t]; 9 | a.push(t + "=" + n) 10 | } 11 | return a.join("&") 12 | } catch (i) { 13 | return "" 14 | } 15 | } 16 | 17 | function signEnc() { 18 | var e = { 19 | appkey: appkey, 20 | // cid: "", 21 | deviceid: "", 22 | expire: "180", 23 | nonce: Math.ceil(1e6 * Math.random()), 24 | timestamp: (new Date).getTime(), 25 | userid: "" 26 | } 27 | , t = CryptoJS.HmacSHA256("httpsgetcdata.58.com/api/v1/pcm/gettoken?" + parseParams(e), "65687FFBF0E5AA5B") 28 | , t = CryptoJS.enc.Base64.stringify(t); 29 | e.signature = t; 30 | t = CryptoJS.enc.Utf8.parse("110FD52DC87A2230"), 31 | e = JSON.stringify(e); 32 | return CryptoJS.AES.encrypt(e, t, { 33 | mode: CryptoJS.mode.ECB, 34 | padding: CryptoJS.pad.Pkcs7 35 | }).ciphertext.toString() 36 | } 37 | 38 | 39 | const decrypt = function (e) { 40 | return CryptoJS.AES.decrypt(e, CryptoJS.enc.Utf8.parse("110FD52DC87A2230"), { 41 | mode: CryptoJS.mode.ECB, 42 | padding: CryptoJS.pad.Pkcs7 43 | }).toString(CryptoJS.enc.Utf8); 44 | } 45 | 46 | const encryptBrowser = function (e) { 47 | var n = CryptoJS.enc.Utf8.parse("6F579B981C222BB7") 48 | , a = JSON.stringify(e) 49 | , r = CryptoJS.AES.encrypt(a, n, { 50 | mode: CryptoJS.mode.ECB, 51 | padding: CryptoJS.pad.Pkcs7 52 | }); 53 | r = r.ciphertext.toString(); 54 | var i = { 55 | appkey: appkey, 56 | data: r, 57 | expire: "180", 58 | nonce: Math.ceil(1e6 * Math.random()), 59 | timestamp: (new Date).getTime() 60 | }; 61 | e = CryptoJS.HmacSHA256("httpspostcdata.58.com/api/v1/pcm/report?" + function (e) { 62 | try { 63 | var t, n = []; 64 | for (t in e) { 65 | var a = encodeURIComponent(t) 66 | , r = encodeURIComponent(e[t]); 67 | n.push(a + "=" + r) 68 | } 69 | return n.join("&") 70 | } catch (i) { 71 | return "" 72 | } 73 | }(i), "3B9426B12A547049"), 74 | e = CryptoJS.enc.Base64.stringify(e); 75 | i.signature = e; 76 | n = CryptoJS.enc.Utf8.parse("BF81BEE8DC405054"), 77 | a = JSON.stringify(i); 78 | r = (r = CryptoJS.AES.encrypt(a, n, { 79 | mode: CryptoJS.mode.ECB, 80 | padding: CryptoJS.pad.Pkcs7 81 | })).ciphertext.toString(); 82 | return r; 83 | } 84 | 85 | function decryptBrowser(e) { 86 | return CryptoJS.AES.decrypt(e, CryptoJS.enc.Utf8.parse("BF81BEE8DC405054"), { 87 | mode: CryptoJS.mode.ECB, 88 | padding: CryptoJS.pad.Pkcs7 89 | }).toString(CryptoJS.enc.Utf8); 90 | } 91 | 92 | module.exports = { 93 | "signEnc": signEnc, 94 | "decrypt": decrypt, 95 | "encryptBrowser": encryptBrowser, 96 | "decryptBrowser": decryptBrowser 97 | } -------------------------------------------------------------------------------- /安居客/brower_feature.js: -------------------------------------------------------------------------------- 1 | e = { 2 | "id58": "CpQB3mGErkgEO5hZA6wnAg==|-1|-1|-1|-1", 3 | "cookie": "-1", 4 | "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36", 5 | "language": "zh-CN", 6 | "color": 24, 7 | "screen_r": "864,1536", 8 | "timezone": -480, 9 | "session_storage": 1, 10 | "local_storage": 1, 11 | "indexed_db": 1, 12 | "add_behavior": 0, 13 | "open_database": 1, 14 | "cpu": "-1", 15 | "platform": "Win32", 16 | "treed": "-1", 17 | "touch": 0, 18 | "adblock": -1, 19 | "change_lang": 0, 20 | "change_size": 0, 21 | "change_os": 0, 22 | "change_browser": 0, 23 | "plugin": "Chrome PDF Viewer:Portable Document Format:application/pdf~pdf,text/pdf~pdf|Chromium PDF Viewer:Portable Document Format:application/pdf~pdf,text/pdf~pdf|Microsoft Edge PDF Viewer:Portable Document Format:application/pdf~pdf,text/pdf~pdf|PDF Viewer:Portable Document Format:application/pdf~pdf,text/pdf~pdf|WebKit built-in PDF:Portable Document Format:application/pdf~pdf,text/pdf~pdf", 24 | "font": -1, 25 | "canvas": "000600d4003200b2", 26 | "webgl": "00fd00f000710083|ANGLE (Intel, Intel(R) UHD Graphics 620 Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.100.9664)|Google Inc. (Intel)", 27 | "domain": "login.anjuke.com", 28 | "device_type": "pc", 29 | "local_time": 1636087225475, 30 | "screen_top": "-1", 31 | "screen_y": "-1", 32 | "screen_left": "-1", 33 | "avail_width": 1536, 34 | "avail_height": 824, 35 | "avail_top": "-1", 36 | "avail_left": "-1", 37 | "inner_height": "-1", 38 | "inner_width": "-1", 39 | "device_pixel_ratio": 1.25, 40 | "pixel_depth": 24, 41 | "build_id": "-1", 42 | "product_sub": "20030107", 43 | "product": "Gecko", 44 | "max_touch_points": "-1", 45 | "device_memory": 8, 46 | "user_language": "-1", 47 | "browser_language": "-1", 48 | "system_language": "-1", 49 | "window_api_num": 1044, 50 | "is_canvas_supported": true, 51 | "canvas_arr": "002800bb00a900b3,00e7000e00e700f7,00c90012000b00f5", 52 | "infinity": null, 53 | "downlink": 10, 54 | "effective_type": "4g", 55 | "rtt": 50, 56 | "save_data": "-1", 57 | "cookie_enabled": true, 58 | "scroll_restoration": "auto", 59 | "is_secure_context": true, 60 | "audio": "19f2ec826da994356fe069ffbebc1d80db815a8f|124.04347527516074", 61 | "font_list": "-1", 62 | "lan_ip": "-1", 63 | "battery_info": "true|0|Infinity", 64 | "webrt_cid_list": "-1", 65 | "app_name": "Mozilla", 66 | "app_code_name": "Netscape", 67 | "app_version": "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36", 68 | "vendor": "Google Inc.", 69 | "web_driver": "-1", 70 | "hardware_concurrency": 8, 71 | "plugin_hash": 1037947369, 72 | "font_hash": "-1", 73 | "browser_name": "Chrome", 74 | "browser_version": "95.0.4638.69", 75 | "device_info": "-1|-1|-1", 76 | "engine_name": "WebKit", 77 | "os_name": "Windows", 78 | "os_version": "10", 79 | "languages": "zh-CN", 80 | "navigator_keys": "vendorSub|productSub|vendor|maxTouchPoints|userActivation|doNotTrack|geolocation|connection|plugins|mimeTypes|webkitTemporaryStorage|webkitPersistentStorage|hardwareConcurrency|cookieEnabled|appCodeName|appName|appVersion|platform|product|userAgent|language|languages|onLine|webdriver|getBattery|getGamepads|javaEnabled|sendBeacon|vibrate|pdfViewerEnabled|scheduling|bluetooth|clipboard|credentials|keyboard|managed|mediaDevices|storage|serviceWorker|wakeLock|deviceMemory|ink|hid|locks|mediaCapabilities|mediaSession|permissions|presentation|serial|virtualKeyboard|usb|xr|userAgentData|canShare|share|clearAppBadge|setAppBadge|getInstalledRelatedApps|getUserMedia|requestMIDIAccess|requestMediaKeySystemAccess|webkitGetUserMedia|registerProtocolHandler|unregisterProtocolHandler", 81 | "uuid": "580681b1-ab08-4291-ae71-166ce7811873", 82 | "xxzl_cid": "755d4f3bb901429ca7925c6aafa85e02" 83 | } -------------------------------------------------------------------------------- /安居客/browser.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/05/12:46 4 | description 5 | """ 6 | browser_feature = { 7 | "cookie": "-1", 8 | "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36", 9 | "language": "zh-CN", 10 | "color": 24, 11 | "screen_r": "864,1536", 12 | "timezone": -480, 13 | "session_storage": 1, 14 | "local_storage": 1, 15 | "indexed_db": 1, 16 | "add_behavior": 0, 17 | "open_database": 1, 18 | "cpu": "-1", 19 | "platform": "Win32", 20 | "treed": "-1", 21 | "touch": 0, 22 | "adblock": -1, 23 | "change_lang": 0, 24 | "change_size": 0, 25 | "change_os": 0, 26 | "change_browser": 0, 27 | "plugin": "Chrome PDF Viewer:Portable Document Format:application/pdf~pdf,text/pdf~pdf|Chromium PDF Viewer:Portable Document Format:application/pdf~pdf,text/pdf~pdf|Microsoft Edge PDF Viewer:Portable Document Format:application/pdf~pdf,text/pdf~pdf|PDF Viewer:Portable Document Format:application/pdf~pdf,text/pdf~pdf|WebKit built-in PDF:Portable Document Format:application/pdf~pdf,text/pdf~pdf", 28 | "font": -1, 29 | "canvas": "000600d4003200b2", 30 | "webgl": "00fd00f000710083|ANGLE (Intel, Intel(R) UHD Graphics 620 Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.100.9664)|Google Inc. (Intel)", 31 | "domain": "login.anjuke.com", 32 | "device_type": "pc", 33 | "screen_top": "-1", 34 | "screen_y": "-1", 35 | "screen_left": "-1", 36 | "avail_width": 1536, 37 | "avail_height": 824, 38 | "avail_top": "-1", 39 | "avail_left": "-1", 40 | "inner_height": "-1", 41 | "inner_width": "-1", 42 | "device_pixel_ratio": 1.25, 43 | "pixel_depth": 24, 44 | "build_id": "-1", 45 | "product_sub": "20030107", 46 | "product": "Gecko", 47 | "max_touch_points": "-1", 48 | "device_memory": 8, 49 | "user_language": "-1", 50 | "browser_language": "-1", 51 | "system_language": "-1", 52 | "window_api_num": 1044, 53 | "is_canvas_supported": True, 54 | "canvas_arr": "002800bb00a900b3,00e7000e00e700f7,00c90012000b00f5", 55 | "infinity": None, 56 | "downlink": 10, 57 | "effective_type": "4g", 58 | "rtt": 50, 59 | "save_data": "-1", 60 | "cookie_enabled": None, 61 | "scroll_restoration": "auto", 62 | "is_secure_context": True, 63 | "audio": "19f2ec826da994356fe069ffbebc1d80db815a8f|124.04347527516074", 64 | "font_list": "-1", 65 | "lan_ip": "-1", 66 | "battery_info": "true|0|Infinity", 67 | "webrt_cid_list": "-1", 68 | "app_name": "Mozilla", 69 | "app_code_name": "Netscape", 70 | "app_version": "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36", 71 | "vendor": "Google Inc.", 72 | "web_driver": "-1", 73 | "hardware_concurrency": 8, 74 | "plugin_hash": 1037947369, 75 | "font_hash": "-1", 76 | "browser_name": "Chrome", 77 | "browser_version": "95.0.4638.69", 78 | "device_info": "-1|-1|-1", 79 | "engine_name": "WebKit", 80 | "os_name": "Windows", 81 | "os_version": "10", 82 | "languages": "zh-CN", 83 | "navigator_keys": "vendorSub|productSub|vendor|maxTouchPoints|userActivation|doNotTrack|geolocation|connection|plugins|mimeTypes|webkitTemporaryStorage|webkitPersistentStorage|hardwareConcurrency|cookieEnabled|appCodeName|appName|appVersion|platform|product|userAgent|language|languages|onLine|webdriver|getBattery|getGamepads|javaEnabled|sendBeacon|vibrate|pdfViewerEnabled|scheduling|bluetooth|clipboard|credentials|keyboard|managed|mediaDevices|storage|serviceWorker|wakeLock|deviceMemory|ink|hid|locks|mediaCapabilities|mediaSession|permissions|presentation|serial|virtualKeyboard|usb|xr|userAgentData|canShare|share|clearAppBadge|setAppBadge|getInstalledRelatedApps|getUserMedia|requestMIDIAccess|requestMediaKeySystemAccess|webkitGetUserMedia|registerProtocolHandler|unregisterProtocolHandler", 84 | # 下面几个可变 85 | "uuid": "", 86 | "xxzl_cid": "", 87 | "sessionid": "", 88 | "xxzl_deviceid": "", 89 | "id58": "", 90 | "local_time": "", 91 | } 92 | -------------------------------------------------------------------------------- /安居客/login.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/04/18:41 4 | description 5 | """ 6 | import random 7 | import re 8 | import time 9 | 10 | import requests 11 | from requests import Response 12 | 13 | session = requests.session() 14 | 15 | headers = { 16 | 'accept': '*/*', 17 | 'accept-encoding': 'gzip, deflate, br', 18 | 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6', 19 | 'cache-control': 'no-cache', 20 | 'pragma': 'no-cache', 21 | 'referer': 'https://login.anjuke.com/', 22 | 'origin': 'https://login.anjuke.com', 23 | 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36' 24 | } 25 | 26 | finger2 = 'zh-CN|24|1.25|8|1536_864|1536_824|-480|1|1|1|undefined|1|unknown|Win32|unknown|5|false|false|false|false|false|0_false_false|d41d8cd98f00b204e9800998ecf8427e|44b6a56736f2cfe7969b79d6927946a2' 27 | iframe_time = '' 28 | 29 | 30 | def get_token() -> str: 31 | """ 32 | 获取token 33 | :return: token 34 | """ 35 | res = session.get( 36 | "https://cloud-passport.anjuke.com/ajk/mobile/init?source=ajk-anjuke-pc&path=https%253A%252F%252Flogin.anjuke.com%252Flogin%252Fiframeform%252F&psdk-d=jsdk&psdk-v=1.0.1&callback=JsonpCallBack" + str( 37 | int(time.time() * 1000000)), headers=headers) 38 | return re.search('"token":"(.*?)"', res.text).group(1) 39 | 40 | 41 | def anti_spider(): 42 | sign = session.get("http://localhost:8000/signEnc").text 43 | params = { 44 | "param": sign, 45 | "callback": "dpjsonp_" + str(random.random()).replace(".", "") 46 | } 47 | res = session.get("https://antispider-security.anjuke.com/api/v1/pcm/gettoken", params=params, 48 | headers=headers) 49 | enc_data = re.search(r"\('(.*?)'\)", res.text).group(1) 50 | data = session.post("http://127.0.0.1:8000/decrypt", data={"data": enc_data}).json()['data'] 51 | cid, deviceid, token, _ = data.split('') 52 | from browser import browser_feature 53 | browser_feature['xxzl_cid'] = cid 54 | browser_feature['sessionid'] = token 55 | browser_feature['xxzl_deviceid'] = deviceid 56 | browser_feature['id58'] = session.cookies.get("id58") + "|-1|-1|-1|-1" 57 | browser_feature["local_time"] = str(int(time.time() * 1000000)) 58 | enc_browser = session.post("http://127.0.0.1:8000/encryptBrowser", data=browser_feature).text 59 | res = session.post("https://antispider-security.anjuke.com/api/v1/pcm/report", data=enc_browser, headers=headers) 60 | 61 | res = session.post("http://127.0.0.1:8000/decryptBrowser", data={"data": res.text}) 62 | anti_data = res.json()['data'] 63 | *_, xxzl_cid, xzuid = anti_data.split('') 64 | print(xxzl_cid, xzuid) 65 | session.cookies.set("xxzl_cid", xxzl_cid) 66 | session.cookies.set("xzuid", xzuid) 67 | 68 | 69 | def do_login(token: str, username, enc_pwd) -> Response: 70 | session.get("https://login.anjuke.com/login/checkbroker?account=" + username, headers=headers) 71 | time.sleep(1) 72 | formdata = {"username": username, 73 | "password": enc_pwd, 74 | 'token': token, 75 | 'source': 'ajk-anjuke-pc', 76 | 'path': '', 77 | 'domain': 'anjuke.com', 78 | 'finger2': finger2, 79 | 'psdk-d': 'jsdk', 80 | 'psdk-v': '1.0.1', 81 | 'callback': 'SDK_CALLBACK_FUN.successFun', 82 | } 83 | res = session.post( 84 | "https://cloud-passport.anjuke.com/ajk/login/pc/dologin", 85 | data=formdata, headers=headers) 86 | return res 87 | 88 | 89 | def request_stb(): 90 | formdata = {'p': 'track_login_page_changetab', 91 | 'h': 'https://login.anjuke.com/login/iframeform?style=1&forms=11&third_parts=111&other_parts=111&check_bind_phone=1&t=' + iframe_time, 92 | 'r': 'https://login.anjuke.com/login/form', 93 | 'site': 'anjuke-npv', 94 | 'guid': session.cookies.get("aQQ_ajkguid"), 95 | 'ssid': session.cookies.get("sessid"), 96 | 'uid': 0, 97 | 't': str(int(time.time() * 1000000)), 98 | 'ctid': session.cookies.get("ctid"), 99 | 'luid': '', 100 | 'm': '', 101 | 'sc': '{"w":"540","h":"433","r":"0"}', 102 | 'pn': 'track_login_page_changetab'} 103 | session.post("https://s.anjuke.com/stb?__site=anjuke-npv&", headers=headers, data=formdata) 104 | 105 | 106 | if __name__ == '__main__': 107 | username, password = "", "" 108 | # 登陆页面 109 | session.get("https://login.anjuke.com/login/form", headers=headers) 110 | token = get_token() 111 | enc_pwd = session.post("http://127.0.0.1:8000/signPwd", data={"password": password}).text 112 | time.sleep(3) 113 | # res = do_login(token, username, enc_pwd) 114 | # print(res.text) 115 | # print(session.get("https://login.anjuke.com/login/success", headers=headers).text) 116 | 117 | anti_spider() 118 | -------------------------------------------------------------------------------- /安居客/rsa.js: -------------------------------------------------------------------------------- 1 | module.exports = function encryptString(pwd) { 2 | var r = RSAUtils.getKeyPair("010001", "", "008baf14121377fc76eaf7794b8a8af17085628c3590df47e6534574efcfd81ef8635fcdc67d141c15f51649a89533df0db839331e30b8f8e4440ebf7ccbcc494f4ba18e9f492534b8aafc1b1057429ac851d3d9eb66e86fce1b04527c7b95a2431b07ea277cde2365876e2733325df04389a9d891c5d36b7bc752140db74cb69f"); 3 | return RSAUtils.encryptedString(r, "1411093327735" + pwd) 4 | } 5 | 6 | !function (e) { 7 | void 0 === e.RSAUtils && (e.RSAUtils = {}); 8 | 9 | function v(i) { 10 | this.digits = "boolean" == typeof i && 1 == i ? null : s.slice(0), 11 | this.isNeg = !1 12 | } 13 | 14 | var s, g, c, N = 16, m = 65536, M = m - 1; 15 | e.BigInt || (e.BigInt = v), 16 | RSAUtils.setMaxDigits = function (i) { 17 | s = new Array(i); 18 | for (var t = 0; t < s.length; t++) 19 | s[t] = 0; 20 | g = new v, 21 | (c = new v).digits[0] = 1 22 | } 23 | , 24 | RSAUtils.setMaxDigits(20); 25 | RSAUtils.biFromNumber = function (i) { 26 | var t = new v; 27 | t.isNeg = i < 0, 28 | i = Math.abs(i); 29 | for (var s = 0; 0 < i;) 30 | t.digits[s++] = i & M, 31 | i = Math.floor(i / m); 32 | return t 33 | } 34 | ; 35 | var l = RSAUtils.biFromNumber(1e15); 36 | RSAUtils.biFromDecimal = function (i) { 37 | for (var t, s = "-" == i.charAt(0), r = s ? 1 : 0; r < i.length && "0" == i.charAt(r);) 38 | ++r; 39 | if (r == i.length) 40 | t = new v; 41 | else { 42 | var e = (i.length - r) % 15; 43 | for (0 == e && (e = 15), 44 | t = RSAUtils.biFromNumber(Number(i.substr(r, e))), 45 | r += e; r < i.length;) 46 | t = RSAUtils.biAdd(RSAUtils.biMultiply(t, l), RSAUtils.biFromNumber(Number(i.substr(r, 15)))), 47 | r += 15; 48 | t.isNeg = s 49 | } 50 | return t 51 | } 52 | , 53 | RSAUtils.biCopy = function (i) { 54 | var t = new v(!0); 55 | return t.digits = i.digits.slice(0), 56 | t.isNeg = i.isNeg, 57 | t 58 | } 59 | , 60 | RSAUtils.reverseStr = function (i) { 61 | for (var t = "", s = i.length - 1; -1 < s; --s) 62 | t += i.charAt(s); 63 | return t 64 | } 65 | ; 66 | var n = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]; 67 | RSAUtils.biToString = function (i, t) { 68 | var s = new v; 69 | s.digits[0] = t; 70 | for (var r = RSAUtils.biDivideModulo(i, s), e = n[r[1].digits[0]]; 1 == RSAUtils.biCompare(r[0], g);) 71 | r = RSAUtils.biDivideModulo(r[0], s), 72 | digit = r[1].digits[0], 73 | e += n[r[1].digits[0]]; 74 | return (i.isNeg ? "-" : "") + RSAUtils.reverseStr(e) 75 | } 76 | , 77 | RSAUtils.biToDecimal = function (i) { 78 | var t = new v; 79 | t.digits[0] = 10; 80 | for (var s = RSAUtils.biDivideModulo(i, t), r = String(s[1].digits[0]); 1 == RSAUtils.biCompare(s[0], g);) 81 | s = RSAUtils.biDivideModulo(s[0], t), 82 | r += String(s[1].digits[0]); 83 | return (i.isNeg ? "-" : "") + RSAUtils.reverseStr(r) 84 | } 85 | ; 86 | var r = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]; 87 | RSAUtils.digitToHex = function (t) { 88 | var s = ""; 89 | for (i = 0; i < 4; ++i) 90 | s += r[15 & t], 91 | t >>>= 4; 92 | return RSAUtils.reverseStr(s) 93 | } 94 | , 95 | RSAUtils.biToHex = function (i) { 96 | for (var t = "", s = (RSAUtils.biHighIndex(i), 97 | RSAUtils.biHighIndex(i)); -1 < s; --s) 98 | t += RSAUtils.digitToHex(i.digits[s]); 99 | return t 100 | } 101 | , 102 | RSAUtils.charToHex = function (i) { 103 | return 48 <= i && i <= 57 ? i - 48 : 65 <= i && i <= 90 ? 10 + i - 65 : 97 <= i && i <= 122 ? 10 + i - 97 : 0 104 | } 105 | , 106 | RSAUtils.hexToDigit = function (i) { 107 | for (var t = 0, s = Math.min(i.length, 4), r = 0; r < s; ++r) 108 | t <<= 4, 109 | t |= RSAUtils.charToHex(i.charCodeAt(r)); 110 | return t 111 | } 112 | , 113 | RSAUtils.biFromHex = function (i) { 114 | for (var t = new v, s = i.length, r = 0; 0 < s; s -= 4, 115 | ++r) 116 | t.digits[r] = RSAUtils.hexToDigit(i.substr(Math.max(s - 4, 0), Math.min(s, 4))); 117 | return t 118 | } 119 | , 120 | RSAUtils.biFromString = function (i, t) { 121 | var s = "-" == i.charAt(0) 122 | , r = s ? 1 : 0 123 | , e = new v 124 | , g = new v; 125 | g.digits[0] = 1; 126 | for (var l = i.length - 1; r <= l; l--) { 127 | var n = i.charCodeAt(l) 128 | , d = RSAUtils.charToHex(n) 129 | , o = RSAUtils.biMultiplyDigit(g, d); 130 | e = RSAUtils.biAdd(e, o), 131 | g = RSAUtils.biMultiplyDigit(g, t) 132 | } 133 | return e.isNeg = s, 134 | e 135 | } 136 | , 137 | RSAUtils.biDump = function (i) { 138 | return (i.isNeg ? "-" : "") + i.digits.join(" ") 139 | } 140 | , 141 | RSAUtils.biAdd = function (i, t) { 142 | var s; 143 | if (i.isNeg != t.isNeg) 144 | t.isNeg = !t.isNeg, 145 | s = RSAUtils.biSubtract(i, t), 146 | t.isNeg = !t.isNeg; 147 | else { 148 | s = new v; 149 | for (var r, e = 0, g = 0; g < i.digits.length; ++g) 150 | r = i.digits[g] + t.digits[g] + e, 151 | s.digits[g] = r % m, 152 | e = Number(m <= r); 153 | s.isNeg = i.isNeg 154 | } 155 | return s 156 | } 157 | , 158 | RSAUtils.biSubtract = function (i, t) { 159 | var s; 160 | if (i.isNeg != t.isNeg) 161 | t.isNeg = !t.isNeg, 162 | s = RSAUtils.biAdd(i, t), 163 | t.isNeg = !t.isNeg; 164 | else { 165 | var r, e; 166 | s = new v; 167 | for (var g = e = 0; g < i.digits.length; ++g) 168 | r = i.digits[g] - t.digits[g] + e, 169 | s.digits[g] = r % m, 170 | s.digits[g] < 0 && (s.digits[g] += m), 171 | e = 0 - Number(r < 0); 172 | if (-1 == e) { 173 | for (g = e = 0; g < i.digits.length; ++g) 174 | r = 0 - s.digits[g] + e, 175 | s.digits[g] = r % m, 176 | s.digits[g] < 0 && (s.digits[g] += m), 177 | e = 0 - Number(r < 0); 178 | s.isNeg = !i.isNeg 179 | } else 180 | s.isNeg = i.isNeg 181 | } 182 | return s 183 | } 184 | , 185 | RSAUtils.biHighIndex = function (i) { 186 | for (var t = i.digits.length - 1; 0 < t && 0 == i.digits[t];) 187 | --t; 188 | return t 189 | } 190 | , 191 | RSAUtils.biNumBits = function (i) { 192 | var t, s = RSAUtils.biHighIndex(i), r = i.digits[s], e = (s + 1) * N; 193 | for (t = e; e - N < t && 0 == (32768 & r); --t) 194 | r <<= 1; 195 | return t 196 | } 197 | , 198 | RSAUtils.biMultiply = function (i, t) { 199 | for (var s, r, e, g = new v, l = RSAUtils.biHighIndex(i), n = RSAUtils.biHighIndex(t), d = 0; d <= n; ++d) { 200 | for (e = d, 201 | j = s = 0; j <= l; ++j, 202 | ++e) 203 | r = g.digits[e] + i.digits[j] * t.digits[d] + s, 204 | g.digits[e] = r & M, 205 | s = r >>> 16; 206 | g.digits[d + l + 1] = s 207 | } 208 | return g.isNeg = i.isNeg != t.isNeg, 209 | g 210 | } 211 | , 212 | RSAUtils.biMultiplyDigit = function (i, t) { 213 | var s, r, e; 214 | result = new v, 215 | s = RSAUtils.biHighIndex(i); 216 | for (var g = r = 0; g <= s; ++g) 217 | e = result.digits[g] + i.digits[g] * t + r, 218 | result.digits[g] = e & M, 219 | r = e >>> 16; 220 | return result.digits[1 + s] = r, 221 | result 222 | } 223 | , 224 | RSAUtils.arrayCopy = function (i, t, s, r, e) { 225 | for (var g = Math.min(t + e, i.length), l = t, n = r; l < g; ++l, 226 | ++n) 227 | s[n] = i[l] 228 | } 229 | ; 230 | var d = [0, 32768, 49152, 57344, 61440, 63488, 64512, 65024, 65280, 65408, 65472, 65504, 65520, 65528, 65532, 65534, 65535]; 231 | RSAUtils.biShiftLeft = function (i, t) { 232 | var s = Math.floor(t / N) 233 | , r = new v; 234 | RSAUtils.arrayCopy(i.digits, 0, r.digits, s, r.digits.length - s); 235 | for (var e = t % N, g = N - e, l = r.digits.length - 1, n = l - 1; 0 < l; --l, 236 | --n) 237 | r.digits[l] = r.digits[l] << e & M | (r.digits[n] & d[e]) >>> g; 238 | return r.digits[0] = r.digits[l] << e & M, 239 | r.isNeg = i.isNeg, 240 | r 241 | } 242 | ; 243 | var o = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]; 244 | 245 | function u(i) { 246 | var t = RSAUtils 247 | , s = t.biDivideByRadixPower(i, this.k - 1) 248 | , r = t.biMultiply(s, this.mu) 249 | , e = t.biDivideByRadixPower(r, this.k + 1) 250 | , g = t.biModuloByRadixPower(i, this.k + 1) 251 | , l = t.biMultiply(e, this.modulus) 252 | , n = t.biModuloByRadixPower(l, this.k + 1) 253 | , d = t.biSubtract(g, n); 254 | d.isNeg && (d = t.biAdd(d, this.bkplus1)); 255 | for (var o = 0 <= t.biCompare(d, this.modulus); o;) 256 | d = t.biSubtract(d, this.modulus), 257 | o = 0 <= t.biCompare(d, this.modulus); 258 | return d 259 | } 260 | 261 | function S(i, t) { 262 | var s = RSAUtils.biMultiply(i, t); 263 | return this.modulo(s) 264 | } 265 | 266 | function a(i, t) { 267 | var s = new v; 268 | s.digits[0] = 1; 269 | for (var r = i, e = t; 0 != (1 & e.digits[0]) && (s = this.multiplyMod(s, r)), 270 | 0 != (e = RSAUtils.biShiftRight(e, 1)).digits[0] || 0 != RSAUtils.biHighIndex(e);) 271 | r = this.multiplyMod(r, r); 272 | return s 273 | } 274 | 275 | RSAUtils.biShiftRight = function (i, t) { 276 | var s = Math.floor(t / N) 277 | , r = new v; 278 | RSAUtils.arrayCopy(i.digits, s, r.digits, 0, i.digits.length - s); 279 | for (var e = t % N, g = N - e, l = 0, n = l + 1; l < r.digits.length - 1; ++l, 280 | ++n) 281 | r.digits[l] = r.digits[l] >>> e | (r.digits[n] & o[e]) << g; 282 | return r.digits[r.digits.length - 1] >>>= e, 283 | r.isNeg = i.isNeg, 284 | r 285 | } 286 | , 287 | RSAUtils.biMultiplyByRadixPower = function (i, t) { 288 | var s = new v; 289 | return RSAUtils.arrayCopy(i.digits, 0, s.digits, t, s.digits.length - t), 290 | s 291 | } 292 | , 293 | RSAUtils.biDivideByRadixPower = function (i, t) { 294 | var s = new v; 295 | return RSAUtils.arrayCopy(i.digits, t, s.digits, 0, s.digits.length - t), 296 | s 297 | } 298 | , 299 | RSAUtils.biModuloByRadixPower = function (i, t) { 300 | var s = new v; 301 | return RSAUtils.arrayCopy(i.digits, 0, s.digits, 0, t), 302 | s 303 | } 304 | , 305 | RSAUtils.biCompare = function (i, t) { 306 | if (i.isNeg != t.isNeg) 307 | return 1 - 2 * Number(i.isNeg); 308 | for (var s = i.digits.length - 1; 0 <= s; --s) 309 | if (i.digits[s] != t.digits[s]) 310 | return i.isNeg ? 1 - 2 * Number(i.digits[s] > t.digits[s]) : 1 - 2 * Number(i.digits[s] < t.digits[s]); 311 | return 0 312 | } 313 | , 314 | RSAUtils.biDivideModulo = function (i, t) { 315 | var s, r, e = RSAUtils.biNumBits(i), g = RSAUtils.biNumBits(t), l = t.isNeg; 316 | if (e < g) 317 | return i.isNeg ? ((s = RSAUtils.biCopy(c)).isNeg = !t.isNeg, 318 | i.isNeg = !1, 319 | t.isNeg = !1, 320 | r = biSubtract(t, i), 321 | i.isNeg = !0, 322 | t.isNeg = l) : (s = new v, 323 | r = RSAUtils.biCopy(i)), 324 | [s, r]; 325 | s = new v, 326 | r = i; 327 | for (var n = Math.ceil(g / N) - 1, d = 0; t.digits[n] < 32768;) 328 | t = RSAUtils.biShiftLeft(t, 1), 329 | ++d, 330 | ++g, 331 | n = Math.ceil(g / N) - 1; 332 | r = RSAUtils.biShiftLeft(r, d), 333 | e += d; 334 | for (var o = Math.ceil(e / N) - 1, u = RSAUtils.biMultiplyByRadixPower(t, o - n); -1 != RSAUtils.biCompare(r, u);) 335 | ++s.digits[o - n], 336 | r = RSAUtils.biSubtract(r, u); 337 | for (var S = o; n < S; --S) { 338 | var a = S >= r.digits.length ? 0 : r.digits[S] 339 | , b = S - 1 >= r.digits.length ? 0 : r.digits[S - 1] 340 | , A = S - 2 >= r.digits.length ? 0 : r.digits[S - 2] 341 | , R = n >= t.digits.length ? 0 : t.digits[n] 342 | , h = n - 1 >= t.digits.length ? 0 : t.digits[n - 1]; 343 | s.digits[S - n - 1] = a == R ? M : Math.floor((a * m + b) / R); 344 | for (var U = s.digits[S - n - 1] * (R * m + h), f = 4294967296 * a + (b * m + A); f < U;) 345 | --s.digits[S - n - 1], 346 | U = s.digits[S - n - 1] * (R * m | h), 347 | f = a * m * m + (b * m + A); 348 | u = RSAUtils.biMultiplyByRadixPower(t, S - n - 1), 349 | (r = RSAUtils.biSubtract(r, RSAUtils.biMultiplyDigit(u, s.digits[S - n - 1]))).isNeg && (r = RSAUtils.biAdd(r, u), 350 | --s.digits[S - n - 1]) 351 | } 352 | return r = RSAUtils.biShiftRight(r, d), 353 | s.isNeg = i.isNeg != l, 354 | i.isNeg && (s = l ? RSAUtils.biAdd(s, c) : RSAUtils.biSubtract(s, c), 355 | t = RSAUtils.biShiftRight(t, d), 356 | r = RSAUtils.biSubtract(t, r)), 357 | 0 == r.digits[0] && 0 == RSAUtils.biHighIndex(r) && (r.isNeg = !1), 358 | [s, r] 359 | } 360 | , 361 | RSAUtils.biDivide = function (i, t) { 362 | return RSAUtils.biDivideModulo(i, t)[0] 363 | } 364 | , 365 | RSAUtils.biModulo = function (i, t) { 366 | return RSAUtils.biDivideModulo(i, t)[1] 367 | } 368 | , 369 | RSAUtils.biMultiplyMod = function (i, t, s) { 370 | return RSAUtils.biModulo(RSAUtils.biMultiply(i, t), s) 371 | } 372 | , 373 | RSAUtils.biPow = function (i, t) { 374 | for (var s = c, r = i; 0 != (1 & t) && (s = RSAUtils.biMultiply(s, r)), 375 | 0 != (t >>= 1);) 376 | r = RSAUtils.biMultiply(r, r); 377 | return s 378 | } 379 | , 380 | RSAUtils.biPowMod = function (i, t, s) { 381 | for (var r = c, e = i, g = t; 0 != (1 & g.digits[0]) && (r = RSAUtils.biMultiplyMod(r, e, s)), 382 | 0 != (g = RSAUtils.biShiftRight(g, 1)).digits[0] || 0 != RSAUtils.biHighIndex(g);) 383 | e = RSAUtils.biMultiplyMod(e, e, s); 384 | return r 385 | } 386 | , 387 | e.BarrettMu = function (i) { 388 | this.modulus = RSAUtils.biCopy(i), 389 | this.k = RSAUtils.biHighIndex(this.modulus) + 1; 390 | var t = new v; 391 | t.digits[2 * this.k] = 1, 392 | this.mu = RSAUtils.biDivide(t, this.modulus), 393 | this.bkplus1 = new v, 394 | this.bkplus1.digits[this.k + 1] = 1, 395 | this.modulo = u, 396 | this.multiplyMod = S, 397 | this.powMod = a 398 | } 399 | ; 400 | 401 | function b(i, t, s) { 402 | var r = RSAUtils; 403 | this.e = r.biFromHex(i), 404 | this.d = r.biFromHex(t), 405 | this.m = r.biFromHex(s), 406 | this.chunkSize = 2 * r.biHighIndex(this.m), 407 | this.radix = 16, 408 | this.barrett = new e.BarrettMu(this.m) 409 | } 410 | 411 | RSAUtils.getKeyPair = function (i, t, s) { 412 | return new b(i, t, s) 413 | } 414 | , 415 | void 0 === e.twoDigit && (e.twoDigit = function (i) { 416 | return (i < 10 ? "0" : "") + String(i) 417 | } 418 | ), 419 | RSAUtils.encryptedString = function (i, t) { 420 | for (var s = [], r = t.length, e = 0; e < r;) 421 | s[e] = t.charCodeAt(e), 422 | e++; 423 | for (; s.length % i.chunkSize != 0;) 424 | s[e++] = 0; 425 | var g, l, n, d = s.length, o = ""; 426 | for (e = 0; e < d; e += i.chunkSize) { 427 | for (n = new v, 428 | g = 0, 429 | l = e; l < e + i.chunkSize; ++g) 430 | n.digits[g] = s[l++], 431 | n.digits[g] += s[l++] << 8; 432 | var u = i.barrett.powMod(n, i.e); 433 | o += (16 == i.radix ? RSAUtils.biToHex(u) : RSAUtils.biToString(u, i.radix)) + " " 434 | } 435 | return o.substring(0, o.length - 1) 436 | } 437 | , 438 | RSAUtils.decryptedString = function (i, t) { 439 | var s, r, e, g = t.split(" "), l = ""; 440 | for (s = 0; s < g.length; ++s) { 441 | var n; 442 | for (n = 16 == i.radix ? RSAUtils.biFromHex(g[s]) : RSAUtils.biFromString(g[s], i.radix), 443 | e = i.barrett.powMod(n, i.d), 444 | r = 0; r <= RSAUtils.biHighIndex(e); ++r) 445 | l += String.fromCharCode(255 & e.digits[r], e.digits[r] >> 8) 446 | } 447 | return 0 == l.charCodeAt(l.length - 1) && (l = l.substring(0, l.length - 1)), 448 | l 449 | } 450 | , 451 | RSAUtils.setMaxDigits(130) 452 | }(global); 453 | 454 | -------------------------------------------------------------------------------- /安居客/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const rsaEncrypt = require('./rsa'); 3 | const aes = require('./aes'); 4 | const bodyParser = require('body-parser'); 5 | const app = express(); 6 | const port = process.env.crackLoginServerPort || 8000; 7 | 8 | app.use(bodyParser.urlencoded({limit: "2100000kb"})); 9 | 10 | app.post('/signPwd', (req, res) => { 11 | res.send(rsaEncrypt(req.body.password)); 12 | }); 13 | 14 | app.post('/decrypt', (req, res) => { 15 | const data = aes.decrypt(req.body.data); 16 | res.json(JSON.parse(data)); 17 | }); 18 | 19 | app.post('/encryptBrowser', (req, res) => { 20 | const enc = aes.encryptBrowser(req.body); 21 | res.send(enc); 22 | }) 23 | 24 | app.post('/decryptBrowser', (req, res) => { 25 | const dec = aes.decryptBrowser(req.body.data); 26 | // res.send(dec); 27 | res.json(JSON.parse(dec)); 28 | }); 29 | 30 | app.get('/signEnc', (req, res) => { 31 | res.send(aes.signEnc()); 32 | }); 33 | 34 | app.listen(port, () => { 35 | console.log(`node server listening at http://localhost:${port}`) 36 | }); 37 | 38 | -------------------------------------------------------------------------------- /安居客/test.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/12/18:27 4 | description 5 | """ 6 | import os 7 | import subprocess 8 | import time 9 | 10 | os.environ.setdefault("crackLoginServerPort", "5000") 11 | p = subprocess.run("node -v", stdout=subprocess.PIPE) 12 | print(f"系统node版本为:{p.stdout.decode()}") 13 | # p = subprocess.Popen("node server.js") 14 | # print("sdfadf") 15 | # time.sleep(100) 16 | # p.kill() 17 | # print("dddd") 18 | for k, v in os.environ.items(): 19 | print(k, v) 20 | -------------------------------------------------------------------------------- /建筑市场监管平台/decrypt.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rufeng-h/CrackJS/5f0a08cfd94355cd7043c90663603922aff524b0/建筑市场监管平台/decrypt.js -------------------------------------------------------------------------------- /建筑市场监管平台/main.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/12/23/8:53 4 | description 5 | """ 6 | 7 | -------------------------------------------------------------------------------- /建筑市场监管平台/server.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rufeng-h/CrackJS/5f0a08cfd94355cd7043c90663603922aff524b0/建筑市场监管平台/server.js -------------------------------------------------------------------------------- /惠农网/main.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/12/08/16:50 4 | description 5 | """ 6 | import requests 7 | 8 | headers = { 9 | 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36', 10 | 'x-b3-traceid': '0KWXAI3SN1XEHHIQ', 11 | 'x-client-appid': '5', 12 | 'x-client-id': 'f868570-4b86-4cbc-8a6d-3c603edcc', 13 | 'x-client-nonce': 'fcb8f852063168f2828dbdd51aa5b098', 14 | 'x-client-page': '/hangqing/cd-2000156-0-0-1261/', 15 | 'x-client-sid': 'S_0KWXAI3LB074VB3L', 16 | 'x-client-time': '1638953637510', 17 | 'x-client-sign': '79dc30a614aea223eb3b5da186956458d6a6dd43e790fe76ce22c3b8cf26bda161fe85ad4ed3bbecc290c0262ebf7c7e', 18 | } 19 | 20 | session = requests.session() 21 | session.headers.update(headers) 22 | 23 | res = requests.post("https://pcapi.cnhnb.com/hn-biz-gateway/api/biz-gateway/pc/hot/search/cate", json={"pageNumber":8}) 24 | print(res.text) 25 | -------------------------------------------------------------------------------- /房天下/login.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/04/17:09 4 | description 5 | """ 6 | import requests 7 | from pprint import pprint 8 | 9 | headers = { 10 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 11 | 'Accept-Encoding': 'gzip, deflate, br', 12 | 'Accept-Language': 'zh-CN,zh;q=0.9', 13 | 'Cache-Control': 'no-cache', 14 | 'Connection': 'keep-alive', 15 | 'Host': 'passport.fang.com', 16 | 'Pragma': 'no-cache', 17 | 'Referer': 'https://bj.fang.com/', 18 | 'sec-ch-ua': '"Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"', 19 | 'sec-ch-ua-mobile': '?0', 20 | 'sec-ch-ua-platform': '"Windows"', 21 | 'Sec-Fetch-Dest': 'document', 22 | 'Sec-Fetch-Mode': 'navigate', 23 | 'Sec-Fetch-Site': 'same-site', 24 | 'Sec-Fetch-User': '?1', 25 | 'Upgrade-Insecure-Requests': '1', 26 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36', 27 | } 28 | session = requests.session() 29 | 30 | if __name__ == '__main__': 31 | username, password = "18280484271", "Aa1234567890" 32 | session.get("https://passport.fang.com/", headers=headers) 33 | en_pwd = session.post("http://localhost:8000", data={"password": password}).text 34 | formdata = { 35 | "uid": username, 36 | "pwd": en_pwd, 37 | "Service": "soufun-passport-web", 38 | "AutoLogin": "1", 39 | } 40 | res = session.post("https://passport.fang.com/login.api", data=formdata, headers=headers) 41 | pprint(res.json()) 42 | -------------------------------------------------------------------------------- /房天下/rsa.js: -------------------------------------------------------------------------------- 1 | function setMaxDigits(n) { 2 | maxDigits = n; 3 | ZERO_ARRAY = new Array(maxDigits); 4 | for (var t = 0; t < ZERO_ARRAY.length; t++) 5 | ZERO_ARRAY[t] = 0; 6 | bigZero = new BigInt; 7 | bigOne = new BigInt; 8 | bigOne.digits[0] = 1 9 | } 10 | 11 | function BigInt(n) { 12 | this.digits = typeof n == "boolean" && n == !0 ? null : ZERO_ARRAY.slice(0); 13 | this.isNeg = !1 14 | } 15 | 16 | function biFromDecimal(n) { 17 | for (var u = n.charAt(0) == "-", t = u ? 1 : 0, i, f, r; t < n.length && n.charAt(t) == "0";) 18 | ++t; 19 | if (t == n.length) 20 | i = new BigInt; 21 | else { 22 | for (f = n.length - t, 23 | r = f % dpl10, 24 | r == 0 && (r = dpl10), 25 | i = biFromNumber(Number(n.substr(t, r))), 26 | t += r; t < n.length;) 27 | i = biAdd(biMultiply(i, lr10), biFromNumber(Number(n.substr(t, dpl10)))), 28 | t += dpl10; 29 | i.isNeg = u 30 | } 31 | return i 32 | } 33 | 34 | function biCopy(n) { 35 | var t = new BigInt(!0); 36 | return t.digits = n.digits.slice(0), 37 | t.isNeg = n.isNeg, 38 | t 39 | } 40 | 41 | function biFromNumber(n) { 42 | var t = new BigInt, i; 43 | for (t.isNeg = n < 0, 44 | n = Math.abs(n), 45 | i = 0; n > 0;) 46 | t.digits[i++] = n & maxDigitVal, 47 | n = Math.floor(n / biRadix); 48 | return t 49 | } 50 | 51 | function reverseStr(n) { 52 | for (var i = "", t = n.length - 1; t > -1; --t) 53 | i += n.charAt(t); 54 | return i 55 | } 56 | 57 | function biToString(n, t) { 58 | var r = new BigInt, i, u; 59 | for (r.digits[0] = t, 60 | i = biDivideModulo(n, r), 61 | u = hexatrigesimalToChar[i[1].digits[0]]; biCompare(i[0], bigZero) == 1;) 62 | i = biDivideModulo(i[0], r), 63 | digit = i[1].digits[0], 64 | u += hexatrigesimalToChar[i[1].digits[0]]; 65 | return (n.isNeg ? "-" : "") + reverseStr(u) 66 | } 67 | 68 | function biToDecimal(n) { 69 | var i = new BigInt, t, r; 70 | for (i.digits[0] = 10, 71 | t = biDivideModulo(n, i), 72 | r = String(t[1].digits[0]); biCompare(t[0], bigZero) == 1;) 73 | t = biDivideModulo(t[0], i), 74 | r += String(t[1].digits[0]); 75 | return (n.isNeg ? "-" : "") + reverseStr(r) 76 | } 77 | 78 | function digitToHex(n) { 79 | var t = ""; 80 | for (i = 0; i < 4; ++i) 81 | t += hexToChar[n & 15], 82 | n >>>= 4; 83 | return reverseStr(t) 84 | } 85 | 86 | function biToHex(n) { 87 | for (var i = "", r = biHighIndex(n), t = biHighIndex(n); t > -1; --t) 88 | i += digitToHex(n.digits[t]); 89 | return i 90 | } 91 | 92 | function charToHex(n) { 93 | var t = 48 94 | , u = t + 9 95 | , i = 97 96 | , f = i + 25 97 | , r = 65; 98 | return n >= t && n <= u ? n - t : n >= r && n <= 90 ? 10 + n - r : n >= i && n <= f ? 10 + n - i : 0 99 | } 100 | 101 | function hexToDigit(n) { 102 | for (var t = 0, r = Math.min(n.length, 4), i = 0; i < r; ++i) 103 | t <<= 4, 104 | t |= charToHex(n.charCodeAt(i)); 105 | return t 106 | } 107 | 108 | function biFromHex(n) { 109 | for (var i = new BigInt, u = n.length, t = u, r = 0; t > 0; t -= 4, 110 | ++r) 111 | i.digits[r] = hexToDigit(n.substr(Math.max(t - 4, 0), Math.min(t, 4))); 112 | return i 113 | } 114 | 115 | function biFromString(n, t) { 116 | var f = n.charAt(0) == "-", e = f ? 1 : 0, i = new BigInt, r = new BigInt, u; 117 | for (r.digits[0] = 1, 118 | u = n.length - 1; u >= e; u--) { 119 | var o = n.charCodeAt(u) 120 | , s = charToHex(o) 121 | , h = biMultiplyDigit(r, s); 122 | i = biAdd(i, h); 123 | r = biMultiplyDigit(r, t) 124 | } 125 | return i.isNeg = f, 126 | i 127 | } 128 | 129 | function biDump(n) { 130 | return (n.isNeg ? "-" : "") + n.digits.join(" ") 131 | } 132 | 133 | function biAdd(n, t) { 134 | var r, u, f, i; 135 | if (n.isNeg != t.isNeg) 136 | t.isNeg = !t.isNeg, 137 | r = biSubtract(n, t), 138 | t.isNeg = !t.isNeg; 139 | else { 140 | for (r = new BigInt, 141 | u = 0, 142 | i = 0; i < n.digits.length; ++i) 143 | f = n.digits[i] + t.digits[i] + u, 144 | r.digits[i] = f % biRadix, 145 | u = Number(f >= biRadix); 146 | r.isNeg = n.isNeg 147 | } 148 | return r 149 | } 150 | 151 | function biSubtract(n, t) { 152 | var r, f, u, i; 153 | if (n.isNeg != t.isNeg) 154 | t.isNeg = !t.isNeg, 155 | r = biAdd(n, t), 156 | t.isNeg = !t.isNeg; 157 | else { 158 | for (r = new BigInt, 159 | u = 0, 160 | i = 0; i < n.digits.length; ++i) 161 | f = n.digits[i] - t.digits[i] + u, 162 | r.digits[i] = f % biRadix, 163 | r.digits[i] < 0 && (r.digits[i] += biRadix), 164 | u = 0 - Number(f < 0); 165 | if (u == -1) { 166 | for (u = 0, 167 | i = 0; i < n.digits.length; ++i) 168 | f = 0 - r.digits[i] + u, 169 | r.digits[i] = f % biRadix, 170 | r.digits[i] < 0 && (r.digits[i] += biRadix), 171 | u = 0 - Number(f < 0); 172 | r.isNeg = !n.isNeg 173 | } else 174 | r.isNeg = n.isNeg 175 | } 176 | return r 177 | } 178 | 179 | function biHighIndex(n) { 180 | for (var t = n.digits.length - 1; t > 0 && n.digits[t] == 0;) 181 | --t; 182 | return t 183 | } 184 | 185 | function biNumBits(n) { 186 | for (var i = biHighIndex(n), r = n.digits[i], u = (i + 1) * bitsPerDigit, t = u; t > u - bitsPerDigit; --t) { 187 | if ((r & 32768) != 0) 188 | break; 189 | r <<= 1 190 | } 191 | return t 192 | } 193 | 194 | function biMultiply(n, t) { 195 | for (var i = new BigInt, u, o = biHighIndex(n), s = biHighIndex(t), e, f, r = 0; r <= s; ++r) { 196 | for (u = 0, 197 | f = r, 198 | j = 0; j <= o; ++j, 199 | ++f) 200 | e = i.digits[f] + n.digits[j] * t.digits[r] + u, 201 | i.digits[f] = e & maxDigitVal, 202 | u = e >>> biRadixBits; 203 | i.digits[r + o + 1] = u 204 | } 205 | return i.isNeg = n.isNeg != t.isNeg, 206 | i 207 | } 208 | 209 | function biMultiplyDigit(n, t) { 210 | var u, r, f, i; 211 | for (result = new BigInt, 212 | u = biHighIndex(n), 213 | r = 0, 214 | i = 0; i <= u; ++i) 215 | f = result.digits[i] + n.digits[i] * t + r, 216 | result.digits[i] = f & maxDigitVal, 217 | r = f >>> biRadixBits; 218 | return result.digits[1 + u] = r, 219 | result 220 | } 221 | 222 | function arrayCopy(n, t, i, r, u) { 223 | for (var o = Math.min(t + u, n.length), f = t, e = r; f < o; ++f, 224 | ++e) 225 | i[e] = n[f] 226 | } 227 | 228 | function biShiftLeft(n, t) { 229 | var e = Math.floor(t / bitsPerDigit), i = new BigInt, u, o, r, f; 230 | for (arrayCopy(n.digits, 0, i.digits, e, i.digits.length - e), 231 | u = t % bitsPerDigit, 232 | o = bitsPerDigit - u, 233 | r = i.digits.length - 1, 234 | f = r - 1; r > 0; --r, 235 | --f) 236 | i.digits[r] = i.digits[r] << u & maxDigitVal | (i.digits[f] & highBitMasks[u]) >>> o; 237 | return i.digits[0] = i.digits[r] << u & maxDigitVal, 238 | i.isNeg = n.isNeg, 239 | i 240 | } 241 | 242 | function biShiftRight(n, t) { 243 | var e = Math.floor(t / bitsPerDigit), i = new BigInt, u, o, r, f; 244 | for (arrayCopy(n.digits, e, i.digits, 0, n.digits.length - e), 245 | u = t % bitsPerDigit, 246 | o = bitsPerDigit - u, 247 | r = 0, 248 | f = r + 1; r < i.digits.length - 1; ++r, 249 | ++f) 250 | i.digits[r] = i.digits[r] >>> u | (i.digits[f] & lowBitMasks[u]) << o; 251 | return i.digits[i.digits.length - 1] >>>= u, 252 | i.isNeg = n.isNeg, 253 | i 254 | } 255 | 256 | function biMultiplyByRadixPower(n, t) { 257 | var i = new BigInt; 258 | return arrayCopy(n.digits, 0, i.digits, t, i.digits.length - t), 259 | i 260 | } 261 | 262 | function biDivideByRadixPower(n, t) { 263 | var i = new BigInt; 264 | return arrayCopy(n.digits, t, i.digits, 0, i.digits.length - t), 265 | i 266 | } 267 | 268 | function biModuloByRadixPower(n, t) { 269 | var i = new BigInt; 270 | return arrayCopy(n.digits, 0, i.digits, 0, t), 271 | i 272 | } 273 | 274 | function biCompare(n, t) { 275 | if (n.isNeg != t.isNeg) 276 | return 1 - 2 * Number(n.isNeg); 277 | for (var i = n.digits.length - 1; i >= 0; --i) 278 | if (n.digits[i] != t.digits[i]) 279 | return n.isNeg ? 1 - 2 * Number(n.digits[i] > t.digits[i]) : 1 - 2 * Number(n.digits[i] < t.digits[i]); 280 | return 0 281 | } 282 | 283 | function biDivideModulo(n, t) { 284 | var a = biNumBits(n), s = biNumBits(t), v = t.isNeg, r, i, u, e, h, o, f, y, p; 285 | if (a < s) 286 | return n.isNeg ? (r = biCopy(bigOne), 287 | r.isNeg = !t.isNeg, 288 | n.isNeg = !1, 289 | t.isNeg = !1, 290 | i = biSubtract(t, n), 291 | n.isNeg = !0, 292 | t.isNeg = v) : (r = new BigInt, 293 | i = biCopy(n)), 294 | [r, i]; 295 | for (r = new BigInt, 296 | i = n, 297 | u = Math.ceil(s / bitsPerDigit) - 1, 298 | e = 0; t.digits[u] < biHalfRadix;) 299 | t = biShiftLeft(t, 1), 300 | ++e, 301 | ++s, 302 | u = Math.ceil(s / bitsPerDigit) - 1; 303 | for (i = biShiftLeft(i, e), 304 | a += e, 305 | h = Math.ceil(a / bitsPerDigit) - 1, 306 | o = biMultiplyByRadixPower(t, h - u); biCompare(i, o) != -1;) 307 | ++r.digits[h - u], 308 | i = biSubtract(i, o); 309 | for (f = h; f > u; --f) { 310 | var c = f >= i.digits.length ? 0 : i.digits[f] 311 | , w = f - 1 >= i.digits.length ? 0 : i.digits[f - 1] 312 | , b = f - 2 >= i.digits.length ? 0 : i.digits[f - 2] 313 | , l = u >= t.digits.length ? 0 : t.digits[u] 314 | , k = u - 1 >= t.digits.length ? 0 : t.digits[u - 1]; 315 | for (r.digits[f - u - 1] = c == l ? maxDigitVal : Math.floor((c * biRadix + w) / l), 316 | y = r.digits[f - u - 1] * (l * biRadix + k), 317 | p = c * biRadixSquared + (w * biRadix + b); y > p;) 318 | --r.digits[f - u - 1], 319 | y = r.digits[f - u - 1] * (l * biRadix | k), 320 | p = c * biRadix * biRadix + (w * biRadix + b); 321 | o = biMultiplyByRadixPower(t, f - u - 1); 322 | i = biSubtract(i, biMultiplyDigit(o, r.digits[f - u - 1])); 323 | i.isNeg && (i = biAdd(i, o), 324 | --r.digits[f - u - 1]) 325 | } 326 | return i = biShiftRight(i, e), 327 | r.isNeg = n.isNeg != v, 328 | n.isNeg && (r = v ? biAdd(r, bigOne) : biSubtract(r, bigOne), 329 | t = biShiftRight(t, e), 330 | i = biSubtract(t, i)), 331 | i.digits[0] == 0 && biHighIndex(i) == 0 && (i.isNeg = !1), 332 | [r, i] 333 | } 334 | 335 | function biDivide(n, t) { 336 | return biDivideModulo(n, t)[0] 337 | } 338 | 339 | function biModulo(n, t) { 340 | return biDivideModulo(n, t)[1] 341 | } 342 | 343 | function biMultiplyMod(n, t, i) { 344 | return biModulo(biMultiply(n, t), i) 345 | } 346 | 347 | function biPow(n, t) { 348 | for (var r = bigOne, i = n; ;) { 349 | if ((t & 1) != 0 && (r = biMultiply(r, i)), 350 | t >>= 1, 351 | t == 0) 352 | break; 353 | i = biMultiply(i, i) 354 | } 355 | return r 356 | } 357 | 358 | function biPowMod(n, t, i) { 359 | for (var f = bigOne, u = n, r = t; ;) { 360 | if ((r.digits[0] & 1) != 0 && (f = biMultiplyMod(f, u, i)), 361 | r = biShiftRight(r, 1), 362 | r.digits[0] == 0 && biHighIndex(r) == 0) 363 | break; 364 | u = biMultiplyMod(u, u, i) 365 | } 366 | return f 367 | } 368 | 369 | function BarrettMu(n) { 370 | this.modulus = biCopy(n); 371 | this.k = biHighIndex(this.modulus) + 1; 372 | var t = new BigInt; 373 | t.digits[2 * this.k] = 1; 374 | this.mu = biDivide(t, this.modulus); 375 | this.bkplus1 = new BigInt; 376 | this.bkplus1.digits[this.k + 1] = 1; 377 | this.modulo = BarrettMu_modulo; 378 | this.multiplyMod = BarrettMu_multiplyMod; 379 | this.powMod = BarrettMu_powMod 380 | } 381 | 382 | function BarrettMu_modulo(n) { 383 | var r = biDivideByRadixPower(n, this.k - 1), u = biMultiply(r, this.mu), f = biDivideByRadixPower(u, this.k + 1), 384 | e = biModuloByRadixPower(n, this.k + 1), o = biMultiply(f, this.modulus), 385 | s = biModuloByRadixPower(o, this.k + 1), t = biSubtract(e, s), i; 386 | for (t.isNeg && (t = biAdd(t, this.bkplus1)), 387 | i = biCompare(t, this.modulus) >= 0; i;) 388 | t = biSubtract(t, this.modulus), 389 | i = biCompare(t, this.modulus) >= 0; 390 | return t 391 | } 392 | 393 | function BarrettMu_multiplyMod(n, t) { 394 | var i = biMultiply(n, t); 395 | return this.modulo(i) 396 | } 397 | 398 | function BarrettMu_powMod(n, t) { 399 | var u = new BigInt, r, i; 400 | for (u.digits[0] = 1, 401 | r = n, 402 | i = t; ;) { 403 | if ((i.digits[0] & 1) != 0 && (u = this.multiplyMod(u, r)), 404 | i = biShiftRight(i, 1), 405 | i.digits[0] == 0 && biHighIndex(i) == 0) 406 | break; 407 | r = this.multiplyMod(r, r) 408 | } 409 | return u 410 | } 411 | 412 | function RSAKeyPair(n, t, i) { 413 | this.e = biFromHex(n); 414 | this.d = biFromHex(t); 415 | this.m = biFromHex(i); 416 | this.digitSize = 2 * biHighIndex(this.m) + 2; 417 | this.chunkSize = this.digitSize - 11; 418 | this.radix = 16; 419 | this.barrett = new BarrettMu(this.m) 420 | } 421 | 422 | function twoDigit(n) { 423 | return (n < 10 ? "0" : "") + String(n) 424 | } 425 | 426 | function encryptedString(n, t) { 427 | var e, o, s, h, c, i, f, u, v, l, y; 428 | if (n.chunkSize > n.digitSize - 11) 429 | return "Error"; 430 | for (var a = [], p = t.length, r = 0; r < p;) 431 | a[r] = t.charCodeAt(r), 432 | r++; 433 | for (e = a.length, 434 | o = "", 435 | r = 0; r < e; r += n.chunkSize) { 436 | for (c = new BigInt, 437 | s = 0, 438 | f = r + n.chunkSize > e ? e % n.chunkSize : n.chunkSize, 439 | u = [], 440 | i = 0; i < f; i++) 441 | u[i] = a[r + f - 1 - i]; 442 | for (u[f] = 0, 443 | v = Math.max(8, n.digitSize - 3 - f), 444 | i = 0; i < v; i++) 445 | u[f + 1 + i] = Math.floor(Math.random() * 254) + 1; 446 | for (u[n.digitSize - 2] = 2, 447 | u[n.digitSize - 1] = 0, 448 | h = 0; h < n.digitSize; ++s) 449 | c.digits[s] = u[h++], 450 | c.digits[s] += u[h++] << 8; 451 | l = n.barrett.powMod(c, n.e); 452 | y = n.radix == 16 ? biToHex(l) : biToString(l, n.radix); 453 | o += y + " " 454 | } 455 | return o.substring(0, o.length - 1) 456 | } 457 | 458 | function decryptedString(n, t) { 459 | for (var e = t.split(" "), i = "", r, u, o, f = 0; f < e.length; ++f) 460 | for (o = n.radix === 16 ? biFromHex(e[f]) : biFromString(e[f], n.radix), 461 | u = n.barrett.powMod(o, n.d), 462 | r = 0; r <= biHighIndex(u); ++r) 463 | i += String.fromCharCode(u.digits[r] & 255, u.digits[r] >> 8); 464 | return i.charCodeAt(i.length - 1) === 0 && (i = i.substring(0, i.length - 1)), 465 | i 466 | } 467 | 468 | var biRadixBase = 2, biRadixBits = 16, bitsPerDigit = biRadixBits, biRadix = 65536, biHalfRadix = biRadix >>> 1, 469 | biRadixSquared = biRadix * biRadix, maxDigitVal = biRadix - 1, maxInteger = 9999999999999998, maxDigits, ZERO_ARRAY, 470 | bigZero, bigOne, dpl10, lr10, hexatrigesimalToChar, hexToChar, highBitMasks, lowBitMasks; 471 | setMaxDigits(20); 472 | dpl10 = 15; 473 | lr10 = biFromNumber(1e15); 474 | hexatrigesimalToChar = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]; 475 | hexToChar = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]; 476 | highBitMasks = [0, 32768, 49152, 57344, 61440, 63488, 64512, 65024, 65280, 65408, 65472, 65504, 65520, 65528, 65532, 65534, 65535]; 477 | lowBitMasks = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]; 478 | setMaxDigits(129); 479 | 480 | const rsa = new RSAKeyPair("010001", "", "978C0A92D2173439707498F0944AA476B1B62595877DD6FA87F6E2AC6DCB3D0BF0B82857439C99B5091192BC134889DFF60C562EC54EFBA4FF2F9D55ADBCCEA4A2FBA80CB398ED501280A007C83AF30C3D1A142D6133C63012B90AB26AC60C898FB66EDC3192C3EC4FF66925A64003B72496099F4F09A9FB72A2CF9E4D770C41"); 481 | 482 | module.exports = function (pwd) { 483 | return encryptedString(rsa, pwd); 484 | } 485 | 486 | -------------------------------------------------------------------------------- /房天下/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const encrypt = require('./rsa'); 3 | const bodyParser = require('body-parser'); 4 | const app = express(); 5 | const port = 8000; 6 | 7 | app.use(bodyParser.urlencoded({limit: "2100000kb"})); 8 | 9 | app.post('/', (req, res) => { 10 | res.send(encrypt(req.body.password)); 11 | }); 12 | 13 | app.listen(port, () => { 14 | console.log(`Example app listening at http://localhost:${port}`) 15 | }); 16 | 17 | -------------------------------------------------------------------------------- /新浪微博/login.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/08/17:58 4 | description 5 | """ 6 | import base64 7 | import copy 8 | import json 9 | import re 10 | import time 11 | 12 | import requests 13 | from scrapy import Selector 14 | 15 | 16 | def enc_username(username: str) -> str: 17 | return base64.b64encode(username.encode()).decode() 18 | 19 | 20 | def timestamp(): 21 | return int(time.time() * 1000) 22 | 23 | 24 | def pre_login(username: str) -> tuple: 25 | tmp_headers = copy.copy(headers) 26 | tmp_headers["Referer"] = "https://weibo.com/" 27 | url = "https://login.sina.com.cn/sso/prelogin.php?entry=weibo&callback=sinaSSOController.preloginCallBack&su={}&rsakt=mod&checkpin=1&client=ssologin.js(v1.4.19)&_{}" 28 | response = session.get(url.format(enc_username(username), timestamp()), headers=tmp_headers) 29 | print(response.text) 30 | data = json.loads(re.search('({.*?})', response.text).group(1)) 31 | return data.get("servertime"), data.get("pcid"), data.get("nonce"), data.get("pubkey"), data.get("rsakv"), data.get( 32 | 'exectime') 33 | 34 | 35 | def do_login(username, password, servertime, nonce, rsakv, pubkey, exce_time, pre_login_time_start): 36 | enc_pwd = session.post("http://127.0.0.1:8000", 37 | data={"password": password, "servertime": servertime, "nonce": nonce, "pubkey": pubkey}).text 38 | formdata = {"entry": "weibo", 39 | "gateway": "1", 40 | "from": "", 41 | "savestate": "7", 42 | "qrcode_flag": "false", 43 | "useticket": "1", 44 | "pagerefer": "https://weibo.com/newlogin?tabtype=weibo&gid=102803&url=https%3A%2F%2Fwww.weibo.com%2F", 45 | "vsnf": "1", 46 | "su": enc_username(username), 47 | "service": "miniblog", 48 | "servertime": servertime, 49 | "nonce": nonce, 50 | "pwencode": "rsa2", 51 | "rsakv": rsakv, 52 | "sp": enc_pwd, 53 | "sr": "1536*864", 54 | "encoding": "UTF-8", 55 | "prelt": timestamp() - pre_login_time_start - exce_time, 56 | "url": "https://weibo.com/ajaxlogin.php?framelogin=1&callback=parent.sinaSSOController.feedBackUrlCallBack", 57 | "returntype": "META"} 58 | # time.sleep(2) 59 | login_headers = copy.copy(headers) 60 | login_headers["Host"] = "login.sina.com.cn" 61 | login_headers["Referer"] = "https://weibo.com/" 62 | login_headers['Origin'] = 'https://weibo.com' 63 | return session.post("https://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.4.19)", data=formdata, 64 | headers=login_headers) 65 | 66 | 67 | def redirect(url): 68 | tmp_headers = copy.copy(headers) 69 | tmp_headers['Host'] = 'weibo.com' 70 | tmp_headers['Referer'] = 'https://login.sina.com.cn/' 71 | response = session.get(url, headers=tmp_headers) 72 | 73 | token = re.search('token=(.*?)"', response.text).group(1) 74 | 75 | target_url = json.loads(re.search("\(({.*?})\)", response.text).group(1))["protection_url"] 76 | 77 | tmp_headers['Host'] = "passport.weibo.com" 78 | tmp_headers['Referer'] = "https://weibo.com/" 79 | response = session.get(target_url, headers=tmp_headers) 80 | html = response.content.decode() 81 | selector = Selector(text=html) 82 | encrypt_mobile = selector.xpath('//input[@name="encrypt_mobile"]/@value').extract_first() 83 | tmp_headers[ 84 | 'Referer'] = "Referer: https://passport.weibo.com/protection/index?token={}&callback_url=https%3A%2F%2Fweibo.com".format( 85 | token) 86 | tmp_headers['Host'] = "passport.weibo.com" 87 | tmp_headers['Origin'] = 'https://passport.weibo.com' 88 | ret = session.post("https://passport.weibo.com/protection/mobile/sendcode?token={}".format(token), 89 | data={"encrypt_mobile": encrypt_mobile}, headers=tmp_headers).json() 90 | if ret['retcode'] != 20000000: 91 | print("验证码发送失败!") 92 | print(ret["msg"]) 93 | exit(0) 94 | 95 | redirect_url = '' 96 | while True: 97 | code = input("请输入收到的手机验证码:") 98 | 99 | ret = session.post("https://passport.weibo.com/protection/mobile/confirm?token={}".format(token), 100 | headers=tmp_headers, data={"encrypt_mobile": encrypt_mobile, 101 | "code": code}).json() 102 | print(ret) 103 | if ret['code'] != 20000000: 104 | print(ret['msg']) 105 | continue 106 | 107 | redirect_url = ret['data']["redirect_url"] 108 | break 109 | if not redirect_url: 110 | exit(0) 111 | 112 | tmp_headers.pop("Origin") 113 | tmp_headers['Host'] = "login.sina.com.cn" 114 | tmp_headers['Referer'] = "https://passport.weibo.com/" 115 | response = session.get(redirect_url, headers=tmp_headers) 116 | url = re.search('location\.replace\("(.*?)"\)', response.content.decode("gbk")).group(1) 117 | tmp_headers['Referer'] = redirect_url 118 | 119 | response = session.get(url, headers=tmp_headers) 120 | d = json.loads(re.search('\(({.*?})\)', response.text).group(1)) 121 | url = d['arrURL'][ 122 | 0] + "&callback=sinaSSOController.doCrossDomainCallBack&scriptId=ssoscript0&client=ssologin.js(v1.4.19)&_={}".format( 123 | int(time.time() * 1000)) 124 | tmp_headers['Host'] = 'passport.weibo.com' 125 | tmp_headers['Referer'] = 'https://login.sina.com.cn' 126 | 127 | response = session.get(url, headers=tmp_headers) 128 | print(json.loads(re.search('\(({.*?})\)', response.text).group(1))) 129 | 130 | 131 | def gen_visotor(): 132 | portal_headers = copy.copy(headers) 133 | portal_headers['Host'] = "weibo.com" 134 | response = session.get("https://weibo.com/", headers=portal_headers, allow_redirects=False) 135 | visitor_url = response.headers['Location'] 136 | 137 | gen_headers = copy.copy(headers) 138 | gen_headers['Host'] = 'passport.weibo.com' 139 | gen_headers['Referer'] = visitor_url 140 | gen_headers['Origin'] = 'https://passport.weibo.com' 141 | gen_visotor_url = "https://passport.weibo.com/visitor/genvisitor" 142 | data = {'cb': 'gen_callback', 143 | 'fp': '{"os":"1","browser":"Chrome95,0,4638,69","fonts":"undefined","screenInfo":"1536*864*24","plugins":"Portable Document Format::internal-pdf-viewer::PDF Viewer|Portable Document Format::internal-pdf-viewer::Chrome PDF Viewer|Portable Document Format::internal-pdf-viewer::Chromium PDF Viewer|Portable Document Format::internal-pdf-viewer::Microsoft Edge PDF Viewer|Portable Document Format::internal-pdf-viewer::WebKit built-in PDF"}'} 144 | response = session.post(gen_visotor_url, data=data, headers=gen_headers) 145 | tid = re.search('"tid":"(.*?)"', response.text).group(1) 146 | tid = re.sub(r"\\/", "/", tid) 147 | session.cookies.set("tid", tid + "__095", domain='.passport.weibo.com', path='/visitor') 148 | 149 | params = {"a": "incarnate", 150 | "t": tid, 151 | "w": "2", 152 | "c": "095", 153 | "gc": "", 154 | "cb": "cross_domain", 155 | "from": "weibo", 156 | "_rand": "0.5799231670299148"} 157 | session.get("https://passport.weibo.com/visitor/visitor", headers=gen_headers, params=params, allow_redirects=False) 158 | 159 | portal_headers['Referer'] = 'https://passport.weibo.com/' 160 | session.get("https://weibo.com", headers=portal_headers, allow_redirects=False) 161 | # for k, v in session.cookies.items(): 162 | # print(k, v) 163 | 164 | 165 | headers = { 166 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 167 | 'Accept-Encoding': 'gzip, deflate, br', 168 | 'Accept-Language': 'zh-CN,zh;q=0.9', 169 | 'Cache-Control': 'no-cache', 170 | 'Connection': 'keep-alive', 171 | 'Pragma': 'no-cache', 172 | 'sec-ch-ua': '"Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"', 173 | 'sec-ch-ua-mobile': '?0', 174 | 'sec-ch-ua-platform': '"Windows"', 175 | 'Sec-Fetch-Dest': 'document', 176 | 'Sec-Fetch-Mode': 'navigate', 177 | 'Sec-Fetch-Site': 'none', 178 | 'Sec-Fetch-User': '?1', 179 | 'Upgrade-Insecure-Requests': '1', 180 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36', } 181 | 182 | session = requests.session() 183 | 184 | if __name__ == '__main__': 185 | gen_visotor() 186 | username, password = "18280484271", "@rufeng20001123" 187 | 188 | session.get("https://weibo.com/login.php", headers=headers) 189 | pre_login_time_start = timestamp() 190 | servertime, pcid, nonce, pubkey, rsakv, exec_time = pre_login(username) 191 | login_res = do_login(username, password, servertime, nonce, rsakv, pubkey, exec_time, pre_login_time_start) 192 | redirect_url = re.search('location\.replace\("(.*?)"\)', login_res.content.decode("gbk")).group(1) 193 | # res = session.get(redirect_url, headers=headers) 194 | redirect(redirect_url) 195 | -------------------------------------------------------------------------------- /新浪微博/login_qr_code.py: -------------------------------------------------------------------------------- 1 | import copy 2 | import hashlib 3 | import io 4 | import json 5 | import os 6 | import pickle 7 | import re 8 | import time 9 | from pathlib import Path 10 | import typing 11 | from abc import ABCMeta, abstractmethod 12 | 13 | import requests 14 | from redis import StrictRedis 15 | from requests import Session 16 | 17 | 18 | class SessionManager(metaclass=ABCMeta): 19 | @abstractmethod 20 | def store_session(self, session: Session): 21 | raise NotImplementedError 22 | 23 | @abstractmethod 24 | def load_session(self, **kwargs): 25 | raise NotImplementedError 26 | 27 | 28 | class RedisSessionManager(SessionManager): 29 | def __init__(self, username): 30 | self._redis = StrictRedis() 31 | self._redis_key = f"weibo:login:{username}" 32 | 33 | def store_session(self, session: Session): 34 | oo = io.BytesIO() 35 | pickle.dump(session, oo) 36 | self._redis.set(self._redis_key, oo.getvalue()) 37 | 38 | def load_session(self, **kwargs) -> typing.Union[Session, None]: 39 | value = self._redis.get(self._redis_key) 40 | if not value: 41 | return None 42 | return pickle.loads(value) 43 | 44 | 45 | def jsoncallback_str2json(text: str) -> dict: 46 | return json.loads(re.search(r"\(({.*?})\)", text).group(1)) 47 | 48 | 49 | class WeiboLoginScanQrCode(object): 50 | def __init__(self, session_manager: SessionManager = None, **kwargs): 51 | self.session_manager = session_manager 52 | self.session = (session_manager and session_manager.load_session(**kwargs)) or requests.session() 53 | headers = { 54 | 'Accept': '*/*', 55 | 'Accept-Encoding': 'gzip, deflate, br', 56 | 'Accept-Language': 'zh-CN,zh;q=0.9', 57 | 'Cache-Control': 'no-cache', 58 | 'Connection': 'keep-alive', 59 | 'Pragma': 'no-cache', 60 | 'sec-ch-ua': '"Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"', 61 | 'sec-ch-ua-mobile': '?0', 62 | 'sec-ch-ua-platform': '"Windows"', 63 | 'Sec-Fetch-Dest': 'script', 64 | 'Sec-Fetch-Mode': 'no-cors', 65 | 'Sec-Fetch-Site': 'cross-site', 66 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36', 67 | } 68 | self.session.headers.update(headers) 69 | 70 | def _is_login(self): 71 | response = self.session.get("https://security.weibo.com/account/security", allow_redirects=False) 72 | return response.status_code == 200 73 | 74 | def _download_qr_image(self) -> tuple: 75 | """ 76 | :return: (二维码图片绝对路径, qrid) 77 | """ 78 | response = self.session.get( 79 | "https://login.sina.com.cn/sso/qrcode/image?entry=sinawap&size=180&callback=STK_%s" % ( 80 | int(time.time() * 1000))) 81 | data = jsoncallback_str2json(response.text)['data'] 82 | qrid = data['qrid'] 83 | res = self.session.get(data['image']) 84 | file = os.path.join(os.path.expanduser('~'), hashlib.md5(str(time.time()).encode()).hexdigest() + ".png") 85 | Path(file).write_bytes(res.content) 86 | return file, qrid 87 | 88 | def _wait_for_scan(self, file: str, qrid: str) -> str: 89 | """ 90 | :param file: 图片绝对路径 91 | :param qrid: qrid 92 | :return: 登录的alt 93 | """ 94 | command = f'start "Pillow" /WAIT "{file}" && ping -n 2 127.0.0.1 >NUL && del /f "{file}"' 95 | os.system(command) 96 | 97 | alt = "" 98 | while True: 99 | res = self.session.get( 100 | "https://login.sina.com.cn/sso/qrcode/check?entry=sinawap&qrid={}&callback=STK_{}".format( 101 | qrid, int(time.time() * 1000))) 102 | res_json = json.loads(re.search(r"\(({.*?})\)", res.text).group(1)) 103 | if res_json['retcode'] == 50114003: 104 | print(res_json['msg']) 105 | break 106 | 107 | if res_json['retcode'] == 20000000: 108 | print("扫码成功!") 109 | alt = res_json["data"]["alt"] 110 | break 111 | 112 | time.sleep(1) 113 | 114 | if not alt: 115 | print("登录失败!") 116 | exit(0) 117 | 118 | return alt 119 | 120 | # def _visitor(self): 121 | # """ 122 | # 模拟访客,新浪访客系统 123 | # :return: 124 | # """ 125 | # gen_visotor_url = "https://passport.weibo.com/visitor/genvisitor" 126 | # data = {'cb': 'gen_callback', 127 | # 'fp': '{"os":"1","browser":"Chrome95,0,4638,69","fonts":"undefined","screenInfo":"1536*864*24","plugins":"Portable Document Format::internal-pdf-viewer::PDF Viewer|Portable Document Format::internal-pdf-viewer::Chrome PDF Viewer|Portable Document Format::internal-pdf-viewer::Chromium PDF Viewer|Portable Document Format::internal-pdf-viewer::Microsoft Edge PDF Viewer|Portable Document Format::internal-pdf-viewer::WebKit built-in PDF"}'} 128 | # response = self.session.post(gen_visotor_url, data=data) 129 | # tid = re.search('"tid":"(.*?)"', response.text).group(1) 130 | # tid = re.sub(r"\\/", "/", tid) 131 | # self.session.cookies.set("tid", tid + "__095", domain='.passport.weibo.com', path='/visitor') 132 | # 133 | # params = {"a": "incarnate", 134 | # "t": tid, 135 | # "w": "2", 136 | # "c": "095", 137 | # "gc": "", 138 | # "cb": "cross_domain", 139 | # "from": "weibo", 140 | # "_rand": "0.5799231670299148"} 141 | # self.session.get("https://passport.weibo.com/visitor/visitor", params=params, allow_redirects=False) 142 | 143 | # self.session.get("https://weibo.com", allow_redirects=False) 144 | 145 | def login(self): 146 | """ 147 | :return: 登录成功的session 148 | """ 149 | if self._is_login(): 150 | print("cookie有效!") 151 | return self.session 152 | 153 | print("不存在cookie或cookie过时!,重新登录!") 154 | file, qrid = self._download_qr_image() 155 | alt = self._wait_for_scan(file, qrid) 156 | response = self.session.get( 157 | f"https://login.sina.com.cn/sso/login.php?entry=sinawap&returntype=TEXT&crossdomain=1&cdult=3&domain=weibo.com&alt={alt}&savestate=30&callback=STK_{int(time.time() * 1000)}") 158 | 159 | data = jsoncallback_str2json(response.text) 160 | cross_domain_urls, uid, nick = data["crossDomainUrlList"], data['uid'], data['nick'] 161 | for url in cross_domain_urls: 162 | self.session.get(url) 163 | 164 | self._cross_domain() 165 | self.session.get("https://weibo.com/newlogin?tabtype=weibo&gid=102803&url=https%3A%2F%2Fweibo.com%2F") 166 | 167 | self.session.headers["traceparent"] = "00-46d545e2f58917a67fed36addafd5996-7072876a58e5ea30-00" 168 | self.session.headers['x-xsrf-token'] = self.session.cookies.get('XSRF-TOKEN') 169 | 170 | if self._is_login(): 171 | print("访问安全页面") 172 | 173 | print(f"uid: {uid}, nickname: {nick}, 登录成功!") 174 | 175 | if self.session_manager: 176 | self.session_manager.store_session(self.session) 177 | 178 | return self.session 179 | 180 | def _cross_domain(self): 181 | """ 182 | 默认cookie是.login.sina.com,我们设置成所有网站 183 | :return: 184 | """ 185 | cookies = copy.deepcopy(self.session.cookies) 186 | for k, v in cookies.items(): 187 | self.session.cookies.set(k, v) 188 | 189 | 190 | if __name__ == '__main__': 191 | s = RedisSessionManager(18280484271) 192 | session = WeiboLoginScanQrCode(session_manager=s).login() 193 | -------------------------------------------------------------------------------- /新浪微博/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const sinaSSOEncoder = require('./sinaSSOEncoder'); 3 | const bodyParser = require('body-parser'); 4 | const app = express(); 5 | const port = 8000; 6 | 7 | app.use(bodyParser.urlencoded({limit: "2100000kb"})); 8 | 9 | app.post('/', (req, res) => { 10 | const f = new sinaSSOEncoder.RSAKey; 11 | const me = req.body; 12 | console.log(me.pubkey); 13 | f.setPublic(me.pubkey, "10001"); 14 | b = f.encrypt([me.servertime, me.nonce].join("\t") + "\n" + me.password); 15 | res.send(b); 16 | }); 17 | 18 | app.listen(port, () => { 19 | console.log(`Example app listening at http://localhost:${port}`) 20 | }); 21 | 22 | -------------------------------------------------------------------------------- /新浪微博/sinaSSOEncoder.js: -------------------------------------------------------------------------------- 1 | const sinaSSOEncoder = {}; 2 | const window = global; 3 | const navigator = {"appName": "Netscape"}; 4 | window.appVersion = "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"; 5 | (function () { 6 | function bt(a) { 7 | var b = bp(a, this.n.bitLength() + 7 >> 3); 8 | if (b == null) 9 | return null; 10 | var c = this.doPublic(b); 11 | if (c == null) 12 | return null; 13 | var d = c.toString(16); 14 | return (d.length & 1) == 0 ? d : "0" + d 15 | } 16 | 17 | function bs(a) { 18 | return a.modPowInt(this.e, this.n) 19 | } 20 | 21 | function br(a, b) { 22 | if (a != null && b != null && a.length > 0 && b.length > 0) { 23 | this.n = bm(a, 16); 24 | this.e = parseInt(b, 16) 25 | } else 26 | alert("Invalid RSA public key") 27 | } 28 | 29 | function bq() { 30 | this.n = null; 31 | this.e = 0; 32 | this.d = null; 33 | this.p = null; 34 | this.q = null; 35 | this.dmp1 = null; 36 | this.dmq1 = null; 37 | this.coeff = null 38 | } 39 | 40 | function bp(a, b) { 41 | if (b < a.length + 11) { 42 | alert("Message too long for RSA"); 43 | return null 44 | } 45 | var c = [] 46 | , e = a.length - 1; 47 | while (e >= 0 && b > 0) { 48 | var f = a.charCodeAt(e--); 49 | if (f < 128) 50 | c[--b] = f; 51 | else if (f > 127 && f < 2048) { 52 | c[--b] = f & 63 | 128; 53 | c[--b] = f >> 6 | 192 54 | } else { 55 | c[--b] = f & 63 | 128; 56 | c[--b] = f >> 6 & 63 | 128; 57 | c[--b] = f >> 12 | 224 58 | } 59 | } 60 | c[--b] = 0; 61 | var g = new bl 62 | , h = []; 63 | while (b > 2) { 64 | h[0] = 0; 65 | while (h[0] == 0) 66 | g.nextBytes(h); 67 | c[--b] = h[0] 68 | } 69 | c[--b] = 2; 70 | c[--b] = 0; 71 | return new d(c) 72 | } 73 | 74 | function bo(a) { 75 | return a < 16 ? "0" + a.toString(16) : a.toString(16) 76 | } 77 | 78 | function bn(a, b) { 79 | var c = "" 80 | , d = 0; 81 | while (d + b < a.length) { 82 | c += a.substring(d, d + b) + "\n"; 83 | d += b 84 | } 85 | return c + a.substring(d, a.length) 86 | } 87 | 88 | function bm(a, b) { 89 | return new d(a, b) 90 | } 91 | 92 | function bl() { 93 | } 94 | 95 | function bk(a) { 96 | var b; 97 | for (b = 0; b < a.length; ++b) 98 | a[b] = bj() 99 | } 100 | 101 | function bj() { 102 | if (bc == null) { 103 | bg(); 104 | bc = ba(); 105 | bc.init(bd); 106 | for (be = 0; be < bd.length; ++be) 107 | bd[be] = 0; 108 | be = 0 109 | } 110 | return bc.next() 111 | } 112 | 113 | function bg() { 114 | bf((new Date).getTime()) 115 | } 116 | 117 | function bf(a) { 118 | bd[be++] ^= a & 255; 119 | bd[be++] ^= a >> 8 & 255; 120 | bd[be++] ^= a >> 16 & 255; 121 | bd[be++] ^= a >> 24 & 255; 122 | be >= bb && (be -= bb) 123 | } 124 | 125 | function ba() { 126 | return new Z 127 | } 128 | 129 | function _() { 130 | var a; 131 | this.i = this.i + 1 & 255; 132 | this.j = this.j + this.S[this.i] & 255; 133 | a = this.S[this.i]; 134 | this.S[this.i] = this.S[this.j]; 135 | this.S[this.j] = a; 136 | return this.S[a + this.S[this.i] & 255] 137 | } 138 | 139 | function $(a) { 140 | var b, c, d; 141 | for (b = 0; b < 256; ++b) 142 | this.S[b] = b; 143 | c = 0; 144 | for (b = 0; b < 256; ++b) { 145 | c = c + this.S[b] + a[b % a.length] & 255; 146 | d = this.S[b]; 147 | this.S[b] = this.S[c]; 148 | this.S[c] = d 149 | } 150 | this.i = 0; 151 | this.j = 0 152 | } 153 | 154 | function Z() { 155 | this.i = 0; 156 | this.j = 0; 157 | this.S = [] 158 | } 159 | 160 | function Y(a, b) { 161 | var c; 162 | a < 256 || b.isEven() ? c = new J(b) : c = new Q(b); 163 | return this.exp(a, c) 164 | } 165 | 166 | function X(a, b) { 167 | if (a > 4294967295 || a < 1) 168 | return d.ONE; 169 | var c = e() 170 | , f = e() 171 | , g = b.convert(this) 172 | , h = y(a) - 1; 173 | g.copyTo(c); 174 | while (--h >= 0) { 175 | b.sqrTo(c, f); 176 | if ((a & 1 << h) > 0) 177 | b.mulTo(f, g, c); 178 | else { 179 | var i = c; 180 | c = f; 181 | f = i 182 | } 183 | } 184 | return b.revert(c) 185 | } 186 | 187 | function W() { 188 | return (this.t > 0 ? this[0] & 1 : this.s) == 0 189 | } 190 | 191 | function V(a, b, c) { 192 | a.multiplyTo(b, c); 193 | this.reduce(c) 194 | } 195 | 196 | function U(a, b) { 197 | a.squareTo(b); 198 | this.reduce(b) 199 | } 200 | 201 | function T(a) { 202 | while (a.t <= this.mt2) 203 | a[a.t++] = 0; 204 | for (var b = 0; b < this.m.t; ++b) { 205 | var c = a[b] & 32767 206 | , d = c * this.mpl + ((c * this.mph + (a[b] >> 15) * this.mpl & this.um) << 15) & a.DM; 207 | c = b + this.m.t; 208 | a[c] += this.m.am(0, d, a, b, 0, this.m.t); 209 | while (a[c] >= a.DV) { 210 | a[c] -= a.DV; 211 | a[++c]++ 212 | } 213 | } 214 | a.clamp(); 215 | a.drShiftTo(this.m.t, a); 216 | a.compareTo(this.m) >= 0 && a.subTo(this.m, a) 217 | } 218 | 219 | function S(a) { 220 | var b = e(); 221 | a.copyTo(b); 222 | this.reduce(b); 223 | return b 224 | } 225 | 226 | function R(a) { 227 | var b = e(); 228 | a.abs().dlShiftTo(this.m.t, b); 229 | b.divRemTo(this.m, null, b); 230 | a.s < 0 && b.compareTo(d.ZERO) > 0 && this.m.subTo(b, b); 231 | return b 232 | } 233 | 234 | function Q(a) { 235 | this.m = a; 236 | this.mp = a.invDigit(); 237 | this.mpl = this.mp & 32767; 238 | this.mph = this.mp >> 15; 239 | this.um = (1 << a.DB - 15) - 1; 240 | this.mt2 = 2 * a.t 241 | } 242 | 243 | function P() { 244 | if (this.t < 1) 245 | return 0; 246 | var a = this[0]; 247 | if ((a & 1) == 0) 248 | return 0; 249 | var b = a & 3; 250 | b = b * (2 - (a & 15) * b) & 15; 251 | b = b * (2 - (a & 255) * b) & 255; 252 | b = b * (2 - ((a & 65535) * b & 65535)) & 65535; 253 | b = b * (2 - a * b % this.DV) % this.DV; 254 | return b > 0 ? this.DV - b : -b 255 | } 256 | 257 | function O(a, b) { 258 | a.squareTo(b); 259 | this.reduce(b) 260 | } 261 | 262 | function N(a, b, c) { 263 | a.multiplyTo(b, c); 264 | this.reduce(c) 265 | } 266 | 267 | function M(a) { 268 | a.divRemTo(this.m, null, a) 269 | } 270 | 271 | function L(a) { 272 | return a 273 | } 274 | 275 | function K(a) { 276 | return a.s < 0 || a.compareTo(this.m) >= 0 ? a.mod(this.m) : a 277 | } 278 | 279 | function J(a) { 280 | this.m = a 281 | } 282 | 283 | function I(a) { 284 | var b = e(); 285 | this.abs().divRemTo(a, null, b); 286 | this.s < 0 && b.compareTo(d.ZERO) > 0 && a.subTo(b, b); 287 | return b 288 | } 289 | 290 | function H(a, b, c) { 291 | var f = a.abs(); 292 | if (!(f.t <= 0)) { 293 | var g = this.abs(); 294 | if (g.t < f.t) { 295 | b != null && b.fromInt(0); 296 | c != null && this.copyTo(c); 297 | return 298 | } 299 | c == null && (c = e()); 300 | var h = e() 301 | , i = this.s 302 | , j = a.s 303 | , k = this.DB - y(f[f.t - 1]); 304 | if (k > 0) { 305 | f.lShiftTo(k, h); 306 | g.lShiftTo(k, c) 307 | } else { 308 | f.copyTo(h); 309 | g.copyTo(c) 310 | } 311 | var l = h.t 312 | , m = h[l - 1]; 313 | if (m == 0) 314 | return; 315 | var n = m * (1 << this.F1) + (l > 1 ? h[l - 2] >> this.F2 : 0) 316 | , o = this.FV / n 317 | , p = (1 << this.F1) / n 318 | , q = 1 << this.F2 319 | , r = c.t 320 | , s = r - l 321 | , t = b == null ? e() : b; 322 | h.dlShiftTo(s, t); 323 | if (c.compareTo(t) >= 0) { 324 | c[c.t++] = 1; 325 | c.subTo(t, c) 326 | } 327 | d.ONE.dlShiftTo(l, t); 328 | t.subTo(h, h); 329 | while (h.t < l) 330 | h[h.t++] = 0; 331 | while (--s >= 0) { 332 | var u = c[--r] == m ? this.DM : Math.floor(c[r] * o + (c[r - 1] + q) * p); 333 | if ((c[r] += h.am(0, u, c, s, 0, l)) < u) { 334 | h.dlShiftTo(s, t); 335 | c.subTo(t, c); 336 | while (c[r] < --u) 337 | c.subTo(t, c) 338 | } 339 | } 340 | if (b != null) { 341 | c.drShiftTo(l, b); 342 | i != j && d.ZERO.subTo(b, b) 343 | } 344 | c.t = l; 345 | c.clamp(); 346 | k > 0 && c.rShiftTo(k, c); 347 | i < 0 && d.ZERO.subTo(c, c) 348 | } 349 | } 350 | 351 | function G(a) { 352 | var b = this.abs() 353 | , c = a.t = 2 * b.t; 354 | while (--c >= 0) 355 | a[c] = 0; 356 | for (c = 0; c < b.t - 1; ++c) { 357 | var d = b.am(c, b[c], a, 2 * c, 0, 1); 358 | if ((a[c + b.t] += b.am(c + 1, 2 * b[c], a, 2 * c + 1, d, b.t - c - 1)) >= b.DV) { 359 | a[c + b.t] -= b.DV; 360 | a[c + b.t + 1] = 1 361 | } 362 | } 363 | a.t > 0 && (a[a.t - 1] += b.am(c, b[c], a, 2 * c, 0, 1)); 364 | a.s = 0; 365 | a.clamp() 366 | } 367 | 368 | function F(a, b) { 369 | var c = this.abs() 370 | , e = a.abs() 371 | , f = c.t; 372 | b.t = f + e.t; 373 | while (--f >= 0) 374 | b[f] = 0; 375 | for (f = 0; f < e.t; ++f) 376 | b[f + c.t] = c.am(0, e[f], b, f, 0, c.t); 377 | b.s = 0; 378 | b.clamp(); 379 | this.s != a.s && d.ZERO.subTo(b, b) 380 | } 381 | 382 | function E(a, b) { 383 | var c = 0 384 | , d = 0 385 | , e = Math.min(a.t, this.t); 386 | while (c < e) { 387 | d += this[c] - a[c]; 388 | b[c++] = d & this.DM; 389 | d >>= this.DB 390 | } 391 | if (a.t < this.t) { 392 | d -= a.s; 393 | while (c < this.t) { 394 | d += this[c]; 395 | b[c++] = d & this.DM; 396 | d >>= this.DB 397 | } 398 | d += this.s 399 | } else { 400 | d += this.s; 401 | while (c < a.t) { 402 | d -= a[c]; 403 | b[c++] = d & this.DM; 404 | d >>= this.DB 405 | } 406 | d -= a.s 407 | } 408 | b.s = d < 0 ? -1 : 0; 409 | d < -1 ? b[c++] = this.DV + d : d > 0 && (b[c++] = d); 410 | b.t = c; 411 | b.clamp() 412 | } 413 | 414 | function D(a, b) { 415 | b.s = this.s; 416 | var c = Math.floor(a / this.DB); 417 | if (c >= this.t) 418 | b.t = 0; 419 | else { 420 | var d = a % this.DB 421 | , e = this.DB - d 422 | , f = (1 << d) - 1; 423 | b[0] = this[c] >> d; 424 | for (var g = c + 1; g < this.t; ++g) { 425 | b[g - c - 1] |= (this[g] & f) << e; 426 | b[g - c] = this[g] >> d 427 | } 428 | d > 0 && (b[this.t - c - 1] |= (this.s & f) << e); 429 | b.t = this.t - c; 430 | b.clamp() 431 | } 432 | } 433 | 434 | function C(a, b) { 435 | var c = a % this.DB, d = this.DB - c, e = (1 << d) - 1, f = Math.floor(a / this.DB), g = this.s << c & this.DM, 436 | h; 437 | for (h = this.t - 1; h >= 0; --h) { 438 | b[h + f + 1] = this[h] >> d | g; 439 | g = (this[h] & e) << c 440 | } 441 | for (h = f - 1; h >= 0; --h) 442 | b[h] = 0; 443 | b[f] = g; 444 | b.t = this.t + f + 1; 445 | b.s = this.s; 446 | b.clamp() 447 | } 448 | 449 | function B(a, b) { 450 | for (var c = a; c < this.t; ++c) 451 | b[c - a] = this[c]; 452 | b.t = Math.max(this.t - a, 0); 453 | b.s = this.s 454 | } 455 | 456 | function A(a, b) { 457 | var c; 458 | for (c = this.t - 1; c >= 0; --c) 459 | b[c + a] = this[c]; 460 | for (c = a - 1; c >= 0; --c) 461 | b[c] = 0; 462 | b.t = this.t + a; 463 | b.s = this.s 464 | } 465 | 466 | function z() { 467 | return this.t <= 0 ? 0 : this.DB * (this.t - 1) + y(this[this.t - 1] ^ this.s & this.DM) 468 | } 469 | 470 | function y(a) { 471 | var b = 1, c; 472 | if ((c = a >>> 16) != 0) { 473 | a = c; 474 | b += 16 475 | } 476 | if ((c = a >> 8) != 0) { 477 | a = c; 478 | b += 8 479 | } 480 | if ((c = a >> 4) != 0) { 481 | a = c; 482 | b += 4 483 | } 484 | if ((c = a >> 2) != 0) { 485 | a = c; 486 | b += 2 487 | } 488 | if ((c = a >> 1) != 0) { 489 | a = c; 490 | b += 1 491 | } 492 | return b 493 | } 494 | 495 | function x(a) { 496 | var b = this.s - a.s; 497 | if (b != 0) 498 | return b; 499 | var c = this.t; 500 | b = c - a.t; 501 | if (b != 0) 502 | return b; 503 | while (--c >= 0) 504 | if ((b = this[c] - a[c]) != 0) 505 | return b; 506 | return 0 507 | } 508 | 509 | function w() { 510 | return this.s < 0 ? this.negate() : this 511 | } 512 | 513 | function v() { 514 | var a = e(); 515 | d.ZERO.subTo(this, a); 516 | return a 517 | } 518 | 519 | function u(a) { 520 | if (this.s < 0) 521 | return "-" + this.negate().toString(a); 522 | var b; 523 | if (a == 16) 524 | b = 4; 525 | else if (a == 8) 526 | b = 3; 527 | else if (a == 2) 528 | b = 1; 529 | else if (a == 32) 530 | b = 5; 531 | else if (a == 4) 532 | b = 2; 533 | else 534 | return this.toRadix(a); 535 | var c = (1 << b) - 1, d, e = !1, f = "", g = this.t, h = this.DB - g * this.DB % b; 536 | if (g-- > 0) { 537 | if (h < this.DB && (d = this[g] >> h) > 0) { 538 | e = !0; 539 | f = n(d) 540 | } 541 | while (g >= 0) { 542 | if (h < b) { 543 | d = (this[g] & (1 << h) - 1) << b - h; 544 | d |= this[--g] >> (h += this.DB - b) 545 | } else { 546 | d = this[g] >> (h -= b) & c; 547 | if (h <= 0) { 548 | h += this.DB; 549 | --g 550 | } 551 | } 552 | d > 0 && (e = !0); 553 | e && (f += n(d)) 554 | } 555 | } 556 | return e ? f : "0" 557 | } 558 | 559 | function t() { 560 | var a = this.s & this.DM; 561 | while (this.t > 0 && this[this.t - 1] == a) 562 | --this.t 563 | } 564 | 565 | function s(a, b) { 566 | var c; 567 | if (b == 16) 568 | c = 4; 569 | else if (b == 8) 570 | c = 3; 571 | else if (b == 256) 572 | c = 8; 573 | else if (b == 2) 574 | c = 1; 575 | else if (b == 32) 576 | c = 5; 577 | else if (b == 4) 578 | c = 2; 579 | else { 580 | this.fromRadix(a, b); 581 | return 582 | } 583 | this.t = 0; 584 | this.s = 0; 585 | var e = a.length 586 | , f = !1 587 | , g = 0; 588 | while (--e >= 0) { 589 | var h = c == 8 ? a[e] & 255 : o(a, e); 590 | if (h < 0) { 591 | a.charAt(e) == "-" && (f = !0); 592 | continue 593 | } 594 | f = !1; 595 | if (g == 0) 596 | this[this.t++] = h; 597 | else if (g + c > this.DB) { 598 | this[this.t - 1] |= (h & (1 << this.DB - g) - 1) << g; 599 | this[this.t++] = h >> this.DB - g 600 | } else 601 | this[this.t - 1] |= h << g; 602 | g += c; 603 | g >= this.DB && (g -= this.DB) 604 | } 605 | if (c == 8 && (a[0] & 128) != 0) { 606 | this.s = -1; 607 | g > 0 && (this[this.t - 1] |= (1 << this.DB - g) - 1 << g) 608 | } 609 | this.clamp(); 610 | f && d.ZERO.subTo(this, this) 611 | } 612 | 613 | function r(a) { 614 | var b = e(); 615 | b.fromInt(a); 616 | return b 617 | } 618 | 619 | function q(a) { 620 | this.t = 1; 621 | this.s = a < 0 ? -1 : 0; 622 | a > 0 ? this[0] = a : a < -1 ? this[0] = a + DV : this.t = 0 623 | } 624 | 625 | function p(a) { 626 | for (var b = this.t - 1; b >= 0; --b) 627 | a[b] = this[b]; 628 | a.t = this.t; 629 | a.s = this.s 630 | } 631 | 632 | function o(a, b) { 633 | var c = k[a.charCodeAt(b)]; 634 | return c == null ? -1 : c 635 | } 636 | 637 | function n(a) { 638 | return j.charAt(a) 639 | } 640 | 641 | function h(a, b, c, d, e, f) { 642 | var g = b & 16383 643 | , h = b >> 14; 644 | while (--f >= 0) { 645 | var i = this[a] & 16383 646 | , j = this[a++] >> 14 647 | , k = h * i + j * g; 648 | i = g * i + ((k & 16383) << 14) + c[d] + e; 649 | e = (i >> 28) + (k >> 14) + h * j; 650 | c[d++] = i & 268435455 651 | } 652 | return e 653 | } 654 | 655 | function g(a, b, c, d, e, f) { 656 | var g = b & 32767 657 | , h = b >> 15; 658 | while (--f >= 0) { 659 | var i = this[a] & 32767 660 | , j = this[a++] >> 15 661 | , k = h * i + j * g; 662 | i = g * i + ((k & 32767) << 15) + c[d] + (e & 1073741823); 663 | e = (i >>> 30) + (k >>> 15) + h * j + (e >>> 30); 664 | c[d++] = i & 1073741823 665 | } 666 | return e 667 | } 668 | 669 | function f(a, b, c, d, e, f) { 670 | while (--f >= 0) { 671 | var g = b * this[a++] + c[d] + e; 672 | e = Math.floor(g / 67108864); 673 | c[d++] = g & 67108863 674 | } 675 | return e 676 | } 677 | 678 | function e() { 679 | return new d(null) 680 | } 681 | 682 | function d(a, b, c) { 683 | a != null && ("number" == typeof a ? this.fromNumber(a, b, c) : b == null && "string" != typeof a ? this.fromString(a, 256) : this.fromString(a, b)) 684 | } 685 | 686 | var a, b = 0xdeadbeefcafe, c = (b & 16777215) == 15715070; 687 | if (c && navigator.appName == "Microsoft Internet Explorer") { 688 | d.prototype.am = g; 689 | a = 30 690 | } else if (c && navigator.appName != "Netscape") { 691 | d.prototype.am = f; 692 | a = 26 693 | } else { 694 | d.prototype.am = h; 695 | a = 28 696 | } 697 | d.prototype.DB = a; 698 | d.prototype.DM = (1 << a) - 1; 699 | d.prototype.DV = 1 << a; 700 | var i = 52; 701 | d.prototype.FV = Math.pow(2, i); 702 | d.prototype.F1 = i - a; 703 | d.prototype.F2 = 2 * a - i; 704 | var j = "0123456789abcdefghijklmnopqrstuvwxyz", k = [], l, m; 705 | l = "0".charCodeAt(0); 706 | for (m = 0; m <= 9; ++m) 707 | k[l++] = m; 708 | l = "a".charCodeAt(0); 709 | for (m = 10; m < 36; ++m) 710 | k[l++] = m; 711 | l = "A".charCodeAt(0); 712 | for (m = 10; m < 36; ++m) 713 | k[l++] = m; 714 | J.prototype.convert = K; 715 | J.prototype.revert = L; 716 | J.prototype.reduce = M; 717 | J.prototype.mulTo = N; 718 | J.prototype.sqrTo = O; 719 | Q.prototype.convert = R; 720 | Q.prototype.revert = S; 721 | Q.prototype.reduce = T; 722 | Q.prototype.mulTo = V; 723 | Q.prototype.sqrTo = U; 724 | d.prototype.copyTo = p; 725 | d.prototype.fromInt = q; 726 | d.prototype.fromString = s; 727 | d.prototype.clamp = t; 728 | d.prototype.dlShiftTo = A; 729 | d.prototype.drShiftTo = B; 730 | d.prototype.lShiftTo = C; 731 | d.prototype.rShiftTo = D; 732 | d.prototype.subTo = E; 733 | d.prototype.multiplyTo = F; 734 | d.prototype.squareTo = G; 735 | d.prototype.divRemTo = H; 736 | d.prototype.invDigit = P; 737 | d.prototype.isEven = W; 738 | d.prototype.exp = X; 739 | d.prototype.toString = u; 740 | d.prototype.negate = v; 741 | d.prototype.abs = w; 742 | d.prototype.compareTo = x; 743 | d.prototype.bitLength = z; 744 | d.prototype.mod = I; 745 | d.prototype.modPowInt = Y; 746 | d.ZERO = r(0); 747 | d.ONE = r(1); 748 | Z.prototype.init = $; 749 | Z.prototype.next = _; 750 | var bb = 256, bc, bd, be; 751 | if (bd == null) { 752 | bd = []; 753 | be = 0; 754 | var bh; 755 | if (navigator.appName == "Netscape" && navigator.appVersion < "5" && window.crypto && typeof window.crypto.random == "function") { 756 | var bi = window.crypto.random(32); 757 | for (bh = 0; bh < bi.length; ++bh) 758 | bd[be++] = bi.charCodeAt(bh) & 255 759 | } 760 | while (be < bb) { 761 | bh = Math.floor(65536 * Math.random()); 762 | bd[be++] = bh >>> 8; 763 | bd[be++] = bh & 255 764 | } 765 | be = 0; 766 | bg() 767 | } 768 | bl.prototype.nextBytes = bk; 769 | bq.prototype.doPublic = bs; 770 | bq.prototype.setPublic = br; 771 | bq.prototype.encrypt = bt; 772 | this.RSAKey = bq; 773 | }).call(sinaSSOEncoder); 774 | 775 | module.exports = sinaSSOEncoder; -------------------------------------------------------------------------------- /有道翻译/trans.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/12/22/22:10 4 | description 5 | """ 6 | import hashlib 7 | import random 8 | import time 9 | 10 | import requests 11 | 12 | 13 | class YouDaoTranslation: 14 | def __init__(self): 15 | self.session = requests.Session() 16 | headers = { 17 | "Origin": "https://fanyi.youdao.com", 18 | "Referer": "https://fanyi.youdao.com/", 19 | # "Cookie": "OUTFOX_SEARCH_USER_ID_NCOO=1806019051.9222953; OUTFOX_SEARCH_USER_ID=144129320@182.139.46.64; ___rl__test__cookies=1640183554281", 20 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36", 21 | } 22 | self.trans_url = "https://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule" 23 | self.session.headers.update(headers) 24 | self.session.get("https://fanyi.youdao.com/") 25 | 26 | def _salt_sign(self, word: str) -> dict: 27 | t = "fdac15c78f51b91dabd0a15d9a1b10f5" 28 | r = str(int(time.time() * 1000)) 29 | i = r + "1" 30 | return { 31 | "bv": t, 32 | "ts": r, 33 | "salt": i, 34 | "sign": hashlib.md5(("fanyideskweb" + word + i + "Y2FYu%TNSbMCxc3t2u^XT").encode()).hexdigest() 35 | } 36 | 37 | def traslate(self, word: str, from_lang: str = "AUTO", to_lang: str = "AUTO"): 38 | sign = self._salt_sign(word) 39 | 40 | formdata = { 41 | 'i': word, 42 | 'from': from_lang, 43 | 'to': to_lang, 44 | 'smartresult': 'dict', 45 | 'client': 'fanyideskweb', 46 | 'salt': sign['salt'], 47 | 'sign': sign['sign'], 48 | 'lts': sign['ts'], 49 | 'bv': sign['bv'], 50 | 'doctype': 'json', 51 | 'version': '2.1', 52 | 'keyfrom': 'fanyi.web', 53 | 'action': 'FY_BY_CLICKBUTTION' 54 | } 55 | self.session.cookies.set("OUTFOX_SEARCH_USER_ID_NCOO", str(2147483647 * random.random()), domain=".youdao.com") 56 | self.session.cookies.set("___rl__test__cookies", str(int(time.time() * 1000)), domain="fanyi.youdao.com") 57 | print(self.session.post(self.trans_url, data=formdata).text) 58 | 59 | 60 | if __name__ == '__main__': 61 | y = YouDaoTranslation() 62 | y.traslate("Python") 63 | -------------------------------------------------------------------------------- /水信息系统/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const waterSecurity = require('./waterSecurity'); 3 | const bodyParser = require('body-parser'); 4 | const app = express(); 5 | /* 设置传输大小限制 */ 6 | app.use(bodyParser.urlencoded({limit: "2100000kb"})); 7 | app.use(bodyParser.json({limit: "2100000kb"})); 8 | const port = 8000 9 | 10 | app.post('/encode', (req, res) => { 11 | const resJson = waterSecurity.paramEncode(req.body); 12 | res.json(resJson); 13 | }) 14 | 15 | app.post('/decode', (req, res) => { 16 | const result = waterSecurity.decode(req.body.data); 17 | res.json(result); 18 | }); 19 | 20 | app.listen(port, () => { 21 | console.log(`Example app listening at http://localhost:${port}`) 22 | }) 23 | -------------------------------------------------------------------------------- /水信息系统/water.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/03/12:32 4 | description 5 | """ 6 | import datetime 7 | import random 8 | 9 | import requests 10 | 11 | headers = { 12 | 'Accept': '*/*', 13 | 'Accept-Encoding': 'gzip, deflate', 14 | 'Accept-Language': 'zh-CN,zh;q=0.9', 15 | 'Cache-Control': 'no-cache', 16 | 'Connection': 'keep-alive', 17 | 'Host': '61.191.22.196:5566', 18 | 'Origin': 'http://yc.wswj.net', 19 | 'Pragma': 'no-cache', 20 | 'Referer': 'http://yc.wswj.net/', 21 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36' 22 | } 23 | 24 | session = requests.session() 25 | 26 | 27 | def encode(data: dict) -> dict: 28 | return session.post("http://127.0.0.1:8000/encode", data=data).json() 29 | 30 | 31 | def decode(data: dict) -> dict: 32 | return session.post("http://127.0.0.1:8000/decode", data=data).json() 33 | 34 | 35 | if __name__ == '__main__': 36 | session.get("http://yc.wswj.net/ahsxx/LOL/public/public.html", headers=headers) 37 | rwData = { 38 | "hourClass": "1,2,3,6,12", 39 | "name": "SelectRainWarnInfo", 40 | "snsw": "sn", 41 | "time": "" 42 | } 43 | formdata = encode(rwData) 44 | formdata['random'] = random.random() 45 | ret = session.post("http://61.191.22.196:5566/AHSXX/service/PublicBusinessHandler.ashx", headers=headers, 46 | data=formdata) 47 | print("第一次请求:", decode(ret.json())) 48 | btime = datetime.datetime.now().strftime("%Y%m%d%H") + "00" 49 | etime = (datetime.datetime.now() + datetime.timedelta(hours=1)).strftime("%Y%m%d%H") + "00" 50 | m = { 51 | "btime": btime, 52 | "etime": etime, 53 | "fresh": 0, 54 | "heatRange": 50, 55 | "isoline": "N", 56 | "name": "SelectRainMapData", 57 | "points": "", 58 | "rainlevel": "A:10,25,50,100", 59 | "stcdtype": "1,0,0,0,0,0" 60 | } 61 | formdata = encode(m) 62 | formdata['random'] = random.random() 63 | ret = session.post("http://61.191.22.196:5566/AHSXX/service/PublicBusinessHandler.ashx", headers=headers, 64 | data=formdata) 65 | print("第二次请求:", decode(ret.json())) 66 | -------------------------------------------------------------------------------- /水信息系统/waterSecurity.js: -------------------------------------------------------------------------------- 1 | const waterSecurity = { 2 | version: "2.1", 3 | init: function () { 4 | String.prototype.gblen = function () { 5 | for (var r = 0, t = 0; t < this.length; t++) 6 | this.charCodeAt(t) > 127 || 94 == this.charCodeAt(t) ? r += 2 : r++; 7 | return r 8 | } 9 | }, 10 | encode: function (r) { 11 | if (this.print(r), 12 | "" == (r += "")) 13 | return ""; 14 | (r = encodeURI(r).replace(/\+/g, "%2B")).gblen() % 2 != 0 && (r += "*"), 15 | this.print(r), 16 | r = this.parityTransposition(r), 17 | this.print(r); 18 | var t = this.version + this.utf16to8(this.base64encode(r)); 19 | return this.print(t), 20 | t 21 | }, 22 | print: function (r) { 23 | }, 24 | parityTransposition: function (r) { 25 | for (var t = [], e = 0; e < r.length; e += 2) 26 | t.push(r[e + 1]), 27 | t.push(r[e]); 28 | return t = t.join("") 29 | }, 30 | decode: function (r) { 31 | if ("string" != typeof r && (r += ""), 32 | this.print(r), 33 | r.length < 5 && ("" == r || "null" == r)) 34 | return "[]"; 35 | if (this.version) { 36 | if (r.substring(0, 3) !== this.version) 37 | return alert("加解密版本不一致!"); 38 | r = r.substring(3, r.length) 39 | } 40 | let t, e, s, h = {}; 41 | t = r.substring(r.length - 4), 42 | e = r.substring(r.indexOf(t)), 43 | s = new Array, 44 | e = e.substring(4, e.length - 4); 45 | for (let r = 0; 4 * r < e.length; r++) { 46 | let t = e.substr(4 * r, 4); 47 | s[r] = t, 48 | h[t] = null 49 | } 50 | const n = this.getTagsPosition(r, s); 51 | let i = 0; 52 | for (c = 0; c < n.length; c++) { 53 | var a = r.substring(i, n[c]); 54 | h[r.substr(n[c], 4)] = a, 55 | i = n[c] + 4 56 | } 57 | r = null; 58 | for (var o = [], c = 0; c < s.length; c++) 59 | o.push(h[s[c]]); 60 | return o = o.join(""), 61 | o = this.utf8to16(this.base64decode(o)) 62 | }, 63 | getTagsPosition: function (r, t) { 64 | var e = new Array; 65 | for (i = 0; i < t.length; i++) 66 | e[i] = r.indexOf(t[i]); 67 | return e.sort(function (r, t) { 68 | return r > t ? 1 : -1 69 | }) 70 | }, 71 | base64EncodeChars: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 72 | base64DecodeChars: new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1), 73 | base64encode: function (r) { 74 | var t, e, s, h, n, i; 75 | for (s = r.length, 76 | e = 0, 77 | t = []; e < s;) { 78 | if (h = 255 & r.charCodeAt(e++), 79 | e == s) { 80 | t.push(this.base64EncodeChars.charAt(h >> 2)), 81 | t.push(this.base64EncodeChars.charAt((3 & h) << 4)), 82 | t.push("=="); 83 | break 84 | } 85 | if (n = r.charCodeAt(e++), 86 | e == s) { 87 | t.push(this.base64EncodeChars.charAt(h >> 2)), 88 | t.push(this.base64EncodeChars.charAt((3 & h) << 4 | (240 & n) >> 4)), 89 | t.push(this.base64EncodeChars.charAt((15 & n) << 2)), 90 | t.push("="); 91 | break 92 | } 93 | i = r.charCodeAt(e++), 94 | t.push(this.base64EncodeChars.charAt(h >> 2)), 95 | t.push(this.base64EncodeChars.charAt((3 & h) << 4 | (240 & n) >> 4)), 96 | t.push(this.base64EncodeChars.charAt((15 & n) << 2 | (192 & i) >> 6)), 97 | t.push(this.base64EncodeChars.charAt(63 & i)) 98 | } 99 | return t.join("") 100 | }, 101 | base64decode: function (r) { 102 | var t, e, s, h, n, i, a; 103 | for (i = r.length, 104 | n = 0, 105 | a = []; n < i;) { 106 | do { 107 | t = this.base64DecodeChars[255 & r.charCodeAt(n++)] 108 | } while (n < i && -1 == t); 109 | if (-1 == t) 110 | break; 111 | do { 112 | e = this.base64DecodeChars[255 & r.charCodeAt(n++)] 113 | } while (n < i && -1 == e); 114 | if (-1 == e) 115 | break; 116 | a.push(String.fromCharCode(t << 2 | (48 & e) >> 4)); 117 | do { 118 | if (61 == (s = 255 & r.charCodeAt(n++))) 119 | return a.join(""); 120 | s = this.base64DecodeChars[s] 121 | } while (n < i && -1 == s); 122 | if (-1 == s) 123 | break; 124 | a.push(String.fromCharCode((15 & e) << 4 | (60 & s) >> 2)); 125 | do { 126 | if (61 == (h = 255 & r.charCodeAt(n++))) 127 | return a.join(""); 128 | h = this.base64DecodeChars[h] 129 | } while (n < i && -1 == h); 130 | if (-1 == h) 131 | break; 132 | a.push(String.fromCharCode((3 & s) << 6 | h)) 133 | } 134 | return a.join("") 135 | }, 136 | utf16to8: function (r) { 137 | var t, e, s, h; 138 | for (t = [], 139 | s = r.length, 140 | e = 0; e < s; e++) 141 | (h = r.charCodeAt(e)) >= 1 && h <= 127 ? t.push(r.charAt(e)) : h > 2047 ? (t.push(String.fromCharCode(224 | h >> 12 & 15)), 142 | t.push(String.fromCharCode(128 | h >> 6 & 63)), 143 | t.push(String.fromCharCode(128 | h >> 0 & 63))) : (t.push(String.fromCharCode(192 | h >> 6 & 31)), 144 | t.push(String.fromCharCode(128 | h >> 0 & 63))); 145 | return t.join("") 146 | }, 147 | utf8to16: function (r) { 148 | var t, e, s, h, n, i; 149 | for (t = [], 150 | s = r.length, 151 | e = 0; e < s;) 152 | switch ((h = r.charCodeAt(e++)) >> 4) { 153 | case 0: 154 | case 1: 155 | case 2: 156 | case 3: 157 | case 4: 158 | case 5: 159 | case 6: 160 | case 7: 161 | t.push(r.charAt(e - 1)); 162 | break; 163 | case 12: 164 | case 13: 165 | n = r.charCodeAt(e++), 166 | t.push(String.fromCharCode((31 & h) << 6 | 63 & n)); 167 | break; 168 | case 14: 169 | n = r.charCodeAt(e++), 170 | i = r.charCodeAt(e++), 171 | t.push(String.fromCharCode((15 & h) << 12 | (63 & n) << 6 | (63 & i) << 0)) 172 | } 173 | return t.join("") 174 | }, 175 | paramEncode: function (e) { 176 | for (var t in e) 177 | e[t] || (e[t] = ""), 178 | "" == e[t] && 0 != e[t] || (e[t] = this.encode(e[t])); 179 | return e.waterEncode = this.encode("true"), 180 | e 181 | }, 182 | 183 | }; 184 | waterSecurity.init(); 185 | module.exports = waterSecurity 186 | 187 | -------------------------------------------------------------------------------- /百度翻译/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const bodyParser = require('body-parser'); 3 | const sign = require('./sign') 4 | const app = express(); 5 | const port = process.env.port || 8000; 6 | 7 | app.use(bodyParser.urlencoded({limit: "2100000kb", extended: true})); 8 | 9 | app.post("/sign", (req, res) => { 10 | res.send(sign(req.body.key)) 11 | }) 12 | 13 | app.listen(port, () => { 14 | console.log(`Example app listening at http://localhost:${port}`) 15 | }) -------------------------------------------------------------------------------- /百度翻译/sign.js: -------------------------------------------------------------------------------- 1 | module.exports = (function () { 2 | "use strict"; 3 | 4 | function a(r) { 5 | if (Array.isArray(r)) { 6 | for (var o = 0, t = Array(r.length); o < r.length; o++) 7 | t[o] = r[o]; 8 | return t 9 | } 10 | return Array.from(r) 11 | } 12 | 13 | function n(r, o) { 14 | for (var t = 0; t < o.length - 2; t += 3) { 15 | var a = o.charAt(t + 2); 16 | a = a >= "a" ? a.charCodeAt(0) - 87 : Number(a), 17 | a = "+" === o.charAt(t + 1) ? r >>> a : r << a, 18 | r = "+" === o.charAt(t) ? r + a & 4294967295 : r ^ a 19 | } 20 | return r 21 | } 22 | 23 | function e(r) { 24 | var o = r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g); 25 | if (null === o) { 26 | var t = r.length; 27 | t > 30 && (r = "" + r.substr(0, 10) + r.substr(Math.floor(t / 2) - 5, 10) + r.substr(-10, 10)) 28 | } else { 29 | for (var e = r.split(/[\uD800-\uDBFF][\uDC00-\uDFFF]/), C = 0, h = e.length, f = []; h > C; C++) 30 | "" !== e[C] && f.push.apply(f, a(e[C].split(""))), 31 | C !== h - 1 && f.push(o[C]); 32 | var g = f.length; 33 | g > 30 && (r = f.slice(0, 10).join("") + f.slice(Math.floor(g / 2) - 5, Math.floor(g / 2) + 5).join("") + f.slice(-10).join("")) 34 | } 35 | var u = void 0 36 | , l = "" + String.fromCharCode(103) + String.fromCharCode(116) + String.fromCharCode(107); 37 | // u = null !== i ? i : (i = window[l] || "") || ""; 38 | u = '320305.131321201' 39 | for (var d = u.split("."), m = Number(d[0]) || 0, s = Number(d[1]) || 0, S = [], c = 0, v = 0; v < r.length; v++) { 40 | var A = r.charCodeAt(v); 41 | 128 > A ? S[c++] = A : (2048 > A ? S[c++] = A >> 6 | 192 : (55296 === (64512 & A) && v + 1 < r.length && 56320 === (64512 & r.charCodeAt(v + 1)) ? (A = 65536 + ((1023 & A) << 10) + (1023 & r.charCodeAt(++v)), 42 | S[c++] = A >> 18 | 240, 43 | S[c++] = A >> 12 & 63 | 128) : S[c++] = A >> 12 | 224, 44 | S[c++] = A >> 6 & 63 | 128), 45 | S[c++] = 63 & A | 128) 46 | } 47 | for (var p = m, F = "" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(97) + ("" + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(54)), D = "" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(51) + ("" + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(98)) + ("" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(102)), b = 0; b < S.length; b++) 48 | p += S[b], 49 | p = n(p, F); 50 | return p = n(p, D), 51 | p ^= s, 52 | 0 > p && (p = (2147483647 & p) + 2147483648), 53 | p %= 1e6, 54 | p.toString() + "." + (p ^ m) 55 | } 56 | 57 | return e; 58 | })() 59 | 60 | // console.log(sign("Java")); 61 | 62 | -------------------------------------------------------------------------------- /百度翻译/trans.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/12/22/20:46 4 | description 5 | """ 6 | import re 7 | 8 | import requests 9 | 10 | 11 | class BaiduTranslation: 12 | def __init__(self): 13 | self.session = requests.session() 14 | headers = { 15 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36", 16 | } 17 | self._trans_url = "https://fanyi.baidu.com/v2transapi" 18 | self.session.headers.update(headers) 19 | self._token = self._get_token() 20 | 21 | def _get_token(self): 22 | self.session.get("https://fanyi.baidu.com/") 23 | return re.search("token: '(.*?)'", self.session.get("https://fanyi.baidu.com/").text).group(1) 24 | 25 | def translate(self, word: str, from_lang: str = "en", to_lang: str = "zh"): 26 | if not str: 27 | return "" 28 | 29 | params = { 30 | "from": from_lang, 31 | "to": to_lang 32 | } 33 | formdata = { 34 | 'from': from_lang, 35 | 'to': to_lang, 36 | 'query': word, 37 | 'transtype': 'translang', 38 | 'simple_means_flag': '3', 39 | 'sign': self.session.post("http://127.0.0.1:8000/sign", data={"key": word}).text, 40 | 'token': self._token, 41 | "domain": "common" 42 | } 43 | return self.session.post(self._trans_url, params=params, data=formdata) 44 | 45 | 46 | if __name__ == '__main__': 47 | t = BaiduTranslation() 48 | response = t.translate("Python") 49 | print(response.json()) 50 | -------------------------------------------------------------------------------- /空中网/encrypt.js: -------------------------------------------------------------------------------- 1 | module.exports = function encrypt(str, pwd) { 2 | if (pwd == null || pwd.length <= 0) { 3 | return null 4 | } 5 | ;var prand = ""; 6 | for (var i = 0; i < pwd.length; i++) { 7 | prand += pwd.charCodeAt(i).toString() 8 | } 9 | ;var sPos = Math.floor(prand.length / 5); 10 | var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos * 2) + prand.charAt(sPos * 3) + prand.charAt(sPos * 4) + prand.charAt(sPos * 5)); 11 | var incr = Math.ceil(pwd.length / 2); 12 | var modu = Math.pow(2, 31) - 1; 13 | if (mult < 2) { 14 | return null 15 | } 16 | ;var salt = Math.round(Math.random() * 1000000000) % 100000000; 17 | prand += salt; 18 | while (prand.length > 10) { 19 | var a = prand.substring(0, 1); 20 | var b = prand.substring(10, prand.length); 21 | if (b.length > 10) { 22 | prand = b 23 | } else { 24 | prand = (parseInt(a) + parseInt(b)).toString() 25 | } 26 | } 27 | ;prand = (mult * prand + incr) % modu; 28 | var enc_chr = ""; 29 | var enc_str = ""; 30 | for (var i = 0; i < str.length; i++) { 31 | enc_chr = parseInt(str.charCodeAt(i) ^ Math.floor((prand / modu) * 255)); 32 | if (enc_chr < 16) { 33 | enc_str += "0" + enc_chr.toString(16) 34 | } else 35 | enc_str += enc_chr.toString(16); 36 | prand = (mult * prand + incr) % modu 37 | } 38 | ;salt = salt.toString(16); 39 | while (salt.length < 8) 40 | salt = "0" + salt; 41 | enc_str += salt; 42 | return enc_str 43 | } 44 | -------------------------------------------------------------------------------- /空中网/eval.js: -------------------------------------------------------------------------------- 1 | eval(function (p, a, c, k, e, d) { 2 | e = function (c) { 3 | return (c < a ? "" : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) 4 | } 5 | ; 6 | if (!''.replace(/^/, String)) { 7 | while (c--) 8 | d[e(c)] = k[c] || e(c); 9 | k = [function (e) { 10 | return d[e] 11 | } 12 | ]; 13 | e = function () { 14 | return '\\w+' 15 | } 16 | ; 17 | c = 1; 18 | } 19 | ; 20 | while (c--) 21 | if (k[c]) 22 | p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); 23 | return p; 24 | }('d 1x={\'1y\':\'1f-1c-1w\',\'1d\':\'1u://1v.1f.1z\',\'c\':\'\',\'k\':\'\',\'h\':e,\'p\':e,\'K\':0,\'Z\':z,\'l\':z,\'1e\':n(){6.h=e;6.p=e;6.K=0;6.Z=M;},\'W\':n(s){6.1e();6.p=s;d 7="1a=j";9(6.c!=e&&C.E(6.c)!=""){7+="&c="+x(6.c)};9(6.k!=e&&C.E(6.k)!=""){7+="&k="+x(6.k)};9(6.l){7+="&l=1"};6.A(7)},\'A\':n(7){9(6.Z==z){N z};9(6.h!=e&&6.h["1b"]=="1"){d g={};g["o"]=6.h["o"];g["c"]=6.h["c"];g["17"]=M;g["F"]=6.h["F"];6.p(g);N z};d 12=6.1d+"/1D";C.1E({1C:z,12:12,D:\'1A\',1B:\'1a\',1a:\'j\',g:7,1o:"j",1n:1m,1r:n(1q){},1p:n(1s){}})},\'1F\':n(u){6.h=u;6.K=y.X(Y y());9(6.p!=e){d g={};9(u["1b"]=="0"){g["c"]=u["c"];g["17"]=z;g["1O"]=u["1N"];9(u["T"]!=e&&u["T"]=="1"){g["T"]=M}m{g["T"]=z}}m 9(u["1b"]=="1"){g["o"]=u["o"];g["c"]=u["c"];g["17"]=M};g["F"]=6.h["F"];6.p(g)};6.Z=M},\'1c\':n(o,r,w,t,s){d I=y.X(Y y())-6.K;9((I/14)>=13){6.h=e};9(6.h==e||6.h==""){6.W(n(g){6.p=s;d 7="";7+="&D=1";9(6.c!=e&&C.E(6.c)!=""){7+="&c="+x(6.c)};7+="&H="+o;7+="&V="+6.18(r,g["F"]);7+="&t="+t;9(w){7+="&q=1"}m{7+="&q=0"};9(6.k!=e&&C.E(6.k)!=""){7+="&k="+x(6.k)};9(6.l){7+="&l=1"};6.A(7)})}m{6.p=s;d 7="";7+="&D=1";9(6.c!=e&&C.E(6.c)!=""){7+="&c="+x(6.c)};7+="&H="+o;7+="&V="+6.18(r,6.h["F"]);7+="&t="+t;9(w){7+="&q=1"}m{7+="&q=0"};9(6.k!=e&&C.E(6.k)!=""){7+="&k="+x(6.k)};9(6.l){7+="&l=1"};6.A(7)}},\'1L\':n(o,Q,w,t,s){d I=y.X(Y y())-6.K;9((I/14)>=13){6.h=e};9(6.h==e||6.h==""){6.W(n(){6.p=s;d 7="";7+="&D=2";7+="&c="+6.c;7+="&H="+o;7+="&t="+t;7+="&Q="+Q;9(w){7+="&q=1"}m{7+="&q=0"};9(6.k!=e){7+="&k="+x(6.k)};9(6.l){7+="&l=1"};6.A(7)})}m{6.p=s;d 7="";7+="&D=2";7+="&c="+6.c;7+="&H="+o;7+="&t="+t;7+="&Q="+Q;9(w){7+="&q=1"}m{7+="&q=0"};9(6.k!=e){7+="&k="+x(6.k)};9(6.l){7+="&l=1"};6.A(7)}},\'1P\':n(o,r,w,s){d I=y.X(Y y())-6.K;9((I/14)>=13){6.h=e};9(6.h==e||6.h==""){6.W(n(){6.p=s;d 7="";7+="&D=1l";7+="&c="+6.c;7+="&H="+o;7+="&V="+r;9(w){7+="&q=1"}m{7+="&q=0"};9(6.l){7+="&l=1"};6.A(7)})}m{6.p=s;d 7="";7+="&D=1l";7+="&c="+6.c;7+="&H="+o;7+="&V="+r;9(w){7+="&q=1"}m{7+="&q=0"};9(6.l){7+="&l=1"};6.A(7)}},\'18\':n(15,r){9(r==e||r.v<=0){N e};d f="";1g(d i=0;i10){d a=f.1i(0,1);d b=f.1i(10,f.v);9(b.v>10){f=b}m{f=(11(a)+11(b)).O()}};f=(S*f+19)%U;d P="";d R="";1g(d i=0;i<15.v;i++){P=11(15.1h(i)^G.1k((f/U)*1t));9(P<16){R+="0"+P.O(16)}m R+=P.O(16);f=(S*f+19)%U};B=B.O(16);1j(B.v<8)B="0"+B;R+=B;N R}};', 62, 115, '||||||this|param||if|||service|var|null|prand|data|j_data|||targetService|renew|else|function|user|f_call_back|toSave|pwd|call_back|vcode|vData|length|to_save|decodeURIComponent|Date|false|exec_login|salt|jQuery|type|trim|dc|Math|username|tempTime|sPos|timestamp|charAt|true|return|toString|enc_chr|smscode|enc_str|mult|requirevcode|modu|password|check|parse|new|completed||parseInt|url|180|1000|str||logged|encrypt|incr|jsonp|state|login|loginServer|init|空中网|for|charCodeAt|substring|while|floor|101|5000|timeout|jsonpCallback|error|json|success|xhr|255|http|sso|agent|KZLoginHandler|id|com|post|dataType|async|ajaxLogin|ajax|jsonpCallbackKongZ|1000000000|100000000|31|random|round|login_sms|pow|kzmsg|errors|login_reg|ceil'.split('|'), 0, {})) 25 | -------------------------------------------------------------------------------- /空中网/login.py: -------------------------------------------------------------------------------- 1 | import copy 2 | import re 3 | import time 4 | 5 | import requests 6 | 7 | session = requests.session() 8 | 9 | headers = { 10 | 'accept': "*/*", 11 | 'accept-encoding': 'gzip, deflate, br', 12 | 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6', 13 | 'cache-control': 'no-cache', 14 | 'Pragma': 'no-cache', 15 | 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Edg/95.0.1020.40', 16 | } 17 | 18 | sso_headers = copy.deepcopy(headers) 19 | sso_headers['Host'] = "sso.kongzhong.com" 20 | sso_headers['Referer'] = 'https://passport.kongzhong.com' 21 | 22 | 23 | def get_dc(): 24 | res = session.get( 25 | "https://sso.kongzhong.com/ajaxLogin?j=j&jsonp=j&service=https://passport.kongzhong.com/&_=" + str( 26 | int(time.time() * 1000)), headers=sso_headers) 27 | search = re.search('"dc":"(.*?)"', res.text) 28 | if search is None: 29 | raise ValueError("dc参数获取失败!") 30 | return search.group(1) 31 | 32 | 33 | if __name__ == '__main__': 34 | username, password = "", "" 35 | 36 | session.get("https://passport.kongzhong.com/login", headers=headers) 37 | session.get("https://sso.kongzhong.com/createQRCode", headers=sso_headers) 38 | dc = get_dc() 39 | enc_pwd = session.get("http://localhost:8000", params={"pwd": password, "salt": dc}).text 40 | 41 | login_url = "https://sso.kongzhong.com/ajaxLogin?j=j&&type=1&service=https://passport.kongzhong.com/&username={}&password={}&vcode=&toSave=0&_={}" 42 | # 太快了不行 43 | time.sleep(5) 44 | res = session.get(login_url.format(username, enc_pwd, int(time.time() * 1000)), headers=sso_headers) 45 | print(res.text) 46 | -------------------------------------------------------------------------------- /空中网/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const encrypt = require('./encrypt') 3 | const app = express(); 4 | const port = 8000; 5 | 6 | app.get('/', (req, res) => { 7 | const salt = req.query["salt"]; 8 | const pwd = req.query["pwd"]; 9 | console.log("pwd: " + pwd + " salt: " + salt); 10 | res.send(encrypt(pwd, salt)); 11 | }); 12 | 13 | app.listen(port, () => { 14 | console.log(`Example app listening at http://localhost:${port}`) 15 | }); 16 | 17 | -------------------------------------------------------------------------------- /网易云音乐/netease.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/15/20:43 4 | description 5 | """ 6 | import base64 7 | import binascii 8 | import random 9 | import string 10 | 11 | import requests 12 | from Crypto.Cipher import AES 13 | from Crypto.Util.Padding import pad 14 | 15 | from common import headers 16 | 17 | 18 | class NeteaseEncryptor(object): 19 | _aes_iv = b"0102030405060708" 20 | _aes_key = b'0CoJUm6Qyw8W8jud' 21 | _rsa_pubkey = "010001" 22 | _rsa_modulus = "00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7" 23 | _aes_block_size = 16 24 | _chars = string.ascii_letters + string.digits 25 | 26 | @staticmethod 27 | def _random_str() -> str: 28 | return ''.join(random.choices(NeteaseEncryptor._chars, k=16)) 29 | 30 | @staticmethod 31 | def _aes_encrypt(msg: str, key: bytes) -> str: 32 | padded = pad(msg.encode(), NeteaseEncryptor._aes_block_size) 33 | return base64.b64encode( 34 | AES.new(key=key, mode=AES.MODE_CBC, IV=NeteaseEncryptor._aes_iv).encrypt(padded)).decode() 35 | 36 | @staticmethod 37 | def _rsa_encrypt(msg: str): 38 | v = pow(int(msg, 16), int(NeteaseEncryptor._rsa_pubkey, 16), int(NeteaseEncryptor._rsa_modulus, 16)) 39 | return format(v, 'x').zfill(256) 40 | 41 | @staticmethod 42 | def encrypt(msg: str) -> dict: 43 | random_str = NeteaseEncryptor._random_str() 44 | enc_text = NeteaseEncryptor._aes_encrypt(msg, NeteaseEncryptor._aes_key) 45 | enc_text = NeteaseEncryptor._aes_encrypt(enc_text, random_str.encode()) 46 | hex_str = binascii.hexlify(random_str[::-1].encode()).decode() 47 | return {"params": enc_text, 48 | "encSecKey": NeteaseEncryptor._rsa_encrypt(hex_str)} 49 | 50 | 51 | if __name__ == '__main__': 52 | res = requests.post("https://music.163.com/weapi/search/suggest/web?csrf_token=", 53 | data=NeteaseEncryptor.encrypt('{\"s\":\"王菲\",\"limit\":\"8\",\"csrf_token\":\"\"}'), 54 | headers=headers) 55 | -------------------------------------------------------------------------------- /网易云音乐/qrcode.py: -------------------------------------------------------------------------------- 1 | """ 2 | author rufeng 3 | date 2021/11/15/20:55 4 | description 5 | """ 6 | 7 | from selenium import webdriver 8 | from selenium.webdriver.common.by import By 9 | from selenium.webdriver.support import expected_conditions as EC 10 | from selenium.webdriver.support.wait import WebDriverWait 11 | 12 | COMMON_TIME_OUT = 5 13 | 14 | opts = webdriver.ChromeOptions() 15 | opts.add_argument('--window-size=1920,1080') 16 | chrome = webdriver.Chrome(options=opts) 17 | try: 18 | chrome.get("https://music.163.com/") 19 | WebDriverWait(chrome, COMMON_TIME_OUT).until( 20 | EC.element_to_be_clickable((By.XPATH, '//a[@data-action="login"]'))).click() 21 | WebDriverWait(chrome, COMMON_TIME_OUT).until( 22 | EC.presence_of_element_located((By.XPATH, '//div[@class="qr"]/div[2]/canvas'))) 23 | base64img = chrome.execute_script( 24 | "return document.querySelector('#login-qrcode > div > div.main.j-flag > div > div.right > div.qr > div.canvas.f-pen.j-flag > canvas').toDataURL()") 25 | print(base64img) 26 | finally: 27 | chrome.quit() 28 | --------------------------------------------------------------------------------