-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot-account-creator.js
192 lines (155 loc) · 5.65 KB
/
bot-account-creator.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
"use strict";
const request = require("request");
const fs = require('fs');
const parameters = require('./const');
const puppeteer = require('puppeteer-extra');
const slugify = require('slugify');
const pluginStealth = require("puppeteer-extra-plugin-stealth");
const { installMouseHelper } = require('./mouse-helper');
puppeteer.use(pluginStealth());
const html_path = parameters.htmlPath;
const screenshot_path = parameters.screenshotPath;
const SimpleNodeLogger = require('simple-node-logger'),
opts = {
logFilePath: 'logs/' + 'bot.log',
timestampFormat: 'YYYY-MM-DD HH:mm:ss.SSS',
args: [
'--proxy-server=' + parameters.proxy,
]
};
let html = '';
var emailVal = parameters.emailPrefix + (Math.floor((Math.random() * 9000) + 1000)).toString() + '@gmail.com';
var smsEmail = parameters.smsEmail;
var token = parameters.token;
var passwordVal = parameters.passwordToCreateAccount;
var fNameVal = parameters.name;
var sNameVal = parameters.surname;
var info;
var themessage;
//GET DOM TRAVERSAL VALUES
const AcceptCookies = '#cookie-settings-layout > div > div > div > div.ncss-row.mt5-sm.mb7-sm > div:nth-child(2) > button';
const loginBtn = 'li.member-nav-item.d-sm-ib.va-sm-m > button';
const registerBtn = '.loginJoinLink.current-member-signin > a';
const email = 'input[type="email"]';
const password = 'input[type="password"]';
const fName = '.firstName.nike-unite-component.empty > input[type="text"]';
const sName = '.lastName.nike-unite-component.empty > input[type="text"]';
const dob = 'input[type="date"]';
const gender = 'li:nth-child(1) > input[type="button"]';
const submit = '.joinSubmit.nike-unite-component > input[type="button"]';
const phone = 'div.sendCode > div.mobileNumber-div > input';
const sendNum = '#nike-unite-progressiveForm > div > div > input[type="button"]';
const enterTheValue = 'input[type="number"]';
const storedSubmit = '#nike-unite-progressiveForm > div > input[type="button"]';
//Create Sleep function to use in Async/Await function
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
//callback for phone number request
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
info = body;
console.log("Phone Number: " + info);
}
}
//values for phone number request
const options = {
url: 'http://www.getsmscode.com/vndo.php?action=getmobile&username='+smsEmail+'&token='+token+'&cocode=uk&pid=462',
headers: {'User-Agent': 'request'}
};
//callback for text message response
function callbacktwo(error, response, body) {
if (!error && response.statusCode == 200) {
themessage = body;
console.log("Message: " + themessage);
}
}
console.log("Le bot de création de compte démarre...");
(async () => {
// Ouverture du navigateur
const browser = await puppeteer.launch({
ignoreHTTPSErrors: true,
headless: true,
executablePath: process.env.CHROMIUM_PATH,
args: [
'--proxy-server=http=' + parameters.proxy,
'--no-sandbox',
]
});
const page = await browser.newPage();
let log = SimpleNodeLogger.createSimpleFileLogger(opts);
// Création des répertoires qui contiennent les logs
if (parameters.debug === true) {
installMouseHelper(page);
let dir = 'htmls';
if (!fs.existsSync(dir)) {
try {
fs.mkdirSync(dir);
}
catch (error) {
console.log('Error : ' + error);
}
}
dir = 'screenshots';
if (!fs.existsSync(dir)) {
try {
fs.mkdirSync(dir);
}
catch (error) {
console.log('Error : ' + error);
}
}
dir = 'logs';
if (!fs.existsSync(dir)) {
try {
fs.mkdirSync(dir);
}
catch (error) {
console.log('Error : ' + error);
}
}
log.setLevel('info');
}
await page.setViewport({ width: 1200, height: 800 });
await page.goto(parameters.urlLaunch);
await page.waitFor(1000);
await generateInfoLog('1.Page chargée', parameters.debug);
await page.click(loginBtn);
console.log("Login Button Clicked...")
await page.click(registerBtn);
console.log("Register Button Clicked");
await page.waitFor(2000);
console.log("email: " + emailVal);
await page.type(email, emailVal);
console.log("entered email");
await page.type(password, passwordVal);
await page.type(fName, fNameVal);
await page.type(sName, sNameVal);
await page.type(dob, '01/05/19'+(Math.floor((Math.random() * (99-55)) + 55)).toString());
await page.click(gender);
console.log("waiting 0.5s");
await page.waitFor(500);
console.log("waiting done");
await page.click(submit);
console.log("submitted");
await generateInfoLog("2.Formulaire d'inscription rempli", parameters.debug);
browser.close();
process.exit();
function generateInfoLog(info, debug) {
if (debug === true) {
log.info(info);
html = page.content();
let fileName = slugify(info, {
replacement: '-',
lower: true
});
try {
fs.writeFileSync(html_path + fileName + Math.floor(new Date() / 1000) + ".html", html);
page.screenshot({ path: screenshot_path + fileName + Math.floor(new Date() / 1000) + '.png' });
}
catch (error) {
console.log(error);
}
}
}
})();