Compare commits

...

12 Commits

Author SHA1 Message Date
minicx 8430eff3cf ... 2023-02-17 03:29:48 +03:00
minicx 06b5dcd4ee ... x2 2023-02-17 03:16:48 +03:00
minicx 3f33e53d8f changed getIP 2023-02-17 03:13:03 +03:00
minicx 0e600e33bb ... 2023-02-17 03:10:15 +03:00
minicx 467b447475 maybe fix of docker 2022-12-28 23:48:38 +03:00
minicx accd9026a2 formatting 2022-12-20 21:05:39 +03:00
minicx 05414e2841 update package 2022-12-20 20:21:51 +03:00
minicx a436d91a26 same issue 2022-12-20 20:10:42 +03:00
minicx fa742746bf maybe fixed issue with multiple dockers 2022-12-20 20:06:42 +03:00
minicx 88b34acc45 patch 2022-12-15 15:46:04 +03:00
minicx 22361c3cb2 added skeleton of solving system 2022-12-15 15:41:01 +03:00
minicx d02929d114 Changed README file 2022-12-15 00:11:06 +03:00
13 changed files with 141 additions and 59 deletions

2
.gitignore vendored Normal file → Executable file
View File

@ -11,3 +11,5 @@ settings.json
yarn-error.log
yarn.lock
db.json1
db.sqlite

0
LICENSE Normal file → Executable file
View File

69
README.md Normal file → Executable file
View File

