| const axios = require('axios'); | |
| const fs = require('fs').promises; | |
| const path = require('path'); | |
| async function loginAndSave() { | |
| const config = require('./config.json'); | |
| const loginData = { | |
| email: config.web_email, | |
| password: config.web_password | |
| }; | |
| const headers = { | |
| 'host': 'x.mnitnetwork.com', | |
| 'sec-ch-ua-platform': '"Android"', | |
| 'user-agent': 'Mozilla/5.0 (Linux; Android 14; CPH2641 Build/UP1A.231005.007) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.7499.34 Mobile Safari/537.36', | |
| 'accept': 'application/json, text/plain, */*', | |
| 'sec-ch-ua': '"Android WebView";v="143", "Chromium";v="143", "Not A(Brand";v="24"', | |
| 'content-type': 'application/json', | |
| 'sec-ch-ua-mobile': '?1', | |
| 'origin': 'https://x.mnitnetwork.com', | |
| 'x-requested-with': 'mark.via.gp', | |
| 'sec-fetch-site': 'same-origin', | |
| 'sec-fetch-mode': 'cors', | |
| 'sec-fetch-dest': 'empty', | |
| 'referer': 'https://x.mnitnetwork.com/mauth/login', | |
| 'accept-language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7', | |
| 'priority': 'u=1, i' | |
| }; | |
| try { | |
| console.log('🔐 Logging in...'); | |
| const response = await axios.post( | |
| 'https://x.mnitnetwork.com/mapi/v1/mauth/login', | |
| loginData, | |
| { headers, decompress: true } | |
| ); | |
| if (response.data.meta.code === 200) { | |
| const token = response.data.data.token; | |
| const sessionData = { | |
| email: response.data.data.user.email, | |
| username: response.data.data.user.username, | |
| uid: response.data.data.user.uid, | |
| balance: response.data.data.user.balance, | |
| token: token, | |
| expiry: new Date(new Date().getTime() + 24 * 60 * 60 * 1000).toISOString(), | |
| cookie: `mauthtoken=${token}`, | |
| lastLogin: new Date().toISOString() | |
| }; | |
| await fs.mkdir('./data', { recursive: true }); | |
| await fs.writeFile('./data/session.json', JSON.stringify(sessionData, null, 2)); | |
| console.log('✅ Session saved to data/session.json'); | |
| console.log('👤 User:', sessionData.username); | |
| console.log('💰 Balance:', sessionData.balance); | |
| console.log('⏰ Expires:', sessionData.expiry); | |
| } | |
| } catch (error) { | |
| console.log('❌ Login error:', error.message); | |
| } | |
| } | |
| loginAndSave(); |