You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#TODO: Refactor this now that I'm better at Powershell :)
78
+
# Build Services property. What a mess...but exclude non-open/non-open|filtered ports and blank service info, and exclude servicefp too for the sake of tidiness.
79
+
if ($_.state.state-like"open*"-and ($_.service.tunnel.length-gt2-or$_.service.product.length-gt2-or$_.service.proto.length-gt2)) {
# Process each of the <address> nodes, extracting by type.
56
-
$hostnode.address|foreach-object {
57
-
if ($_.addrtype-eq"ipv4") { $entry.IPv4+=$_.addr+""}
58
-
if ($_.addrtype-eq"ipv6") { $entry.IPv6+=$_.addr+""}
59
-
if ($_.addrtype-eq"mac") { $entry.MAC+=$_.addr+""}
60
-
}
61
-
if ($entry.IPv4-eq$null) { $entry.IPv4=$null } else { $entry.IPv4=$entry.IPv4.Trim()}
62
-
if ($entry.IPv6-eq$null) { $entry.IPv6=$null } else { $entry.IPv6=$entry.IPv6.Trim()}
63
-
if ($entry.MAC-eq$null) { $entry.MAC=$null } else { $entry.MAC=$entry.MAC.Trim()}
64
-
65
-
66
-
# Process all ports from <ports><port>, and note that <port> does not contain an array if it only has one item in it.
67
-
if ($hostnode.ports.port-eq$null) { $entry.Ports=$null ; $entry.Services=$null }
68
-
else
69
-
{
70
-
$entry.Ports=@()
71
-
72
-
$hostnode.ports.port|foreach-object {
73
-
if ($_.service.name-eq$null) { $service="unknown" } else { $service=$_.service.name }
74
-
$entry.Ports+= [ordered]@{
75
-
Protocol=$_.protocol
76
-
Port=$_.portid
77
-
Service=$service
78
-
State=$_.state.state
88
+
#Port Script Result Processing
89
+
foreach ($scriptItemin$_.script) {
90
+
$scriptResultEntry= [ordered]@{
91
+
PSTypeName='PoshNmapScriptResult'
92
+
id=$ScriptItem.id
93
+
output=$ScriptItem.output
94
+
table= [Collections.Arraylist]@()
79
95
}
80
96
81
-
# Build Services property. What a mess...but exclude non-open/non-open|filtered ports and blank service info, and exclude servicefp too for the sake of tidiness.
}.GetNewClosure() #GetNewClosure "Freezes" the mock. We use this to expand the variable present inside: https://stackoverflow.com/questions/49681015/access-external-variable-from-with-in-mock-script-block-pester
<ports><portprotocol="udp"portid="161"><statestate="open"reason="udp-response"reason_ttl="64"/><servicename="snmp"method="table"conf="3"/><scriptid="snmp-brute"output="
 public - Valid credentials
 private - Valid credentials"><table>
16
+
<elemkey="password">public</elem>
17
+
<elemkey="state">Valid credentials</elem>
18
+
</table>
19
+
<table>
20
+
<elemkey="password">private</elem>
21
+
<elemkey="state">Valid credentials</elem>
22
+
</table>
23
+
</script></port>
24
+
</ports>
25
+
<timessrtt="125"rttvar="4000"to="100000"/>
26
+
</host>
27
+
<runstats><finishedtime="1553187612"timestr="Thu Mar 21 10:00:12 2019"elapsed="4.95"summary="Nmap done at Thu Mar 21 10:00:12 2019; 1 IP address (1 host up) scanned in 4.95 seconds"exit="success"/><hostsup="1"down="0"total="1"/>
0 commit comments