forked from airdropinsiders/Oasis-Auto-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoreff.js
215 lines (187 loc) · 6.83 KB
/
autoreff.js
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
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
import Mailjs from "@cemalgnlts/mailjs";
import axios from "axios";
import fs from 'fs';
import { HttpsProxyAgent } from 'https-proxy-agent';
import readline from "readline/promises";
import { delay } from "./utils/file.js";
import { logger } from "./utils/logger.js";
import { showBanner } from "./utils/banner.js";
const mailjs = new Mailjs();
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
function extractCodeFromEmail(text) {
const regex = /code=([A-Za-z0-9]+)/;
const match = text.match(regex);
return match ? match[1] : null;
}
function readProxies(filePath) {
return new Promise((resolve, reject) => {
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) return reject(err);
const proxies = data.split('\n').map(proxy => proxy.trim()).filter(proxy => proxy);
resolve(proxies);
});
});
}
async function verifyEmail(code, proxy) {
const proxyAgent = new HttpsProxyAgent(proxy);
const url = "https://api.oasis.ai/internal/authVerifyEmail?batch=1";
const payload = {
"0": {
json: {
token: code,
},
},
};
try {
const response = await axios.post(url, payload, {
headers: { "Content-Type": "application/json" },
httpsAgent: proxyAgent,
});
return response.data[0].result.data;
} catch (error) {
logger(
"Error verifying email:",
error.response ? error.response.data : error.message,
'error'
);
return null;
}
}
// Check for new emails
async function checkForNewEmails(proxy) {
try {
const emailData = await mailjs.getMessages();
const latestEmail = emailData.data[0];
if (latestEmail) {
logger("Received new Email:", latestEmail.subject);
const msgId = latestEmail.id;
const emailMessage = await mailjs.getMessage(msgId);
const textContent = emailMessage.data.text;
if (textContent) {
const verificationCode = extractCodeFromEmail(textContent);
if (verificationCode) {
const verifyResult = await verifyEmail(verificationCode, proxy);
if (verifyResult) {
logger("Email successfully verified:", verifyResult.json.message, 'success');
return true;
} else {
await verifyEmail(verificationCode, proxy);
}
}
} else {
logger("No text content in the email.", '', 'error');
}
await mailjs.deleteMessage(msgId);
}
return false;
} catch (error) {
logger("Error checking new emails:", error, 'error');
return false;
}
}
// Send signup request
async function sendSignupRequest(email, password, proxy, referralCode) {
const proxyAgent = new HttpsProxyAgent(proxy);
const url = "https://api.oasis.ai/internal/authSignup?batch=1";
const payload = {
"0": {
json: {
email,
password,
referralCode,
},
},
};
try {
const response = await axios.post(url, payload, {
headers: { "Content-Type": "application/json" },
httpsAgent: proxyAgent,
});
logger(`Signup successful for`, email, 'success');
return { email, status: "success", data: response.data };
} catch (error) {
const errorMessage = error.response
? error.response.statusText
: error.message;
logger(`Error during signup for ${email}:`, errorMessage, 'error');
return null;
}
}
async function saveAccountToFile(email, password) {
const account = `${email}|${password}\n`;
fs.appendFileSync("accountsReff.txt", account, (err) => {
if (err) {
logger("Error saving account:", err, 'error');
} else {
logger("Account saved successfully to accounts.txt.");
}
});
}
// Main process
async function main() {
try {
showBanner()
const proxies = await readProxies('proxy.txt');
if (proxies.length === 0) {
throw new Error('No proxies available in proxy.txt');
}
const referralCode = await rl.question("Enter Your Referral code: ");
const numAccounts = await rl.question("How many accounts do you want to create: ");
const totalAccounts = parseInt(numAccounts);
if (isNaN(totalAccounts) || totalAccounts <= 0) {
logger("Please enter a valid number of accounts.", '', 'warn');
return;
}
for (let i = 1; i <= totalAccounts; i++) {
const proxy = proxies[i % proxies.length];
logger(`Creating account ${i} of ${totalAccounts}...`);
try {
const account = await mailjs.createOneAccount();
if (!account.status || !account.data) {
logger(`Error creating account ${i}:`, account.error || "Rate Limited, Recreating in 5 second...", 'error');
i--;
await delay(5000);
continue;
}
const username = account.data.username;
const password = account.data.password;
logger(`Account ${i} created:`, username);
mailjs.on("open", () => logger(`Awaiting verification email for account ${i}...`));
let isSignup = await sendSignupRequest(username, password, proxy, referralCode);
while (!isSignup) {
isSignup = await sendSignupRequest(username, password, proxy, referralCode);
await delay(5000);
}
let isEmailVerified = false;
while (!isEmailVerified) {
isEmailVerified = await checkForNewEmails(proxy);
if (!isEmailVerified) {
await delay(5000);
}
}
mailjs.on("arrive", () => onNewMessageReceived(i, username, password, proxy));
await delay(10000);
} catch (error) {
logger(`Error during account creation ${i}:`, error, 'error');
}
}
rl.close();
} catch (error) {
logger("Error:", error.message || error, 'error');
rl.close();
}
}
async function onNewMessageReceived(i, username, password, proxy) {
try {
logger(`New message received for account ${i}. Processing...`);
await checkForNewEmails(proxy);
mailjs.off();
saveAccountToFile(username, password);
} catch (error) {
logger("Error processing new message:", error, 'error');
}
}
main();