-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
120 lines (112 loc) · 4.62 KB
/
index.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
const config = {
proxyListPath: './proxy_list.txt',
accountOutputPath: './accounts.txt',
filteredProxyOutputPath: './filtered_proxies.txt', // Optionnal
emailDomain: 'aol.com',
proxy: {
timeout: 20000,
followRedirect: true
//maxRedirects: 10
}
};
const PROXYLIST_ARRAY_INDEX = 0; // Indicate the starting line in the proxy list
const PROXY_REQUEST_DELAY = 900; // A too low request delay may trigger the server's protection and refuse proxies requests. Be carefull modifying this variable!
const COUNTRY_CHECK_URL = 'https://hidemyna.me/api/geoip.php?out=js&htmlentities';
const ALLOWED_COUNTRIES = [
'BD', 'BE', 'BJ', 'MM', 'BO', 'CM', 'CA', 'CY', 'FR', 'GB',
'IQ', 'JP', 'LS', 'MO', 'MT', 'MU', 'MN', 'NI', 'NG', 'NP',
'PK', 'PA', 'PG', 'PY', 'PR', 'PE', 'SV', 'SD', 'PS'
];
const URL_PROTOCOL = /(http|https):\/\//g;
var count = 1;
var proxyList;
var proxyCountriesList;
const Account = require('./account')(config);
const fs = require('fs');
const request = require('request');
process.setMaxListeners(0);
(function init() {
var emptyProxyError = () => console.log(
'\x1b[41m Please fill your proxies in the new proxy_list.txt file as below \x1b[0m',
'\n\n\x1b[32mhttp://36.46.126.204:32507\nhttp://178.163.23.244:52077\n... \x1b[0m'
);
return new Promise(resolve => {
fs.readFile(config.proxyListPath, 'utf8', (err, data) => {
if (!err) {
if (data.length > 0) {
proxyList = data
.replace(/\r?\n|\r/g, '→') // remove LF and CRLF
.split('→')
.slice(PROXYLIST_ARRAY_INDEX);
request.post(COUNTRY_CHECK_URL, {
form: {
ip: proxyList
.map(url => url.substring(0, url.indexOf(':', 6)))
.join(',')
.replace(URL_PROTOCOL, '')
}
}, (err, response, body) => {
if (!err && response.headers['content-type'] == "text/javascript") {
proxyCountriesList = JSON.parse(body);
fs.readFile(config.accountOutputPath, 'utf8', (err, data) => {
if (!err && data.length > 0) {
count = data.split('\n').length;
}
resolve();
});
} else {
console.log('Failed to check proxies location');
process.exit(0);
}
});
} else {
emptyProxyError();
process.exit(0);
}
} else {
switch (err.code) {
case 'ENOENT':
emptyProxyError();
fs.appendFileSync(config.proxyListPath, '');
process.exit(0);
break;
default:
throw err;
}
}
});
});
})()
.then(() => {
(function createAccount(i, loop = true) {
if (i == proxyList.length + 1) return;
var proxyUrl = proxyList[i - 1];
let proxyIP = proxyUrl
.substring(0, proxyUrl.indexOf(':', 6))
.replace(URL_PROTOCOL, '');
let proxyData = proxyCountriesList[proxyIP];
var proxyFileLine = PROXYLIST_ARRAY_INDEX + i;
if (proxyData) {
if (ALLOWED_COUNTRIES.includes(proxyData[0])) {
setTimeout(() => {
Account.create(proxyUrl)
.then(params => {
count++;
console.log(`\x1b[42m ${proxyFileLine} [Account #${count}] ${params.login}:${params.password} \x1b[0m`);
createAccount(i, false);
})
.catch(err => {
console.log(proxyFileLine, err.code || err.key || err);
});
}, PROXY_REQUEST_DELAY * i);
} else {
console.log(proxyFileLine, proxyUrl.replace(URL_PROTOCOL, ''), 'invalid_country');
}
} else {
console.log(proxyFileLine, proxyUrl.replace(URL_PROTOCOL, ''), 'country_not_found');
}
if (loop) {
process.nextTick(() => createAccount(i + 1));
}
})(1);
});