Skip to content

Commit 766daea

Browse files
authored
Adding Desktop Version on the main script
You can also check in release section.
1 parent 5db8c28 commit 766daea

File tree

4 files changed

+160
-0
lines changed

4 files changed

+160
-0
lines changed

Desktop-Version/app.js

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
const WebSocket = require('ws');
2+
const fs = require('fs');
3+
const crypto = require('crypto');
4+
const { SocksProxyAgent } = require('socks-proxy-agent');
5+
const { v4: uuidv4, v3: uuidv3 } = require('uuid');
6+
const pino = require('pino');
7+
const logger = pino({ level: 'info', transport: { target: 'pino-pretty' } });
8+
const config = require('./config');
9+
10+
let CoderMarkPrinted = false;
11+
12+
const cl = {
13+
gr: '\x1b[32m',
14+
br: '\x1b[34m',
15+
red: '\x1b[31m',
16+
yl: '\x1b[33m',
17+
gb: '\x1b[4m',
18+
rt: '\x1b[0m'
19+
};
20+
21+
function CoderMark() {
22+
if (!CoderMarkPrinted) {
23+
console.log(`
24+
╭━━━╮╱╱╱╱╱╱╱╱╱╱╱╱╱╭━━━┳╮
25+
┃╭━━╯╱╱╱╱╱╱╱╱╱╱╱╱╱┃╭━━┫┃${cl.gr}
26+
┃╰━━┳╮╭┳━┳━━┳━━┳━╮┃╰━━┫┃╭╮╱╭┳━╮╭━╮
27+
┃╭━━┫┃┃┃╭┫╭╮┃╭╮┃╭╮┫╭━━┫┃┃┃╱┃┃╭╮┫╭╮╮${cl.br}
28+
┃┃╱╱┃╰╯┃┃┃╰╯┃╰╯┃┃┃┃┃╱╱┃╰┫╰━╯┃┃┃┃┃┃┃
29+
╰╯╱╱╰━━┻╯╰━╮┣━━┻╯╰┻╯╱╱╰━┻━╮╭┻╯╰┻╯╰╯${cl.rt}
30+
╱╱╱╱╱╱╱╱╱╱╱┃┃╱╱╱╱╱╱╱╱╱╱╱╭━╯┃
31+
╱╱╱╱╱╱╱╱╱╱╱╰╯╱╱╱╱╱╱╱╱╱╱╱╰━━╯
32+
\n${cl.gb}${cl.yl}getGrass Minner Bot ${cl.rt}${cl.gb}v0.2${cl.rt}
33+
`);
34+
CoderMarkPrinted = true;
35+
}
36+
}
37+
38+
async function connectToWss(socks5Proxy, userId) {
39+
const deviceId = uuidv3(socks5Proxy, uuidv3.DNS);
40+
logger.info(deviceId);
41+
while (true) {
42+
try {
43+
await new Promise(resolve => setTimeout(resolve, Math.random() * 900 + 100));
44+
const customHeaders = { "User-Agent": config.UserAgent };
45+
const uriList = ["wss://proxy2.wynd.network:4444/", "wss://proxy2.wynd.network:4650/"];
46+
const uri = uriList[Math.floor(Math.random() * uriList.length)];
47+
const agent = new SocksProxyAgent(socks5Proxy);
48+
const ws = new WebSocket(uri, { agent, headers: { "User-Agent": customHeaders["User-Agent"] }, rejectUnauthorized: false });
49+
50+
ws.on('open', () => {
51+
const sendPing = () => {
52+
const sendMessage = JSON.stringify({ id: uuidv4(), version: "1.0.0", action: "PING", data: {} });
53+
logger.debug(sendMessage);
54+
ws.send(sendMessage);
55+
setTimeout(sendPing, 110000);
56+
};
57+
sendPing();
58+
});
59+
60+
ws.on('message', (data) => {
61+
const message = JSON.parse(data);
62+
logger.info(message);
63+
if (message.action === "AUTH") {
64+
const authResponse = {
65+
id: message.id,
66+
origin_action: "AUTH",
67+
result: {
68+
browser_id: deviceId,
69+
user_id: userId,
70+
user_agent: customHeaders['User-Agent'],
71+
timestamp: Math.floor(Date.now() / 1000),
72+
device_type: "desktop",
73+
version: "4.29.0",
74+
}
75+
};
76+
logger.debug(authResponse);
77+
ws.send(JSON.stringify(authResponse));
78+
} else if (message.action === "PONG") {
79+
const pongResponse = { id: message.id, origin_action: "PONG" };
80+
logger.debug(pongResponse);
81+
ws.send(JSON.stringify(pongResponse));
82+
}
83+
});
84+
85+
await new Promise((resolve, reject) => {
86+
ws.on('close', () => reject(new Error('WebSocket closed')));
87+
ws.on('error', (error) => reject(error));
88+
});
89+
} catch (e) {
90+
logger.error(`Error with proxy ${socks5Proxy}: ${e.message}`);
91+
if (["Host unreachable", "[SSL: WRONG_VERSION_NUMBER]", "invalid length of packed IP address string", "Empty connect reply", "Device creation limit exceeded", "sent 1011 (internal error) keepalive ping timeout; no close frame received"].some(msg => e.message.includes(msg))) {
92+
logger.info(`Removing error proxy from the list: ${socks5Proxy}`);
93+
removeProxyFromList(socks5Proxy);
94+
return null;
95+
}
96+
}
97+
}
98+
}
99+
100+
async function main() {
101+
const proxyFile = config.proxyFile;
102+
const userId = config.userId;
103+
const allProxies = fs.readFileSync(proxyFile, 'utf-8').split('\n').filter(Boolean);
104+
let activeProxies = allProxies.sort(() => 0.5 - Math.random()).slice(0, 100);
105+
let tasks = new Map(activeProxies.map(proxy => [connectToWss(proxy, userId), proxy]));
106+
107+
while (true) {
108+
const [done] = await Promise.race([...tasks.keys()].map(p => p.then(() => [p])));
109+
const failedProxy = tasks.get(done);
110+
tasks.delete(done);
111+
112+
if (await done === null) {
113+
logger.info(`Removing and replacing failed proxy: ${failedProxy}`);
114+
activeProxies = activeProxies.filter(p => p !== failedProxy);
115+
const newProxy = allProxies[Math.floor(Math.random() * allProxies.length)];
116+
activeProxies.push(newProxy);
117+
tasks.set(connectToWss(newProxy, userId), newProxy);
118+
}
119+
120+
for (const proxy of activeProxies) {
121+
if (![...tasks.values()].includes(proxy)) {
122+
tasks.set(connectToWss(proxy, userId), proxy);
123+
}
124+
}
125+
}
126+
}
127+
128+
function removeProxyFromList(proxy) {
129+
const proxyFile = config.proxyFile;
130+
const proxyList = fs.readFileSync(proxyFile, "utf-8").split('\n');
131+
const updatedList = proxyList.filter(line => line.trim() !== proxy);
132+
fs.writeFileSync(proxyFile, updatedList.join('\n'));
133+
}
134+
CoderMark();
135+
main().catch(console.error);
136+

Desktop-Version/config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// configuration
2+
const config = {
3+
UserAgent : 'xxxxxxxxxxxxxx', // Replace with Your useragent
4+
userId: 'xxxxxxxxxxxxxx', // Replace with Your User ID HERE
5+
proxyFile: 'proxy.txt' // your Path to Proxy.txt file
6+
// format proxies is => socks://username:pass@ip:port
7+
};
8+
9+
module.exports = config;

Desktop-Version/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"dependencies": {
3+
"crypto": "^1.0.1",
4+
"fs": "^0.0.1-security",
5+
"pino": "^9.5.0",
6+
"pino-pretty": "^13.0.0",
7+
"socks-proxy-agent": "^8.0.4",
8+
"uuid": "^11.0.3",
9+
"ws": "^8.18.0"
10+
}
11+
}

Desktop-Version/proxy.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
format proxies is => socks://username:pass@ip:port
2+
socks://username-session-xxxxxxxx:[email protected]:10808
3+
socks://username-session-xxxxxxxx:[email protected]:10808
4+
socks://username-session-xxxxxxxx:[email protected]:10808

0 commit comments

Comments
 (0)