Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
With npm:
npm install ntp-time
With yarn:
yarn add ntp-time
To instantiate an NTP Client you just have to require the client class from the module and then instantiate it inside your code. To get the time you must use the syncTime
method.
const NTP = require('ntp-time').Client;
const client = new NTP('a.st1.ntp.br', 123, { timeout: 5000 });
async function sync() {
try {
await client.syncTime();
} catch (err) {
console.log(err);
}
}
sync();
// Or using .then
client
.syncTime()
.then(time => console.log(time)) // time is the whole NTP packet
.catch(console.log);
To put a server up, you must require the server class from the ntp-time
module, pass a request callback to it and use the listen method, with a port and an callback as an argument. Inside the request callback you can manipulate the message the way you want.
const NTPServer = require('ntp-time').Server;
const server = new NTPServer();
// Define your custom handler for requests
server.handle((message, response) => {
console.log('Server message:', message);
message.transmitTimestamp = Math.floor(Date.now() / 1000);
response(message);
});
// Check if node has the necessary permissions
// to listen on ports less than 1024
// https://stackoverflow.com/questions/413807/is-there-a-way-for-non-root-processes-to-bind-to-privileged-ports-on-linux
server.listen(123, err => {
if (err) throw err;
console.log('Server listening');
});
For more didatic code, go to the examples page.
FAQs
A ntp library for nodejs
The npm package ntp-time receives a total of 347 weekly downloads. As such, ntp-time popularity was classified as not popular.
We found that ntp-time demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.