Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aws
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
aws
Commits
f232942d
Commit
f232942d
authored
Nov 07, 2024
by
Ahmad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inikt
parent
9a96ca71
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
0 deletions
+37
-0
2fa.bat
2fa.bat
+7
-0
fff.js
fff.js
+28
-0
package.json
package.json
+2
-0
No files found.
2fa.bat
0 → 100644
View file @
f232942d
@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
fff.js
0 → 100644
View file @
f232942d
// 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
);
package.json
View file @
f232942d
...
...
@@ -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
"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment