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) { if ($classname_selected !== null) {
$wiz = new $classname_selected($page); $wiz = new $classname_selected($page);
$result = $wiz->run(); $result = $wiz->run();
// TODO: Here we'll controlle if return is a valid recon task id. if (is_array($result) === true) {
hd($result); 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) { if ($classname_selected === null) {

View File

@ -160,13 +160,17 @@ class HostDevices extends Wizard
} }
if ($mode == 'netscan') { if ($mode == 'netscan') {
$this->setBreadcrum( if ($this->page != 3) {
[ // Do not paint breadcrum in last page. Redirected.
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd">Host&devices</a>', $this->setBreadcrum(
'<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan">Net scan</a>', [
] '<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd">Host&devices</a>',
); '<a href="index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan">Net scan</a>',
$this->printHeader(); ]
);
$this->printHeader();
}
return $this->runNetScan(); return $this->runNetScan();
} }
@ -258,6 +262,9 @@ class HostDevices extends Wizard
if ($task !== false) { if ($task !== false) {
$this->task = $task; $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) { if (isset($this->task['id_rt']) === false) {
@ -334,6 +341,8 @@ class HostDevices extends Wizard
$parent_detection = get_parameter_switch('parent_detection'); $parent_detection = get_parameter_switch('parent_detection');
$parent_recursion = get_parameter_switch('parent_recursion'); $parent_recursion = get_parameter_switch('parent_recursion');
$vlan_enabled = get_parameter_switch('vlan_enabled'); $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); $snmp_version = get_parameter('snmp_version', null);
$community = get_parameter('community', null); $community = get_parameter('community', null);
$snmp_context = get_parameter('snmp_context', 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_detection'] = $parent_detection;
$this->task['parent_recursion'] = $parent_recursion; $this->task['parent_recursion'] = $parent_recursion;
$this->task['vlan_enabled'] = $vlan_enabled; $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_version'] = $snmp_version;
$this->task['snmp_auth_user'] = $snmp_auth_user; $this->task['snmp_auth_user'] = $snmp_auth_user;
$this->task['snmp_auth_pass'] = $snmp_auth_pass; $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'] = [ $form['form'] = [
'method' => 'POST', '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) // XXX: Could be improved validating inputs before continue (JS)
@ -682,12 +698,13 @@ class HostDevices extends Wizard
$form['inputs'][] = [ $form['inputs'][] = [
'label' => __('Module template'), 'label' => __('Module template'),
'arguments' => [ 'arguments' => [
'name' => 'id_network_profile', 'name' => 'id_network_profile',
'type' => 'select_from_sql', 'type' => 'select_from_sql',
'sql' => 'SELECT id_np, name 'sql' => 'SELECT id_np, name
FROM tnetwork_profile FROM tnetwork_profile
ORDER BY name', ORDER BY name',
'return' => true, 'return' => true,
'selected' => $this->task['id_network_profile'],
], ],
]; ];
@ -700,7 +717,7 @@ class HostDevices extends Wizard
'name' => 'snmp_enabled', 'name' => 'snmp_enabled',
'type' => 'switch', 'type' => 'switch',
'return' => true, 'return' => true,
'value' => 1, 'value' => (isset($this->task['snmp_enabled'])) ? $this->task['snmp_enabled'] : 1,
'onclick' => 'extraSNMP();', 'onclick' => 'extraSNMP();',
], ],
@ -714,15 +731,16 @@ class HostDevices extends Wizard
[ [
'label' => __('SNMP version'), 'label' => __('SNMP version'),
'arguments' => [ 'arguments' => [
'name' => 'snmp_version', 'name' => 'snmp_version',
'fields' => [ 'fields' => [
'1' => 'v. 1', '1' => 'v. 1',
'2c' => 'v. 2c', '2c' => 'v. 2c',
'3' => 'v. 3', '3' => 'v. 3',
], ],
'type' => 'select', 'type' => 'select',
'script' => 'SNMPExtraShow(this.value)', 'script' => 'SNMPExtraShow(this.value)',
'return' => true, 'selected' => $this->task['snmp_version'],
'return' => true,
], ],
], ],
], ],
@ -743,6 +761,7 @@ class HostDevices extends Wizard
'arguments' => [ 'arguments' => [
'name' => 'community', 'name' => 'community',
'type' => 'text', 'type' => 'text',
'value' => $this->task['snmp_community'],
'size' => 25, 'size' => 25,
'return' => true, 'return' => true,
@ -761,6 +780,7 @@ class HostDevices extends Wizard
'arguments' => [ 'arguments' => [
'name' => 'snmp_context', 'name' => 'snmp_context',
'type' => 'text', 'type' => 'text',
'value' => $this->task['snmp_community'],
'size' => 15, 'size' => 15,
'return' => true, 'return' => true,
@ -771,6 +791,7 @@ class HostDevices extends Wizard
'arguments' => [ 'arguments' => [
'name' => 'snmp_auth_user', 'name' => 'snmp_auth_user',
'type' => 'text', 'type' => 'text',
'value' => $this->task['snmp_auth_user'],
'size' => 15, 'size' => 15,
'return' => true, 'return' => true,
@ -786,6 +807,7 @@ class HostDevices extends Wizard
'arguments' => [ 'arguments' => [
'name' => 'snmp_auth_pass', 'name' => 'snmp_auth_pass',
'type' => 'password', 'type' => 'password',
'value' => $this->task['snmp_auth_pass'],
'size' => 15, 'size' => 15,
'return' => true, 'return' => true,
@ -794,14 +816,15 @@ class HostDevices extends Wizard
[ [
'label' => '<b>'.__('Privacy method').'</b>', 'label' => '<b>'.__('Privacy method').'</b>',
'arguments' => [ 'arguments' => [
'name' => 'snmp_privacy_method', 'name' => 'snmp_privacy_method',
'type' => 'select', 'type' => 'select',
'fields' => [ 'fields' => [
'DES' => __('DES'), 'DES' => __('DES'),
'AES' => __('AES'), 'AES' => __('AES'),
], ],
'size' => 15, 'selected' => $this->task['snmp_privacy_method'],
'return' => true, 'size' => 15,
'return' => true,
], ],
], ],
@ -815,6 +838,7 @@ class HostDevices extends Wizard
'arguments' => [ 'arguments' => [
'name' => 'snmp_privacy_pass', 'name' => 'snmp_privacy_pass',
'type' => 'password', 'type' => 'password',
'value' => $this->task['snmp_privacy_pass'],
'size' => 15, 'size' => 15,
'return' => true, 'return' => true,
@ -823,29 +847,31 @@ class HostDevices extends Wizard
[ [
'label' => '<b>'.__('Auth method').'</b>', 'label' => '<b>'.__('Auth method').'</b>',
'arguments' => [ 'arguments' => [
'name' => 'snmp_auth_method', 'name' => 'snmp_auth_method',
'type' => 'select', 'type' => 'select',
'fields' => [ 'fields' => [
'MD5' => __('MD5'), 'MD5' => __('MD5'),
'SHA' => __('SHA'), 'SHA' => __('SHA'),
], ],
'size' => 15, 'selected' => $this->task['snmp_auth_method'],
'return' => true, 'size' => 15,
'return' => true,
], ],
], ],
[ [
'label' => '<b>'.__('Security level').'</b>', 'label' => '<b>'.__('Security level').'</b>',
'arguments' => [ 'arguments' => [
'name' => 'snmp_security_level', 'name' => 'snmp_security_level',
'type' => 'select', 'type' => 'select',
'fields' => [ 'fields' => [
'noAuthNoPriv' => __('Not auth and not privacy method'), 'noAuthNoPriv' => __('Not auth and not privacy method'),
'authNoPriv' => __('Auth and not privacy method'), 'authNoPriv' => __('Auth and not privacy method'),
'authPriv' => __('Auth and privacy method'), 'authPriv' => __('Auth and privacy method'),
], ],
'size' => 15, 'selected' => $this->task['snmp_security_level'],
'return' => true, 'size' => 15,
'return' => true,
], ],
], ],
@ -859,22 +885,27 @@ class HostDevices extends Wizard
'arguments' => [ 'arguments' => [
'name' => 'wmi_enabled', 'name' => 'wmi_enabled',
'type' => 'switch', 'type' => 'switch',
'value' => (isset($this->task['wmi_enabled'])) ? $this->task['wmi_enabled'] : 0,
'return' => true, 'return' => true,
'onclick' => "\$('#wmi_extra').toggle();", 'onclick' => 'toggleWMI();',
], ],
]; ];
// WMI CONFIGURATION. // WMI CONFIGURATION.
$form['inputs'][] = [ $form['inputs'][] = [
'label' => __('WMI Auth. strings'), 'block_id' => 'wmi_extra',
'hidden' => 1, 'hidden' => 1,
'id' => 'wmi_extra', 'block_content' => [
'arguments' => [ [
'name' => 'auth_strings', 'label' => __('WMI Auth. strings'),
'type' => 'text', 'arguments' => [
'return' => true, 'name' => 'auth_strings',
'type' => 'text',
'value' => $this->task['auth_strings'],
'return' => true,
],
],
], ],
]; ];
@ -885,7 +916,7 @@ class HostDevices extends Wizard
'name' => 'os_detect', 'name' => 'os_detect',
'type' => 'switch', 'type' => 'switch',
'return' => true, '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', 'name' => 'resolve_names',
'type' => 'switch', 'type' => 'switch',
'return' => true, 'return' => true,
'value' => (isset($this->task['resolve_names'])) ? $this->task['resolve_names'] : 0,
], ],
]; ];
@ -907,7 +939,7 @@ class HostDevices extends Wizard
'name' => 'parent_detection', 'name' => 'parent_detection',
'type' => 'switch', 'type' => 'switch',
'return' => true, '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', 'name' => 'parent_recursion',
'type' => 'switch', 'type' => 'switch',
'return' => true, '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', 'name' => 'vlan_enabled',
'type' => 'switch', 'type' => 'switch',
'return' => true, '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() { $(function() {
SNMPExtraShow($("#snmp_version").val()) SNMPExtraShow($("#snmp_version").val());
toggleWMI();
}); });
'; ';
@ -1082,6 +1122,7 @@ $("select#interval_manual_defined").change(function() {
}).change();'; }).change();';
$this->printForm($form); $this->printForm($form);
return null;
} }
if ($this->page == 3) { if ($this->page == 3) {