Thursday, August 5, 2010

Powershell and NMAP

This is a Powershell function which is very useful to check that your servers have an HP Management interface listening on on port 2381. The Powershell script uses NMAP to effectively scan the remote system and output back the complete http link to the service.

You can also use this script againts a list of hosts. And, of course, this function can be used againts any known open port on the remote system.

#*===================================
#* Function: NMAP_Port_2301
#* Arguments: $Comp
#* Output: $hp_management_info
#* Purpose: Retrieve the service information for the
#* HP Management Interface. Port 2381 is the port
#* for the website and 2301 for the effective connection.
#*
#*===================================
function NMAP_Port_2301
{
write-debug "Entering NMAP_Port_2301"
$global:hp_management_info = $null
$global:hp_management_site = $null
$global:nmap_hp_management_2301 = $null
$global:nmap_hp_management_2301 = nmap -p 2301 -sV $Comp
$global:hp_management_info = $global:nmap_hp_management_2301.SyncRoot[4]
if($global:hp_management_info -match "open")
{
$global:hp_management_site = "https://" + $Comp + ":2381"
}
else
{
$global:hp_management_info = $null
$global:hp_management_site = $null
}
write-debug "EXIT"
}

NMAP_Port_2301 $Comp

NMAP (Network MAPper) is a securityscanner that sends specially crafted packets to the target host and then analyzes the responses. You can download it from here.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...