Commit f232942d authored by Ahmad's avatar Ahmad

inikt

parent 9a96ca71
@echo off
title Running Node.js 2fa
echo Starting Node.js Create...
cd /d "%~dp0" // Ensures the script runs from the directory where the batch file is located
node fff.js // Runs your Node.js application
pause // Keeps the command prompt open after the script finishes
// Import the required packages
const otplib = require('otplib');
const clipboardy = require('clipboardy');
// Variable to store the last generated token
let lastToken = '';
// Function to check and display the 2FA code if it changes
async function checkForNewCode() {
try {
// Read the secret key from the clipboard
const secret = await clipboardy.read();
// Generate the TOTP code using the secret from the clipboard
const currentToken = otplib.authenticator.generate(secret);
// If the current token is different from the last token, log it
if (currentToken !== lastToken) {
console.log(`New 2FA code: ${currentToken}`);
lastToken = currentToken;
}
} catch (error) {
console.error("Failed to read from clipboard or generate TOTP:", error);
}
}
// Run the check every second (1000 ms) to monitor changes in the TOTP code
setInterval(checkForNewCode, 1000);
......@@ -12,8 +12,10 @@
"dependencies": {
"aws-sdk": "^2.1677.0",
"axios": "^1.7.4",
"clipboardy": "^4.0.0",
"csv-parser": "^3.0.0",
"node-ssh": "^13.2.0",
"otplib": "^12.0.1",
"ssh2": "^1.15.0"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment