Implemented PacketType Disassociation

f_influx-checks
Ruakij 3 years ago
parent fe5dec7860
commit d2178f3b73

@ -12,6 +12,7 @@ const PacketType = {
Authentication: 'Authentication', Authentication: 'Authentication',
AssociationRequest: 'AssociationRequest', AssociationRequest: 'AssociationRequest',
AssociationResponse: 'AssociationResponse', AssociationResponse: 'AssociationResponse',
Disassociation: 'Disassociation',
Unknown: 'Unknown' Unknown: 'Unknown'
} }
@ -58,6 +59,10 @@ class AssociationResponsePacket extends Packet{
associationIsSuccessful; associationIsSuccessful;
} }
class DisassociationPacket extends Packet{
disassociationReason;
}
// Specify exports // Specify exports
module.exports = { module.exports = {
PacketType, PacketType,

@ -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
} }

Loading…
Cancel
Save