Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
haraka-net-utils
Advanced tools
This module provides network utility functions.
const net_utils = require('haraka-net-utils');
// Convert IPv4 to long
const long = net_utils.ip_to_long('11.22.33.44') // 185999660
// Convert long to IPv4
const ip = net_utils.long_to_ip(185999660) // 11.22.33.44
// Convert decimal to hex
const hex = net_utils.dec_to_hex(20111104) // 132df00
// Convert hex to decimal
const dec = net_utils.hex_to_dec('132df00') // 20111104
// Is IPv4 address on a local network?
net_utils.is_local_ipv4('127.0.0.200') // true (localhost)
net_utils.is_local_ipv4('169.254.0.0') // true (link local)
net_utils.is_local_ipv4('226.0.0.1') // false
// Is IPv4 address in RFC 1918 reserved private address space?
net_utils.is_private_ipv4('10.0.0.0') // true
net_utils.is_private_ipv4('192.168.0.0') // true
net_utils.is_private_ipv4('172.16.0.0') // true
// Is IPv6 addr on local network?
net_utils.is_local_ipv6('::1') // true (localhost)
net_utils.is_local_ipv6('fe80::') // true (link local)
net_utils.is_local_ipv6('fc00::') // true (unique local)
net_utils.is_local_ipv6('fd00::') // true (unique local)
Determines if an IPv4 or IPv6 address is on a "private" network. For IPv4, returns true if is_private_ipv4 or is_local_ipv4 are true For IPv6, returns true if is_local_ipv6 is true
Checks to see if a host name matches our server hostname or resolves to any local ip. Local IPs include those bound to a local network interface and public IPs discovered with STUN.
Checks to see if an IP is bound locally or an IPv4 or IPv6 localhost address.
// searches for 'ip' as a hash key in the list object or array
// ip can be a host, an IP, or an IPv4 or IPv6 range
net_utils.ip_in_list(object, ip)
net_utils.ip_in_list(array, ip)
net_utils.ip_in_list(tls.no_tls_hosts, '127.0.0.5')
Returns an array of all the IPv4 and IPv6 addresses of the provided hostname.
try {
const ips = await net_utils.get_ips_by_host(domain)
for (const ip of ips) {
// do something with the IPs
}
} catch (err) {
// handle any errors
}
try {
const mxList = await net_utils.get_mx(domain)
for (const mx of mxList) {
// do something with each mx
}
} catch (err) {
// handle any errors
}
An object class representing a MX. HarakaMx objects may contain the following properties:
{
exchange: '', // required: a FQDN or IP address
path: '', // the file path to a socket
priority: 0, // integer, a MX priority.
port: 25, // integer: an alternate port
bind: '', // an outbound IP address to bind to
bind_helo: '', // an outbound helo hostname
using_lmtp: false, // boolean, specify LMTP delivery
auth_user: '', // an AUTH username (required if AUTH is desired)
auth_pass: '', // an AUTH password (required if AUTH is desired)
auth_type: '', // an AUTH type that should be used with the MX.
from_dns: '', // the DNS name from which the MX was queried
}
Create a HarakaMx object in The Usual Way:
const nu = require('haraka-net-utils')
const myMx = new nu.HarakaMx(parameter)
The parameter can be one of:
An optional second parameter is an alias for from_dns.
[1.7.1] - 2024-11-13
FAQs
haraka network utilities
The npm package haraka-net-utils receives a total of 1,851 weekly downloads. As such, haraka-net-utils popularity was classified as popular.
We found that haraka-net-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.