H&D network scan

Former-commit-id: dcd22994d6addf69ab5d68a6724d12e26e994d15
This commit is contained in:
fbsanchez 2019-02-15 13:57:33 +01:00
parent efdc17b801
commit ec672d6bfb
2 changed files with 100 additions and 49 deletions

View File

@ -53,8 +53,18 @@ $classname_selected = get_wiz_class($wiz_in_use);
if ($classname_selected !== null) {
$wiz = new $classname_selected($page);
$result = $wiz->run();
// TODO: Here we'll controlle if return is a valid recon task id.
hd($result);
if (is_array($result) === true) {
if ($result['result'] === 0) {
// Success.
ui_print_success_message($result['msg']);
// TODO: Show task progress before redirect to main discovery menu.
} else {
// Failed.
ui_print_error_message($result['msg']);
}
$classname_selected = null;
}
}
if ($classname_selected === null) {

View File

@ -160,6 +160,8 @@ class HostDevices extends Wizard
}
if ($mode == 'netscan') {
if ($this->page != 3) {
// Do not paint breadcrum in last page. Redirected.
$this->setBreadcrum(
[
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd">Host&devices</a>',
@ -167,6 +169,8 @@ class HostDevices extends Wizard
]
);
$this->printHeader();
}
return $this->runNetScan();
}
@ -258,6 +262,9 @@ class HostDevices extends Wizard
if ($task !== false) {
$this->task = $task;
}
$this->msg = __('This network scan task has been already defined. Please edit it or create a new one.');
return false;
}
if (isset($this->task['id_rt']) === false) {
@ -334,6 +341,8 @@ class HostDevices extends Wizard
$parent_detection = get_parameter_switch('parent_detection');
$parent_recursion = get_parameter_switch('parent_recursion');
$vlan_enabled = get_parameter_switch('vlan_enabled');
$wmi_enabled = get_parameter_switch('wmi_enabled');
$resolve_names = get_parameter_switch('resolve_names');
$snmp_version = get_parameter('snmp_version', null);
$community = get_parameter('community', null);
$snmp_context = get_parameter('snmp_context', null);
@ -357,6 +366,8 @@ class HostDevices extends Wizard
$this->task['parent_detection'] = $parent_detection;
$this->task['parent_recursion'] = $parent_recursion;
$this->task['vlan_enabled'] = $vlan_enabled;
$this->task['wmi_enabled'] = $wmi_enabled;
$this->task['resolve_names'] = $resolve_names;
$this->task['snmp_version'] = $snmp_version;
$this->task['snmp_auth_user'] = $snmp_auth_user;
$this->task['snmp_auth_pass'] = $snmp_auth_pass;
@ -640,9 +651,14 @@ class HostDevices extends Wizard
],
];
$task_url = '';
if (isset($this->task['id_rt'])) {
$task_url = '&task='.$this->task['id_rt'];
}
$form['form'] = [
'method' => 'POST',
'action' => $this->url.'&mode=netscan&page='.($this->page + 1),
'action' => $this->url.'&mode=netscan&page='.($this->page + 1).$task_url,
];
// XXX: Could be improved validating inputs before continue (JS)
@ -688,6 +704,7 @@ class HostDevices extends Wizard
FROM tnetwork_profile
ORDER BY name',
'return' => true,
'selected' => $this->task['id_network_profile'],
],
];
@ -700,7 +717,7 @@ class HostDevices extends Wizard
'name' => 'snmp_enabled',
'type' => 'switch',
'return' => true,
'value' => 1,
'value' => (isset($this->task['snmp_enabled'])) ? $this->task['snmp_enabled'] : 1,
'onclick' => 'extraSNMP();',
],
@ -722,6 +739,7 @@ class HostDevices extends Wizard
],
'type' => 'select',
'script' => 'SNMPExtraShow(this.value)',
'selected' => $this->task['snmp_version'],
'return' => true,
],
],
@ -743,6 +761,7 @@ class HostDevices extends Wizard
'arguments' => [
'name' => 'community',
'type' => 'text',
'value' => $this->task['snmp_community'],
'size' => 25,
'return' => true,
@ -761,6 +780,7 @@ class HostDevices extends Wizard
'arguments' => [
'name' => 'snmp_context',
'type' => 'text',
'value' => $this->task['snmp_community'],
'size' => 15,
'return' => true,
@ -771,6 +791,7 @@ class HostDevices extends Wizard
'arguments' => [
'name' => 'snmp_auth_user',
'type' => 'text',
'value' => $this->task['snmp_auth_user'],
'size' => 15,
'return' => true,
@ -786,6 +807,7 @@ class HostDevices extends Wizard
'arguments' => [
'name' => 'snmp_auth_pass',
'type' => 'password',
'value' => $this->task['snmp_auth_pass'],
'size' => 15,
'return' => true,
@ -800,6 +822,7 @@ class HostDevices extends Wizard
'DES' => __('DES'),
'AES' => __('AES'),
],
'selected' => $this->task['snmp_privacy_method'],
'size' => 15,
'return' => true,
@ -815,6 +838,7 @@ class HostDevices extends Wizard
'arguments' => [
'name' => 'snmp_privacy_pass',
'type' => 'password',
'value' => $this->task['snmp_privacy_pass'],
'size' => 15,
'return' => true,
@ -829,6 +853,7 @@ class HostDevices extends Wizard
'MD5' => __('MD5'),
'SHA' => __('SHA'),
],
'selected' => $this->task['snmp_auth_method'],
'size' => 15,
'return' => true,
@ -844,6 +869,7 @@ class HostDevices extends Wizard
'authNoPriv' => __('Auth and not privacy method'),
'authPriv' => __('Auth and privacy method'),
],
'selected' => $this->task['snmp_security_level'],
'size' => 15,
'return' => true,
@ -859,22 +885,27 @@ class HostDevices extends Wizard
'arguments' => [
'name' => 'wmi_enabled',
'type' => 'switch',
'value' => (isset($this->task['wmi_enabled'])) ? $this->task['wmi_enabled'] : 0,
'return' => true,
'onclick' => "\$('#wmi_extra').toggle();",
'onclick' => 'toggleWMI();',
],
];
// WMI CONFIGURATION.
$form['inputs'][] = [
'label' => __('WMI Auth. strings'),
'block_id' => 'wmi_extra',
'hidden' => 1,
'id' => 'wmi_extra',
'block_content' => [
[
'label' => __('WMI Auth. strings'),
'arguments' => [
'name' => 'auth_strings',
'type' => 'text',
'value' => $this->task['auth_strings'],
'return' => true,
],
],
],
];
@ -885,7 +916,7 @@ class HostDevices extends Wizard
'name' => 'os_detect',
'type' => 'switch',
'return' => true,
'value' => 1,
'value' => (isset($this->task['os_detect'])) ? $this->task['os_detect'] : 1,
],
];
@ -897,6 +928,7 @@ class HostDevices extends Wizard
'name' => 'resolve_names',
'type' => 'switch',
'return' => true,
'value' => (isset($this->task['resolve_names'])) ? $this->task['resolve_names'] : 0,
],
];
@ -907,7 +939,7 @@ class HostDevices extends Wizard
'name' => 'parent_detection',
'type' => 'switch',
'return' => true,
'value' => 1,
'value' => (isset($this->task['parent_detection'])) ? $this->task['parent_detection'] : 1,
],
];
@ -918,7 +950,7 @@ class HostDevices extends Wizard
'name' => 'parent_recursion',
'type' => 'switch',
'return' => true,
'value' => 1,
'value' => (isset($this->task['parent_recursion'])) ? $this->task['parent_recursion'] : 1,
],
];
@ -929,7 +961,7 @@ class HostDevices extends Wizard
'name' => 'vlan_enabled',
'type' => 'switch',
'return' => true,
'value' => 1,
'value' => (isset($this->task['vlan_enabled'])) ? $this->task['vlan_enabled'] : 1,
],
];
@ -979,8 +1011,16 @@ function extraSNMP() {
}
}
function toggleWMI() {
if (document.getElementsByName("wmi_enabled")[0].checked)
$("#wmi_extra").show();
else
$("#wmi_extra").hide();
}
$(function() {
SNMPExtraShow($("#snmp_version").val())
SNMPExtraShow($("#snmp_version").val());
toggleWMI();
});
';
@ -1082,6 +1122,7 @@ $("select#interval_manual_defined").change(function() {
}).change();';
$this->printForm($form);
return null;
}
if ($this->page == 3) {