2018-04-26 12:33:32 +00:00
|
|
|
import { Component, OnInit, AfterContentInit, Output, EventEmitter, Input } from '@angular/core';
|
2018-04-10 10:20:44 +00:00
|
|
|
import { Store, select } from '@ngrx/store';
|
|
|
|
import { RPCClientError } from '@loafer/ng-rpc/protocol';
|
|
|
|
import {
|
|
|
|
DiscoveryStartInfo,
|
|
|
|
DiscoveryZone,
|
|
|
|
Zone,
|
|
|
|
DiscoveryPort,
|
|
|
|
DiscoveryService
|
|
|
|
} from '../../model';
|
|
|
|
import * as CIDR from 'ip-cidr';
|
|
|
|
import * as DiscoveredStore from '../../store/setting';
|
2018-04-06 11:02:18 +00:00
|
|
|
// import * as DiscoverStore from '../../store/discover';
|
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
import { SettingSelector, DiscoverSelector } from '../../store';
|
|
|
|
import * as DiscoverStore from '../../store/discover';
|
|
|
|
|
|
|
|
import * as RegistStore from '../../store/regist';
|
|
|
|
import { Host } from 'packages/discovery/model/Host';
|
|
|
|
import { Port } from 'packages/discovery/model/Port';
|
|
|
|
import { Service } from 'packages/discovery/model/Service';
|
|
|
|
import * as ProbeDetailStore from 'packages/probe/store';
|
|
|
|
import { Probe } from 'packages/probe/model';
|
|
|
|
|
|
|
|
import { DetailSelector as ProbeDetailSelector } from 'packages/probe/store';
|
|
|
|
import { TreeNode } from 'primeng/primeng';
|
2018-04-13 10:32:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
// import { TreeNode } from 'angular-tree-component';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'of-discovery-setting',
|
|
|
|
templateUrl: './setting.component.html',
|
|
|
|
styleUrls: ['./setting.component.scss']
|
|
|
|
})
|
|
|
|
export class SettingComponent implements OnInit, AfterContentInit {
|
|
|
|
|
2018-04-26 12:33:32 +00:00
|
|
|
@Input() cidr: string;
|
2018-04-13 10:32:17 +00:00
|
|
|
@Output() close = new EventEmitter();
|
2018-04-10 10:20:44 +00:00
|
|
|
|
|
|
|
probe$ = this.probeDetailStore.pipe(select(ProbeDetailSelector.select('probe')));
|
|
|
|
|
|
|
|
settingSucceed$: any;
|
|
|
|
discoveryResult$: any;
|
2018-04-23 12:31:16 +00:00
|
|
|
|
|
|
|
discoveryReq$: any;
|
|
|
|
discoveryStart$: any;
|
|
|
|
discoveryEnd$: any;
|
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
probe: Probe = null;
|
|
|
|
started = false;
|
|
|
|
|
2018-04-26 12:33:32 +00:00
|
|
|
// cidr;
|
2018-04-10 10:20:44 +00:00
|
|
|
startIP;
|
|
|
|
endIP;
|
|
|
|
startPort;
|
|
|
|
endPort;
|
|
|
|
// private settingForm: FormGroup;
|
2018-04-16 08:13:25 +00:00
|
|
|
hostChecked = ['host'];
|
|
|
|
portChecked = [];
|
|
|
|
serviceChecked = [];
|
2018-04-10 10:20:44 +00:00
|
|
|
tcpChecked = true;
|
|
|
|
udpChecked = true;
|
2018-04-16 08:13:25 +00:00
|
|
|
includeServices = [];
|
2018-04-10 10:20:44 +00:00
|
|
|
|
|
|
|
serviceItems = [
|
|
|
|
{ name: 'SSH' },
|
|
|
|
{ name: 'PostgreSQL' },
|
|
|
|
{ name: 'DNS' },
|
|
|
|
{ name: 'WMI'},
|
|
|
|
{ name: 'SMB' },
|
|
|
|
{ name: 'ActiveDirectory' },
|
|
|
|
{ name: 'Cassandra' },
|
|
|
|
{ name: 'FTP' },
|
|
|
|
{ name: 'HTTP' },
|
|
|
|
{ name: 'IMAP' },
|
|
|
|
{ name: 'LDAP' },
|
|
|
|
{ name: 'MongoDB' },
|
|
|
|
{ name: 'MySQL' },
|
|
|
|
{ name: 'NBSS' },
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
treeNodes = [];
|
2018-04-25 08:55:36 +00:00
|
|
|
selectedNodes = [];
|
2018-04-10 10:20:44 +00:00
|
|
|
zones: Map<string, Zone> = null;
|
|
|
|
|
|
|
|
checkedSet = new Set();
|
|
|
|
|
|
|
|
testObj: any[] = testDiscovery;
|
|
|
|
selectedDiscoveryResult: TreeNode[];
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private discoverdstore: Store<DiscoveredStore.State>,
|
|
|
|
private discoverstore: Store<DiscoverStore.State>,
|
|
|
|
private registStore: Store<RegistStore.State>,
|
|
|
|
private probeDetailStore: Store<ProbeDetailStore.State>
|
|
|
|
) {
|
|
|
|
this.settingSucceed$ = discoverdstore.pipe(select(SettingSelector.select('isStart')));
|
|
|
|
this.discoveryResult$ = this.discoverstore.pipe(select(DiscoverSelector.select('zones')));
|
2018-04-23 12:31:16 +00:00
|
|
|
this.discoveryReq$ = this.discoverstore.pipe(select(DiscoverSelector.select('isReq')));
|
|
|
|
this.discoveryStart$ = this.discoverstore.pipe(select(DiscoverSelector.select('isStart')));
|
|
|
|
this.discoveryEnd$ = this.discoverstore.pipe(select(DiscoverSelector.select('isEnd')));
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
2018-04-23 12:31:16 +00:00
|
|
|
// this.treeNodes = this.convertViewHost(this.testObj);
|
2018-04-10 10:20:44 +00:00
|
|
|
|
2018-04-18 11:42:05 +00:00
|
|
|
this.settingSucceed$.subscribe(
|
|
|
|
(succeed: boolean) => {
|
|
|
|
if (succeed) {
|
|
|
|
this.started = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
(error: RPCClientError) => {
|
|
|
|
console.log(error.response.message);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
this.probe$.subscribe(
|
|
|
|
(probe: Probe) => {
|
|
|
|
if (probe != null) {
|
|
|
|
this.probe = probe;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
(error: RPCClientError) => {
|
|
|
|
console.log(error.response.message);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
this.discoveryResult$.subscribe(
|
|
|
|
(zones: Map<string, Zone>) => {
|
2018-04-23 12:31:16 +00:00
|
|
|
|
|
|
|
if (zones !== undefined && zones !== null) {
|
|
|
|
console.log('ZoneZoneZoneZoneZoneZoneZone');
|
|
|
|
// console.log(JSON.stringify(zones));
|
|
|
|
this.treeNodes = this.convertTreeViewZone(zones);
|
|
|
|
this.zones = zones;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
(error: RPCClientError) => {
|
|
|
|
console.log(error.response.message);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
this.discoveryReq$.subscribe(
|
|
|
|
(isReq: boolean) => {
|
|
|
|
|
|
|
|
if (isReq !== undefined && isReq !== null) {
|
|
|
|
console.log('isReqisReqisReqisReq');
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
(error: RPCClientError) => {
|
|
|
|
console.log(error.response.message);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
this.discoveryReq$.subscribe(
|
|
|
|
(isStart: boolean) => {
|
|
|
|
|
|
|
|
if (isStart !== undefined && isStart !== null) {
|
|
|
|
console.log('isStartisStartisStart');
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
(error: RPCClientError) => {
|
|
|
|
console.log(error.response.message);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
this.discoveryEnd$.subscribe(
|
|
|
|
(isEnd: boolean) => {
|
|
|
|
|
|
|
|
if (isEnd !== undefined && isEnd !== null) {
|
|
|
|
console.log('isEndisEndisEndisEnd');
|
|
|
|
}
|
|
|
|
|
2018-04-18 11:42:05 +00:00
|
|
|
},
|
|
|
|
(error: RPCClientError) => {
|
|
|
|
console.log(error.response.message);
|
|
|
|
}
|
|
|
|
);
|
2018-04-10 10:20:44 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-04-13 10:32:17 +00:00
|
|
|
closeDialog() {
|
|
|
|
this.close.emit();
|
|
|
|
}
|
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
isZone(zone: Zone): boolean {
|
|
|
|
|
2018-04-23 12:31:16 +00:00
|
|
|
// for (let i = 0; i < this.treeNodes.length; ++i) {
|
|
|
|
// if (zone.iface === this.treeNodes[i].iface) {
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
// }
|
2018-04-10 10:20:44 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngAfterContentInit() {
|
2018-04-26 12:33:32 +00:00
|
|
|
if (this.cidr === undefined || this.cidr === null) {
|
|
|
|
this.cidr = '192.168.10.0/24';
|
|
|
|
}
|
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
this.hostRange();
|
|
|
|
this.portRange();
|
|
|
|
}
|
|
|
|
|
|
|
|
hostRange() {
|
|
|
|
const cidr = new CIDR(this.cidr);
|
|
|
|
if (!cidr.isValid()) {
|
|
|
|
alert('Invalid cidr : ' + this.cidr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.startIP = cidr.addressStart.address;
|
|
|
|
this.endIP = cidr.addressEnd.address;
|
|
|
|
}
|
|
|
|
|
|
|
|
portRange() {
|
|
|
|
this.startPort = '1';
|
|
|
|
this.endPort = '1024';
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-16 08:13:25 +00:00
|
|
|
handleHostCheckChange(e: any) {
|
|
|
|
// console.log(e);
|
|
|
|
this.hostChecked = ['host'];
|
|
|
|
// e.source.checked = true;
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-16 08:13:25 +00:00
|
|
|
handlePortCheckChange(e: any) {
|
|
|
|
console.log(e);
|
|
|
|
this.serviceChecked = [];
|
|
|
|
// this.serviceChecked = false;
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-16 08:13:25 +00:00
|
|
|
handleServiceCheckChange(e: any) {
|
|
|
|
console.log(e);
|
|
|
|
if (e) {
|
|
|
|
this.portChecked = ['port'];
|
|
|
|
}
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
handleServiceChange(list: any) {
|
|
|
|
this.includeServices = list;
|
|
|
|
}
|
|
|
|
|
|
|
|
discovery() {
|
2018-04-11 12:26:51 +00:00
|
|
|
|
2018-04-16 08:13:25 +00:00
|
|
|
console.log(this.startIP);
|
|
|
|
|
|
|
|
console.log(this.startPort);
|
|
|
|
console.log(this.endPort);
|
|
|
|
|
|
|
|
let discoveryPort: DiscoveryPort = null;
|
|
|
|
let discoveryService: DiscoveryService = null;
|
|
|
|
|
|
|
|
if (this.serviceChecked.length > 0) {
|
|
|
|
const services = new Array();
|
|
|
|
for (const service of this.includeServices) {
|
|
|
|
services.push(service.name);
|
|
|
|
}
|
|
|
|
discoveryService = {
|
|
|
|
includeServices: services,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (this.portChecked.length > 0) {
|
|
|
|
discoveryPort = {
|
|
|
|
firstScanRange: this.startPort,
|
|
|
|
lastScanRange: this.endPort,
|
|
|
|
includeTCP: this.tcpChecked,
|
|
|
|
includeUDP: this.udpChecked,
|
|
|
|
excludePorts: null,
|
|
|
|
discoveryService: discoveryService
|
|
|
|
};
|
|
|
|
}
|
|
|
|
const discoveryZone: DiscoveryZone = {
|
|
|
|
discoveryHost: {
|
|
|
|
firstScanRange: this.startIP,
|
|
|
|
lastScanRange: this.endIP,
|
|
|
|
discoveryPort: discoveryPort,
|
|
|
|
},
|
|
|
|
};
|
2018-04-11 12:26:51 +00:00
|
|
|
|
2018-04-16 08:13:25 +00:00
|
|
|
console.log(discoveryZone);
|
2018-04-11 12:26:51 +00:00
|
|
|
|
|
|
|
// console.log('start discovery - ' + this.probe.probeKey);
|
2018-04-18 11:15:56 +00:00
|
|
|
this.discoverstore.dispatch(new DiscoverStore.DiscoverZone(
|
|
|
|
{ probeID: this.probe.probeKey, discoveryZone: discoveryZone }));
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-18 11:15:56 +00:00
|
|
|
this.started = true;
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
checkDiscoveryResult(node) {
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
node.toggleActivated(true);
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
if (node.isActive) {
|
|
|
|
if (node.data.obj !== undefined) {
|
|
|
|
node.data.obj.target = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (node.data.obj !== undefined) {
|
|
|
|
node.data.obj.target = false;
|
|
|
|
}
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
console.log(this.zones);
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
convertMapToList(map: Map<any, any>): Array<any> {
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
if (undefined === map || null === map || map.size < 0) {
|
|
|
|
return null;
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
const retArr = new Array();
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
map.forEach((v: any, k: any) => {
|
|
|
|
retArr.push(v);
|
|
|
|
});
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
return retArr;
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
discoveryResultSave() {
|
|
|
|
// console.log(this.checkedSet);
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
// send discovery save this.zones;
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
// this.registStore.dispatch(new DiscoverStore.DiscoverZone(
|
|
|
|
// {probeID: '52abd6fd57e511e7ac52080027658d13', discoveryZone: discoveryZone}));
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-25 08:55:36 +00:00
|
|
|
// console.log(this.zones);
|
2018-04-24 12:05:57 +00:00
|
|
|
// isTarget Check
|
|
|
|
|
2018-04-26 12:33:32 +00:00
|
|
|
|
2018-04-25 08:55:36 +00:00
|
|
|
for ( const sn of this.selectedNodes) {
|
|
|
|
if (sn.obj !== undefined && sn.obj !== null) {
|
|
|
|
if (sn.obj.target !== undefined && sn.obj.target !== null) {
|
|
|
|
sn.obj.target = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
this.zones.forEach((zone: Zone, key: string) => {
|
|
|
|
if (zone.hosts !== undefined && zone.hosts !== null && zone.hosts.size > 0) {
|
|
|
|
// FIXME: getHosts
|
|
|
|
const hosts: Host[] = [];
|
|
|
|
zone.hosts.forEach((h: Host, hKey: string) => {
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-24 12:05:57 +00:00
|
|
|
h.zone = null;
|
|
|
|
if (h.ports !== undefined && h.ports !== null) {
|
|
|
|
h.portList = [];
|
|
|
|
h.ports.forEach((p: Port, pKey: number) => {
|
|
|
|
|
|
|
|
p.host = null;
|
|
|
|
if (p.services !== undefined && p.services !== null) {
|
|
|
|
p.serviceList = [];
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-24 12:05:57 +00:00
|
|
|
p.services.forEach((s: Service, sKey: string) => {
|
|
|
|
s.port = null;
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-24 12:05:57 +00:00
|
|
|
p.serviceList.push(s);
|
|
|
|
});
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-24 12:05:57 +00:00
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-24 12:05:57 +00:00
|
|
|
h.portList.push(p);
|
|
|
|
});
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
hosts.push(h);
|
|
|
|
});
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
if (hosts.length > 0) {
|
|
|
|
const sd: any = { hosts: hosts, probe: { id: 1 } };
|
|
|
|
console.log(JSON.stringify(sd));
|
|
|
|
console.log('--------');
|
|
|
|
this.registStore.dispatch(new RegistStore.DiscoverySaveAllTarget(sd));
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
handleClick(event) {
|
|
|
|
// console.log(this.filesTree4);
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
this.checkTarget(this.selectedDiscoveryResult);
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
console.log(this.testObj);
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
checkTarget(treeList: any[]) {
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
if (treeList === undefined || treeList === null) {
|
|
|
|
return;
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
for (let i = 0 ; i < treeList.length; ++i) {
|
|
|
|
treeList[i].obj.target = true;
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
this.checkTarget(treeList[i].children);
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
convertTreeViewZone(zones: Map<string, Zone>) {
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
if (zones === undefined || zones === null) {
|
|
|
|
return;
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
// console.log('convertTreeViewZone');
|
|
|
|
const treeNodes: any[] = [];
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
zones.forEach((value: Zone, key: string, map) => {
|
|
|
|
if (this.isZone(value)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const jZone: any = {
|
|
|
|
label: 'Zone - ' + value.iface,
|
|
|
|
// className: 'cn' + value.ip,
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
};
|
|
|
|
jZone.obj = value;
|
|
|
|
jZone.children = this.convertViewHost(value.hosts);
|
|
|
|
treeNodes.push(jZone);
|
|
|
|
});
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-13 10:32:17 +00:00
|
|
|
return treeNodes;
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
convertViewHost(hosts): any[] {
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
if (hosts === undefined || hosts === null) {
|
|
|
|
return null;
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
const hostNodes: any[] = [];
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
hosts.forEach((host, hostKey) => {
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
const jHost: any = {
|
|
|
|
label: 'Host - ' + host.ip,
|
|
|
|
// className: 'cn' + host.ip
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
};
|
|
|
|
jHost.obj = host;
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
jHost.children = this.convertViewPort(host.ports);
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
hostNodes.push(jHost);
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return hostNodes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
convertViewPort(ports): any[] {
|
|
|
|
|
2018-04-24 12:05:57 +00:00
|
|
|
if (ports === undefined || ports === null || ports.size < 0) {
|
2018-04-10 10:20:44 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const portChildren: any[] = [];
|
|
|
|
|
|
|
|
ports.forEach((port, portKey) => {
|
|
|
|
|
|
|
|
const jPort: any = {
|
|
|
|
label: 'Port - ' + port.portNumber,
|
|
|
|
// className: 'cn' + port.portNumber,
|
|
|
|
expandedIcon: 'fa-folder-open',
|
|
|
|
collapsedIcon: 'fa-folder',
|
|
|
|
};
|
|
|
|
jPort.obj = port;
|
|
|
|
|
|
|
|
jPort.children = this.convertViewService(port.services);
|
|
|
|
|
|
|
|
portChildren.push(jPort);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return portChildren;
|
|
|
|
}
|
|
|
|
|
|
|
|
convertViewService(services): any[] {
|
|
|
|
|
|
|
|
if (services === undefined || services === null || services.size <= 0) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const serviceChildren: any[] = [];
|
|
|
|
|
|
|
|
services.forEach((service, serviceKey) => {
|
|
|
|
const jService: any = {
|
|
|
|
label: 'Service - ' + service.serviceName,
|
|
|
|
// className: 'cn' + service.serviceName,
|
|
|
|
};
|
|
|
|
jService.obj = service;
|
|
|
|
|
|
|
|
serviceChildren.push(jService);
|
|
|
|
});
|
|
|
|
|
|
|
|
return serviceChildren;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const testDiscovery: any[] = [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.254',
|
|
|
|
mac: '64:e5:99:63:e7:80',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'UDP',
|
|
|
|
portNumber: 53,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
cryptoType: null,
|
|
|
|
serviceName: 'DNS',
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
port: null,
|
|
|
|
target: false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.99',
|
|
|
|
mac: '00:25:b3:fa:ca:9b',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'UDP',
|
|
|
|
portNumber: 161,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
cryptoType: null,
|
|
|
|
serviceName: 'SNMP_V2',
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
port: null,
|
|
|
|
target: false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'TCP',
|
|
|
|
portNumber: 7,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: null
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.206',
|
|
|
|
mac: '30:9c:23:15:a3:09',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.50',
|
|
|
|
mac: '6c:f0:49:7a:60:68',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'TCP',
|
|
|
|
portNumber: 22,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
cryptoType: 'TCP',
|
|
|
|
serviceName: 'SSH',
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
port: null,
|
|
|
|
target: false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.15',
|
|
|
|
mac: '00:19:b9:35:8e:a6',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'TCP',
|
|
|
|
portNumber: 22,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'TCP',
|
|
|
|
portNumber: 25,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: null
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.100',
|
|
|
|
mac: '00:17:08:8d:cf:f7',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'UDP',
|
|
|
|
portNumber: 161,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
cryptoType: null,
|
|
|
|
serviceName: 'SNMP_V2',
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
port: null,
|
|
|
|
target: false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'TCP',
|
|
|
|
portNumber: 23,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'TCP',
|
|
|
|
portNumber: 21,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: null
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.16',
|
|
|
|
mac: '00:19:b9:19:7e:c7',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'TCP',
|
|
|
|
portNumber: 22,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: null
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.106',
|
|
|
|
mac: '44:8a:5b:f1:3a:7d',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'UDP',
|
|
|
|
portNumber: 161,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
cryptoType: null,
|
|
|
|
serviceName: 'SNMP_V2',
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
port: null,
|
|
|
|
target: false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'TCP',
|
|
|
|
portNumber: 21,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: null
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.101',
|
|
|
|
mac: '44:8a:5b:f1:f1:f3',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.102',
|
|
|
|
mac: '44:8a:5b:f1:f2:d3',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.205',
|
|
|
|
mac: '40:98:ad:7b:d0:43',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.103',
|
|
|
|
mac: '44:8a:5b:44:8c:e8',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'TCP',
|
|
|
|
portNumber: 21,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: null
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.10',
|
|
|
|
mac: 'd0:50:99:97:5d:99',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: [
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
portType: 'TCP',
|
|
|
|
portNumber: 22,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
host: null,
|
|
|
|
services: null
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 0,
|
|
|
|
ip: '192.168.1.203',
|
|
|
|
mac: 'a8:e5:39:5b:c9:62',
|
|
|
|
os: null,
|
|
|
|
discoveredDate: -62135596800000,
|
|
|
|
target: false,
|
|
|
|
zone: null,
|
|
|
|
ports: null
|
|
|
|
}
|
|
|
|
];
|
2018-04-06 11:02:18 +00:00
|
|
|
|