|
|
@ -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 } = require.main.require('./dto/Packet.js');
|
|
|
|
const { PacketType, Packet, PacketWithSSID, BeaconPacket, ProbeRequestPacket, ProbeResponsePacket, AuthenticationPacket, AuthenticationType, AssociationResponsePacket, DisassociationPacket } = require.main.require('./dto/Packet.js');
|
|
|
|
|
|
|
|
|
|
|
|
const PACKET_TYPE_MAP = {
|
|
|
|
const PACKET_TYPE_MAP = {
|
|
|
|
"Beacon": PacketType.Beacon,
|
|
|
|
"Beacon": PacketType.Beacon,
|
|
|
@ -16,6 +16,7 @@ const PACKET_TYPE_MAP = {
|
|
|
|
"Authentication": PacketType.Authentication,
|
|
|
|
"Authentication": PacketType.Authentication,
|
|
|
|
"Assoc Request": PacketType.AssociationRequest,
|
|
|
|
"Assoc Request": PacketType.AssociationRequest,
|
|
|
|
"Assoc Response": PacketType.AssociationResponse,
|
|
|
|
"Assoc Response": PacketType.AssociationResponse,
|
|
|
|
|
|
|
|
"Disassociation:": PacketType.Disassociation,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const PACKET_TYPES_REGEX = Object.keys(PACKET_TYPE_MAP).join('|');
|
|
|
|
const PACKET_TYPES_REGEX = Object.keys(PACKET_TYPE_MAP).join('|');
|
|
|
|
|
|
|
|
|
|
|
@ -92,6 +93,11 @@ class PacketStreamFactory extends Transform{
|
|
|
|
newPacket = new AssociationResponsePacket();
|
|
|
|
newPacket = new AssociationResponsePacket();
|
|
|
|
newPacket.associationIsSuccessful = data.match(/Assoc Response\s.{0,30}Successful(?=\s|$)/img) ? true : false;
|
|
|
|
newPacket.associationIsSuccessful = data.match(/Assoc Response\s.{0,30}Successful(?=\s|$)/img) ? true : false;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case PacketType.Disassociation:
|
|
|
|
|
|
|
|
newPacket = new DisassociationPacket();
|
|
|
|
|
|
|
|
newPacket.disassociationReason = data.match(/(?<=(^|\s)Disassociation:\s).*?(?=\sBSS|$)/img)?.[0] ?? null;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(newPacket) packet = Object.assign(new newPacket, packet); // Use new, more specific, packet and copy old data over
|
|
|
|
if(newPacket) packet = Object.assign(new newPacket, packet); // Use new, more specific, packet and copy old data over
|
|
|
|
}
|
|
|
|
}
|
|
|
|