Added hexConverter helper-module

f_influx-checks
Ruakij 3 years ago
parent 09bea81058
commit ffe14e3f53

@ -13,6 +13,7 @@ const PacketType = {
AssociationRequest: 'AssociationRequest', AssociationRequest: 'AssociationRequest',
AssociationResponse: 'AssociationResponse', AssociationResponse: 'AssociationResponse',
Disassociation: 'Disassociation', Disassociation: 'Disassociation',
Handshake: 'Handshake',
Unknown: 'Unknown' Unknown: 'Unknown'
} }
@ -65,6 +66,17 @@ class DisassociationPacket extends Packet{
disassociationReason; disassociationReason;
} }
const HandshakeStage = {
1: '1',
2: '2',
3: '3',
4: '4'
}
class HandshakePacket extends Packet{
handshakeStage;
}
// Specify exports // Specify exports
module.exports = { module.exports = {
PacketType, PacketType,
@ -77,4 +89,6 @@ module.exports = {
AuthenticationPacket, AuthenticationPacket,
AssociationRequestPacket, AssociationRequestPacket,
AssociationResponsePacket, AssociationResponsePacket,
HandshakeStage,
HandshakePacket,
}; };

@ -0,0 +1,24 @@
// From https://stackoverflow.com/a/34356351
// Convert a hex string to a byte array
function hexToBytes(hex) {
for (var bytes = [], c = 0; c < hex.length; c += 2)
bytes.push(parseInt(hex.substr(c, 2), 16));
return bytes;
}
// Convert a byte array to a hex string
function bytesToHex(bytes) {
for (var hex = [], i = 0; i < bytes.length; i++) {
var current = bytes[i] < 0 ? bytes[i] + 256 : bytes[i];
hex.push((current >>> 4).toString(16));
hex.push((current & 0xF).toString(16));
}
return hex.join("");
}
// Specify exports
module.exports = {
hexToBytes,
bytesToHex
}

@ -1,7 +1,7 @@
const logger = require.main.require("./helper/logger.js")("PacketStreamFactory"); const logger = require.main.require("./helper/logger.js")("PacketStreamFactory");
const { Transform } = require('stream'); const { Transform } = require('stream');
const { DateTime } = require("luxon"); const { DateTime } = require("luxon");
const { PacketType, Packet, PacketWithSSID, BeaconPacket, ProbeRequestPacket, ProbeResponsePacket, AuthenticationPacket, AuthenticationType, AssociationResponsePacket, DisassociationPacket } = require.main.require('./dto/Packet.js'); const { PacketType, Packet, PacketWithSSID, BeaconPacket, ProbeRequestPacket, ProbeResponsePacket, AuthenticationPacket, AuthenticationType, AssociationResponsePacket, DisassociationPacket, HandshakePacket, HandshakeStage } = require.main.require('./dto/Packet.js');
const PACKET_TYPE_MAP = { const PACKET_TYPE_MAP = {
"Beacon": PacketType.Beacon, "Beacon": PacketType.Beacon,
@ -17,6 +17,7 @@ const PACKET_TYPE_MAP = {
"Assoc Request": PacketType.AssociationRequest, "Assoc Request": PacketType.AssociationRequest,
"Assoc Response": PacketType.AssociationResponse, "Assoc Response": PacketType.AssociationResponse,
"Disassociation:": PacketType.Disassociation, "Disassociation:": PacketType.Disassociation,
"EAPOL": PacketType.Handshake,
}; };
const PACKET_TYPES_REGEX = Object.keys(PACKET_TYPE_MAP).join('|'); const PACKET_TYPES_REGEX = Object.keys(PACKET_TYPE_MAP).join('|');

Loading…
Cancel
Save