@ -1,31 +1,50 @@
<div align="center">
<h1><b>HK_BOT🤖</b></h1>
<a href="https://hits.sh/git.disroot.org/minicx/hk_bot/"><img alt="Hits" src="https://hits.sh/git.disroot.org/minicx/hk_bot.svg"/></a>
<a href="https://git.disroot.org/minicx/hk_bot/LiCENSE"><img src="https://shields.io/badge/license-MIT-green" alt='License'/></a>
<a href="https://git.disroot.org/minicx/hk_bot/src/commit/0c7f8c9e6c43f0f3784b39b7fbf8b3cea1c27832/LICENSE"><img src="https://shields.io/badge/license-MIT-green" alt='License'/></a>
</div>
# List of content
* [Installing](#installing)
* [Prerequirements](#prerequirements)
* [Cloning repo](#cloning-repo)
* [Installing all dependencies](#installing-all-dependencies)
* [Starting](#starting)
* [Format of Faucet wallets](#format-of-faucet-https-faucetpay-io-wallets)
* [Settings](#settings)
# Installing
1. #### Prerequirements
You need to install this packages:
* `NodeJS>=14.x` version
* `Docker`
* `yarn` or `npm`
#### Linux:
After installing packages, you must add your user at `docker` group to have access to `docker`'s commands without root(**Without this the script will not work ❗**)
2. #### Cloning repo
1. #### Cloning repo
To do this run `git clone https://git.disroot.org/minicx/hk_bot.git`
3. #### Installing all dependencies
To do this run `git clone https://git.disroot.org/minicx/hk_bot.git`
2. #### Installing all dependencies
Run in `hk_bot` directory `npm install` or `yarn install`
4. #### Starting
Run in `hk_bot` directory `npm install` or `yarn install`
3. #### Starting
Run `npm start` or `yarn start`
Run `npm start` or `yarn start`
<details>
<summary>Other commands</summary>
<details>
<summary>Other commands</summary>
| Command | Description |
| ------- | ------------------------------------------------------------------ |
| build | just compile all `.ts` files to `build` directory into `.js` |
| Command | Description |
| ------- | ------------------------------------------------------------------ |
| build | just compile all `.ts` files to `build` directory into `.js` |
</details>
</details>
# Format of [Faucet](https://faucetpay.io) wallets data
# Format of [Faucet](https://faucetpay.io) wallets
* **❗ The script currently does not use the email or password of the faucet account ❗**
* **JSON file must be in root of `hk_bot` directory**
@ -45,8 +64,26 @@
}
```
</details>
</details>
# Settings
Script will create `settings.json` file
from there you can change some settings
| Setting | Description |
| ------- | ------------------------------------------------------------------ |
| logLevel | Sets level of logs |
| pararels | This setting affects the number of running groups of accounts |
| mainCrypto | Temp setting |
| minimalToWithdraw | This setting sets the minimum balance at which the withdrawal will be made |
| maxRefferals | This setting affects the maximum depth of the referral tree |
| botMessages | This setting specifies the messages the script is searching for |
| botButtons | This setting specifies the text buttons that are available in `hk_bot` |
| telegramLinks | This setting sets the links to the bot and the groups you need to join in order to use it |
| sleepTime | This setting sets the delay time |
| shuffleAccounts | This setting determines whether or not accounts will be migrated (this is needed to simulate a live user) |
| bypassMode | This parameter manages that the script will bypass the timer on timed ad pages |
# Creator and contributors
<div align='center'>

0
automatization.ts Normal file → Executable file
View File

31
database.ts Normal file → Executable file
View File

@ -8,6 +8,7 @@ import { arrayWithoutElementAtIndex } from "./utils";
export class Database {
public readonly default: interfacesDB.DatabaseInterface = {
accounts: [],
accountsToLeave: []
};
private json: JsonDB;
constructor() {
@ -98,9 +99,27 @@ export class Database {
account.phoneNumber,
"phoneNumber"
);
logger.debug(`Index in database is ${index} of ${account.phoneNumber}`);
// logger.debug(`Index in database is ${index} of ${account.phoneNumber}`);
await this.json.push(`/accounts[${index}]`, account, true);
}
async addUserToLeave(account: interfacesDB.AccountInterface){
const isAdded: boolean=(await this.getUsersToLeave()).filter((value)=>{
if (value.phoneNumber==account.phoneNumber){
return true
} else {
return false
}
}).length>0 ? true : false
if (isAdded!=true){
const _account:interfacesDB.AccountToLeaveInterface={phoneNumber:account.phoneNumber}
await this.json.push(`/accountsToLeaves[]`, _account);
await this.save();
}
}
async deleteUserToLeave(account: interfacesDB.AccountInterface){
await this.json.delete(`/accountsToLeaves[${await this.json.getIndex('/accountsToLeaves',account.phoneNumber,'phoneNumber')}]`)
}
async addUser(
account: Omit<
interfacesDB.AccountInterface,
@ -146,7 +165,15 @@ export class Database {
}
await this.save();
}
async getUsersToLeave(): Promise<interfacesDB.AccountToLeaveInterface[]>{
try {
return await this.json.getObject<interfacesDB.AccountToLeaveInterface[]>(
"/accountsToLeave"
);
} catch {
return [];
}
}
async getUsers(): Promise<interfacesDB.AccountInterface[]> {
try {
return await this.json.getObject<interfacesDB.AccountInterface[]>(

29
index.ts Normal file → Executable file
View File

@ -4,7 +4,10 @@ import prompt from "prompts";
import logger from "./logger";
import * as telegram from "telegram";
import { LogLevel } from "telegram/extensions/Logger";
import { AccountInterface } from "./interfaces/databaseInterface";
import {
AccountInterface,
AccountToLeaveInterface,
} from "./interfaces/databaseInterface";
import { sleep } from "telegram/Helpers";
import findFreePorts from "find-free-ports";
import {
@ -237,7 +240,6 @@ const farm: () => Promise<void> = async () => {
connectionToCore: {
host: `ws://127.0.0.1:${ports.minerPort}`,
},
disableDevtools: true, // to bypass hk site
showChrome: true, // to debug
userAgent: fingerprint.navigator.userAgent,
viewport: fingerprint.screen,
@ -412,6 +414,7 @@ const farm: () => Promise<void> = async () => {
if (err instanceof telegram.errors.RPCError) {
switch (err.errorMessage) {
case "CHANNELS_TOO_MUCH":
await db.addUserToLeave(worker);
logger.error(
`Too much groups | ${worker.phoneNumber}`
);
@ -605,7 +608,7 @@ const farm: () => Promise<void> = async () => {
const pararels: Promise<void>[] = [];
const miner = new Miner();
await miner.listen({ port: (await findFreePorts(1))[0] });
await miner.listen();
const _ports = await findFreePorts(workers.length * 3);
// logger.debug(`Is there port of miner:${_ports.indexOf(await miner.port)}, ${await miner.port}`)
@ -657,7 +660,7 @@ const farm: () => Promise<void> = async () => {
logger.debug("Closing opened docker containers ");
for (const container of containers) {
try {
await container.stop();
await container.remove({ force: true, v: true });
} catch (err) {}
}
await db.save();
@ -668,8 +671,10 @@ const farm: () => Promise<void> = async () => {
(async () => {
while (true) {
let accounts: AccountInterface[] = [];
let accountsToLeave: AccountToLeaveInterface[] = [];
try {
accounts = await db.getUsers();
accountsToLeave = await db.getUsersToLeave();
} catch (err) {
continue;
}
@ -696,6 +701,18 @@ const farm: () => Promise<void> = async () => {
description: "Add accounts to database",
value: "addAccounts",
},
accountsToLeave.length > 0
? {
title: "Solve issue with max amount of groups",
description: `Solve issue for ${accountsToLeave.length} accounts`,
value: "leaveGroups",
}
: {
title: "Solve issue with max amount of groups",
description: `Nothing to solve`,
value: "leaveGroups",
disabled: true,
},
{
title: "Check balances",
value: "checkBalances",
@ -730,7 +747,8 @@ const farm: () => Promise<void> = async () => {
}
}
break;
case "leaveGroups":
break;
default:
logger.info("Bye bye");
process.exit();
@ -744,4 +762,3 @@ process.on("SIGINT", function () {
process.exit();
});
});

5
interfaces/databaseInterface.d.ts vendored Normal file → Executable file
View File

@ -14,6 +14,10 @@ export interface AccountCompletedGroupsTasksInterface {
groupID: string;
}
export interface AccountToLeaveInterface {
phoneNumber: string
}
export interface AccountWithdrawInterface {}
export interface AccountInterface {
phoneNumber: string;
@ -32,4 +36,5 @@ export interface AccountInterface {
}
export interface DatabaseInterface {
accounts: AccountInterface[];
accountsToLeave:AccountToLeaveInterface[]
}

0
interfaces/otherInterfaces.d.ts vendored Normal file → Executable file
View File

0
interfaces/settingsInterface.d.ts vendored Normal file → Executable file
View File

0
logger.ts Normal file → Executable file
View File

10
package.json Normal file → Executable file
View File

@ -1,8 +1,8 @@
{
"dependencies": {
"@ulixee/execute-js-plugin": "^2.0.0-alpha.16",
"@ulixee/hero": "^2.0.0-alpha.16",
"@ulixee/miner": "^2.0.0-alpha.16",
"@ulixee/execute-js-plugin": "^2.0.0-alpha.17",
"@ulixee/hero": "^2.0.0-alpha.17",
"@ulixee/miner": "^2.0.0-alpha.17",
"axios": "^1.2.1",
"cli-progress": "^3.11.2",
"dockerode": "^3.3.4",
@ -12,7 +12,7 @@
"node-json-db": "^2.1.3",
"prompts": "^2.4.2",
"socks5-https-client": "^1.2.1",
"telegram": "^2.14.7",
"telegram": "^2.15.2",
"tor-control": "^0.0.3",
"typescript": "^4.9.4",
"winston": "^3.8.2"
@ -25,7 +25,7 @@
"@types/cli-progress": "^3.11.0",
"@types/dockerode": "^3.3.14",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.12",
"@types/node": "^18.11.17",
"@types/prompts": "^2.4.2"
},
"scripts": {

0
tsconfig.json Normal file → Executable file
View File

54
utils.ts Normal file → Executable file
View File

@ -3,17 +3,24 @@ import logger from "./logger";
import { settings } from "./database";
// import Hero from "@ulixee/hero";
// import Miner from "@ulixee/miner";
import { Session } from "@ulixee/hero-core";
import { sleep } from "telegram/Helpers";
import { AccountInterface } from "./interfaces/databaseInterface";
import * as telegram from "telegram";
import axios from "axios";
import cliProgress from "cli-progress";
import { isNull, isUndefined } from "lodash";
import * as fs from "fs/promises";
export class CaptchaError extends Error {}
export class NoNewMessagesError extends Error {}
export class DockerIsBrockenError extends Error {}
Session.events.on("closed", (data) => {
if (isUndefined(data) != true) {
fs.unlink(data!.databasePath).catch();
}
});
export function randomAB(a: number, b: number) {
return Math.floor(Math.random() * (b - a + 1) + a);
}
@ -96,7 +103,7 @@ export async function getIP(proxyPort: number): Promise<string | null> {
})
).data;
} catch (err) {
logger.debug(err);
// logger.debug(err);
return null;
}
@ -147,21 +154,23 @@ export async function startNewTorDocker(
const tags = image.RepoTags;
if (tags !== undefined)
for (const repoTag of tags) {
if (repoTag.search("dperson/torproxy:latest") != -1) {
if (repoTag.search("dockage/tor-privoxy:latest") != -1) {
isPulled = true;
break mainLoop;
}
}
}
if (isPulled != true) {
await docker.pull("dperson/torproxy:latest");
await docker.pull("dockage/tor-privoxy:latest");
logger.warn("Restart script to continue")
process.exit()
}
// bugy shit
const options: Docker.ContainerCreateOptions = {
Image: "dperson/torproxy",
Env: ["PASSWORD=qwerty", "LOCATION=US", "TOR_NewCircuitPeriod=50"],
ExposedPorts: {},
Image: "dockage/tor-privoxy",
// Env: ["PASSWORD=qwerty", "LOCATION=US", "TOR_NewCircuitPeriod=50","TORUSER=root"],
// ExposedPorts: {},
HostConfig: {
PortBindings: {
"8118/tcp": [
@ -181,12 +190,12 @@ export async function startNewTorDocker(
],
},
},
Healthcheck: {
Interval: 2 * 1000000000,
Timeout: 50 * 1000000000,
StartPeriod: 50 * 1000000000,
// Test:['CMD_SHELL',`curl -sx localhost:8118 'https://check.torproject.org/' | grep -qm1 Congratulations`]
},
// Healthcheck: {
// Interval: 2 * 1000000000,
// Timeout: 50 * 1000000000,
// StartPeriod: 50 * 1000000000,
// // Test:['CMD_SHELL',`curl -sx localhost:8118 'https://check.torproject.org/' | grep -qm1 Congratulations`]
// },
};
const container = await docker.createContainer(options);
await container.start();
@ -198,28 +207,13 @@ export async function startNewTorDocker(
: ""
}`,
});
while ((await container.inspect())!.State.Health!.Status != "healthy") {
const state = (await container.inspect())!.State.Health!.Status;
while (await getIP(proxyPort)===null) {
if (progressBar.getProgress() >= timeout) {
await container.kill();
await container.remove({force:true,v:true});
progressBar.update(timeout / 2, { status: "Failed" });
progressBar.stop();
throw new DockerIsBrockenError(`Docker ${container.id} is broken`);
}
if (state == "unhealthy") {
await container.kill();
progressBar.update(timeout / 2, {
status: "Docker is unhealthy...",
});
progressBar.stop();
return await startNewTorDocker(
proxyPort,
socksPort,
controlPort,
mainProgressBar,
timeout / 2
);
}
progressBar.increment();
await sleep(2000);
}