
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@ldapjs/asn1
Advanced tools
@ldapjs/asn1 is a Node.js library for encoding and decoding Abstract Syntax Notation One (ASN.1) data structures. ASN.1 is a standard interface description language for defining data structures that can be serialized and deserialized in a cross-platform way. This package is particularly useful for working with LDAP (Lightweight Directory Access Protocol) data, which often uses ASN.1 encoding.
Encoding ASN.1 Data
This feature allows you to encode data into ASN.1 format. The code sample demonstrates how to create a BER (Basic Encoding Rules) writer, start a sequence, write an integer, and then end the sequence. The resulting buffer contains the encoded ASN.1 data.
const asn1 = require('@ldapjs/asn1');
const Ber = asn1.Ber;
const writer = new Ber.Writer();
writer.startSequence();
writer.writeInt(42);
writer.endSequence();
const encodedData = writer.buffer;
console.log(encodedData);
Decoding ASN.1 Data
This feature allows you to decode ASN.1 data. The code sample demonstrates how to create a BER reader, read a sequence, and then read an integer from the encoded data. The resulting value is the decoded integer.
const asn1 = require('@ldapjs/asn1');
const Ber = asn1.Ber;
const encodedData = Buffer.from([0x30, 0x03, 0x02, 0x01, 0x2A]);
const reader = new Ber.Reader(encodedData);
reader.readSequence();
const value = reader.readInt();
console.log(value); // 42
asn1.js is a pure JavaScript implementation of ASN.1. It provides a comprehensive set of tools for encoding and decoding ASN.1 data structures. Compared to @ldapjs/asn1, asn1.js offers more flexibility and is widely used in various cryptographic applications.
node-asn1 is a library for encoding and decoding ASN.1 datatypes in pure JS. Currently BER encoding is supported; at some point I'll likely have to do DER.
Mostly, if you're actually needing to read and write ASN.1, you probably don't need this readme to explain what and why. If you have no idea what ASN.1 is, see this: ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
The source is pretty much self-explanatory, and has read/write methods for the common types out there.
The following reads an ASN.1 sequence with a boolean.
var Ber = require('asn1').Ber;
var reader = new Ber.Reader(Buffer.from([0x30, 0x03, 0x01, 0x01, 0xff]));
reader.readSequence();
console.log('Sequence len: ' + reader.length);
if (reader.peek() === Ber.Boolean)
console.log(reader.readBoolean());
The following generates the same payload as above.
var Ber = require('asn1').Ber;
var writer = new Ber.Writer();
writer.startSequence();
writer.writeBoolean(true);
writer.endSequence();
console.log(writer.buffer);
npm install asn1
MIT.
FAQs
Contains parsers and serializers for ASN.1 (currently BER only)
The npm package @ldapjs/asn1 receives a total of 141,783 weekly downloads. As such, @ldapjs/asn1 popularity was classified as popular.
We found that @ldapjs/asn1 demonstrated a not healthy version release cadence and project activity because the last version was released 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.