From ad23e2f6a00f4a407445a982339a723cbaa7f30e Mon Sep 17 00:00:00 2001 From: songsu Date: Sun, 14 Jan 2024 16:17:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A8=8B=E5=BA=8F=E7=BB=93?= =?UTF-8?q?=E6=9E=84=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=B8=80=E6=AC=A1=E6=80=A7?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 8196 -> 6148 bytes .gitignore | 3 ++- config/runner.json | 4 +-- package-lock.json | 6 +++++ package.json | 1 + {qna3 => src/qna3}/ABI/qna3.json | 0 {qna3 => src/qna3}/qna3.js | 15 +++++++---- {robots => src/robots}/ABI/abi.json | 0 {robots => src/robots}/README.md | 0 {robots => src/robots}/claimRaffle.js | 2 +- {robots => src/robots}/getTicket.js | 15 +++++++---- {web3go => src/web3go}/ABI/reiki.json | 0 {web3go => src/web3go}/README.md | 0 {web3go => src/web3go}/reikiTask.js | 14 +++++++--- {web3go => src/web3go}/web3goMint.js | 15 +++++++---- taskRunner.js | 37 ++++++++++++++++++++++++++ 16 files changed, 89 insertions(+), 23 deletions(-) rename {qna3 => src/qna3}/ABI/qna3.json (100%) rename {qna3 => src/qna3}/qna3.js (93%) rename {robots => src/robots}/ABI/abi.json (100%) rename {robots => src/robots}/README.md (100%) rename {robots => src/robots}/claimRaffle.js (98%) rename {robots => src/robots}/getTicket.js (92%) rename {web3go => src/web3go}/ABI/reiki.json (100%) rename {web3go => src/web3go}/README.md (100%) rename {web3go => src/web3go}/reikiTask.js (93%) rename {web3go => src/web3go}/web3goMint.js (90%) create mode 100644 taskRunner.js diff --git a/.DS_Store b/.DS_Store index 91c0ec5566aef2f767567240b2314aadc790c9c3..a01ab0432d553381fcc6bf980fb4b38930b01351 100644 GIT binary patch delta 374 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5r;6q~50$SAlmU^g?P;A9?w?It`7c?|gs zDGaF$@eH|ORw+XckXP)Plb@WFlb;0Dyc$Ta_zwmQllKd3sApy<`IH{ZntY7Ix!lFL({tvu=oQ~{Sw!6EAlvb-Pz!&qL1 z5{5*e)3OMaISK92|no5LXIt h18G-K&}}UI&ODi4#uF5f3`~$f1%)%i=6Iet%mBZETR{K- delta 718 zcmZoMXmOBWU|?W$DortDU;r^WfEYvza8E20o2aMAD7G? zP3B?QKKVDxntC>dB8Gg1Bp@zfDE7?BPfp6oPXcLXU|>oI(t7{F0LWrsKvA2MZWx@L zpIZQyVUU@GE}xt4;sP~`Bl|AbbmQem9Wm7yrVvzAkb!KG!Q^5#7oe-l8B&3+HfBg? z$VYWG!+M}CYfxN`q&BI%xB%*^ok;~bnZ+dr2G; zi=7gSqCvcn{QR6G7&|d3EHkyfJYGP=IX|x?F*7f<2&^MBB^9V9COk7QCBNJ$zceqU z7_2!MBEiAQ!5J?gSzT>tWM-hFU~Xz&tD{hDX#`}O7@O7Ba&m|&>strKXXoVR<#$8E zl#vlaGw?!b7}Zk`WT6BBYGf#1M3+a73^qn?L}VZZO>RCSE^w)V#)T?0)*V1DLUBl0 za8X`PejX_0FizgWW;EGBL}If)&wgeu32va6D=1ZN7UcNOJegm_bFx1V2M5rTpajdX JIi6<@GXOG}t?&Q< diff --git a/.gitignore b/.gitignore index 89657c0..65ccb86 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .env .DS_Store -node_modules \ No newline at end of file +node_modules +config/runner.json diff --git a/config/runner.json b/config/runner.json index 6c7f849..7e93484 100644 --- a/config/runner.json +++ b/config/runner.json @@ -4,8 +4,8 @@ "bscrpc": "https://rpc.ankr.com/bsc", "opbnb": "https://1rpc.io/opbnb", "walletPath": "/Users/admin/Desktop/testwallet/wallet.csv", - "proxy": " ", - "maxGasPrice": 30, + "proxy": "http://9xmb93yh:9vhpElay773mbXc2@proxy.proxy-cheap.com:31112", + "maxGasPrice": 50, "minInterval": 10, "maxInterval": 120 } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e6845e4..227ca2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "child_process": "^1.0.2", "csv-parser": "^3.0.0", "csv-writer": "^1.6.0", "ethers": "^5.7.2", @@ -726,6 +727,11 @@ "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==" }, + "node_modules/child_process": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz", + "integrity": "sha512-Wmza/JzL0SiWz7kl6MhIKT5ceIlnFPJX+lwUGj7Clhy5MMldsSoJR0+uvRzOS5Kv45Mq7t1PoE8TsOA9bzvb6g==" + }, "node_modules/csv-parser": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-3.0.0.tgz", diff --git a/package.json b/package.json index 8033a90..0c50aa5 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "author": "", "license": "ISC", "dependencies": { + "child_process": "^1.0.2", "csv-parser": "^3.0.0", "csv-writer": "^1.6.0", "ethers": "^5.7.2", diff --git a/qna3/ABI/qna3.json b/src/qna3/ABI/qna3.json similarity index 100% rename from qna3/ABI/qna3.json rename to src/qna3/ABI/qna3.json diff --git a/qna3/qna3.js b/src/qna3/qna3.js similarity index 93% rename from qna3/qna3.js rename to src/qna3/qna3.js index ecccdbe..3963e3f 100644 --- a/qna3/qna3.js +++ b/src/qna3/qna3.js @@ -4,7 +4,7 @@ const fs = require('fs'); const csv = require('csv-parser'); const readlineSync = require('readline-sync'); const axios = require('axios'); -const config = require('../config/runner.json'); +const config = require('../../config/runner.json'); const fakeUa = require('fake-useragent'); const contractAddress = '0xb342e7d33b806544609370271a8d074313b7bc30'; const contractABI = require('./ABI/qna3.json'); @@ -27,10 +27,15 @@ const headers = { }; function getKeyFromUser() { - const key = readlineSync.question('请输入你的密码: ', { - hideEchoBack: true, // 密钥不回显 - }); - return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32); // 使用SHA-256生成密钥 + let key; + if (process.env.SCRIPT_PASSWORD) { + key = process.env.SCRIPT_PASSWORD; + } else { + key = readlineSync.question('请输入你的密码: ', { + hideEchoBack: true, + }); + } + return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32); } function decrypt(text, secretKey) { diff --git a/robots/ABI/abi.json b/src/robots/ABI/abi.json similarity index 100% rename from robots/ABI/abi.json rename to src/robots/ABI/abi.json diff --git a/robots/README.md b/src/robots/README.md similarity index 100% rename from robots/README.md rename to src/robots/README.md diff --git a/robots/claimRaffle.js b/src/robots/claimRaffle.js similarity index 98% rename from robots/claimRaffle.js rename to src/robots/claimRaffle.js index 1bd3ad5..f99a230 100644 --- a/robots/claimRaffle.js +++ b/src/robots/claimRaffle.js @@ -1,7 +1,7 @@ const axios = require('axios'); const fs = require('fs'); const csv = require('csv-parser'); -const config = require('../config/runner.json'); +const config = require('../../config/runner.json'); const { HttpsProxyAgent } = require('https-proxy-agent'); const agent = new HttpsProxyAgent(config.proxy); const fakeUa = require('fake-useragent'); diff --git a/robots/getTicket.js b/src/robots/getTicket.js similarity index 92% rename from robots/getTicket.js rename to src/robots/getTicket.js index 6c99d33..1d58507 100644 --- a/robots/getTicket.js +++ b/src/robots/getTicket.js @@ -3,7 +3,7 @@ const crypto = require('crypto'); const fs = require('fs'); const csv = require('csv-parser'); const readlineSync = require('readline-sync'); -const config = require('../config/runner.json'); +const config = require('../../config/runner.json'); const contractAddress = '0xC91AAacC5adB9763CEB57488CC9ebE52C76A2b05'; const contractABI = require('./ABI/abi.json'); @@ -12,10 +12,15 @@ const ethereumProvider = new ethers.providers.JsonRpcProvider(config.ethrpc); const contractTemplate = new ethers.Contract(contractAddress, contractABI); function getKeyFromUser() { - const key = readlineSync.question('请输入你的密码: ', { - hideEchoBack: true, // 密钥不回显 - }); - return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32); // 使用SHA-256生成密钥 + let key; + if (process.env.SCRIPT_PASSWORD) { + key = process.env.SCRIPT_PASSWORD; + } else { + key = readlineSync.question('请输入你的密码: ', { + hideEchoBack: true, + }); + } + return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32); } function decrypt(text, secretKey) { diff --git a/web3go/ABI/reiki.json b/src/web3go/ABI/reiki.json similarity index 100% rename from web3go/ABI/reiki.json rename to src/web3go/ABI/reiki.json diff --git a/web3go/README.md b/src/web3go/README.md similarity index 100% rename from web3go/README.md rename to src/web3go/README.md diff --git a/web3go/reikiTask.js b/src/web3go/reikiTask.js similarity index 93% rename from web3go/reikiTask.js rename to src/web3go/reikiTask.js index afea5e4..346ded6 100644 --- a/web3go/reikiTask.js +++ b/src/web3go/reikiTask.js @@ -4,19 +4,25 @@ const fs = require('fs'); const csv = require('csv-parser'); const readlineSync = require('readline-sync'); const axios = require('axios'); -const config = require('../config/runner.json'); +const config = require('../../config/runner.json'); const fakeUa = require('fake-useragent'); const { HttpsProxyAgent } = require('https-proxy-agent'); const agent = new HttpsProxyAgent(config.proxy); function getKeyFromUser() { - const key = readlineSync.question('请输入你的密码: ', { - hideEchoBack: true, - }); + let key; + if (process.env.SCRIPT_PASSWORD) { + key = process.env.SCRIPT_PASSWORD; + } else { + key = readlineSync.question('请输入你的密码: ', { + hideEchoBack: true, + }); + } return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32); } + function decrypt(text, secretKey) { let parts = text.split(':'); let iv = Buffer.from(parts.shift(), 'hex'); diff --git a/web3go/web3goMint.js b/src/web3go/web3goMint.js similarity index 90% rename from web3go/web3goMint.js rename to src/web3go/web3goMint.js index 9387f2d..0d69e83 100644 --- a/web3go/web3goMint.js +++ b/src/web3go/web3goMint.js @@ -3,7 +3,7 @@ const crypto = require('crypto'); const fs = require('fs'); const csv = require('csv-parser'); const readlineSync = require('readline-sync'); -const config = require('../config/runner.json'); +const config = require('../../config/runner.json'); const contractAddress = '0xa4Aff9170C34c0e38Fed74409F5742617d9E80dc'; const contractABI = require('./ABI/reiki.json'); @@ -11,10 +11,15 @@ const provider = new ethers.providers.JsonRpcProvider(config.bscrpc); const contractTemplate = new ethers.Contract(contractAddress, contractABI); function getKeyFromUser() { - const key = readlineSync.question('请输入你的密码: ', { - hideEchoBack: true, // 密钥不回显 - }); - return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32); // 使用SHA-256生成密钥 + let key; + if (process.env.SCRIPT_PASSWORD) { + key = process.env.SCRIPT_PASSWORD; + } else { + key = readlineSync.question('请输入你的密码: ', { + hideEchoBack: true, + }); + } + return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32); } function decrypt(text, secretKey) { diff --git a/taskRunner.js b/taskRunner.js new file mode 100644 index 0000000..ef737f7 --- /dev/null +++ b/taskRunner.js @@ -0,0 +1,37 @@ +const { spawn } = require('child_process'); +const readlineSync = require('readline-sync'); +const path = require('path'); + +// 脚本路径列表 +const scripts = [ + './src/web3go/reikiTask.js', + './src/web3go/web3goMint.js', + './src/robots/getTicket.js', + './src/robots/claimRaffle.js', +]; + +const password = readlineSync.question('请输入密码: ', { + hideEchoBack: true // 密码输入时不显示字符 +}); + +runScript(0); + +function runScript(index) { + if (index < scripts.length) { + const scriptName = path.basename(scripts[index], '.js'); + console.log(`开始执行脚本: ${scriptName}`); + + const childProcess = spawn('node', [scripts[index]], { + env: { ...process.env, SCRIPT_PASSWORD: password }, + stdio: 'inherit' + }); + + childProcess.on('close', (code) => { + console.log(`脚本 ${scriptName} 执行完成,退出码 ${code}`); + if (index + 1 < scripts.length) { + console.log(`脚本 ${scriptName} 执行完成,开始执行脚本 ${path.basename(scripts[index + 1], '.js')}`); + } + runScript(index + 1); + }); + } +}